akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
void lackcardp(int num,int a[20],int count){
  int k = 0;
  for(int i =1;i < 14;i++){
    for(int j = 0;j <count;j++){
      if(a[j] == i){
        k = 1;
        break;
      }
    }
    if(k == 0){
      if(num == 0){
        cout << "S "<< i << endl;
      }else if(num == 1){
        cout << "H "<< i << endl;
      }else if(num == 2){
        cout << "C "<< i << endl;
      }else if(num == 3){
        cout << "D "<< i << endl;
      }
    }
    k = 0;
  }
}

int main(){
  int n;
  cin >> n;
  std::string cirast;
  int cnum;
  int ccount=0;
  int hcount=0;
  int dcount=0;
  int scount=0;
  int sp[20]={0};
  int he[20]={0};
  int cl[20]={0};
  int di[20]={0};
  for(int i = 0;i < n;i++ ){
    cin >> cirast >> cnum;
    if( cirast == "S"){
      sp[scount] = cnum;
      scount += 1;
    }else if( cirast == "H"){
      he[hcount] = cnum;
      hcount += 1;
    }else if(cirast == "C"){
      cl[ccount] = cnum;
      ccount += 1;
    }else if(cirast == "D"){
      di[dcount] = cnum;
      dcount += 1;
    }
  }
  lackcardp(0,sp,scount);
  lackcardp(1,he,hcount);
  lackcardp(2,cl,ccount);
  lackcardp(3,di,dcount);
}

