akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const int N=2e6+7;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}
int main()
{
    int n;
    cin>>n;
    map<string,int>m;
    rep(i,0,n)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<m.size();




















}


Measured memory_bytes: 19252
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int A = int.Parse(Console.ReadLine());
		string ans = "NO";
		if(A==3 || A==5 || A==7){
			ans = "YES";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
from collections import Counter

N = int(input())
A = [int(a) for a in input().split()]
Q = int(input())
BC = [tuple(map(int, input().split())) for _ in range(Q)]

count = Counter(A)
s = sum(A)
for b, c in BC:
    if b in count:
        s -= count[b] * b
        s += c * count[b]
        if c in count:
            count[c] += count[b]
        else:
            count[c] = count[b]
        count[b] = 0

    print(s)

Measured memory_bytes: 104052
#include<stdio.h>
#define N 10001

int linearSearch(int A[],int n,int key)
{
  int i=0;

  A[n]=key;
  if(A[0]==key){
    return 1;
  }
  while(A[i]!=key){
    i++;
  }
  if(i==n){
    return 0;
  }
  return i;
}

int main(){

  int i,n,q,key,sum=0,A[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&key);
    if(linearSearch(A,n,key)){
      sum++;
    }
  }


  printf("%d\n",sum);
  return 0;

}

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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<(n*a<b? n*a: b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char nc() {
	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
} 
template<class T> void read(T &x) {
	x=0; int f=1,ch=nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x*=f;
}
typedef long long ll;
const int MAXH=1e5+50;
const int MAXW=1e5+50;
const int maxnode=MAXH+MAXW;
int N,H,W; 
struct edge {
	int u,v,w;
	edge(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
	inline bool operator <(const edge &other) {
		return w>other.w;
	}
};
vector<edge> E;
namespace us {
	int fa[maxnode];
	bool mark[maxnode];
	void init(int n) {
		for(int i=1;i<=n;++i) {
			fa[i]=i,mark[i]=0;
		}
	} 
	int find(int a) {return a==fa[a]?a:fa[a]=find(fa[a]);}
	bool merge(int u,int v) {
		u=find(u),v=find(v);
		if(u==v) {
			if(mark[u]) return false;
			mark[u]=1; 
			return true;
		}
		if(mark[u]&&mark[v]) return false;
		fa[u]=v;
		mark[v]|=mark[u];
		return true;
	}
}
ll sol() {
	sort(E.begin(),E.end());
	ll an=0;
	us::init(H+W);
	for(unsigned int i=0;i<E.size();++i) {
		if(us::merge(E[i].u,E[i].v)) {
			an+=E[i].w;
		}
	}
	return an;
}
int main() {
	read(N),read(H),read(W);
	for(int i=1;i<=N;++i) {
		int R,C,A; read(R),read(C),read(A);
		E.push_back(edge(R,H+C,A));
	}
	printf("%lld\n",sol());
	return 0;
}

Measured memory_bytes: 2804
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 100000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

vector<ll> dijkstra(vector<vector<edge>> &g, int start, int n) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<ll> dist(n, INF_LL);
    dist[start] = 0;
    que.push(P(0, start));
    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(edge e : g[v]) {
            if(dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
    return dist;
}

signed main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> g(n);
    rep(i, n - 1) { g[i + 1].push_back({i, 0}); }
    rep(i, m) {
        int l, r;
        ll c;
        cin >> l >> r >> c;
        g[l - 1].push_back({r - 1, c});
    }
    vl dist = dijkstra(g, 0, n);
    if(dist[n - 1] == INF_LL) {
        cout << -1 << endl;
    } else {
        cout << dist[n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 10104
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int jpy = 0;
	double btc = 0;
	rep(i, n){
		double a;
		string s;
		cin >> a >> s;
		if(s == "BTC"){
			btc += a;
		}
		else{
			jpy += (int)a;
		}
	}
	double ans = jpy + (btc * 380000);
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

struct SparseTable {
private :
    const long long id = 1e18;
    vector<vector<long long>> st;
    vector<int> index;

public :
    SparseTable (const vector<long long> &v) {
        int b = 0;
        while ((1<<b) <= (int)v.size()) b++;
        st.resize(b, vector<long long>(1<<b, id));
        for (int i = 0; i < v.size(); i++) st[0][i] = v[i];
        for (int i = 1; i < b; i++) {
            for (int j = 0; j + (1<<i) <= (1<<b); j++) {
                st[i][j] = min(st[i-1][j], st[i-1][j+(1<<(i-1))]);
            }
        }
        index.resize((int)v.size() + 1);
        for (int i = 2; i < (int)index.size(); i++) {
            index[i] = index[i>>1] + 1;
        }
    }

    inline long long query (int l, int r) {
        assert(l <= r);
        if (l == r) return id;
        int b = index[r-l];
        return min(st[b][l], st[b][r-(1<<b)]);
    }

};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    long long x;
    cin >> n >> x;
    vector<long long> v(n);
    for (auto& e : v) cin >> e;

    SparseTable st(v);
    
    int l = 0, r = n-1;
    while (abs(l - r) > 2) {
        int c1 = (l * 2 + r) / 3;
        int c2 = (l + r * 2) / 3;
        long long r1 = c1 * x, r2 = c2 * x;
        for (int i = 0; i < n; i++) {
            if (c1 <= i) r1 += st.query(i-c1, i+1);
            else r1 += min(st.query(0, i+1), st.query(n-c1+i, n));
            if (c2 <= i) r2 += st.query(i-c2, i+1);
            else r2 += min(st.query(0, i+1), st.query(n-c2+i, n));
        }
        if (r1 > r2) l = c1;
        else r = c2;
    }
    
    long long a1 = l * x, a2 = (l+1) * x, a3 = (l+2) * x;
    for (int i = 0; i < n; i++) {
        if (l <= i) a1 += st.query(i-l, i+1);
        else a1 += min(st.query(0, i+1), st.query(n-l+i, n));
        if (l+1 <= i) a2 += st.query(i-l-1, i+1);
        else a2 += min(st.query(0, i+1), st.query(n-l-1+i, n));
        if (l+2 <= i) a3 += st.query(i-l-2, i+1);
        else a3 += min(st.query(0, i+1), st.query(n-l-2+i, n));
    }
    
    cout << min({a1, a2, a3}) << endl;
    return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    int mini = 1001001001;
    int mn;
    rep(i, N){
        cin >> A[i];
        if(mini > A[i]){
            mini = A[i];
            mn = i;
        }
    }
    N--;
    N--;
    int ans = (N/(K-1))+1;

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define PI 				acos(-1)
	#define mp				make_pair
	#define pb				push_back
	#define all(a)			(a).begin(), (a).end()
	#define sz(a)			a.size()
	#define srt(a)			sort(all(a))
	#define mem(a, h)		memset(a, (h), sizeof(a))
	#define f 				first
	#define s 				second
	#define MOD1			998244353
	#define fore(i, b, e)	for(int i = b; i < e; i++)
	#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
	int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

	using namespace std;
	using namespace __gnu_pbds;

	typedef long long 		ll;
	typedef unsigned long long 		ull;
	typedef pair<int, int>  ii;
	typedef vector<int>     vi;
	typedef vector<ii>      vii;
	typedef vector<ll>      vll;
	typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
	const int tam = 100010;
	const int MOD = 1e9+7;
	const double EPS = 1e-9;

		int n, m;
		char grid[100][100];
		bool visited[100][100];
		bool valid(int x, int y)
		{
			if(x >= 0 && x < n && y >= 0 && y < m && !visited[x][y] && grid[x][y] == '.')
				return true;
			return false;
		}
	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0);
		//freopen("qwe.txt", "r", stdin);
		//freopen("asd.txt", "w", stdout);
		cin>>n>>m;
		mem(visited, 0);
		int conbla = 0;
		fore(i, 0, n) 
		{
			cin>>grid[i];
			fore(j, 0, m)
				conbla += grid[i][j] == '#';
		}
		queue<pair<pair<int, int>,int>> que;
		que.push(mp(mp(0, 0), 1));
		int pasos = -1;
		int x, y, pas;
		int mover[2][4] = {{1, 0, -1, 0}, {0, 1, 0, -1}};
		while(!que.empty())
		{
			x = que.front().f.f;
			y = que.front().f.s;
			pas = que.front().s;
			if(x == n-1 && y == m-1)
				pasos = pas;
			que.pop();
			fore(i, 0, 4)
			{
				if(valid(x + mover[0][i], y + mover[1][i]))
				{
					visited[x + mover[0][i]][y + mover[1][i]] = 1;
					que.push(mp(mp(x + mover[0][i], y + mover[1][i]), pas + 1));
				}
			}
		}
		if(pasos == -1)
			cout<<"-1\n";
		else
			cout<<n * m - pasos - conbla<<'\n';
		return 0;
	}

	// read the question correctly (is y a vowel? what are the exact constraints?)
	// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	cout<<n/2+(n%2!=0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.rbegin(); i!=a.rend();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define mod 998244353
#define limit 1000
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  

typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
ll dp[3][100005],a[100005],b[100005],c[100005],n;

ll ans(int i,int last) {
	if(i==n) return 0; 
	if(dp[last][i]!=-1) return dp[last][i];
	if(last == 0) {		
		return dp[last][i] = max(b[i]+ans(i+1,1),c[i]+ans(i+1,2));
	}
	else if(last == 1) {
		return dp[last][i] = max(a[i]+ans(i+1,0),c[i]+ans(i+1,2));
	}
	else if(last==2){
		return dp[last][i] = max(a[i]+ans(i+1,0),b[i]+ans(i+1,1));
	}
}

void solve() {
	cin >> n ;
	rep(i,0,n) cin >> a[i] >> b[i] >> c[i] ;
	fl(dp,-1);
	cout << max({a[0]+ans(1,0),b[0]+ans(1,1),c[0]+ans(1,2)}) ;
}

int32_t main() {

    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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

const int MAX = 1001001001;
template<class T> bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

int dp[10050];

int main(){
  int h, n; cin >> h >> n;
  vector<int> a(n), b(n);
  for(int i = 1; i <= h + 10; i++) dp[i] = MAX;
  for(int i = 0; i < n; i++){
    cin >> a.at(i) >> b.at(i);
    dp[a[i]] = b[i];
  }
  for(int i = 1; i <= h; i++){
    for(int j = 0; j < n; j++){
      if(i-a[j] > 0){
        chmin(dp[i], dp[i-a[j]] + b[j]);
      }
      else{
        chmin(dp[i], b[j]);
      }
    }
  }
  cout << dp[h] << endl;
}
    
  


Measured memory_bytes: 3648
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			int n = sc.nextInt();
			int r = sc.nextInt();
			
			if (n == 0 && r == 0) break;
			
			int cards[] = new int[n];
			
			for (int i = 0; i < n; i++)
			{
				cards[i] = n - i;
			}
			int top = 0;
			for (int i = 0; i < r; i++)
			{
				int p = sc.nextInt();
				int c = sc.nextInt();
				int tmp[] = new int[c];
				for (int j = p - 1; j < p + c - 1; j++)
				{
					tmp[j - p + 1] = cards[j];
				}
				for (int j = p - 2; j >= 0; j--)
				{
					cards[j + c] = cards[j];
				}
				for (int j = 0; j < c; j++)
				{
					cards[j] = tmp[j];
				}
				top = tmp[0];
			}
			System.out.println(top);
		}
	}
}

Measured memory_bytes: 12000
# https://atcoder.jp/contests/abc109/tasks/abc109_c

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def gcd(x: int, y: int) -> int:
    if x < y:
        x, y = y, x
    while y > 0:
        r = x % y
        x, y = y, r
    return x


def main():
    n, x = input_int_list()
    X = input_int_list()
    ans = abs(x - X[0])
    for i in range(1, n):
        ans = gcd(ans, abs(x - X[i]))
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 84892
from sys import stdin,stdout
input = stdin.readline
def write(n,sep="\n"):
	stdout.write(str(n))
	stdout.write(sep)
def gil():
	return list(map(int, input().split()))

s=input()
c=0
ans=0
n=len(s)
for i in range(n):
  if s[i]=='R':
    c+=1
    ans=c
  else:
    c=0
    ans=max(ans,c)
print(ans)

Measured memory_bytes: 61828
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define M 998244353

int main(){
	int n, k;
	cin>>n>>k;
	vector<int> l(k), r(k);
	rep(i, k) cin>>l[i]>>r[i];

	vector<int> dp(n), sdp(n);
	dp[0]=sdp[0]=1;
	for(int i=1; i<n; i++){
		rep(j, k){
			int s=i-r[j];
			int t=i-l[j];
			if(t<0) continue;
			int sdps= (s<=0)?0:sdp[s-1];
			dp[i]=((ll)dp[i] + sdp[t] - sdps +M)%M;
		}
		sdp[i]=((ll)sdp[i-1]+dp[i])%M;
	}

	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;    
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
#define PI 3.1415926535897932384626433832795
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define trav(x,v) for (auto &x : v)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pv(v) trav(x, v) cout << x << " "; cout << endl; // print vector/array
#define pvv(vv) trav(xx, vv){pv(xx);} // print 2-d vector/2-d array
#define pm(m) trav(x, m) cout << x.F << ":" << x.S << " "; cout << endl; //print map/lookup table

const int MOD = 1000000007;

ll dp[2][100005];

ll solve(ll n, ll W, ll *w, ll *v){
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=W;j++){
            if(w[i] > j)
                dp[i%2][j] = dp[(i+1)%2][j];
            else
                dp[i%2][j] = max(dp[(i+1)%2][j - w[i]] + v[i], dp[(i+1)%2][j]);
        }
    }
    return dp[(n-1)%2][W];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,W;
    cin >> n >> W;
    ll v[n],w[n];
    memset(dp,0,sizeof(dp));
    F0R(i, n)
        cin >> w[i] >> v[i];  
    cout << solve(n, W, w, v);
    return 0;
}

