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

int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> xs, ys;

    int i, j;
    i = j = 0;
    while (true) {
        int sum = 100 * a * i;
        if (sum > f) break;
        sum += 100 * b * j;
        if (sum > f) { i++; j = 0; continue; }
        if (sum != 0)
            xs.push_back(sum);
        j++;
    }
    i = j = 0;
    while (true) {
        int sum = c * i;
        if (sum > f) break;
        sum += d * j;
        if (sum > f) { i++; j = 0; continue; }
        ys.push_back(sum);
        j++;
    }

    int ans_ms = 1e9, ans_s = 0;
    for (int x = 0; x < int(xs.size()); x++) {
        for (int y = 0; y < int(ys.size()); y++) {
            int ms = xs[x] + ys[y];
            int sugar = ys[y];
            if (ms > f || sugar * (100 + e) > e * ms) {
                continue;
            }
            if (ans_s * ms <= sugar * ans_ms) {
                ans_ms = ms;
                ans_s = sugar;
            }
        }
    }
    cout << ans_ms << " " << ans_s << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
const int maxn=200009;

int n,K;

int a[maxn];

int l,r,mid,ans;
long long check(int len){
	long long ret=0;
	for(int i=1;i<=n;++i){
		ret+=(a[i]-1)/len;
	}
	return ret;
}