Measured memory_bytes: 3148
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        int W = in.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        for (int i=0;i<N;i++) {
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        long[][] dp = new long[N+1][W+1];
        for (int i=1;i<N+1;i++) {
            for (int j=1;j<W+1;j++) {
                if (j-w[i-1]>=0) {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1]);
                } else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        out.println(dp[N][W]);

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 126548
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll qsm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n,m,k,rt;
pii a[N];
map<pii, int> mp;

inline int fis(int x){
    while(x>=10) x/=10;
    return x;
}

int main(){
    scanf("%d", &n);
    pii tmp;
    ll ans=0;
    rep(i,1,n){
        tmp.first=fis(i);
        tmp.second=i%10;
        a[i] = tmp;
        swap(a[i].first,a[i].second);
        mp[tmp]++;
    }
    rep(i,1,n) ans += mp[a[i]];
    printf("%lld\n",ans);
    return 0;
}
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    int x;
    cin >> x;
    if(360 % x == 0){
        cout << 360 / x << endl;
    }else{
        for(int k=1; k<=360; k++){
            if((x*k) % 360 == 0){
                cout << k << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;



long long W, H;
pair<long long, int> pq[200000];


int main(){
    cin >> W >> H;
    for(int i = 0; i < W; i++){
        long long p;
        cin >> p;
        pq[i] = make_pair(p, 0);
    }
    for(int j = 0; j < H; j++){
        long long q;
        cin >> q;
        pq[j + W] = make_pair(q, 1);
    }
    sort(pq, pq+W+H);

    long long ans = 0, h = H, w = W;
    for(int i = 0; i < W+H; i++){
        long long dist = pq[i].first;
        int direction = pq[i].second;
        // cout << dist << ", " << direction << endl;
        if(direction == 0){
            ans += (h+1) * dist;
            w--;
        }else{
            ans += (w+1) * dist;
            h--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
/*input
3
1000000000 1000000000 0
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
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;
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 arr[maxn],ans[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
    cin>>n;
    ll sum=0;
    REP(i,n){
        cin>>arr[i];
        sum+=arr[i];
    }
    sum/=2;
    ll sum2=0;
    REP(i,n){
        if(i%2==1) sum2+=arr[i];
    }
    ans[0]=sum-sum2;
    for(int i=1;i<n;i++){
        ans[i]=arr[i-1]-ans[i-1];
    }
    REP(i,n) cout<<ans[i]*2<<' ';
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;


signed main()
{
    int n;
    string s;
    cin>>n>>s;
    vector<ll> a(26);
    rep(i,n){
        a[s[i] - 'a']++;
    }
    ll ans = 1;
    rep(i, 26)
    {
        ans = ans * (a[i] + 1) % mod;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b,a!=0||b!=0){
		map<int, int> S;
		string t = "";

		S[a] = 1;
		for(int q = 2;;q++){
			int A[10];
			for(int i = 0;i < b;i++){
				A[i] = a%10;
				char c = a%10 + '0';
				t += (c);
				a /= 10;
			}
			string s1 = "", s2 = "";
			sort(A,A+b);
			for(int i = 0;i < b;i++){
				char c = A[i] + '0';
				s1 += (c);
			}
			reverse(A,A+b);
			for(int i = 0;i < b;i++){
				char c = A[i] + '0';
				s2 += (c);
			}
			int x = atoi(s2.c_str()) - atoi(s1.c_str());

			//cout<<x<<endl;
			if(S[x]){
				cout<<S[x]-1<<" "<<x<<" "<<q - S[x]<<endl;
				break;
			}
			S[x] = q;
			a = x;

		}

	}
}

Measured memory_bytes: 1240
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

K, X = IL()
num = K*500
if num >= X:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ0122();
	}
	class AOJ0122{
		AOJ0122(){
			while(sc.hasNext()){
				int sx=sc.nextInt(),sy=sc.nextInt();
				if((sx|sy)==0)	break;
				solve(sx,sy);
			}
		}
		final int[] vx={2,2,2,1,0,-1,-2,-2,-2,-1,0,1},
					vy={-1,0,1,2,2,2,1,0,-1,-2,-2,-2};
		final int MAX=10;
		void solve(int sx,int sy){
			int n=sc.nextInt();
			Pair[] s=new Pair[n];
			for(int i=0; i<n; ++i)	s[i]=new Pair(sc.nextInt(), sc.nextInt());
			
			LinkedList<State> open=new LinkedList<State>();
			open.add(new State(sx,sy,0));
			
			boolean ans=false;
			
			while(!open.isEmpty()){
				State now=open.poll();
				if(now.z == n){
					ans=true;
					break;
				}
				for(int v=0; v<12; ++v){
					int xx=now.x+vx[v], yy=now.y+vy[v];
					if(!(0<=xx && xx<MAX && 0<=yy && yy<MAX))	continue;
					if(!(abs(s[now.z].x-xx)<=1 && abs(s[now.z].y-yy)<=1))	continue;
					open.add(new State(xx,yy,now.z+1));
				}
			}
			System.out.println(ans?"OK":"NA");
		}
		
	}
	class Pair{
		int x,y;
		Pair(int x,int y){
			this.x=x;
			this.y=y;
		}
	}
	class State{
		int x,y,z;
		State(int x,int y,int z){
			this.x=x;
			this.y=y;
			this.z=z;
		}
	}

}

Measured memory_bytes: 18172
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int h,n,i,sum,ans,a;
  sum = 0;
  ans = 0;
  cin >> h >> n;
  for(i = 0; i < n; i++){
    cin >> a;
    sum += a;
    if(sum >= h){
      ans += 1;
      break;
    }
  }
  if(ans == 1){
    cout << "Yes";
  }else{
    cout << "No";
  }
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner scn = new Scanner(System.in);
    int x = scn.nextInt();
    int y = scn.nextInt();
    if(x * y % 2 == 0){
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 22484
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    string s;
    cin>>s;
    int sz=s.size();
    string yo="";
    s+="#";
    for(int i=0;i<sz;i++)
    {
         if(s[i]=='A')yo+=s[i];
         else if(s[i]=='B' && s[i+1]=='C')yo+='Z',i++;
         else if(s[i]!='#')yo+=s[i];
    }
    yo+="#";
    //cout<<yo<<endl;
    sz=yo.size();
    yo+="#####";
    int a=0,z=0,ses=0,flag=0;
    for(int i=0;i<sz;i++)
    {
        if(yo[i]=='A')
        {
            a++;
            if(yo[i+1]=='A' || (yo[i+1]=='Z') )continue;
            else
            {
                a=0;
            }
        }
        else if(yo[i]=='Z')
        {
            z++;
            if(yo[i+1]=='Z')continue;
            else if(yo[i+1]=='A')
            {
                ses+=(a*z);
                z=0;
            }
            else
            {
                ses+=(a*z);
                a=0;
                z=0;
            }
        }
        else
        {
            ses+=(a*z);
            a=0;
            z=0;
        }
    }
    cout<<ses<<endl;
    return 0;

}













Measured memory_bytes: 916
#include <iostream>

using namespace std;

int main() {
	int k;
	while (cin >> k) {
		if (k == 0) {
			break;
		}
		int sum = 0;
		int a;
		int b;
		b = k * (k-1) / 2;
		for (int i = 0; i < b; i++) {
			cin >> a;
			sum += a;
		}
		sum /= k-1;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

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

  if (S.size() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K) << "..." << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int ans = 0;
		int max = -1;
		for(int i = 1; i <= N; i++) {
			int cc = 0;
			int ck = i;
			while(ck % 2 == 0) {
				ck /= 2;
				cc++;
			}
			if(max < cc) {
				ans = i;
				max = cc;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

a = ["AC", "WA", "TLE", "RE"]

dicts={"AC":0, "WA":0, "TLE":0, "RE":0}

for i in range(N):
    s = one_str()
    dicts[s] += 1


for aa in a:
    print(aa+" x "+str(dicts[aa]))

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int i;
  long k;
  string s;
  cin >> s >> k;
  i=0;
  while (s[i]=='1' && i<s.size() && i<k) i++;
  if (i==s.size() || (i==k && s[k-1]=='1')) cout << 1 << endl;
  else cout << s[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int Maxn=110;
int n,m,a[Maxn];
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
//	freopen("in.txt","r",stdin);
	m=read(),n=read();
	for(int i=1;i<=n;++i)
	a[i]=read();
	if(!n){printf("%d\n",m);return 0;}
	sort(a+1,a+1+n);
	int pos;
	int cur=1,tot,cnt;
	while(a[cur]<m && cur<=n)++cur;
	--cur;
	if(!cur){tot=a[1]-1;goto nxt;}
	pos=cur;
	while(pos && (a[pos]==a[pos+1] || a[pos]==a[pos+1]-1))--pos;
	++pos;
	tot=a[pos]-1;
	nxt:
	while(a[cur]<=m && cur<=n)++cur;
	if(cur>n){cnt=a[n]+1;goto GG;}
	pos=cur;
	while(pos<=n && (a[pos]==a[pos-1] || a[pos]==a[pos-1]+1))++pos;
	--pos;
	cnt=a[pos]+1;
	GG:
	if(m-tot<=cnt-m)printf("%d\n",tot);
	else printf("%d\n",cnt);
	return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    vector<char> T(q), D(q);
    rep(i, q) cin >> T[i] >> D[i];

    int left = 0, right = n;
    int t;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur]) {
                if (D[i] == 'L') --cur;
                else ++cur;
            }
            if (cur == -1) {
                check = true;
                break;
            }
            /*
            if (cur == n) {
                break;
            }
            */
        }

        if (check) left = t;
        else right = t;
    }

    int ans1 = right;

    left = 0, right = n;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur2 = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur2]) {
                if (D[i] == 'L') --cur2;
                else ++cur2;
            }
            if (cur2 == n) {
                check = true;
                break;
            }
            /*
            if (cur2 == -1) {
                break;
            }
            */
        }

        if (check) right = t;
        else left = t;
    }

    int ans2 = left;

    cout << max(0, ans2 - ans1 + 1) << endl;

    return 0;
}

