akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, g;
    cin >> n >> g;
    vector<int> p(n+1), c(n+1);
    repeat (i, n) cin >> p[i+1] >> c[i+1];
    
    int ans = 1e9;
    vector<int> v;
    repeat_from_to (i, 1, n) {
        v.push_back(i);
    }
    
    do {
        int probs = 0;
        int rest = g;
        for (int score: v) {
            //dump(score); el;
            int maxget = p[score] * score * 100 + c[score]; //dump(maxget);
            if (maxget < rest) {
                probs += p[score]; //dump(probs);
                rest  -= maxget;   //dump(rest); el;
            }
            else if ( (p[score]-1) * score * 100 >= rest ) {
                probs += (rest + (score * 100 - 1)) / (score * 100); //dump(probs); cout << " break" << endl;
                break;
            }
            else {
                probs += p[score]; //dump(probs); cout << " break" << endl;
                break;
            }
        }
        ans = min(ans, probs);
    } while (next_permutation(v.begin(), v.end()));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

ll powl(ll a,ll b){
  ll i,ans=1;
  rep(i,b){
    ans*=a;
  }
  return ans;
}

int main(){
  ll i,j,N,M,K,ans=0;
  cin>>N;
  K=countdigits(N);
  if(K==1){cout<<N<<endl;return 0;}
  if(K%2){
    ans+=N+1-powl(10,K-1);
  }
  while(--K){
    if(K%2){
      ans+=9*powl(10,K-1);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll h,w,k;
    cin>>h>>w>>k;
    ll grid[h][w];
    rep(i,h)
    {
      rep(j,w)
      {
        char ch;
        cin>>ch;
        if(ch=='.')
        {
          grid[i][j]=0;
        }
        else grid[i][j]=1;
      }
    }
    // rep(i,h)
    // {
    //   rep(j,w) cout<<grid[i][j]<<" ";
    //   cout<<'\n';
    // }
    ll ans=0;
    // ll i=1;
    // ll j=1;
    // rep(a,h)
    //     {
    //       if(i&(1<<a))
    //       {
    //         rep(b,w) grid[a][b]=0;
    //       }
    //     }
    //     rep(i,h)
    //     {
    //       rep(j,w) cout<<grid[i][j]<<" ";
    //       cout<<'\n';
    //     }
    rep(i,1<<h)
    {
      rep(j,1<<w)
      {
        ll temp[h][w];
        rep(a,h)
        {
          rep(b,w) temp[a][b]=grid[a][b];
        }
        rep(a,h)
        {
          if(i&(1<<a))
          {
            rep(b,w) temp[a][b]=0;
          }
        }
        rep(b,w)
        {
          if(j&(1<<b))
          {
            rep(a,h) temp[a][b]=0;
          }
        }
        ll num=0;
        rep(a,h)
        {
          rep(b,w)
          {
            if(temp[a][b]==1) num++;
            // watch(temp[a][b]);
          }

        }
        // cout<<'\n';
        if(num==k) ans++;
      }
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int x,y,z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let K: usize = read();
    let A: usize = read();
    let B: usize = read();

    if A / K != B / K || A % K == 0 || B % K == 0 {
        println!("OK");
    } else {
        println!("NG");
    }
}


Measured memory_bytes: 2144
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s = to_string(n);
    rep(i, 2)
    {
        bool ans = true;
        for (int j = i; j < i + 3; j++)
        {
            if (s[i] != s[j])
            {
                ans = false;
            }
        }
        if (ans)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define PP std::pair<int,int>
int N;
char M[210][210];
int DP[210][210];
int ans;
std::vector<PP> B;

void solve(int x,int y){
    x--,y--;
    for(int i=y;i>=0;i--){
            for(int j=x;j>=0;j--){
                if(M[j][i]=='R'){
                    ans++;
                    M[j][i]='.';
                    return;
                }
            }
        }
}
int main(){
    std::cin>>N;
    for(int i=0;i<N;i++){
        int a,b;
        std::cin>>a>>b;
        M[a][b]='R';
    }
    for(int i=0;i<N;i++){
        int a,b;
        std::cin>>a>>b;
        M[a][b]='B';
        B.emplace_back(PP{a,b});
    }
    std::sort(B.begin(),B.end());
    for(auto u:B){
        solve(u.first,u.second);
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)


int node;

void DFS(int start, vector<int> v[],vector<int> &visited) {
    visited[start] = 1;
    node++;
    for(int i= 0; i<v[start].size(); ++i) {        
    if(visited[v[start][i]] == 0)
        DFS(v[start][i], v, visited);        
    }    
}

int main()
{
	fastio();
	int n,m;
	cin>>n>>m;
	vector<int> ed[n+1], visited(n+1,0);
	fr(i,0,m,1){
		int a,b;
		cin>>a>>b;
		ed[a].pb(b);
		ed[b].pb(a);
	}
	int ans=0;
	
	fr(i,1,n+1,1){
		if(visited[i]==0){
			node=0;
			DFS(i,ed,visited);
			ans=max(ans,node);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 24308
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	string s;
	ll date1,date2;
	cin>>s;
	date1=(s[0]-'0')*10+(s[1]-'0');
	date2=(s[2]-'0')*10+(s[3]-'0');
	if(date1<=12&&date1>=1){
		if(date2<=12&&date2>=1) cout<<"AMBIGUOUS"<<endl;
		else cout<<"MMYY"<<endl;
	}else if(date2<=12&&date2>=1){
		cout<<"YYMM"<<endl;
	}else{
		cout<<"NA"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,s1,a[200010],b[200010],sum[200010],ans;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	n=read();
	for (int i=1;i<=n;++i)
	{
		b[i]=s1;
		s1+=i;
	}
	for (int i=1;i<=n;++i)
	{
		a[i]=read();
		sum[i]=sum[i-1]+a[i];
		if (sum[i]==0) ans++;
	}
	sort(sum+1,sum+n+1);
	for (int i=1;i<=n;++i)
	{
		long long s2=1;
		while (sum[i+1]==sum[i]&&i<n)
		{
			s2++;
			i++;
		}
		ans+=b[s2];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
N = int(input())
H = list(map(int, input().split()))
a, b = 0, abs(H[0] - H[1])
for x, y, z in zip(H[0:], H[1:], H[2:]):
    a, b = b, min(a + abs(x - z), b + abs(y - z))
print(b)

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    rep(i, 0, n) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y, y + n);
    rep(i, 0, n) {
        if (x[i] <= y[n / 2 - 1]) cout << y[n / 2] << endl;
        else cout << y[n / 2 - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N,K;
    ll ans = 1;
    cin >> N >> K;
    ans *= K;
    REP(i,N-1){
        ans *= K-1;
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
static const int MAXN = 2004;

int n, m;
bool a[MAXN][MAXN];
bool b[MAXN][MAXN] = {{ false }};

int f[MAXN][MAXN];
int s[MAXN], top;

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        getchar();
        for (int j = 0; j < m; ++j)
            a[i][j] = (getchar() == '#' ? 1 : 0);
    }

    for (int i = 0; i < n - 1; ++i)
        for (int j = 0; j < m - 1; ++j)
            b[i][j] = a[i][j] ^ a[i][j + 1] ^ a[i + 1][j] ^ a[i + 1][j + 1];

    for (int i = 0; i < n - 1; ++i)
        for (int j = 0; j < m - 1; ++j)
            if (b[i][j]) f[i][j] = 0;
            else f[i][j] = 1 + (i == 0 ? 0 : f[i - 1][j]);

    int ans = std::max(n, m);
    for (int i = 0; i < n - 1; ++i) {
        s[0] = 0; top = 1;
        for (int j = 1; j < m - 1; ++j) {
            while (top > 0 && f[i][s[top - 1]] > f[i][j]) {
                ans = std::max(ans, (f[i][s[top - 1]] + 1) * (j - (top >= 2 ? s[top - 2] + 1 : 0) + 1));
                --top;
            }
            s[top++] = j;
        }
        for (int j = 0; j < top; ++j)
            ans = std::max(ans, (f[i][s[j]] + 1) * (m - 1 - (j > 0 ? s[j - 1] + 1 : 0) + 1));
    }

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


Measured memory_bytes: 23680
/*input
10 100000
50000 50001 50002 50003 50004 50005 50006 50007 50008 50009
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll inv[maxn];
ll dp[maxn];
int p[maxn];
int main(){
	IOS;
	int n,x;
	cin>>n>>x;
	for(int i=1;i<=n;i++) inv[i]=mypow(i,MOD-2);
	REP(i,n) cin>>p[i];
	sort(p,p+n);

	dp[x]=1;
	for(int i=1;i<=n;i++) dp[x]=dp[x]*i%MOD;
	for(int i=n-1;i>=0;i--){
		if(i==0){
			REP(j,x+1) if(j>=p[i]){
				dp[j%p[i]]=(dp[j%p[i]]+dp[j])%MOD;
				dp[j]=0;
			}
		}
		else{
			REP(j,x+1) dp[j]=dp[j]*i%MOD*inv[i+1]%MOD;
			REP(j,x+1) dp[j%p[i]]=(dp[j%p[i]]+dp[j]*inv[i])%MOD;
		}
		// for(int i=0;i<=x;i++) cout<<dp[i]<<" \n"[i==x];
	}
	ll ans=0;
	REP(i,x+1){
		ans+=dp[i]*i%MOD;
		if(ans>=MOD) ans-=MOD;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 25
#define M 1000000007
#define ll long long
#define inf 1000000000000000000
ll n, arr[N][N], dp[1 << 21];


int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) for(int j = 1;j <= n; j++) cin >>arr[i][j];
    dp[0] = 1;
    for(int i = 1; i < (1 << n); i++)
    {
        int cn = __builtin_popcount(i);
        for(int j = 0; j < n; j++)
        {
            if(arr[cn][j + 1] && ((i >> j) & 1))
            {
                dp[i] = (dp[i] + dp[i ^ (1 << j)]) % M;
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}





Measured memory_bytes: 16640
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  string str;
  cin >> str;

  int c = str[0];

  int cnt = 0;
  for (int i = 1; i < str.size(); i++){
    if (c == str[i]) continue;
    c = str[i];
    cnt++;
  }

  cout << cnt << endl;

}



Measured memory_bytes: 640
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        long A = sc.nextLong();
	        long B = sc.nextLong();
	        long ans=0;
	        long a1=(B+1)/2-A/2;
	        if(a1%2!=0) {
	        	if(a1>=0)ans++;
	        }
	        long tmp=2;
	        for(long i=1;i<40;i++) {
	        	tmp=2*tmp;
	        	long a = A%tmp;
	        	long b = B%tmp;
	        	if(a<=tmp/2) {
	        		a=0;
	        	} else {
	        		a=tmp-a;
	        	}
	        	if(b<tmp/2) {
	        		b=0;
	        	} else {
	        		b=b-tmp/2+1;
	        	}
	        	if((a+b)%2!=0) {
	        		ans=ans+tmp/2;
	        	}
	        }
	        
	        
	        System.out.println(ans);
	        

	    }
	    
	    

	}

Measured memory_bytes: 21972
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

string s;

int main() {
  init_ios();
  cin >> s;
  if (s.back() == 's')
    s += "es";
  else
    s += "s";
  cout<<s<<"\n";
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph = vector<vector<ll>>;
int main(){
  ll a;
  cin>>a;
  
  vector<ll>vec(0);
  for(ll i=0;;i++){
    ll b=a%26;
    if(b==0){
      b=26;
      a=a-26;
    }
    vec.push_back(b);
    a=a/26;
    if(a==0){
      break;
    }
  }
  reverse(vec.begin(),vec.end());
  for(ll i=0;i<vec.size();i++){
    
    char c='a'+vec.at(i)-1;
    cout<<c;
  }
  cout<<endl;
}

Measured memory_bytes: 3616
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}

int main()
{
    ios;
    int n;
    cin>>n;
    string s,ans="";
    cin>>s;
    for(int i=0;s[i];)
    {
        char k=s[i];
        ans+=k;
        while(s[i]==k)
            i++;
    }
    cout<<ans.size()<<endl;



}










Measured memory_bytes: 3796
#(a,b) = input().rstrip().split(' ')
#a = int(a)
#b = int(b)

#以下でも代替可
(a,b) = [int(x) for x in input().rstrip().split(' ')]

if a < b:
 print("a < b")
elif a > b:
 print("a > b")
else:
 print("a == b")

Measured memory_bytes: 6724
def main():
    H, W = map(int, input().split())
    h, w = map(int, input().split())
    a = h * w
    b = (H - h) * w
    c = (W - w) * h
    ans = H*W - (a + b + c)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
using namespace std;
double dp[310][310][310];
int a1,a2,a3,n;
double dfs(int a,int b,int c){
	if(a==0&&b==0&&c==0) return 0;
	if(dp[a][b][c]) return dp[a][b][c];
	double sum=a+b+c;
	double ans=1.0*n/sum;
	if(a) ans+=(1.0*a/sum)*dfs(a-1,b,c);
	if(b) ans+=(1.0*b/sum)*dfs(a+1,b-1,c);
	if(c) ans+=(1.0*c/sum)*dfs(a,b+1,c-1);
	return dp[a][b][c]=ans;
}
int main(){
	cin>>n;
	rep(i,1,n) {
		int tmp;
	  cin>>tmp;
		if(tmp==1) a1++;
		else if(tmp==2) a2++;
		else a3++;
	}
	dfs(a1,a2,a3);
	printf("%.9f\n",dp[a1][a2][a3]);
}
	

Measured memory_bytes: 225536
import math
n = int(input())
d = list(map(int,input().split()))
li=[]
li2=[]
for i in range(n):
  for j in range(n):
    a = d[i]*d[j]
    li.append(a)
b = sum(li)
for k in range(n):
  c=d[k]**2
  li2.append(c)
d=sum(li2)
b -= d
print(math.floor(b/2))


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(500000)

N = int(input())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
K = int(input())
L = [-float("inf")] * (N+1)
R = [float("inf")] * (N+1)
for _ in range(K):
    v, p = map(int, input().split())
    L[v] = p
    R[v] = p

tour = []
def dfs(v, p):
    tour.append(v)
    for u in E[v]:
        if u!=p:
            dfs(u, v)
            tour.append(v)
dfs(v, 0)

l, r = L[v], R[v]
odd = p % 2
for v in tour[1:]:
    l -= 1
    r += 1
    odd = 1 - odd
    l_, r_ = L[v], R[v]
    if r_ != float("inf") and r_%2 != odd:
        print("No")
        exit()
    l = max(l, l_)
    r = min(r, r_)
    L[v] = l
    R[v] = r
for v in tour[-2::-1]:
    l -= 1
    r += 1
    odd = 1 - odd
    l_, r_ = L[v], R[v]
    l = max(l, l_)
    r = min(r, r_)
    if l > r:
        print("No")
        exit()
    L[v] = l
    R[v] = r
Ans = [-1] * (N+1)
print("Yes")
print("\n".join(map(str, L[1:])))


Measured memory_bytes: 112596
#include <iostream>
#include <string>

using namespace std;

int main() {
	ios_base :: sync_with_stdio(false);
	long long a, b, c, k;
	cin >> a >> b >> c >> k;
	long long ans = 0;
	if (k <= a) {
		cout << k;
		return 0;
	}
	k -= a;
	if (k <= b) {
		cout << a;
		return 0;
	}
	k -= b;
	cout << a - k;
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

int main() {
	ll a, b;
	string op;
	cin >> a >> op >> b;
	if (op == "+") {
		cout << a + b << endl;
	} else {
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// 149 B - Greedy Takahashi 2019/12/29
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int64 a,b,k;
    cin >> a >> b >> k;
    int64 ans_a,ans_b;
    if(a >= k) { ans_a = a-k; ans_b = b; }
    else if ( a < k && b - ( k - a ) > 0 ) { ans_a = 0; ans_b = b - ( k -a );}
    else { ans_a = 0; ans_b = 0;}
    cout << ans_a << " " << ans_b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

int main() {
   int s;

   cin >> s;

   int ans = 0;

   while (s >= 500) {
       s -= 500;
       ans += 1000;
   }

   while (s >= 5) {
       s -= 5;
       ans += 5;
   }

   cout << ans;
}


Measured memory_bytes: 256
import math
def circle(cx1,cy1,cx2,cy2,r1,r2):
    d=math.sqrt((cx1-cx2)**2+(cy1-cy2)**2)
    if d>r1+r2:
        print("4")
    elif d==r1+r2:
        print("3")
    elif abs(r1-r2)<d<r1+r2:
        print("2")
    elif d==abs(r1-r2):
        print("1")
    elif d<abs(r1-r2):
        print("0")
if __name__=="__main__":
    c1=[int(x)for x in raw_input().split()]
    c2=[int(x)for x in raw_input().split()]
    circle(c1[0],c1[1],c2[0],c2[1],c1[2],c2[2])



Measured memory_bytes: 4728
#include<iostream>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=LLONG_MAX;


int main(){
  string n;
  cin>>n;
  bool f=false;
  rep(i,n.size()){
    if(n[i]=='7')f=true;
  }
  if(f)cout<<"Yes";
  else cout<<"No";


  return 0;
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
ll MOD = 1e9 + 7;

const int MAXN = 3e3 + 5;

ll dp[MAXN][MAXN];
ll c[MAXN][MAXN];

void solve(){
	int n;
	cin >> n >> MOD;
	c[0][0] = 1ll;
	dp[0][0] = 1ll;
	REPN(i, 1, n) {
		c[i][0] = 1ll;
		dp[i][0] = 1ll;
		REPN(j, 1, i) {
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
			dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j] + j * dp[i - 1][j]) % MOD;
		}
	}
	ll ans = 0ll;
	REPN(i, 0, n) {
		ll mul = c[n][i];
		if (i % 2 == 1) {
			mul = MOD - mul;
		}
		ll st2 = 2ll;
		ll st2_ni = 1ll;
		REP(j, 0, n - i) {
			st2 = (st2 * st2) % MOD;
			st2_ni = (st2_ni * 2ll) % MOD;
		}
		ll mul2 = 0ll;
		ll st_st2_ni = 1ll;
		REPN(j, 0, i) {
			ll add = (dp[i][j] * st_st2_ni) % MOD;
			mul2 = (mul2 + add) % MOD;
			st_st2_ni = (st_st2_ni * st2_ni) % MOD;
		}
		mul2 = (mul2 * st2) % MOD;
		ans = (ans + mul * mul2) % MOD;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 139648
#include<stdio.h>
 
int main()
{
  int i,j,a[1000],b,c1,c2,n,sum,c4=0,c3=0;
  while(1){
    sum=0;
    j=0;c4=0;c3=0;
  scanf("%d",&n);
  if(n==0)break;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(i==0){c1=a[i];c2=a[i];}
    else{
      if(c1<a[i]){c1=a[i];c3=i;}
      if(c2>a[i]){c2=a[i];c4=i;}
    }
  }
  for(i=0;i<n;i++){
    if(c3==i||c4==i){b++;}
    else{
    sum+=a[i];
    j++;
    }
  }
  printf("%d\n",sum/j);
}
  return 0;
}
 

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

        long answer = 0;

        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0 && a[i] % 2 == 1)
            {
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28208
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, M = MAP()

gout = [[] for _ in range(N)]
deg = [0]*N
for _ in range(M):
	x, y = MAP()
	gout[x-1].append(y-1)
	deg[y-1] += 1
topo = [v for v in range(N) if deg[v]==0]
path_len = [0]*N
deq = deque(topo)
ans = 0
while deq:
    v = deq.popleft()
    for t in gout[v]:
        deg[t] -= 1
        if deg[t]==0:
            deq.append(t)
            path_len[t] = path_len[v] + 1
            ans = path_len[t]

print(ans)


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

typedef long long lint;
const int maxn = 100005;

int n, m;
int fa[maxn], pu, pv;

int f[maxn], siz[maxn], dep[maxn], col[maxn], cnt, p[maxn];
lint ans;

struct edge
{
	int to, next;
} e[maxn * 2];
int h[maxn], tot;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int find(int x)
{
	if (!fa[x]) return x;
	return fa[x] = find(fa[x]);
}

inline void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

void dfs(int u, int fa, int t)
{
	siz[u] += t == 0 ? 1 : -1; col[u] = t;
	dep[u] = dep[fa] + 1;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa) {
			f[v] = u, dfs(v, u, t ^ 1);
			siz[u] += siz[v];
		}
	ans += abs(siz[u]);
}

namespace case1
{
	
	void solve()
	{
		if (siz[1] == 0) printf("%lld\n", ans);
		else puts("-1");
	}

}

namespace case2
{
	
	void solve()
	{
		if (siz[1] & 1) return puts("-1"), void();
		int cnt = siz[1] >> 1;
		memset(siz + 1, 0, sizeof(int) * n);
		ans = abs(cnt); siz[pu] -= cnt; siz[pv] -= cnt;
		dfs(1, 0, 0);
		printf("%lld\n", ans);
	}
	
}

namespace case3
{

    void solve()
	{
		if (siz[1]) return puts("-1"), void();
		ans = 0;
		while (pu != pv) {
			if (dep[pu] > dep[pv]) p[++cnt] = siz[pu], siz[pu] = 0, pu = f[pu];
			else p[++cnt] = -siz[pv], siz[pv] = 0, pv = f[pv];
		}
		p[++cnt] = 0;
		sort(p + 1, p + cnt + 1);
		for (int i = 1; i <= cnt; ++i)
			ans += abs(p[(cnt + 1) >> 1] - p[i]);
		for (int i = 1; i <= n; ++i) ans += abs(siz[i]);
		printf("%lld\n", ans);
	}
	
}

int main()
{
	n = gi(); m = gi();
	for (int u, v, i = 1; i <= m; ++i) {
		u = gi(); v = gi();
		if (find(u) != find(v)) add(u, v), fa[find(u)] = v;
		else pu = u, pv = v;
	}
	
	dfs(1, 0, 0);
	
	if (m == n - 1) case1::solve();
	else if (col[pu] == col[pv]) case2::solve();
	else case3::solve();
	
	return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n, k;
  scanf("%d %d", &n, &k);

  int m = 2000001;

  vector<int> v(m, 0);

  int a;
  REP (i, n) {
    scanf("%d", &a);
    v[a]++;
  }

  sort(v.begin(), v.end(), greater<int>());

  int sum = 0;
  REP (i, m) {
    if (i >= k) {
      sum += v[i];
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >>s;
int count =0;
int output =0;
for(int i=0;i<s.size();i++){
if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
count ++;
}else{
count =0;
}
output =max(output,count);
}
cout << output <<endl;
}


Measured memory_bytes: 3592
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
import bisect
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**21


class Segtree_op():
    def __init__(self, n):
        self.size = 1
        while (n >= 1):
            self.size = self.size << 1
            n = n // 2

        self.arr = [self.unit() for i in range(self.size * 2)]

    def op(self, lch, rch):
        # sum
        return lch + rch

        # update min with holding index
        # if lch[0] <= rch[0]:
        #     return lch
        # else:
        #     return rch

    def unit(self):
        return 0

    def update(self, k, val):
        k += self.size - 1
        self.arr[k] = val
        while (k):
            k = (k - 1) // 2
            self.arr[k] = self.op(self.arr[k * 2 + 1], self.arr[k * 2 + 2])

    def query(self, l, r):
        L = l + self.size
        R = r + self.size
        s = self.unit()
        while L < R:
            if R & 1:
                R -= 1
                s = self.op(s, self.arr[R - 1])

            if L & 1:
                s = self.op(s, self.arr[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return s

    # def show(self):
    #     idx = 1
    #     while (idx <= self.size):
    #         print(self.arr[idx - 1:idx * 2 - 1])
    #         idx *= 2


def main():
    n = getN()
    s = [c for c in input().strip()]
    q = getN()

    # SegTreeをa-zぶん用意する 3文字目がbならsegs[b]の3番目にフラグ1が立つ
    segs = [Segtree_op(n) for i in range(26)]
    for i, c in enumerate(s):
        segs[ord(c) - ord("a")].update(i, 1)

    for query in range(q):
        operand, a, b = input().split()
        if operand == "1":
            # 0-indexed
            a = int(a) - 1
            segs[ord(s[a]) - ord("a")].update(a, 0)
            segs[ord(b) - ord("a")].update(a, 1)
            s[a] = b

        else:  # operand == "2"
            tmp = 0
            # 0-indexed
            a, b = int(a) - 1, int(b) - 1
            for se in segs:
                # a-zそれぞれのSegTreeについて、区間内にフラグが立っていれば tmp += 1
                # 文字自体ではなくその間にindexが降られているので、右側を+1
                if se.query(a, b+1) > 0:
                    tmp += 1
            print(tmp)

    # print(segs[0].arr)

if __name__ == '__main__':
    main()

"""
7 
aaaabbb
3
1 7 c
2 1 5
2 1 7
>> 2
>> 3


26 
abcdefghijklmnopqrstuvwxyz
7
2 1 26
2 2 26
2 5 5
2 11 20
2 25 26 
1 1 z
2 1 26
>> 26
>> 25
>> 1
>> 10
>> 2
>> 25
"""

Measured memory_bytes: 436200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<cstdlib>
#define  ll int
using namespace std;
const ll l=1000;
const ll r=19000;
ll f[90][90][20000],a[90][90];
ll n,m,i,j,k,t,x,y,ans=1e9;
ll read()
{
	ll f=0,c=1;	char ch=getchar();
	while((ch<'0')||(ch>'9'))	{	if(ch=='-') c=-1;	ch=getchar();	}
	while((ch>='0')&&(ch<='9'))	{	f=f*10+ch-'0';	ch=getchar();	}
	return c*f;
}
void dp(ll x, ll y)
{
//	cout<<a[x][y]<<" "<<x<<" "<<y<<" "<<f[0][1][10000]<<endl;
	for(ll i=l;i<r;++i)
	{
//		cout<<f[x][y][i];
//		cout<<i<<" "<<a[x][y]<<" "<<x<<" "<<y<<" "<<f[x][y][i]<<endl;
		f[x][y][i] = f[x-1][y][i-a[x][y]] | f[x-1][y][i+a[x][y]] | f[x][y-1][i-a[x][y]] | f[x][y-1][i+a[x][y]] ;
/*		f[x][y][i]|=f[x-1][y][i-a[x][y]];
		cout<<"fa";
		f[x][y][i]|=f[x-1][y][i+a[x][y]];
		cout<<"fa";
		f[x][y][i]|=f[x][y-1][i-a[x][y]];
		cout<<"fa";
		f[x][y][i]|=f[x][y-1][i+a[x][y]];
		cout<<"fa";*/
//		cout<<i<<" "<<f[x][y][i]<<endl;
		
	}
		
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	f[0][1][10000]=1;
	n=read(); m=read();
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=m;++j)
		{
			a[i][j]=read();
		}
	}
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=m;++j)
		{
			a[i][j]=abs(a[i][j]-read());
//			cout<<a[i][j]<<" ";
		}
//		cout<<endl;
	}
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=m;++j)
		{
			dp(i,j);
		}
	}
	for(ll i=l;i<=r;++i)
	{
		if(f[n][m][i]) ans=min(ans,abs(i-10000));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 563456
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <queue>
using namespace std;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
 
int main() {
//	freopen("test.txt", "r", stdin);
	FASTER;
	int s,w; cin>>s>>w;
	if(s<=w) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
	return 0;
}

Measured memory_bytes: 3128
let () = Scanf.scanf "%d\n" @@ fun n ->
  let xus = Array.init n @@ fun _ -> Scanf.scanf "%f %s\n" @@ fun x u -> x, u in
  Printf.printf "%.10f\n" @@ Array.fold_right (fun (x, u) -> ( +. ) @@
    if u = "JPY" then x else 380000. *. x) xus 0.

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  ll x[N],y[N],z[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  vector<ll> S[8];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 8; j++) {
      ll res = 0;
      if ((1 << 0) & j) {
        res += x[i];
      } else {
        res -= x[i];
      }
      if ((1 << 1) & j) {
        res += y[i];
      } else {
        res -= y[i];
      }
      if ((1 << 2) & j) {
        res += z[i];
      } else {
        res -= z[i];
      }
      S[j].push_back(res);
    }
  }
  ll score[8];
  for (int i = 0; i < 8; i++) {
    sort(S[i].begin(),S[i].end());
    reverse(S[i].begin(),S[i].end());
    score[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 8; j++) {
      score[j] += S[j][i];
    }
  }

  ll ans = -9999999999999999;
  for (int i = 0; i < 8; i++) {
    ans = max(ans,score[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3744
def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    A = [(1+p)/2 for p in P]
    A_cs = [0] * (N+1)
    for i in range(N):
        A_cs[i+1] = A_cs[i] + A[i]
    ans = 0
    for i in range(N-K+1):
        ans = max(ans, A_cs[i+K] - A_cs[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 78284
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

ll input[100001];
vector<ll> mod[100001];
ll c[100001];
ll ps[100001];

int main(){
    ll N,M,x;
    cin >> N >> M;
    for(int i=0;i<=100000;i++){
        input[i] = 0;
        c[i] = 0;
        ps[i] = 0;
    }
    for(int i=0;i<N;i++){
        cin >> x;
        input[x]++;
    }
    for(int i=0;i<=100000;i++){
        if(input[i] != 0){
            mod[i%M].push_back(input[i]);
            c[i%M] += input[i];
            ps[i%M] += input[i] / 2;
        }
    }
    for(int i=0;i<M;i++){
        sort(mod[i].begin(),mod[i].end());
    }
    ll ans = 0;
    for(int i=0;i<=M/2;i++){
        if(i==M-i || i%M==0){
            ans += c[i]/2;
            //cout << i << " " << ps[i] << endl;
            continue;
        }
        ll b = min(c[i],c[M-i]);
        ans += b;
        //cout << i << " " << b << endl;
        if(b < c[i]){
            ans += min(ps[i],(c[i]-b)/2);
            //cout << i << " " << min(ps[i],(c[i]-b)/2) << endl;            
        }
        if(b < c[M-i]){
            ans += min(ps[M-i],(c[M-i]-b)/2);
            //cout << i << " " << min(ps[M-i],(c[M-i]-b)/2) << endl;            
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<ll>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf_char=vector<vector<char>>;
using Graf_int=vector<vector<int>>;
#define MAX 100000

int main()
{
    int x,y;
    cin >> x >> y;
    int a,b,c;
    cin >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a)cin >> p[i];
    rep(i,b)cin >> q[i];
    rep(i,c)cin >> r[i];
    int j,k,l;
    j=0;k=0;l=0;
    ll ans=0;
    ll tmp;
    int x_lim,y_lim;
    x_lim=x;y_lim=y;
    int flag=0;
    rsort(p);rsort(q);rsort(r);
    rep(i,x+y){
        if(flag==0){
            if(p[j]>=q[k]&&p[j]>=r[l]){
                ans+=p[j];
                ++j;
                
                if(j==x){
                    flag=1;
                }
            }else if(q[k]>=p[j]&&q[k]>=r[l]){
                ans+=q[k];
                ++k;
                if(k==y){
                    flag=2;
                }
            }else{
                ans+=r[l];
                l++;
                if(l==c){
                    flag=3;
                }
            }
        }else if(flag==1){
            if(q[k]<r[l]){
                ans+=r[l];
                ++l;
                if(l==c){
                    flag=3;
                }
            }else{
                ans+=q[k];
                k++;
                if(k==y){
                    flag=4;
                }
            }
        }else if(flag==2){
            if(p[j]<r[l]){
                ans+=r[l];
                ++l;
                if(l==c){
                    flag=3;
                }
            }else{
                ans+=p[j];
                j++;
                if(j==x){
                    flag=4;
                }
            }
        }else if(flag==3){
            if(j<x||k<y){
                if(p[j]<q[k]){
                    ans+=q[k];
                    ++k; 
                }else{
                    ans+=p[j];
                    ++j;
                }
            }else if(j<x){
                ans+=p[j];
                ++j;
            }else if(k<y){
                ans+=q[k];
                ++k;
            }
        }
        else if(flag==4){
            ans+=r[l];
            ++l;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 5640
n, k = map(int, input().split())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])

x = 0
candi = [k]
for i in range(31, -1, -1):
    if k & (x + 2 ** i) == x + 2 ** i:
        candi.append(x + 2 ** i - 1)
        x += 2 ** i

ans = 0
tmpans = 0
for can in candi:
    for i in range(n):
        if can & c[i][0] == c[i][0]:
            tmpans += c[i][1]
    ans = max(ans, tmpans)
    tmpans = 0
print(ans)

Measured memory_bytes: 61656
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	s := getString()
	ans := 0
	for i := 0; i < N; i++ {
		m := make(map[byte]int)
		for j := 0; j < i; j++ {
			m[s[j]]++
		}
		cnt := 0
		for j := i; j < N; j++ {
			if m[s[j]] != 0 {
				cnt++
				m[s[j]] = 0
			}
		}
		ans = max(ans, cnt)
	}
	out(ans)
}


Measured memory_bytes: 1812
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e2+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n, x, t;
	cin >> n >> x >> t;
	ll z = ceil(n * 1.0 / x);
	cout << z * t << '\n';

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3696