Measured memory_bytes: 5168
#include <stdio.h>

main(){
  int i,j,a[100],n;
  int flag=1,k,d=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  while(flag){
    flag=0;
    for(i=n-1;i>0;i--){
      if(a[i]<a[i-1]){
	k=a[i-1];
	a[i-1]=a[i];
	a[i]=k;
	flag++;
      }
    }
      d+=flag;
  }
  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]); 
  printf("%d\n",d);
  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int A[N]; 
    rep(i, N) cin >> A[i];

    int num=0;
    rep(i, N) num+=A[i];
    double border=num/(4.0*M);
    int sum=0;
    rep(i, N) if(A[i]>=border) sum++;
    if(sum>=M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
const int M =998244353; 
#define int long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>  
const int mod = 1e9 + 7;
const int N = 3e3 + 7;
 
int n,a[N],sum;
int dp[N][N][2];
int solve(int i,int j,int ch) {

	if(i>j||i>n-1||j<0){
		
		return 0;
	}
	if(dp[i][j][ch]!=-1)return dp[i][j][ch];
	
	int val;
	int x = solve(i,j-1,(ch+1)%2);
	int y = solve(i+1,j,(ch+1)%2);
	if(ch==0){
		x=x+a[j];
		y=y+a[i];
		 val=max(x,y);
		
	}
	else{
		
		 x -=a[j];
		 y -=a[i];
		 val=min(x,y);
		

	}
	dp[i][j][ch]=val;
	return val;
 
 
}
 
signed main() {
  fast;
  
  cin>>n;
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  	
  	
  memset(dp,-1,sizeof(dp));
  cout<<solve(0,n-1,0);
  



  	
}

Measured memory_bytes: 141696
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		println(a*b%2 == 0 ? "Even" : "Odd");

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 21844
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string s;
int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	for(int i=sz(s)-1;i>=1;i--){
		if(i%2)
		continue;
		string t=s.substr(0,i/2),t2=s.substr(i/2,i/2);
		if(t==t2){
			cout<<i;
			re 0;
		}
	}
	cout<<0;
	re 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(W >= S ? "unsafe" : "safe");
	}
	int S,W;
	public Sol(){
		var d = ria();
		S = d[0]; W = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27560
import sys

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))
 