int main(){
	cin>>n>>K;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	
	l=1;r=1000000000;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)<=K){
			ans=mid;r=mid-1;
		}else{
			l=mid+1;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4500
#include <iostream>
#include <cassert>
// #include <queue>

#define INF 922337203685477580
#define N 1100000
typedef long long ll;

using namespace std;

struct Task {string task; int cost;};
struct Task queue[N];
int head = 0;
int tail = 0;

void enqueue(Task t) {
  queue[tail] = t;
  tail = (tail + 1) % N;
}
struct Task dequeue() {
  head = (head + 1) % N;
  return queue[head - 1];
}
int isEmpty () {
  return head == tail;
}


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

  struct Task T[n];

  for (int i = 0; i < n; i++) {
    cin >> T[i].task >> T[i].cost;
  }
  for (int i = 0; i < n; i++) {
    enqueue(T[i]);
  }

  ll elapsed = 0L;

  while(!isEmpty()) {
    struct Task t = dequeue();
    if (t.cost > q) {
      struct Task newT = {t.task, t.cost - q};
      enqueue(newT);
      elapsed += q;
    } else {
      elapsed += t.cost;
      cout << t.task << " " << elapsed << endl;
    }
  }

  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int h, a, ans;
    ans = 0;
    cin >> h >> a;
    while(h > 0) {
        h -= a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
int n=0,lo;
str s;
int xans=0,yans=0;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    char mae,m;
    int same=0;

    lo=s.size();
    //cout << lo << "lo";
    for(int i=0;i<lo;i++){
        mae=s[i];
        same=0;
        if(mae==s[i+1]){
            same=i+1;
            xans=i+1;
            yans=same+1;
        }if(i!=(lo-2)&&mae==s[i+2]){
            same=i+2;
            xans=i+1;
            yans=same+1;
        }
        /*
        if(same){
            if(mae==s[same+1]){
            xans=i+1;
            yans=same+2;
        }if(same!=(lo-2)&&mae==s[same+2]){
            xans=i+1;
            yans=same+3;
        }
        }*/
       // if(same)cout << i << "i" << s[xans-1] << s[yans-1];
    }
    if(!yans){
        cout << "-1" << " " << "-1" << endl;
    }else{
        cout << xans << " " << yans << endl;
    }
return 0;
}



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

int main(){
//srandom((unsigned long)time(NULL));
int n;
cin>>n;
int x[n];
int mn=0;
int ans=0;
for(int i=0;i<n;i++){
    cin>>x[i];
    ans+=x[i]*x[i];
}

for(int p=1;p<=100;p++){
    int con=0;
    for(int i=0;i<n;i++){
        con+=(x[i]-p)*(x[i]-p);
    }
    if(ans>con){
        mn=p;
        ans=con;
    }
}

cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int n,int m){return m?gcd(m,n%m):n;}
int main(){
    int W,H,C;
    cin >> W >> H >> C;
    cout << W*H / (gcd(W,H)*gcd(W,H)) * C << endl;
}


Measured memory_bytes: 3100
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int gcd(int N,int M){
    while(N % M != 0){
        if(N >= M) N %= M;
        else swap(N,M);
    }
    return M;
}

int main(){
    int N,M;
    cin>>N>>M;

    int ans;
    ans = gcd(N,M);
    put(ans);
}


Measured memory_bytes: 3072
n = int(input())
a = [input() for i in range(n)]
for i in range(n):
    num  = a.count(a[i])
    if num > 1:
        print('No')
        exit()
for i in range(n-1):
    if a[i][-1] == a[i+1][0]:
        continue
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
vector <string> A;
int main(){
  cin >> N;
  A.assign(N+10,string());
  for (ll i=1;i<=N;i++){
    cin >> A[i];
  }
  ll m=0,a=0,r=0,c=0,h=0;
  for (ll i=1;i<=N;i++){
    switch(A[i][0]){
      case 'M':
        m++;
      break;
      case 'A':
        a++;
      break;
      case 'R':
        r++;
      break;
      case 'C':
        c++;
      break;
      case 'H':
        h++;
      break;
    }
  }
  cout << m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h << endl;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int h,w,k;
	ll cnt[8] = {},stay[8] = {};
	cin >> h >> w >> k;	
	if(w == 1){
		cout << 1 << '\n';
		return 0;
	}
	cu(i,0,1 << (w-1)){
		bool val = true;
		cu(j,0,w-2){
			if((i >> j) & (i >> (j + 1)) & 1){val = false;break;}
		}
		if(!val)continue;
		cu(j,0,w-1){
			cnt[j] += (i >> j) & 1;
		}
		stay[0] += (i & 1) ^ 1;
		stay[w-1] = stay[0];
		cu(j,1,w-1)stay[j] += (((i >> j) | (i >> (j-1))) & 1) ^ 1;
	}

	ll cur[8] = {},nxt[8] = {};
	cur[0] = 1;
	while(h--){
		cu(i,0,w){
			nxt[i] = stay[i] * cur[i];	
			if(i - 1 >= 0)nxt[i] += cnt[i-1] * cur[i-1];
			if(i < w - 1)nxt[i] += cnt[i] * cur[i+1];
			nxt[i] %= MOD;
		}
		swap(nxt,cur);
	}
	cout << cur[k-1] << '\n';
}


Measured memory_bytes: 256
n = input()

if n[0] == 'A':
    for i in range(len(n)-3):
        ##print(i,n[i+2],n[1:i+2],n[i+3::])
        if n[i+2] == 'C' and (n[1:i+2]+n[i+3::]).islower():
            print('AC')
            exit()

print('WA')
        

Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        while(n != 1){
            if(n % 2 == 0)
                n /= 2;
            else
                ++ (n *= 3);
            ++ ret;
        }
        cout << ret << endl;
    }
}

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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define e "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

#define N 5010

