akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  rep(i, 0, s.size()) {
    if ((i + 1) % 2 == 0) continue;
    cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3716
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n,Y = MI()

limit_x = Y//10000
for x in range(min(limit_x+1,n+1)):
    r = Y - 10000*x
    limit_y = r//5000
    for y in range(min(n+1-x,limit_y+1)):
        r2 = r - 5000*y
        z = n - x - y
        r3 = r2 - 1000*z
        if r3==0:
            print(x,y,z)
            exit()
print(-1,-1,-1)
exit()

Measured memory_bytes: 77296
#include <bits/stdc++.h>
using namespace std;;
#include <set>
#include <math.h>
#include <random>
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <vector>
#define PI 3.14159265359
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define Rep(i, k, n) for(int i = k; i < (int)n; i++)
#define mp make_pair
#define pb push_back
typedef pair<ll, ll> P;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
  int Case = 0;
  while (true) {
    Case++;
    int n, t, k; cin >> n >> t >> k;
    if (n==0&&t==0&&k==0) break;
    vector<vector<int>> edge(n-1, vector<int>(3,0));
    rep(i, n-1){
      cin >> edge[i][1] >> edge[i][2] >> edge[i][0];
    }
    sort(edge.begin(), edge.end(), [](vector<int> x, vector<int> y) { return x[0] > y[0]; });

    int base[t];
    rep(i, t) {
      cin >> base[i];
    }
    bool iedge[n] = {false};
    bool mnode[n+1] = {false};
    rep(i, t){
      mnode[base[i]] = true;
    } 

    UnionFind uf(n+1);
    int num = 0;
    int cnt = 0;
    rep(i, n) {
      if (num == n-t) break;
      int a = edge[i][1];
      int b = edge[i][2];
      int c = edge[i][0];
      if (!mnode[uf.root(a)] && !mnode[uf.root(b)]) {
        uf.unionSet(a, b);
        cnt += c;
        iedge[i] = true;
        num++;
      }
      else if (!mnode[uf.root(a)] || !mnode[uf.root(b)]) {
        uf.unionSet(a, b);
        mnode[uf.root(a)] = true;
        cnt += c;
        iedge[i] = true;
        num++;
      }
    }
    rep(i, n) {
      if (num == n-k-1) break;
      int c = edge[i][0];
      if (!iedge[i]) {
        cnt += c;
        num++;
      }
    }
    int ans = 0;
    rep(i, n-1) {
      ans += edge[i][0];
    }
    printf("Case %d: %d\n", Case, ans-cnt);
  }
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int dp[1<<15];

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> c(m, vector<int>(n, 0));
    int tmp;
    rep(i,m) {
        cin >> a[i] >> b[i];
        rep(j,b[i]) {
            cin >> tmp;
            tmp--;
            c[i][tmp] = 1;
        }
    }

    int inf = 1e9;
    rep(i,1<<n) dp[i] = inf;
    dp[0] = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        rep(i,m) {
            bool ok = false;
            int next = bit;
            rep(j,n) {
                if (c[i][j]) {
                    if (!(bit&(1<<j))) ok = true;
                    next |= (1<<j);
                }
            }
            if (ok) {
                chmin(dp[next], dp[bit]+a[i]);
            }
        }
    }
    if (dp[(1<<n)-1]==inf) {
        cout << -1 << endl;
    } else {
        cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> pairs(N);
  vector<int> d(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    pairs[i].first=b;
    pairs[i].second=a;
  }
  sort(pairs.begin(),pairs.end());
  int cnt=0;
  bool can=true;
  for(int i=0;i<N;i++){
    cnt+=pairs[i].second;
    if(cnt>pairs[i].first){
      can=false;
      break;
    }
  }
  if(can){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}
    
  

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int V, E;
vector<vector<int>> G;
vector<bool> vis, vis2;

bool solve(int u)
{
    vis[u] = vis2[u] = true;

    bool res = false;
    for (auto v : G[u]) {
        if (vis[v]) return true;
        if (vis2[v]) continue;
        res |= solve(v);
    }

    vis[u] = false;
    return res;
}

int main()
{
    cin >> V >> E;
    G.resize(V);
    vis.resize(V);
    vis2.resize(V);

    rep(i, E) {
        int S, T;
        cin >> S >> T;
        G[S].push_back(T);
    }

    bool ok = false;
    rep(i, V) {
        if (vis2[i]) continue;
        fill(vis.begin(), vis.end(), false);
        ok |= solve(i);
    }
    cout << ok << endl;
}

Measured memory_bytes: 3144
#include <cstdio>
#include <utility>
#include <algorithm>

long long th[1000000];

int main()
{
  long long n, h;
  scanf("%lld%lld", &n, &h);
  std::pair<long long, long long> bl[100000];
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld%lld", &bl[i].first, &bl[i].second);
  }
  std::sort(bl, bl + n);
  std::sort(bl, bl + n - 1, [](auto& a, auto& b){ return a.second > b.second; });
  long long th[1000000];
  th[0] = 0;
  long long cth;
  for (cth = 0; cth < n - 1; ++cth)
  {
    if (bl[cth].second < bl[n - 1].first) break;
    th[cth + 1] = th[cth] + bl[cth].second;
  }
  long long ans = 1;
  h -= bl[n - 1].second;
  if (h <= 0)
  {
    puts("1");
    return 0;
  }
  for (long long i = 1; i <= cth; ++i)
  {
    if (h <= th[i])
    {
      ans += i;
      h = 0;
      break;
    }
  }
  if (h <= 0)
  {
    printf("%lld\n", ans);
    return 0;
  }
  ans += cth;
  h -= th[cth];
  printf("%lld\n", ans + (h + bl[n - 1].first - 1) / bl[n - 1].first);
  return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for(l i=a; i<b; i++)
#define fr(i, a, b) for(long  int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
#define all(v) v.begin(),v.end();
//#define pll pair<ll , ll> 
using namespace std;
const int maxn = 2e5+5;
const ll mod = 1e9+7;
ll dp[maxn] = {0,0,0,1,1};
void solve()
{
l n;
cin>>n;
	for(int i=5; i<3000; i++) dp[i] = (dp[i-1] + dp[i-3])%mod;
	
	cout << dp[n] << '\n';
}


int32_t main()
{
FAST
l T=1;
//cin>>T;
while(T--)
{
solve();
}
}










Measured memory_bytes: 3736
from itertools import permutations

n = int(input())
a = set()
l = []
for i in range(n):
    x, y = map(int, input().split())
    a.add((x,y))
    l.append((x,y))

ans = n

for i, j in permutations(range(n), 2):
    ans_tmp = n
    x1, y1 = l[i]
    x2, y2 = l[j]
    p = x2 - x1
    q = y2 - y1
    if p == q == 0:
        continue
    for k in range(n):
        x, y = l[k]
        if (x-p, y-q) in a:
            ans_tmp -= 1
    ans = min(ans_tmp, ans)
print(ans)



Measured memory_bytes: 3188
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    String s = sc.next();
    int k = sc.nextInt();

    /* logic */

    String answer = "";
    char c = s.charAt(k - 1);
    for (int i = 0; i < n; i++) {
      if (s.charAt(i) != c) {
        answer = answer + "*";
      } else {
        answer = answer + c;
      }
    }
    os.print(answer);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
pair<string,int> book[100];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    rep(i,1,n) cin>>book[i].fi>>book[i].se;
    string pos;
    cin>>pos;
    int now=1;
    while(now<=n) {
        if(pos==book[now].fi) break;
        now++;
    }
    int ans=0;
    rep(i,now+1,n) ans+=book[i].se;
    cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
	ll ans = 0;
	ll a, b;
	cin >> a >> b;
	if (b==a) {
		cout << a << endl;
		return 0;
	}
	if (a % 2 == 0) {
		if (b % 2 == 0) {
			ll x = (b - a) / 2;
			x = x & 1;
			ans = b ^ x;
			cout << ans << endl;
		}
		else {
			ll x = (b - a + 1) / 2;
			x = x & 1;
			cout << x << endl;
		}
	}
	else {
		if (b % 2 == 0) {
			ll x = b - a - 1;
			if (x > 0) {
				x = x / 2;
				x = x & 1;
			}
			ans = x ^ a^b;
			cout << ans << endl;
		}
		else {
			ll x = (b - a) / 2;
			x = x & 1;
			ans = a ^ x;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	string S;
	cin >> S;

	if (S == "RRR") cout << 3 << endl;
	else if (S == "RRS" | S == "SRR") cout << 2 << endl;
	else if (S == "SSS") cout << 0 << endl;
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void) {
    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; i+= 2) {
        vector<ll> tmp = divisor(i);
        if (tmp.size() == 8) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int e;
	while (cin >> e, e) {
		int m=20000000;
		int x, y, z;
	
		for (z = 0; z*z*z <= e; z++) {
			for (y = 0; y*y + z*z*z <= e; y++) {
				x = e - (y*y + z*z*z);
				m = min(m, x + y + z);
			}
		}
		cout << m << endl;

	}
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int main(void){
    char S[101];
    int N;
    scanf("%d ",&N);
    for(int i=0; i<N; i++){
        scanf("%c",&S[i]);
    }
    if(N%2==1){
        printf("No");
        return 0;
    }
    for(int i=0; i<N/2; i++){
        if(S[i]!=S[i+N/2]){
            //printf("%d\n",i);
            //printf("S[i]=%d\n",S[i]);
            //printf("S[1+i+N/2]=%d\n",S[i+N/2]);
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}



Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, M;
bool used[100001] = {};
vector<int> G[100001];
list<int> L;

signed main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    L.push_back(1);
    int next = 1;
    while (next != -1) {
        int cur = next;
        next = -1;
        used[cur] = true;
        for (int i = 0; i < G[cur].size(); i++) {
            int d = G[cur][i];
            if (!used[d]) {
                next = d;
                L.push_back(d);
                break;
            }
        }
    }
    next = 1;
    while (next != -1) {
        int cur = next;
        next = -1;
        used[cur] = true;
        for (int i = 0; i < G[cur].size(); i++) {
            int d = G[cur][i];
            if (!used[d]) {
                next = d;
                L.push_front(d);
                break;
            }
        }
    }
    cout << L.size() << endl;
    for (auto itr = L.begin(); itr != L.end(); ++itr) {
        cout << *itr << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 9472
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <assert.h>
using namespace std;
int main() {

	//홀수면 중간에 있는 원소 하나 맨앞으로 보내고
	//짝수랑 같은 알고리즘으로 진행


	int n; scanf("%d", &n);
	vector<long long> front,back, all;
	vector<long long> kotae;
	for (int i = 0; i < n; i++) {
		long long temp; scanf("%lld", &temp);
		all.push_back(temp);
	}
	// 4 1 5 2 6 3 
	sort(all.begin(), all.end());
	int odd_temp = -1000000;
	if (n & 1) {
		odd_temp = all[all.size() / 2];
		all.erase(all.begin()+(n/2));
	}
	int pos = 0;
	for (; pos < all.size() / 2; pos++) front.push_back(all[pos]);
	for (; pos < all.size(); pos++) back.push_back(all[pos]);

	if (n&1) {
		kotae.push_back(odd_temp);
	}
	for (int i = 0; i < front.size(); i++) {
		kotae.push_back(back[i]);
		kotae.push_back(front[i]);
	}
	long long ans = 0;
	for (int i = 0; i < n - 1; i++) {
		ans += abs(kotae[i] - kotae[i + 1]);
	}
	kotae.clear();

	reverse(front.begin(), front.end());
	reverse(back.begin(), back.end());

	if (n&1) {
		kotae.push_back(odd_temp);
	}
	for (int i = 0; i < front.size();i++) {
		kotae.push_back(front[i]);
		kotae.push_back(back[i]);
	}


	//여기에 이제 4 5 6 1 2 3 나눠서 짝짝짞 넣으면 다풀림 ㅋㅋㅋ 엌ㅋㅋ 개꿀~~

	long long ans2 = 0;
	for (int i = 0; i < n-1; i++) {
		ans2 += abs(kotae[i] - kotae[i + 1]);
	}
	printf("%lld", max(ans,ans2));
	return 0;
}

Measured memory_bytes: 3572
inf = 10 ** 18
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
max_a = max(a for a, _ in ab)
dp = [inf] * (h + max_a)
dp[0] = 0
for i in range(1, h + max_a):
    dp[i] = min(dp[i-a] + b for a, b in ab)
print(min(dp[h:]))


Measured memory_bytes: 3832
#include"bits/stdc++.h"
#include<atcoder/dsu.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============
using pii = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vector<tp3> xy(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        xy[i] = make_tuple(x, y, i);
    }
    sort(xy.begin(), xy.end());

    dsu uf(N);
    set<pii> st;
    rep(i, N) {
        auto[x, y, Idx] = xy[i];
        if (!st.empty()) {
            auto init = *st.begin();
            while (!st.empty()) {
                auto[oppY, oppIdx] = *st.begin();
                if (oppY < y) {
                    uf.merge(Idx, oppIdx);
                    st.erase(st.begin());
                }
                else {
                    break;
                }
            }
            st.insert(init);
        }
        st.insert({ y, Idx });
    }
    auto groups = uf.groups();
    map<int, int> mp;
    for (auto group : groups)for (auto member : group) {
        mp[member] = group.size();
    }
    rep(i, N)cout << mp[i] << endl;
    return 0;
}


Measured memory_bytes: 24640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 1e6+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

int main()
{
    ios::sync_with_stdio(false);

    int n, k;
    cin>>n>>k;
    int ac = 0, pen = 0;
    map<int, int>mp, mp1, Ac;
    while(k--){
        int x;
        string str;
        cin>>x>>str;
        if(str == "AC") Ac[x] = 1;
        if(str == "WA" and mp[x] == 0){
                pen++;
                mp1[x]++;
        }
        else if(str == "AC" and mp[x] == 0) mp[x] = 1, ac++;
    }

    for(int i=1 ; i<=n ; i++) if(Ac[i] == 0) pen-=mp1[i];
    cout<<ac<<" "<<pen<<endl;

    return 0;
}


Measured memory_bytes: 84096
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, K; cin >> N >> K;
    vector<int> DQ;
    rep(i,N){
        int Vi; cin >> Vi;
        DQ.push_back(Vi);
    }
    ll max_n = 0;
    int Sel_n;
    if(N < K){
        Sel_n = N;
    }else{
        Sel_n = K;
    }
    rep(A_B,Sel_n+1){
        int del_n = K-A_B;
        for(int A=0; A<=A_B; A++){
            int B = A_B-A;
            vector<int> Sel;
            // cout << A << B << del_n << endl;
            rep(a,A){
                Sel.push_back(DQ[a]);
            }
            rep(b,B){
                Sel.push_back(DQ[N-1-b]);
            }
            sort(Sel.begin(), Sel.end());
            if(Sel.size() > 0){
                rep(i,del_n){
                    if(Sel[i] < 0) Sel[i] = 0;  // 価値がマイナスの宝石を捨てるのと同義
                    else break;
                }
            }
            ll sum = 0;
            rep(i,Sel.size()) sum += Sel[i];
            if(max_n < sum) max_n = sum;
        }
    }
    cout << max_n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

vector<ll> divisor(ll n) {
  vector<ll> res;
  for(ll i=1;i*i<=n;i++) {
    if(n%i==0) {
      res.push_back(i);
      if(i!=n/i) {
        res.push_back(n/i);
      }
    }
  }
  return res;
}

int main() {
  int n,m;
  cin >> n >> m;
  vector<ll> div=divisor(m);
  sort(div.begin(), div.end());
  auto t=*lower_bound(div.begin(), div.end(), n);
  cout << m/t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>//c++14
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e15;
ll x = 25;
ll N,W;
vector<ll> dp,v,w,m;
ll solve(){//O(NWlogm) 
    vector<ll> dp(N*x*50+1,inf);
    dp[0] = 0;
    for(ll i=0;i<N;i++){
	ll num = min(m[i],x) ;
	m[i] -= num;
	for(ll j=1;num > 0; j<<=1 ){
	    ll mul = min(j,num);//最後を上手くやる
	    if(!j)break;
	    for(ll k=N*x*50; k>=0;k--){
		if(k+mul*v[i]<=N*x*50)dp[k+mul*v[i]] = min(dp[k+ mul*v[i] ],dp[k] + mul*w[i]);
	    }
	    num-=mul;
	}
    }
    vector<ll> ord(N);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](ll a,ll b){ return v[a]*w[b] > v[b]*w[a]; } );
    ll ans = 0;
    for(ll i=0;i<=N*x*50;i++){
	ll lim = W-dp[i];
	if(lim < 0 ) continue;
	ll res = i;
	for(ll j=0;j<N;j++){
	    ll k = ord[j];
	    ll c = min( m[k],lim/w[k] );
	    lim -= w[k]*c;
	    res += v[k]*c;
	}
	ans = max(ans,res);
    }
    return ans;
}

int main(){
    cin>>N>>W;
    v = vector<ll>(N);
    w = vector<ll>(N);
    m = vector<ll>(N);
    for(int i=0;i<N;i++)cin>>v[i]>>w[i]>>m[i];
    cout<<solve()<<endl;
    return 0;
}



Measured memory_bytes: 3356
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long N, K;
long long C[100001];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  vector<P> q;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    C[a] += b;
  }
  for (int i=1; i<=100000; i++) {
    K -= C[i];
    if (K <= 0) {
      cout << i << "\n";
      return 0;
    }
  }
  return 1;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	s := sc.Text()
	x, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return x
}

func next(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	as := make([]string, n)
	bs := make([]string, n)
	for i := 0; i < n; i++ {
		x := next(sc)
		as[i] = x
		bs[i] = x
	}
	bubbleSort(as, n)
	fmt.Println("Stable")
	selectionSort(bs, n)
	var isStable = true
	for i := 0; i < n; i++ {
		if as[i] != bs[i] {
			isStable = false
			break
		}
	}
	if isStable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}

func printArray(as []string) {
	fmt.Println(strings.Trim(fmt.Sprint(as), "[]"))
}

func toInt(a string) int {
	x, err := strconv.Atoi(a[1:2])
	if err != nil {
		panic(err)
	}
	return x
}

func bubbleSort(as []string, n int) []string {
	for fixed := 0; fixed < n; fixed++ {
		for j := n - 1; j > fixed; j-- {
			if toInt(as[j-1]) > toInt(as[j]) {
				tmp := as[j-1]
				as[j-1] = as[j]
				as[j] = tmp
			}
		}
	}
	printArray(as)
	return as
}

func selectionSort(as []string, n int) []string {
	for i := 0; i < n; i++ {
		min := i
		for j := i; j < n; j++ {
			if toInt(as[min]) > toInt(as[j]) {
				min = j
			}
		}
		tmp := as[i]
		as[i] = as[min]
		as[min] = tmp
	}
	printArray(as)
	return as
}



Measured memory_bytes: 1156
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m - a].push_back(b);
  }

  priority_queue<int> q;
  long long ans = 0;
  for (int i = m - 1; i >= 0; --i) {
    for (int b: jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top(); q.pop();
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;
void solve(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		int x;
		cin>>x;
		a[i]-=x;
	}
	sort(a,a+n);
	int sum=0;
	rep(i,n){
		if(a[i]>0)sum+=a[i];
	}
	cout<<sum<<endl;
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        long n = cin.nextLong();
        long ans = 100000000000L;
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                String a = String.valueOf(i);
                String b = String.valueOf(n / i);
                ans = Math.max(a.length(), b.length());
            }
        }
        out.println(ans);
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    bool used[26];
    char p[26];
    string str;
    cin>>str;

    for(int i = 0;i < str.size();i++) {
        used[str[i] - 'a'] = true;
        p[i] = str[i];
    }

    if(str.size() == 26) {
        if(next_permutation(p,p+str.size())) {
            for(int i = 0;i < str.size();i++) {
                cout<<p[i];
                if(p[i] != str[i]) {
                    cout<<endl;

                    return 0;
                }
            }
        } else {
            cout<<-1<<endl;

            return 0;
        }
    }

    for(int i = 0;i < 26;i++) {
        if(used[i] == false) {
            str+= 'a' + i;

            break;
        }
    }

    cout<<str<<endl;

    return 0;
}