d = [0]*N
ans = 0
for i in range(N):
    a = A[i]
    l,r = i+a, i-a
    if 0 <= l < N:
        d[l] += 1
    if 0 <= r < N:
        ans += d[r]
 
print(ans)

Measured memory_bytes: 32212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a = s.nextInt();
		int rest = n % 500;

		if (rest == 0) {
			System.out.println("Yes");
		} else if (a < rest) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 21716
while True:
    t,p,r=map(int,raw_input().split())
    if t==0: break
    score=[]
    for i in xrange(t):
        score.append((p,0,i+1))
    wrong=[[0]*p for _ in xrange(t)]
    for _ in xrange(r):
        tID,pID,time,mes=raw_input().split()
        tID=int(tID)-1
        pID=int(pID)-1
        time=int(time)
        if mes=="WRONG":
            wrong[tID][pID]+=1
        else:
            score[tID]=(score[tID][0]-1,score[tID][1]+time+wrong[tID][pID]*1200,score[tID][2])
    score=sorted(score)
    for a,b,c in score:
        print "%d %d %d" % (c,p-a,b)

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

using namespace std;
#define BUF (1000)
#define ll long long 

int n,A,B;

int main(void){
	int ans;
	cin >> n >> A >> B;
	
	ans = (B-A)%2;

	if(ans == 0) cout << "Alice\n";
	else cout << "Borys\n";	
	return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    import heapq
    import collections
    input = sys.stdin.readline
    x, y, z, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort(reverse=True)
    b = list(map(int, input().rstrip('\n').split()))
    b.sort(reverse=True)
    c = list(map(int, input().rstrip('\n').split()))
    c.sort(reverse=True)
    q = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
    heapq.heapify(q)
    fq = collections.defaultdict(list)
    fq[(-(a[0] + b[0] + c[0]), 0, 0, 0), 1] = 1
    t = 0
    for _ in range(k):
        if len(q) != 0:
            p = heapq.heappop(q)
            t = p[0]
            aq = p[1]
            bq = p[2]
            cq = p[3]
            if aq + 1 < len(a):
                if (-(a[aq+1] + b[bq] + c[cq]), aq+1, bq, cq) not in fq:
                    heapq.heappush(q, [-(a[aq+1] + b[bq] + c[cq]), aq+1, bq, cq])
                    fq[(-(a[aq+1] + b[bq] + c[cq]), aq+1, bq, cq)] = 1
            if bq + 1 < len(b):
                if (-(a[aq] + b[bq+1] + c[cq]), aq, bq+1, cq) not in fq:
                    heapq.heappush(q, [-(a[aq] + b[bq+1] + c[cq]), aq, bq+1, cq])
                    fq[(-(a[aq] + b[bq+1] + c[cq]), aq, bq+1, cq)] = 1
            if cq + 1 < len(c):
                if (-(a[aq] + b[bq] + c[cq+1]), aq, bq, cq+1) not in fq:
                    heapq.heappush(q, [-(a[aq] + b[bq] + c[cq+1]), aq, bq, cq+1])
                    fq[(-(a[aq] + b[bq] + c[cq+1]), aq, bq, cq+1)] = 1
        print(-t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 62572
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string s;
int K;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> s>> K;

	std::vector<std::string> vec;
	vec.reserve(5000 * 5);
	for (int32_t k = 1; k <= K; k++)
	{
		for (int32_t i = 0; i <= (int)(s.size()) - k; i++)
		{
			vec.emplace_back(s.substr(i, k));
		}
	}
	std::sort(vec.begin(), vec.end());
	vec.erase(std::unique(all_range(vec)), vec.end());
	out << vec[K - 1] << endl;

	return 0;
}
#endif


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>v(n);
  for(int i=0;i<n;++i) cin>>v[i];
  sort(v.begin(),v.end());
  int sum=0;
  for(int i=0;i<k;++i) sum+=v[i];
  cout<<sum;
return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
int main(){
int h,w,i,j;
  cin>>h>>w;
  int dp[h][w];
  char m[h][w];
  int mod=1000000007;
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
      cin>>m[i][j];
  }
  for(i=h-1;i>=0;i--)
  {
    for(j=w-1;j>=0;j--)
    {
      if(m[i][j]=='#')
        dp[i][j]=0;
      else if(i==h-1 && j==w-1)
        dp[i][j]=1;
      else if(i==h-1)
        dp[i][j]=dp[i][j+1];
      else if(j==w-1)
        dp[i][j]=dp[i+1][j];
      else
        dp[i][j]=(dp[i][j+1]+dp[i+1][j])%mod;
    }
  }
  cout<<dp[0][0]%mod;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

bool is_prime(int x){
	for(int i=2; i*i<x;++i){
		if(x%i==0) return false;
	}
	return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
 
  int x,ans=0; cin >> x;
  while(!is_prime(x)) x++;
  cout << x << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <string>
#include <set>

using namespace std;

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

set<string> str;

void dfs(string s, size_t p, int used) {
    if(p == s.size()){
        str.insert(s);
        return;
    }
    if(s[p] != 'z' && !(used >> (s[p] - 'a' + 1) & 1)){
        s[p]++;
        dfs(s, p + 1, used | 1 << (s[p] - 'a'));
        s[p]--;
    }
    if(used >> (s[p] - 'a') & 1) dfs(s, p + 1, used);
}

int main(){
    for (string in; cin >> in, in != "#";) {
        str.clear();
        dfs(in, 0, 1);
        cout << str.size() << '\n';
        if(str.size() <= 10) for(auto e: str) cout << e << '\n';
        else{
            auto fwd = str.begin();
            auto bwd = next(str.rbegin(), 5);
            rep(i, 5) cout << *(fwd++) << '\n';
            rep(i, 5) cout << *(--bwd) << '\n';
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 200100;

int n, x;
bool u[M];
int a[M];

void read() {
  cin >> n >> x;
}

void kill() {
  n = 2 * n - 1;

  if (x <= 1 || x >= n) {
    cout << "No\n";
    return;
  }

  cout << "Yes\n";

  deque<int> ans;
  for (int i = -1; i <= 1; ++i) {
    ans.push_back(x + i);
    u[x + i] = true;
  }

  int bon = 0;
  for (int i = 1; i <= n; ++i)
    if (!u[i]) {
      if (bon)
        ans.push_back(i);
      else
        ans.push_front(i);
      bon ^= 1;
    }
      

  for (int x : ans)
    cout << x << "\n";
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 2304
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let s = get!(String).chars().collect::<Vec<_>>();

    let mut h = 0;
    let mut t = 0;
    let mut x = 0;
    for i in 0..n {
        if s[i] == '(' {
            x += 1;
        } else if x > 0 {
            x -= 1;
        } else {
            h += 1;
        }
    }
    x = 0;
    for i in (0..n).rev() {
        if s[i] == ')' {
            x += 1;
        } else if x > 0 {
            x -= 1;
        } else {
            t += 1;
        }
    }


    let mut r = Vec::new();
    for _ in 0..h { r.push('('); }
    for c in s.into_iter() { r.push(c); }
    for _ in 0..t { r.push(')'); }
    println!("{}", r.into_iter().collect::<String>());
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int countOne(char* s);
int main() {
  char s[4];
  int cnt;
  cin >> s;
  cnt = countOne(s);  
  cout << cnt << endl;
}
int countOne(char* s) {
  int cnt;
  for(int i = 0; s[i] != '\0'; ++i) 
    if(s[i] == '1')
      ++cnt;
  return cnt;

}

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

int main() {
  int n, x, mi = 1000;
  cin >> n >> x;
  vector<int> m(n);
  rep(i, n) cin >> m[i];
  rep(i, n){
    x -= m[i];
    mi = min(mi, m[i]);
  }
  cout << n + x/mi << endl;
  return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#define sz(v) (int)v.size()
#define ll long long
#define ull unsigned long long
using namespace std;
const int PI = 3.14159265;
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//freopen("file.in","r",stdin);
	//freopen("file.out","w",stdout);
	fast();

	int n, k, p[1001];
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(p, p + n);
	ll sum = 0;
	for (int i = 0; i < k; i++)
	{
		sum += p[i];
	}
	cout << sum << '\n';

	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <vector>
using namespace std;

struct node {
    int val;
    node *left, *right;
    node() : val(-1), left(NULL), right(NULL) { }
};

void print(node* cur) {
    while (cur != NULL) {
        cout << cur->val + 1;
        if (cur->right) cout << " ";
        cur = cur->right;
    }
    cout << endl;
}

int main() {
    int N, Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i], --a[i];

    vector<node*> vec(N);
    node *head = new node();
    node *tail = new node();
    for (int i = 0; i < N; ++i) vec[i] = new node();
    for (int i = 0; i < N; ++i) {
        if (i > 0) vec[a[i]]->left = vec[a[i-1]];
        else head = vec[a[i]];
        if (i+1 < N) vec[a[i]]->right = vec[a[i+1]];
        else tail = vec[a[i]];
        vec[a[i]]->val = a[i];
    }

    //print(head);

    for (int _ = 0; _ < Q; ++_) {
        int q; cin >> q; --q;

        if (vec[q] == head) {
            vec[q]->left = tail;
            tail->right = vec[q];
            vec[q]->right->left = NULL;
            head = vec[q]->right;
            vec[q]->right = NULL;
            tail = vec[q];
        }
        else if (vec[q] == tail) {
            vec[q]->right = head;
            head->left = vec[q];
            vec[q]->left->right = NULL;
            tail = vec[q]->left;
            vec[q]->left = NULL;
            head = vec[q];
        }
        else {
            vec[q]->left->right = NULL;
            swap(vec[q]->left, tail);
            vec[q]->left->right = vec[q];
            vec[q]->right->left = NULL;
            swap(vec[q]->right, head);
            vec[q]->right->left = vec[q];
        }
        
        //print(head);
    }

    print(head);
}


























Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if(s[s.size()-1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  int n, h, w; cin >> n >> h >> w;
  int ans = 0;

  rep(i, n) {
    int a, b; cin >> a >> b;
    if (a >= h && b >= w) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

const int INF = 1e9 + 7;


int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	ll a, b;
	cin >> a >> b;

	ll ans = 0;

	//bit最大は45くらいで
	vector<ll> bit(ARRAY_MAX, 0);

	if ((((b + 1) / 2) % 2) == 1) {
		bit[0] ^= 1;
	}

	//bの各桁のビットを求める
	for (ll i = 45; i > 0; i--) {
		//1桁目は別で調べる
		//i桁目を見る
		ll high = 1LL << (i + 1);//これで割る
		ll low = 1LL << i;
		if (b%high >= low) {
			if ((b%high) % 2 == 0) {
				//この数字まで1が奇数個ある
				bit[i] ^= 1LL;
			}
		}
	}

	a--;//累積和の感覚

	//1桁目
	if ((((a + 1) / 2) % 2) == 1) {
		bit[0] ^= 1LL;
	}

	for (ll i = 45; i > 0; i--) {
		//1桁目は別で調べる
		//i桁目を見る
		ll high = 1LL << (i + 1);//これで割る
		ll low = 1LL << i;
		if (a%high >= low) {
			if ((a%high) % 2 == 0) {
				//この数字まで1が奇数個ある
				bit[i] ^= 1LL;
			}
		}
	}

	for (int i = 0; i <= 45; i++) {
		if (bit[i] == 1) {
			ans += (1LL << i);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    vector<LL> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    LL k;
    cin >> k;
    cout << a.at(k-1) << endl;
    return 0;
}

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

int main(){
    int i,t,n,s,w;
    cin>> s>> w;
    if(w >= s)
        cout<< "unsafe"<<endl;
    else
        cout<<"safe"<<endl;
    
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll A,N,T,K;
    vector<ll>V,V1;
    while(cin>>N>>K){
        ll cnt=0;
        for(ll i=0;i<N;i++){
            ll x;
            cin>>x;
            if(x>=K){
                cnt++;
            }
        }
    cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)

int n,a,b;
string s;

int main() {
    cin>>n>>a>>b;
    cin>>s;
    int c = a+b;

    int p=0, q=0;
    rep(i,n) {
        bool f = false;
        if(s[i]=='a'){
            if(p < c) {
                f = true;
            }
            p++;
        }else if(s[i]=='b'){
            q++;
            if(p<c and q<=b) {
                f = true;
                p++;
            }
        }
        cout << (f ? "Yes" : "No") << "\n";
    }


    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=998244353;
const int N=300;

ll n, m, k, u, v, x, y, t, a, b, ans, cnt;
ll tav[N+1];
bitset<N> A[N], G[N];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	tav[0]=1;
	for (int i=1; i<=N; i++) tav[i]=tav[i-1]*2%mod;
	cin>>n>>m;
	for (int i=0; i<n; i++) for (int j=0; j<m; j++){
		cin>>x;
		if (x) A[i].set(j);
	}
	for (int i=0; i<N; i++){
		for (int j=0; j<cnt; j++){
			int lb=G[j]._Find_first();
			if (A[i][lb]) A[i]^=G[j];
		}
		if (!A[i].count()) continue ;
		for (int j=0; j<cnt; j++){
			int lb=A[i]._Find_first();
			if (G[j][lb]) G[j]^=A[i];
		}
		G[cnt++]=A[i];
	}
	ans=(tav[n]-tav[n-cnt])*tav[m-1]%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
using namespace std;

class unionFind {
private:
	int* p;   //親配列のポインタ
	int N;   //要素数
public:
	unionFind(int);   //コンストラクタ
	int parent(int);   //親要素を返す
	void unit(int, int);   //2要素をつなぐ
	int operator[](int);   //parentの省略形
	~unionFind();
	int size();   //要素数を返す
};

unionFind::unionFind(int n) {
	N = n;
	p = new int[N];
	for (int i = 0; i < N; i++)p[i] = i;
	return;
}

int unionFind::parent(int n) {
	if (n < 0 || n >= N)return -1;
	if (p[n] == n)return n;   //自分が一番上の親
	return p[n] = parent(p[n]);   //つなぎ直しと上にたどる操作
}

int unionFind::operator[](int n) {
	return parent(n);
}

void unionFind::unit(int x, int y) {
	int X = parent(x), Y = parent(y);
	if (X == Y)return;   //根が同じだから何もせずに帰る
	p[X] = Y;
	return;
}

unionFind::~unionFind() {
	delete(p);
	return;
}

int unionFind::size() {
	return N;
}

int N, M;
int P[100000];
void solve() {
	cin >> N >> M;
	for (int n = 0; n < N; n++) {
		cin >> P[n];
		P[n]--;
	}
	unionFind u(N);
	for (int m = 0; m < M; m++) {
		int x, y;
		cin >> x >> y;
		u.unit(--x, --y);
	}
	int ans = 0;
	for (int n = 0; n < N; n++) {
		if (P[n] == n)ans++;
		else if (u[P[n]] == u[n])ans++;
	}
	cout << ans << endl;
	return;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a[3], b[3];
	rep(i, 3) cin >> a[i] >> b[i];
	
	int cnt[4] = {};
	rep(i, 3) {
		cnt[a[i] - 1]++;
		cnt[b[i] - 1]++;
	}
	
	sort(cnt, cnt + 4);
	if (cnt[0] == 1 and cnt[1] == 1 and cnt[2] == 2 and cnt[3] == 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a == b) {
      System.out.println(c);
    } else if (b == c) {
      System.out.println(a);
    } else {
      System.out.println(b);
    }
  }
}

Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

	int a[3];
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	sort(a, a + 3);
	for (int i = 0; i < 2; i++)
		cout << a[i]<<" ";
	cout << a[2] << endl;

	return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B; cin >> A >> B;
	if (A <= B) {
		cout << "unsafe" << endl;
	}
	else cout << "safe" << endl;

	return 0;
}



Measured memory_bytes: 3648
using System;

public class Test
{
	public static void Main()
	{
		var n = int.Parse( Console.ReadLine() );
		for(int i = 1; i <=n; i++) {
			if( (i%3) == 0 ) {
				Console.Write(" " + i);
			} else {
				int x = i;
				while(x != 0) {
					if( (x%10) == 3 ) {
						Console.Write(" " + i);
						break;
					}
					
					x /= 10;
				}
			}
		}
		
		Console.WriteLine();
	}
}

Measured memory_bytes: 9344