void solve()
{
    int a,b,c;
    cin >> a >> b >> c;
    if (c-1>a+b){
        cout<< 2*b+a+1;
    }
    else {
        cout<<c+b;
    }
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




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

int main() {
  int N, A, B;
  cin >> N;
  vector<int>card(N);
  for(int i=0;i<N;i++){
    cin >> card.at(i);
  }
  sort(card.begin(),card.end());
  for(int i=0;i<N/2;i++){
    A+=card.at(N-2*i-1);
    B+=card.at(N-2*i-2);
  }
  if(card.size()%2==1)
    A+=card.at(0);
  cout << A-B << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author Nikunj
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Swap solver = new Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class Swap {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int N = in.scanInt();
            int array[] = new int[N];
            in.scanInt(array);
            int ans = 0;
            for (int i = 0; i < N - 1; i++) {
                if (array[i] == i + 1) {
                    array[i] = array[i + 1] + array[i] - (array[i + 1] = array[i]);
                    ans++;
                }
            }
            if (array[N - 1] == N) ans++;
            out.println(ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public void scanInt(int[] A) {
            for (int i = 0; i < A.length; i++) A[i] = scanInt();
        }

    }
}



Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	int A;//１の枚数
	int B;//０の枚数
	int C;//-１の枚数
	int K;//取得枚数
	int max=0;//最大値
	cin >> A >> B >> C >> K;
	if (A >= K) {
		max = K;
	}
	else {
		if (A + B >= K) {
			max = A;
		}
		else {
			max = 2*A - K + B;
		}
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        //入力
        long n = long.Parse(Console.ReadLine());
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++)
        {
            long[] t =  Console.ReadLine().Split().Select(long.Parse).ToArray();
            a[i] = t[0];
            b[i] = t[1];
        }

        Array.Sort(b, a);
        long sum = 0;
        string ans = "Yes";
        for (int i = 0; i < n; i++)
        {
            sum += a[i];
            if (sum > b[i])
            {
                ans = "No";
                break;
            }   
        }

        Console.WriteLine(ans);
    }

}


Measured memory_bytes: 20496
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	string s, t;
	cin >> s >> t;
	int slen = (int)s.length();
	int tlen = (int)t.length();
	int ans = tlen;
	for(int i = 0; i <= slen - tlen; ++i){
		int cur = 0;
		for(int j = 0; j < tlen; ++j){
			if(s[i + j] != t[j])cur++;
		}
		ans = min(ans, cur);
	}
	cout << ans << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
  ll int n , a , b;
  cin >> n >> a >> b;
  ll int temp = a*(n/(a+b)) ;
  n=n%(a+b);
  if(n<a){ temp+=n;}
  else {
      temp+=a;
  }
  if(a==0) {cout<<"0"; return 0;}
  else{ cout<<temp;}
  return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())

def bgsize(n):
  return 2 ** (n+2) - 3

def patty(n):
  return 2 ** (n+1) - 1

lv1 = 'BPPPB'
ans = 0
pos = 0
lv = n
eat = False

while True:

  if pos == x:
    break

  if eat:
    ans += 1
    pos += 1
    eat = False
    continue

  if lv ==1 and x - pos < 5:
    ans += lv1[:x-pos].count('P')
    break

  if pos + bgsize(lv) <= x:
    ans += patty(lv)
    pos += bgsize(lv)
    eat = True
  else:
    pos += 1
    lv -= 1

print(ans)

Measured memory_bytes: 3064
n = int(input())
lst = [(bin(i)[2:]).zfill(n) for i in range(2**n)]
ans = 0
A_list = []
xy_list = []
for i in range(n):
    a = int(input())
    A_list.append(a)
    for j in range(a):
        x,y = map(int,input().split())
        xy_list.append([x,y])
for i in range(len(lst)):
    choose = lst[i]
    one_count = choose.count("1")
    a_count = 0
    flag = True
    for num, j in enumerate(A_list):
        a_count += j
        for k in range(a_count-j, a_count):
            x,y = xy_list[k][0],xy_list[k][1]
            if choose[num] == "1" and choose[x-1] != str(y):
                flag = False
                break
    if flag:
        ans = max(ans,one_count)
print(ans)


Measured memory_bytes: 5416
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
#    bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

N, M = map( int, input().split())
V = [ i for i in range(N)]
for _ in range(M):
    x, y,_ = map( int, input().split())
    union(V, x-1, y-1)
print( sum( [1 for i in range(N) if i == V[i]]))