Measured memory_bytes: 1044
using System;

namespace ABC125
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ');
            var A = int.Parse(read[0]);
            var B = int.Parse(read[1]);
            var T = int.Parse(read[2]);
            long biscuits = 0;

            for(int i = A ; i <= T ; i += A)
            {
                biscuits += B;
            }
        Console.WriteLine(biscuits);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//cout<<""<<endl;
int main(){
  ll H,W;cin>>H>>W;
  ll ans=100000;
  
 for(int i=1;i<H;i++){
   ll a=W*i,b=((H-i)/2)*W,c=((H-i+1)/2)*W;
     ll d=(W/2)*(H-i),e=((W+1)/2)*(H-i);
   if(i<H-1){
     ans=min(ans,min(max(a,max(b,c))-min(a,min(b,c)) ,max(a,max(d,e))-min(a,min(d,e))));
   }
   else{
     ans=min(ans,   max(a,max(d,e)) - min(a,min(d,e))  );
   }
 }
  for(int i=1;i<W;i++){
   ll a=H*i,b=((W-i)/2)*H,c=((W-i+1)/2)*H;
     ll d=(H/2)*(W-i),e=((H+1)/2)*(W-i);
   if(i<W-1){
     ans=min(ans,min(max(a,max(b,c))-min(a,min(b,c)) ,max(a,max(d,e))-min(a,min(d,e))));
   }
   else{
     ans=min(ans,   max(a,max(d,e)) - min(a,min(d,e))  );
   }
 }

  cout<<ans<<endl;                
}