Measured memory_bytes: 256
// {{{ Template for Competitive Programming
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/math/special_functions/prime.hpp>
#include <boost/range/adaptors.hpp>

#define int int64_t
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) std::accumulate(ALL(x), 0)

using namespace std;

using vint = vector<int>;
using pint = pair<int, int>;

using boost::irange;
using boost::integer::gcd;
using boost::math::prime;

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline void dump(T a) { cout << "[ "; for (const auto e : a) { cout << e << ", "; } cout << "]" << endl; }

int ceil(int a, int b) { return (a + (b - 1)) / b; }

const int64_t INF = (int64_t)(1e18 + 1e16) + 17;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// }}}

signed main() {
	int n;
	cin >> n;
	int mx = sqrt(n) + 2;
	
	for (auto i : irange<int>(0, mx) | boost::adaptors::reversed) {
		if (n % i == 0) {
			int divisor = n / i;
			cout << i + divisor - 2 << endl;
			break;
		}
	}
}



Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    auto a = aryread();
    // writeln(a);
    long cost;
    auto new_a = new long[](n + 2);
    foreach (i; 0 .. n)
    {
        new_a[i + 1] = a[i];
    }
    // writeln(new_a);
    foreach (i; 0 .. (new_a.length - 1))
    {
        cost += abs(new_a[i] - new_a[i + 1]);
    }
    // writeln(cost);
    foreach (i; 1 .. (new_a.length) - 1)
    {
        // writeln(i - 1, i, i + 1);
        writeln(cost - (abs(new_a[i - 1] - new_a[i]) + abs(new_a[i] - new_a[i + 1])) + abs(
                new_a[i - 1] - new_a[i + 1]));
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 7392
//Artie WANG
//io
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <sstream>

//data structure
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
#include <utility>
#include <bitset>
#include <complex>


#include <cassert>

using namespace std;

const char newline = '\n';
typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;



/*
const int maxn = 1e5+1;
ll tree[maxn<<2], lazy[maxn<<2];
ll d[maxn<<2];
void update(int cur, int tl, int tr, int ql, int qr, ll v, ll dif)
{
  if (ql > qr)
    {
      return;
    }
  if (ql <= tl && tr <= qr)
    {
      tree[cur] += v;
      lazy[cur] += v;
      d[cur] += dif;
      return;
    }
  int tm = (tl+tr)>>1;
  if (lazy[cur])
    {
      lazy[cur<<1] += lazy[cur], lazy[(cur<<1)|1] += lazy[cur]
      tree[cur<<1] += lazy[cur], tree[(cur<<1)|1] += lazy[cur];
      lazy[cur] = 0;
    }
  update(cur<<1, tl, tm, ql, min(qr, tm), v);
  update((cur<<1)|1, tm+1, tr, max(tm+1, ql), qr, v);
  tree[cur] = min(tree[cur<<1], tree[(cur<<1)|1]);
}

ll query(int cur, int tl, int tr, int ql, int qr)
{
  if (ql > qr)
    {
      return 1e18;
    }
  if (ql <= tl && tr <= qr)
    {
      return tree[cur];
    }
  int tm = (tl+tr)>>1;
  if (lazy[cur])
    {
      lazy[cur<<1] += lazy[cur], lazy[(cur<<1)|1] += lazy[cur];
      tree[cur<<1] += lazy[cur], tree[(cur<<1)|1] += lazy[cur];
      lazy[cur] = 0;
    }
  ll ret = min(query(cur<<1, tl, tm, ql, min(qr, tm)), query((cur<<1)|1, tm+1, tr, max(ql, tm+1), qr));
  tree[cur] = min(tree[cur<<1], tree[(cur<<1)|1]);
  return ret;
}
*/
const int maxn = 1e5+10;
ll  n, m, a[maxn], b[maxn];
ll base[maxn<<2], dif[maxn<<2];
int main()
{
  //memset(tree, 0, sizeof(tree));
  //  memset(lazy, 0, sizeof(lazy));
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i)
    {
      scanf("%d", a+i);
      //      a[i] %= m;
    }
  for (int i = 0; i < n-1; ++i)
    {
      int cur = a[i], nxt = a[i+1];
      if (cur == nxt) continue;
      if (cur < nxt)
	{
	 
	  base[1] += nxt-cur;
	  dif[cur+1] += 1;
	  dif[nxt] -= 1;
	  base[nxt+1] -= 1;
	  base[nxt+1] += nxt-cur;
	}
      else
	{
	  base[1] += nxt;
	  base[nxt+1] -= 1;
	  base[nxt+1] += nxt+m-cur;
	  dif[1] += 1;
	  dif[nxt] -= 1;
	  dif[cur+1] += 1;
	}
    }
  ll cur = 0, diff = 0;
  for (int i = 1; i <= m; ++i)
    {
      cur += base[i]-diff;
      b[i] = cur;
      diff += dif[i];
      //      cerr << i << " " << cur << " " << diff << endl;
    }
  /*
  for (int i = 1; i <= n; ++i)
    {
      b[i] += b[i+n];
      }*/
    ll ans = b[1];
    for (int i = 1; i <= m; ++i)
    {
        ans = min(ans, b[i]);
    }
  printf("%lld\n", ans);
  
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
	int n ;
	re(n);
	vi h(n);
	re(h);
	vi dp(n);
	for(int i= n- 2 ; i>=0 ; --i){
		if(h[i] >= h[i+1]) dp[i] = 1 + dp[i+1];
	}
	cout << *max_element(all(dp)) << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test   ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

 int main(){
    io ; 
    ll int n ; cin>>n ; 
    ll int arr[n] ; map<ll int,ll int>s ; 
    for(ll int i = 0; i<n ; i++){
         cin>>arr[i] ; 
         s[arr[i]]++ ; 
    }
    ll int sum = 0 ; 
for(ll int i = 0 ; i<n ; i++){
     sum+=arr[i] ; 
}
    //cout<<sum ; 
    ll int q ;cin>>q ; 
    for(ll int i = 0 ;i<q ;i++){
        ll int b,c ;  cin>>b>>c ;
        if(s[b]!=0){
            ll int dif = b*s[b] ; ll int add = c*s[b] ; 
           
       s[c]+=s[b] ; s[b]=0 ;
        sum-=dif ; sum+=add ; 
        }
        cout<<sum<<"\n"; 
    }
    
}


Measured memory_bytes: 10104
#include<bits/stdc++.h>
using namespace std;

int main(){
    list<int> l;
    list<int> ::iterator it = l.end();
    int q, command, x, d;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>command;
        if(command==0){
            cin>>x;
            l.insert(it, x);
            it--;
            
        }else if(command==1){
            cin>>d;
            if(d>0){
                for(int j=0;j<d;j++)it++;
            }else{
                for(int j=0;j<(-1)*d;j++)it--;
            }
            
        }else{
            it = l.erase(it);
        }
    }
    
    for(it=l.begin();it!=l.end();it++){
        cout<<*it<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 18600
# -*- coding: utf-8 -*-
from functools import reduce
from operator import mul
def inpl(): return list(map(int, input().split()))
 
def primes(max_number):
    if max_number <= 2:
        raise StopIteration
    yield 2
    is_prime = [1] * max_number
    square_root_of_max = max_number ** 0.5
    for number in range(3, max_number, 2):
        if is_prime[number] is 0:
            continue
        yield number
        if number <= square_root_of_max:
            for multiple in range(number * 2, max_number, number):
                is_prime[multiple] = 0

N = int(input())
P = tuple(primes(10**3))
D = {k:1 for k in P}

for p in P:
    tmp = p
    while True:
        if tmp > N:
            break
        else:
            D[p] += N//tmp
        tmp *= p

print(reduce(mul, D.values())%(10**9+7))

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define dump(x)      cerr << #x << " = " << (x) << endl;


int main() {
    LL N, K;
    cin >> N >> K;
    VI V(N);
    REP(i, N) {
        cin >> V[i];
    }
    LL ans = 0;
    REP(nl, min(N, K) + 1) {
        REP(nr, min(N, K) + 1 - nl) {
            VI tmp(nl + nr);
            REP(i, nl) {
                tmp[i] = V[i];
            }
            REP(i, nr) {
                tmp[SZ(tmp) - 1 - i] = V[SZ(V) - 1 - i];
            }
            SORT(tmp);
            LL i;
            for (i = 0; i < min(K - (nl + nr), nl + nr); ++i) {
                if (tmp[i] >= 0) break;
            }
            LL ans_ = 0;
            FOR(j, i, SZ(tmp)) {
                ans_ += tmp[j];
            }
            if (ans_ > ans) ans = ans_;
        }
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int W=in();
    int w[N+1];
    int v[N+1];
    REP1(i,N){
        cin>>w[i]>>v[i];
    }
    vector<vector<ll>>dp(N+1);
    REP(i,N+1){
        dp[i].assign(W+1,0);
    }
    REP1(i,N){
        REP(j,W+1){
            if(j-w[i]>=0){
                chmax(dp[i][j],max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]));
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
#define maxn 500005
#define ll long long
#define mod 1000000007
using namespace std;

typedef pair<int, char> P;

int n, l;

int main()
{
    cin >> n >> l;
    int ans = 0;
    int _min = INT_MAX;
    int p = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += l + i - 1;
        if (abs(l + i - 1) < _min)
        {
            _min = abs(l + i - 1);
            p = i;
        }
    }
    printf("%d", ans - (l + p - 1));

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int dp[1001][1001] = { 0 };
int main()
{
	int sy,sx, q, k;
	char x[2001], y[2001];
	k = 0;
	scanf("%d", &q);
	for (int z = 0; z < q; z++)
	{
		if (z != 0)
		{
			for (int i = 1; i <= sy; i++)
			{
				for (int j = 1; j <= sx; j++)
					dp[i][j] = 0;
			}
		}
		scanf("%s %s", x, y);
		sx = strlen(x);
		sy = strlen(y);
		for (int i = 1; i <= sy; i++)
		{
			for (int j = 1; j <= sx; j++)
			{
				if (y[i - 1] == x[j - 1])
					dp[i][j] += dp[i - 1][j - 1] + 1;
				else
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
		printf("%d\n", dp[sy][sx]);
	}
	return 0;
}

Measured memory_bytes: 7064
#include<iostream>
#include <math.h>       /* sin */
using namespace std;
#define PI 3.1415926535897932384626


int min(int x, int y) {  
    return (x < y)? x: y;  
}  
 
double calcAngle(double h, double m)   {  
   
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
 
    double  angle = abs(hour_angle - minute_angle);  
 
    angle = min(360.0 - angle, angle);  
 
    return angle;  
}

double calcSide(double angle, int r, int s) {
double ans = (r*r*1.0);
ans += (s*s*1.0);
ans -= (2*r*1.0*s*1.0*cos(angle*PI/180));
return sqrt(ans);
}

int main() {

int r, s, h, m;
cin>>r>>s>>h>>m;

double angle = calcAngle(1.0*h, 1.0*m);
// cout<<angle<<endl;
printf("%.12f\n", calcSide(angle, r, s));

}


Measured memory_bytes: 4132
#include<bits/stdc++.h>
using namespace std;
int main(){
int h,w;
  char c[111][111];
  cin >> h >> w;
for(int i=0;i<h;i++){
cin >> c[i];
}for(int i=0;i<h;i++){
  cout<<c[i]<<endl<<c[i]<<endl;
}  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
  int a, b;
  cin >> a >> b;
  if(2*b>=a){
    cout << 0 << endl;
  }
  else{
    cout << a-2*b << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll mod = 1e9 + 7;

long long gcd(ll x, ll y){
	if(x > y) swap(x, y);
	while(x != 0){ y %= x; swap(x, y); }
	return y;
}

ll mpow(ll x, ll r){
	if(r == 0) return 1;
	if(r % 2 == 1){ return x * mpow(x, r-1) % mod; }
	else{ ll aa = mpow(x, r/2); return aa*aa%mod; }
}

long double pi = 3.14159265358979;

int main(){
	long double r; cin >> r;
	cout  << setprecision(10)<< 2*r*pi << endl;
	return 0;
}


Measured memory_bytes: 3788
// ???
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;

bool ok(int i, int j, int k){
    return i<j+k && j<i+k && k<i+j;
}

int main(){
    int n;
    cin >> n;
    vector<int> l(n), cnt(1001, 0);
    for(int i = 0; i < n; i++)  cin >> l[i], cnt[l[i]]++;
    ll ans = 0;
    // 1.7e8
    for(int i = 1; i <= 1000; i++){
        if(cnt[i] == 0) continue;
        for(int j = i+1; j <= 1000; j++){
            if(cnt[j] == 0) continue;
            for(int k = j+1; k <= 1000; k++){
                if(cnt[k] == 0) continue;
                if(ok(i,j,k))   ans += cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    vector<int> acc(1001, 0);
    for(int i = 1; i <= 1000; i++)  acc[i] = acc[i-1]+cnt[i];
    for(int i = 1; i <= 1000; i++){
        if(cnt[i] >= 2){
            ans += cnt[i]*(cnt[i]-1)/2*(acc[min(1000,2*i-1)]-cnt[i]);
            if(cnt[i] >= 3) ans += (ll)(cnt[i])*(cnt[i]-1)*(cnt[i]-2)/6;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int H, N; cin >> H >> N;
  int A[N], B[N]; rep(i,N) cin >> A[i] >> B[i];
  int dp[H+1] = {}; fill_n(dp,H+1,INF);

  rep(i,H+1) {
    if (i==0) dp[i] = 0;
    else rep(j,N) dp[i] = min(dp[i],dp[max(0,i-A[j])]+B[j]);
  }

  int result = dp[H];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(){
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m1!=m2){
        cout<<1<<endl;
    }
    else cout<<0<<endl;
}

Measured memory_bytes: 256