Measured memory_bytes: 74400
n,k=map(int,input().split())
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
m=l[k-1]-l[0]
for i in range(1,n-k+1):
  a=l[i+k-1]-l[i]
  if a<m:
    m=a
print(m)

Measured memory_bytes: 7384
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
using vi = vector<int>;

string str;
string stra;
int id = 0;

vi number(){
  vi res;
  for (; isdigit(stra[id]); id++) {
    res.push_back(stra[id] - '0');
  }
  reverse(res.begin(),res.end());
  return res;
}
int solve(){
  stra = str;
  for (int i = 9; i >= 0; i--) {
    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }  
    vi b = number();
    a.resize(max(b.size() + 1,a.size()+1),0);
    for (size_t j = 0; j < b.size(); j++) {
      a[j] += b[j];
      if (a[j]>=10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    for (size_t j = b.size(); j < a.size()-1; j++) {
      if (a[j] >= 10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    if (stra[id] == '=') {
      id++;
    }
    b = number();

    if(a[a.size()-1]==0){
      a.pop_back();
    }
    if (a.size() != b.size()) {
      continue;
    }
    
    // if (a.size() >= b.size()) {
    //   b.resize(a.size(),0);
    // } else {
    //   a.resize(b.size(),0);
    // }
    int flag = 0;
    for (size_t j = 0; j < a.size(); j++) {
      if (a[j] == b[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    } 
    
  }
  return -1;
}
int main(){
  cin >> str;
  while(str.size()){
  int ans = solve();
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    puts("NA");
  }
  str.clear();
  cin >> str;
}
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <string.h>
#include <cmath>


const int MAXN = 5e5;
int max_heap[MAXN];
int n;

void init() {
	
}

void heapify(int i) {
	while(i < n) {
		int L = 2 * i + 1;
		int R = 2 * i + 2;
		int mx;
		if(L >= n) {
			break;
		}
		if( R >= n){
			mx = L;
		}else{
			mx = (max_heap[L] > max_heap[R]) ? L : R;
		}
		if(max_heap[mx] <= max_heap[i]){
			break;
		}
		std::swap(max_heap[mx], max_heap[i]);
		i = mx;
	}
}

void build_heap() {
	for(int i = n / 2; i >= 0; i--){
		heapify(i);
	}
}

void input() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", max_heap + i);
	}
}

void output() {
	build_heap();
	for(int i = 0; i < n; i++){
		printf(" %d", max_heap[i]);
	}
	puts("");
}

int main() {
	init();
	input();
	output();
	return 0;
}


Measured memory_bytes: 5096
#include <stdio.h>
#include <math.h>

int main(void){
    int i,n;
    double s[1000],m,sd;

    while(1){
        scanf("%d",&n);
        if(n==0) break;

        m=0.0;
        sd=0.0;

        for(i=0;i<n;i++){
            scanf("%lf",&s[i]);
            m+=s[i];
        }
        m/=n;
        for(i=0;i<n;i++){
            sd+=(s[i]-m)*(s[i]-m);
        }
        sd/=n;

        printf("%lf\n",sqrt(sd));
    }

    return 0;
}

Measured memory_bytes: 660
# ABC090b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())

ans = 0
for i in range(a, b + 1):
    s = str(i)
    if(s[0] == s[4] and s[1] == s[3]):
        ans += 1
print(ans)

Measured memory_bytes: 3064
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = long.Parse(spl[0]);
        var b     = long.Parse(spl[1]);
        
        var nu = Find(a, b);

        if (nu.first < 0)
            return nu.value;

        var c = b - a;
        c -= nu.first;

        var v = nu.first + (c / nu.span) * nu.span;

        var r = nu.value;
        for(long i = a + v + 1; i<=b; i++) {
            r = r ^ i;
        }

        return r;

        //return BitStr(1000000000000);
        //return Calc(a, b);
    }

    static Num Find(long a, long b) {
        var nums = new Dictionary<long, long>();

        long j = 0;
        long r = a;

        for (long i = a + 1; i <= b; i++) {
            if (nums.ContainsKey(r)) {
                return new Num {
                    value = r,
                    first = nums[r],
                    span  = j - nums[r]
                };
            }

            nums.Add(r, j);
            r ^= i;
            j++;
        }

        return new Num {
            value = r,
            first = -1,
        };
    }

    class Num
    {
        public long value;
        public long first;
        public long span;

        public override string ToString() {
            return "va:" + value + " fi:" + first + " sp:" + span;
        }
    }

    static long Calc(long a,long b) {
        long r = a;
        for (long i=a+1; i<=b; i++) {
            //Debug.Write(BitStr(r));
            //Debug.Write(" * ");
            //Debug.Write(BitStr(i));
            //Debug.WriteLine(" = ");
            r ^= i;
        }
        return r;
    }

    static string BitStr(long x) {
        StringBuilder bu = new StringBuilder(100);

        while (x > 0) {
            bu.Append(x % 2);
            x /= 2;
        }
        while(bu.Length < 10) {
            bu.Append('0');
        }

        StringBuilder b = new StringBuilder(bu.Length);
        for(int i=0; i<bu.Length; i++) {
            b.Append(bu[bu.Length - i - 1]);
        }
        return b.ToString();
    }
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int dp[MAX], h[MAX];

signed main(){
	cout<<fixed<<setprecision(7);
	
	int N;
	
	cin>>N;
	
	for(int i = 1; i <= N; i++){
		cin>>h[i];
		dp[i] = INF;
	}
	dp[1] = 0;
	for(int i = 1; i < N; i++){
		dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}
	
	cout<<dp[N]<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
string s;
char mo[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
string b;
map<string,char> m;
int main(void){
  m["101"] = ' ';
  m["000000"] = '\'';
  m["000011"] = ',';
  m["10010001"] = '-';
  m["010001"] = '.';
  m["000001"] = '?';
  m["100101"] = 'A';
  m["10011010"] = 'B';
  m["0101"] = 'C';
  m["0001"] = 'D';
  m["110"] = 'E';
  m["01001"] = 'F';
  m["10011011"] = 'G';
  m["010000"] = 'H';
  m["0111"] = 'I';
  m["10011000"] = 'J';
  m["0110"] = 'K';
  m["00100"] = 'L';
  m["10011001"] = 'M';
  m["10011110"] = 'N';
  m["00101"] = 'O';
  m["111"] = 'P';
  m["10011111"] = 'Q';
  m["1000"] = 'R';
  m["00110"] = 'S';
  m["00111"] = 'T';
  m["10011100"] = 'U';
  m["10011101"] = 'V';
  m["000010"] = 'W';
  m["10010010"] = 'X';
  m["10010011"] = 'Y';
  m["10010000"] = 'Z';
  while(getline(cin,s)){
    b = "";
    for(int i = 0; i < (int)s.size(); i++){
      for(int j = 0; mo[j] != '\0'; j++){
	if(s[i] == mo[j]){
	  for(int k = 4; k >= 0; k--){
	    b += ((j&(1<<k))?1:0)+'0';
	  }
	  break;
	}
      }
    }
    string t="";
    for(int i = 0; i < (int)b.size(); i++){
      t+=b[i];
      if(m.find(t) != m.end()){
	cout << m[t];
	t = "";
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int A,B;cin>>A>>B;
    if(1<=A&&1<=B&&9>=A&&9>=B)cout<<A*B<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    
    if((a == b && b != c) ||(b == c && a != c) || (a == c && b != c)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
counter = 0
check = [2]
e = 2
while 2**e <= 1000000000:
	check.append(2**e)
	e += 1
for i in range(n):
	if a[i]%2 == 0:
		for k in range(len(check)):
			if a[i]%check[k] == 0:
				counter += 1
			else:
				break
print(counter)

Measured memory_bytes: 4212
/*
“Being happy doesn't mean that everything is perfect. It means
that you decided to look beyond the imperfections.”
*/

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std; 

#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define ii pair<int,int>
#define fr(i,x,n) for(i = x ; i< n ; i++)
#define f(i,n) for(i = 0 ; i< n ; i++)
#define ff first
#define ss second
#define pb push_back
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
void solve();
 
int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}
int fact(int n)
{
    int i, k=1;
    fr(i, 2, n+1) k*=i;
    return k;
}

int  j=1, n, t, dot=0, i, k, a, x, y,z,c, q,toko;

void solve()
{
    // cin >> t;while(t--)
    {
       cin >> n >> k ;
       priority_queue<int> pq;
       f(i,n)
       {
           cin >>x;
           pq.push(x);
       }

       f(i,k)
       {
           
           x=pq.top();
        //    cout << x << '\n';
           pq.pop();
           x/=2;
           pq.push(x);
       }

       toko=0;
       while(!pq.empty())
       {
        //    pr(pq.top())
           toko += pq.top();
           pq.pop();
       }
       pr(toko)

    }
}

Measured memory_bytes: 1400
///Water Hyacinth
///Hakuna Matata
///WAKE THE FUCK UP SAMURAI;WE HAVE A CODE TO RUN <3
///Any Verdict
///(Aes)  Dekhe (Tic) lagche = Aesthetic <3
///**********************************************************///

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define D double
int main()
{

	int n,a,b,sum=0;

	cin >> n >> a >> b;

	sum = n*a;

	if(sum < b)
        cout << sum << endl;
    else if(sum > b)
        cout << b << endl;
    else if(sum == b)
        cout << sum << endl;

	return 0;
}

///Day:36


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

template <typename T> void setmax(T& a, T b) {
	if (a < b) {
		a = b;
	}
}

using ll = long long;

const int MAXN = 105;
int N;
ll Wmax;
ll W[MAXN];
int V[MAXN];

int dp[MAXN][MAXN][3 * MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> N >> Wmax;
	for (int i = 0; i < N; i++) {
		cin >> W[i] >> V[i];
	}

	dp[0][0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int n = 0; n <= i; n++) {
			for (int a = 0; a <= 3 * n; a++) {
				ll curW = n * W[0] + a;
				if (curW > Wmax) continue;
				setmax(dp[i+1][n][a], dp[i][n][a]);
				ll nxtW = (n+1) * W[0] + a + (W[i] - W[0]);
				if (nxtW <= Wmax) {
					setmax(dp[i+1][n+1][a + (W[i] - W[0])], dp[i][n][a] + V[i]);
				}
			}
		}
	}

	int ans = 0;
	for (int n = 0; n <= N; n++) {
		for (int a = 0; a <= 3 * n; a++) {
			setmax(ans, dp[N][n][a]);
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 11392
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  

  int k;
  cin >> k;
  int cur = 0, cnt = 0;
  while(cnt<=10000000){
    cnt++;
    cur = (cur*10+7)%k;
    if(cur==0){
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  

return 0;
}
///....


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    ll n;
    cin>>n;
    ll h[n];
    for(ll i=0;i<n;i++)
        cin>>h[i];
    ll ans[n];
    ans[0] = 0;
    ans[1] = abs(h[1]-h[0]);
    
    for(ll i=2;i<n;i++)
        ans[i] = min(ans[i-1] + abs(h[i]-h[i-1]), ans[i-2] + abs(h[i]-h[i-2]));
    
    cout<<ans[n-1]<<endl;
    
    return 0;
}

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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  int V = 0;
  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
    V += v[i];
  }

  vector<vector<long long>> dp(N + 1, vector<long long>(V + 1, 1ll << 63 - 1));
  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int sum_v = 0; sum_v <= V; ++sum_v) {
      if (sum_v - v[i] >= 0)
        dp[i + 1][sum_v] = min(dp[i][sum_v - v[i]] + w[i], dp[i + 1][sum_v]);
      dp[i + 1][sum_v] = min(dp[i][sum_v], dp[i + 1][sum_v]);
    }
  }

  long long ans = 0;
  for (int sum_v = 0; sum_v <= V; ++sum_v)
    if (dp[N][sum_v] <= W)
      ans = sum_v;
  cout << ans << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  int ans = 0;
  for(int i =1; i<=n; i+=2){
    int count = 0;
    for(int j = 1; j<=n; j++){
      if(i%j==0) count++;
    }
    if(count==8)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
bits = [BinaryIndexedTree(N) for _ in range(26)]

for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)

s = list(S)
ans = []
for a,b,c in qs:
    if a=='1':
        x = int(b)-1
        bits[ctoi(c)].add(x,1)
        bits[ctoi(s[x])].add(x,-1)
        s[x] = c
    else:
        b,c = int(b)-1,int(c)
        tmp = 0
        for i in range(26):
            if bits[i].sum(b,c) > 0:
                tmp += 1
        ans.append(tmp)
print(*ans, sep='\n')

Measured memory_bytes: 171636
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

    int N, M;
    cin >> N >> M;

    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;



    return 0;
}



Measured memory_bytes: 888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class abc158_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextLong();
            long A = in.nextLong();
            long B = in.nextLong();

            long sum = A + B;
            long mul = (long) N / sum;
            long mod = N % sum;

            if (A >= mod) {
                out.println(mul * A + mod);
            } else {
                out.println((mul * A) + A);
            }
        }

    }
}



Measured memory_bytes: 23252
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

S = input()
ans = 0
for i in range(len(S) // 2):
    ans += S[i] != S[-1-i]
print(ans)





Measured memory_bytes: 6608
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int n;
long long vv[100010][3];
long long dp[100010][3];

int main(){
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> vv[i][0] >> vv[i][1] >> vv[i][2];
  }

  for (int i = 0; i < 100010; i++){
    dp[i][0] = 0;
    dp[i][1] = 0;
    dp[i][2] = 0;
  }

  dp[0][0] = vv[0][0];
  dp[0][1] = vv[0][1];
  dp[0][2] = vv[0][2];

  for (int i = 1; i < n; i++) {
		dp[i][0] = vv[i][0] + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = vv[i][1] + max(dp[i-1][2], dp[i-1][0]);
    dp[i][2] = vv[i][2] + max(dp[i-1][0], dp[i-1][1]);
	}

	cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;

	return 0;
}


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

int main(){
	int a,b;cin >> a >> b;
	if((a<0 && b>0) || a==0 || b==0) cout << "Zero" << endl;
	else if(a>0) cout << "Positive" << endl;
	else if(abs(b-a)%2==0) cout << "Negative" << endl;
	else if(abs(b-a)%2!=0) cout << "Positive" << endl;
}

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

int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k){
        cout<<x*n<<"\n";
    }else{
        int a=x*k;
        int b=y*(n-k);
        cout<<a+b<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

int N;
ll dp[3][100010] = {0};
ll a[3][100010];

int main(){
    cin >> N;
    rep(i, N) cin >> a[0][i] >> a[1][i] >> a[2][i];

    rep(i,N){
        rep(j,3){
            rep(k,3){
                if(j==k)
                    continue;
                chmax(dp[k][i + 1], dp[j][i] + a[k][i]);
            }
        }  
    }
    ll ans = 0;
    rep(i, 3) chmax(ans, dp[i][N]);
    cout << ans << endl;
}

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

int main(){
	int64_t N,K;
	cin >> N >> K;

	int64_t d = 0;
	int64_t hito = 0;
	vector<vector<int64_t>> A(K);
	for (int64_t i = 0; i < K; i++) {
		cin >> d;
		for (int64_t j = 0; j < d; j++){
			cin >> hito;
    		A.at(i).push_back(hito);
	  	}
	}

	set<int64_t> array;
	for (auto v : A) {
		for (auto p : v){
			array.insert(p);
	  	}
	}
	cout << (N - array.size()) << endl;

}


Measured memory_bytes: 3676
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
   string s;
   cin >> s;
   for(int i = 0; i < 3; i++){
        if(s[i] == '1'){
            s[i] = '9';
        }else if(s[i] == '9'){
            s[i] = '1';
        }
   }
   cout << s << endl;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
read = sys.stdin.read

N, T, *A = map(int, read().split())
a_maximum = list(reversed(list(accumulate(A[::-1], max))[:-1]))
a = [j - i for i, j in zip(A, a_maximum)]
minimum = max(a)

print(a.count(minimum))

Measured memory_bytes: 14436
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		boolean r = solve(n);
		if (r)
			System.out.println("Yes");
		else
			System.out.println("No");
		in.close();
	}

	private static boolean solve(int n) {
		if (n == 0)
			return false;
		if (n % 10 == 7)
			return true;
		return solve(n /= 10);
	}
}

Measured memory_bytes: 35568
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;

const int mod=1000;
const int maxn=1e5+10;

int h[maxn];
int n,m,val[maxn];

int main()
{
    scanf("%d%d",&n,&m);
    for( int i=1;i<=n;i++ ) scanf("%d",&h[i]);
    for( int i=1;i<=m;i++ )
    {
    	int a,b;
    	scanf("%d%d",&a,&b);
    	val[a]=max(val[a],h[b]);
    	val[b]=max(val[b],h[a]);
	}
	int ans=0;
	for( int i=1;i<=n;i++ ) ans+=val[i]<h[i];
	printf("%d\n",ans);
	
}

Measured memory_bytes: 4644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:https://atcoder.jp/contests/abc133/tasks/abc133_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    res = LINF;
    ll L,R; cin >> L >> R;
    for(ll i = L; i <= min(L+2019,R); i++){
        for(ll j = i+1; j <= min(L+2019,R); j++){
            res = min(res,i*j%2019);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 int main(void){
    double a,b,c,d,e,f;
    double o,p,q,r;
    double x,y;
    while(scanf(" %lf %lf %lf %lf %lf %lf" ,&a ,&b ,&c ,&d ,&e ,&f)!=EOF){  
    o=a*e-b*d;
    p=b*d-a*e;
    q=c*e-b*f;
    r=c*d-a*f;
    x=q/o;
    y=r/p;
    if(x == -0)
       x=0;
    if(y == -0)
       y=0;
    printf("%.3lf %.3lf\n",x,y);
    }   
    return 0;
}

Measured memory_bytes: 652
import numpy as np

N,L=map(int, input().split())
taste=0
Apple_taste=[]

for i in range(N):
    taste=L+i
    Apple_taste.append(taste)

Abs=[abs(t) for t in Apple_taste]

i_m=np.argmin(Abs)
del Apple_taste[i_m]

print(sum(Apple_taste))



Measured memory_bytes: 12448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
     ll N; cin >> N;
     ll A[100010], B[100010], C[100010];
     for (int i = 0; i < N; i++) cin >> A[i];
     for (int i = 0; i < N; i++) cin >> B[i];
     for (int i = 0; i < N; i++) cin >> C[i];
 
     sort(A, A + N);
     sort(B, B + N);
     sort(C, C + N);
 
    ll ans = 0;
 
     for (int i = 0; i < N; i++) {
         ll b = B[i];
         ll *pos_a, *pos_c, dis_a, dis_c;
 
         pos_a = lower_bound(A, A + N, b);
         pos_c = upper_bound(C, C + N, b);
 
         dis_a = distance(A, pos_a); 
         dis_c = distance(pos_c, C + N);
 
         ans += dis_a * dis_c;
     }
 
     cout << ans << endl;
}

Measured memory_bytes: 2560