Measured memory_bytes: 3692
a = list(map(str,input().split()))
dic = {"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"A":10,"B":11,"C":12,"D":14,"E":15,"F":16}
if dic[a[0]]==dic[a[1]]:
  print("=")
elif dic[a[0]]>dic[a[1]]:
  print(">")
else:
  print("<")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        int n;
        cin>>n;
        int a[n];
        int sum=0;
        int h[MAX]={0};
        loop(i,0,n)
        {
            cin>>a[i];
            sum+=a[i];
            h[a[i]]++;
        }
        int q;
        cin>>q;
        while(q--)
        {
            int b,c;
            cin>>b>>c;
            int cnt=h[b];
            // cout<<b<<" "<<c<<"\n";
            // cout<<h[b]<<" "<<h[c]<<"\n";
            sum-=(b*cnt);
            // cout<<"sum is "<<sum<<"\n";
            h[b]=0;
            h[c]+=cnt;
            sum+=(cnt*c);
            cout<<sum<<"\n";
        }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


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


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

int main() {
	int n;
	vector<int> p;
	cin >> n;

	for(int i = 0;i<n;i++){
		int a;
		cin >> a;
		p.push_back(a);
	}
	int ans=0;
	for(int i = 2;i<n;i++){
		if((p[i-2]-p[i-1])*(p[i-1]-p[i])>0)ans++;
	}
	cout << ans;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n;vector<ll> A(n+1,0),ans(n+1,0);
    for (int i=1;i<=n;i++)
    {
        cin >> A[i]; A[i]=2*A[i];
    }
    for (int i=1;i<=n;i++)
    {
        if (i&1)
            ans[1]+=A[i];
        else ans[1]-=A[i];
    }
    ans[1]=ans[1]/2;
    for (int i=1;i<=n-1;i++)
    {
        ans[i+1]=A[i]-ans[i];
    }
    for (int i=1;i<=n;i++)
        cout << ans[i] << " ";
    return 0;
}


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

int main(){
    int A, B, C[3];
    cin >> A >> B;
    C[0] = A + B;
    C[1] = A - B;
    C[2] = A*B;
    sort(C, C+3, greater<int>());
    cout << C[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
 
signed main(){
	IOS();
	cin>>N>>L;
	int sum = 0;
	rep(i,1,N+1){
		sum+=L+i-1;
	}
	int mi = INF;
	int a=-1;
	rep(i,1,N+1){
		int t = sum-(L+i-1);
		if(chmin(mi,abs(sum-t))){
			a = t; 
		}
	}
	cout<<a<<endl;
}

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

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

  if(n == 0) cout<<1<<endl;
  else if(n == 1) cout<<2<<endl;
  else if(n == 2)cout<<1<<endl;
  else cout<<0<<endl;

  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    int A[N], B[N], C[N-1];
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i=0;i<N;i++)
        cin >> B[i];
    for(int i=0;i<N-1;i++)
        cin >> C[i];
    
    int ans = 0, before = -1;
    for(int i=0;i<N;i++){
        // i番目
        ans += B[A[i]];
        if(before + 1 == A[i]){
            ans += C[before];
        }
        before = A[i];
    }

    cout << ans << endl;
}

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

using ll = long long;

struct Mod
{
    static const auto P = int(1e9+7);
    ll k;

    Mod() = default;
    Mod(const ll k) : k(k%P >= 0 ? k%P : k%P + P) {}
};

Mod operator+(const Mod a, const Mod b) { return a.k + b.k; }
Mod operator-(const Mod a, const Mod b) { return a.k - b.k; }
Mod& operator+=(Mod& a, const Mod b) { return a = a+b; }

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

    if (n == 1) cout << 1 << endl;
    else if (n == 2) cout << 4 << endl;
    else
    {
        auto last3 = array<Mod, 3>{n*n, n, 1};
        auto sum = Mod(0);
        for (auto k = 3; k <= n; k++)
        {
            sum += last3[2] - 1;
            const auto x = last3[0] + sum + n*(n-1);

            last3[2] = last3[1];
            last3[1] = last3[0];
            last3[0] = x;
        }
        cout << last3[0].k << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b;
    cin >> a >> b;
    if (a == 2 || b == 2) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, int> PDI;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int N, K, L;
	cin >> N >> K >> L;
	Union_find tr(200000), rd(200000);
	map< PII, int> res;
	REP(i, K){
		int p, q;
		cin >> p >> q;
		tr.unite(p-1, q-1);
	}
	REP(i, L){
		int r, s;
		cin >> r >> s;
		rd.unite(r-1, s-1);
	}
	REP(i, N){
		if(res.find(PII(tr.find(i), rd.find(i))) != res.end()){
			res[PII(tr.find(i), rd.find(i))] += 1;
		}else{
			res[PII(tr.find(i), rd.find(i))] = 1;
		}
	}
	REP(i, N){
		cout << res[PII(tr.find(i), rd.find(i))] << endl;
	}
}


Measured memory_bytes: 15252
#include <stdio.h>
#include <algorithm>
using namespace std;
long long mm[3010][3010];
long long ans[3010][3010][5];
int qx[3010*3010*5];
int qy[3010*3010*5];
int qz[3010*3010*5];

int main()
{
    int r,c,k;
    scanf("%d%d%d",&r,&c,&k);
    for (int i=0;i<k;++i){
        int a,b,c;scanf("%d%d%d",&a,&b,&c);
        mm[a][b]=c;
    }
    for (int i=1;i<=r;++i)
        for (int j=1;j<=c;++j)
            for (int k=0;k<=3;++k)
            ans[i][j][k]=-1;
    int up=1,low=0;
    qx[0]=1;qy[0]=1;qz[0]=0;ans[1][1][0]=0;
    if (mm[1][1]>0){
        qx[1]=1;qy[1]=1;qz[1]=1;ans[1][1][1]=mm[1][1];
        up=2;
    }
    while (low<up){
        int x=qx[low],y=qy[low],z=qz[low];low++;
        //printf("%d %d %d %lld\n",x,y,z,ans[x][y][z]);
        if (x+1<=r){
            if (ans[x+1][y][0]<0){
                qx[up]=x+1;qy[up]=y;qz[up]=0;
                ++up;
            }
            ans[x+1][y][0]=max(ans[x+1][y][0],ans[x][y][z]);
            if (mm[x+1][y]>0){
                if (ans[x+1][y][1]<0) {
                    qx[up] = x + 1;qy[up] = y; qz[up] = 1;
                    ++up;
                }
                ans[x+1][y][1]=max(ans[x+1][y][1],ans[x][y][z]+mm[x+1][y]);
            }
        }
        if (y+1<=c){
            if (ans[x][y+1][z]<0){
                qx[up]=x;qy[up]=y+1;qz[up]=z;
                ++up;
            }
            ans[x][y+1][z] = max(ans[x][y+1][z],ans[x][y][z]);
            if (mm[x][y+1]>0 && z<3) {
                if (ans[x][y+1][z+1]<0){
                    qx[up]=x;qy[up]=y+1;qz[up]=z+1;
                    ++up;
                }
                ans[x][y+1][z+1] = max(ans[x][y+1][z+1],ans[x][y][z]+mm[x][y+1]);
            }
        }
    }

    for (int i=1;i<=3;++i)
        if (ans[r][c][i]>ans[r][c][0])
            ans[r][c][0]=ans[r][c][i];
        printf("%lld\n",ans[r][c][0]);
}

Measured memory_bytes: 837400
A, B, K = map(int, input().split())

if A+K-1 >= B-K+1:
    for i in range(A, B+1):
        print(i)

else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
typedef struct Graph
{
  int key;
  int numOfAdj;
  int *adj;
  int status;//0:not discovered, 1:discovered, 2:finished
} graph;
void depthFirstSearch(void);
void visit(int);
int n;//num of vertice
graph *p;//array of vertice
int *d;//timestamp of first discovered time
int *f;//timestamp of finishing examining time
int timeOfSearch;//time passed during the depth first search
int main(void)
{
  int i,j;//counter
  int key,numOfAdj,adj;
  scanf("%d",&n);
  p=(graph*)malloc(sizeof(graph)*n);
  d=(int*)malloc(sizeof(int)*n);
  f=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&key);
      scanf("%d",&numOfAdj);
      p[key-1].numOfAdj=numOfAdj;
      p[key-1].adj=(int*)malloc(sizeof(int)*numOfAdj);
      for(j=0;j<numOfAdj;j++)
	{
	  scanf("%d",&adj);
	  p[key-1].adj[j]=adj-1;
	}
      p[key-1].status=0;
      d[i]=0;
      f[i]=0;
    }
  depthFirstSearch();
  return 0;
}
void depthFirstSearch(void)
{
  int i;//counter
  timeOfSearch=0;
  for(;;)
    {
      for(i=0;i<n;i++)
	{
	  if(p[i].status==0) visit(i);
	}
      if(i==n) break;
    }
  for(i=0;i<n;i++)
    {
      printf("%d %d %d\n",i+1,d[i],f[i]);
    }
}
void visit(int key)
{
  int i;//counter
  p[key].status=1;
  timeOfSearch++;
  d[key]=timeOfSearch;
  for(i=0;i<p[key].numOfAdj;i++)
    {
      if(p[p[key].adj[i]].status==0) visit(p[key].adj[i]);
    }
  p[key].status=2;
  timeOfSearch++;
  f[key]=timeOfSearch;
}




Measured memory_bytes: 2052
import sys
import numpy as np
from collections import deque,defaultdict

inp=lambda v,w:v[0]*w[0]+v[1]*w[1]
isprop = lambda a,b: a[0]*b[1]==a[1]*b[0]
cwsum = lambda l:[sum([x[0] for x in l]), sum([x[1] for x in l])]
chmin = lambda a,b:(a,b)[b<a]
# cwsum = lambda l:np.sum(l,axis=0)
            
def main():
    N,Ma,Mb=map(int,input().split())
    infty=10**9
    ch=[list(map(int,input().split())) for _ in range(N)]
    p=[(-1)*Mb,Ma]
    # cand=[v[2] for v in ch if inp(p,v[:2])==0]
    # if cand:
        # m1=min(cand)
    # else:
        # m1=infty
    # ncand=[v for v in ch if inp(p,v[:2])!=0] #p方向への射影
    pch=[[inp(v[:2],p),v[2]] for v in ch]
    X=N*max([abs(w[0]) for w in pch])
    dp=[[infty]*(2*X+1) for _ in range(N)]
    for i in range(N):
        for j in range(2*X+1):
            if i==0 and j==X+pch[0][0]:
                dp[i][j]=pch[0][1]
            elif i>0 and j==X+pch[i][0]:
                dp[i][j]=chmin(dp[i-1][j],pch[i][1])
            elif i>0 and j>=pch[i][0] and j<=2*X+pch[i][0]:
                dp[i][j]=chmin(dp[i-1][j],dp[i-1][j-pch[i][0]]+pch[i][1])
            elif i>0:
                dp[i][j]=dp[i-1][j]
    #  print(ch)
    #  print(pch)
    #  print(dp)
    if dp[N-1][X]==infty:
        print(-1)
    else:
        print(dp[N-1][X])

if __name__=='__main__':
    main()


Measured memory_bytes: 29072
using System;
using System.Linq;

class ALDS1
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b, c = 0, d, e = 0;
        for (int i = 0; i < a; i++)
        {
            b = int.Parse(Console.ReadLine());
            if (i == 0) { c = 2000000000; }
            d = b - c;
            if (b < c) { c = b; }
            if (i == 0) { e = d; }
            if (d > e) { e = d; }
        }
        Console.WriteLine(e);
    }
}

Measured memory_bytes: 19932
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  auto a = [&]() -> V<lint> {
    const string t = "FESTIVA";
    string s;
    for (int i = 0; i < 8; ++i) {
      for (char c : t) {
        s += string(1 << i, c);
      }
    }
    V<lint> dp(8);
    dp[0] = 1;
    V<lint> res;
    for (int i = 0; i < (int)s.size(); ++i) {
      auto ndp = dp;
      int j = t.find(s[i]);
      ndp[j + 1] += dp[j];
      swap(dp, ndp);
      if (s[i] == 'A' and s[i + 1] != 'A') {
        res.push_back(dp.back());
      }
    }
    return res;
  }();

  lint k; cin >> k;
  string res;
  for (int i = 7; i >= 0; --i) {
    res += string(k / a[i], 'F');
    for (char c : "ESTIVAL"s) {
      res += string(1 << i, c);
    }
    k %= a[i];
  }
  cout << res << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int N=2e5+5;
struct edge
{
    int u,v,w;
    bool operator<(const edge&o)const
    {
        return w<o.w;
    }
}e[N];
int n,m,a[N];
stack<int>f[N];
int vis[N],dep[N];
ll sum[N];
int getf(int x){return f[x].top()==x?x:getf(f[x].top());}
void del(int x,ll s)
{
    sum[x]-=s;
    if(f[x].top()!=x) del(f[x].top(),s);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) f[i].push(i),sum[i]=a[i];
    for(int i=1;i<=m;i++) scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    sort(e+1,e+1+m);
    for(int i=1;i<=m;i++)
    {
       int fu=getf(e[i].u),fv=getf(e[i].v);
       if(fu==fv) continue;
       if(dep[fu]<dep[fv])
       {
           f[fu].push(fv);
           sum[fv]+=sum[fu];
           vis[i]=fu;
       }
       else
       {
           f[fv].push(fu);
           sum[fu]+=sum[fv];
           dep[fu]=max(dep[fv]+1,dep[fu]);
           vis[i]=fv;
       }
    }
    for(int i=m;i>=1;i--)
        if(vis[i])
        {
            int fu=getf(e[i].u);
            if(e[i].w>sum[fu])
            {
                del(f[vis[i]].top(),sum[vis[i]]);
                f[vis[i]].pop();
            }
        }
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        int fu=getf(e[i].u),fv=getf(e[i].v);
        if(fu!=fv) continue;
        if(e[i].w<=sum[fu]) ans++;
    }
    printf("%d\n",m-ans);
}


Measured memory_bytes: 138880
K=int(input())
lists=[]
for i in range(1,10):
    lists.append(i)
if K<=9:
    print (K)
else:
    for i in range(K):
        if lists[i]%10==0:
            lists.append(lists[i]*10+lists[i]%10)
            lists.append(lists[i]*10+lists[i]%10+1)
        elif lists[i]%10==9:
            lists.append(lists[i]*10+lists[i]%10-1)
            lists.append(lists[i]*10+lists[i]%10)
        else:
            lists.append(lists[i]*10+lists[i]%10-1)
            lists.append(lists[i]*10+lists[i]%10)
            lists.append(lists[i]*10+lists[i]%10+1)
    print (lists[K-1])

Measured memory_bytes: 15704
import java.util.Scanner;

class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < S.length()-2; i++) {
			String substr = S.substring(i, i+3);
			int num = Integer.parseInt(substr);
			int sa = Math.abs(num - 753);
			ans = Math.min(ans, sa);
		}
		
		System.out.print(ans);
	}
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<pair<string, int>> a(n);
	for (auto &i : a) cin >> i.F >> i.S;

	string s;
	cin >> s;

	ll ans = 0;
	for (int i = n-1; ; --i)
	{
		if (a[i].F == s)
		{
			cout << ans << "\n";
			break;
		}
		ans += a[i].S;
	}

	return 0;
}



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

string N;

int dp[10][2][8][2];

int solve(int pos = 0, bool tight = true, int f753 = 0, bool all_zero = false)
{
    if (pos == N.size()) {
        return f753 == 7 ? 1 : 0;
    }

    int digit = N[pos] - '0';

    int& rdp = dp[pos][tight][f753][all_zero];
    if (~rdp) return rdp;

    int res = 0;
 
    if (pos == 0 || all_zero) {
        res += solve(pos+1, tight && digit == 0, f753, true);
    }
    for (int i = 3; i <= (tight ? digit : 7); i+=2) {
        res += solve(pos+1, tight && digit == i, f753 | (1<<(i/2-1)));
    }

    return rdp = res;
}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
 
    cin >> N;
    memset(dp, -1, sizeof(dp));

    cout << solve() <<endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BYYMMOrMMYY solver = new BYYMMOrMMYY();
        solver.solve(1, in, out);
        out.close();
    }

    static class BYYMMOrMMYY {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();

            int a = Integer.parseInt(s.substring(0, 2));
            int b = Integer.parseInt(s.substring(2));

            boolean x = a <= 12 && a > 0;
            boolean y = b <= 12 && b > 0;

            if (x && y) {
                out.println("AMBIGUOUS");
            } else if (x) {
                out.println("MMYY");
            } else if (y) {
                out.println("YYMM");
            } else {
                out.println("NA");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
#define ll long long
using namespace std;

int main(){
  int N; cin >> N;
  ll H[N];
  cin >> H[0];
  int c=0; int max=0;
  for(int i=1; i<N; i++){
    cin >> H[i];
    if(H[i]<=H[i-1]){c++;}
    else{
      if(c>max){max=c;}
      c=0;
    }
  }
  if(c>max){max=c;}
  cout << max;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
  int a = x2 - x1;
  int b = y2 - y1;
  cout<<x2 - b<<" "<<y2 + a<<" "<<x1 - b<<" "<<y1 + a<<"\n";
  return 0;
}


Measured memory_bytes: 256
import sys
from math import sqrt, ceil

cin = sys.stdin
# cin = open("in.txt", "r")

X = int(cin.readline())
'''
i(i+1)/2<=X
i**2 + i - 2X <=0
  -1 +- sqrt( 1 - 4 * (-2X))
  ------
  2
'''
i = ceil((-1+sqrt(1+8*X))/2)


print(i)


Measured memory_bytes: 3060
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	char haiku[20];

	scanf("%s", haiku);

	haiku[5] = ' ';
	haiku[13] = ' ';

	puts(haiku);

	return 0;
}

Measured memory_bytes: 128