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

int n, h[200000], a[200000];
long long BIT[200001] = {};

long long getSum(int index) {
    long long ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, long long val) {
    while (index <= n) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n;
    for (int i=0; i<n; i++)
        cin >> h[i];
    for (int i=0; i<n; i++)
        cin >> a[i];

    long long ret = 0;
    for (int i=0; i<n; i++) {
        long long x = getSum(h[i]) + a[i];
        update(h[i], x);
        ret = max(ret, x);
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		int INF=1000000007;
		SC sc=new SC(System.in);
		int V=sc.nextInt();
		ArrayList<ArrayList<Integer>> v=new ArrayList<ArrayList<Integer>>();
		for(int i=0; i<=V; i++) {
			v.add(new ArrayList<Integer>());
		}
		for(int i=0; i<V-1; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			(v.get(a)).add(b);
			(v.get(b)).add(a);
		}
		int[] Fe=new int[V+1];
		int[] Su=new int[V+1];
		boolean[] Fe_V=new boolean[V+1];
		boolean[] Su_V=new boolean[V+1];
		Arrays.fill(Fe, INF);
		Arrays.fill(Su, INF);
		Fe[1]=0;
		Su[V]=0;
		Stack<Integer> Q=new Stack<Integer>();
		Q.add(1);
		while(!Q.isEmpty()) {
			int tmp=Q.pop();
			for(int i=0; i<v.get(tmp).size(); i++) {
				if(!Fe_V[v.get(tmp).get(i)] && Fe[tmp]+1<Fe[v.get(tmp).get(i)]) {
					Fe_V[v.get(tmp).get(i)]=true;
					Fe[v.get(tmp).get(i)]=Fe[tmp]+1;
					Q.push(v.get(tmp).get(i));
				}
			}
		}

		Q.add(V);
		while(!Q.isEmpty()) {
			int tmp=Q.pop();
			for(int i=0; i<v.get(tmp).size(); i++) {
				if(!Su_V[v.get(tmp).get(i)] && Su[tmp]+1<Su[v.get(tmp).get(i)]) {
					Su_V[v.get(tmp).get(i)]=true;
					Su[v.get(tmp).get(i)]=Su[tmp]+1;
					Q.push(v.get(tmp).get(i));
				}
			}
		}
		int Su_w=0;
		int Fe_w=0;
		for(int i=1; i<=V; i++) {
			if(Fe[i]<=Su[i]) {
				Fe_w++;
			}
			else {
				Su_w++;
			}
		}
		if(Su_w>=Fe_w) {
			System.out.println("Snuke");
			System.out.flush();
		}
		else {
			System.out.println("Fennec");
			System.out.flush();
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 55412
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int m,n;
    cin>>m>>n;
    if(m==2&&n==2)
    {
        cout<<"Yes"<<endl;
    }
    else if((m==4&&(n==4||n==6||n==9||n==11))||(m==6&&(n==4||n==6||n==9||n==11))||(m==9&&(n==4||n==6||n==9||n==11))||(m==11&&(n==4||n==6||n==9||n==11)))
    {
        cout<<"Yes"<<endl;
    }
    else if((m==1&&(n==1||n==3||n==5||n==7||n==8||n==10||n==12))||(m==3&&(n==1||n==3||n==5||n==7||n==8||n==10||n==12))||(m==5&&(n==1||n==3||n==5||n==7||n==8||n==10||n==12))||(m==7&&(n==1||n==3||n==5||n==7||n==8||n==10||n==12))||(m==8&&(n==1||n==3||n==5||n==7||n==8||n==10||n==12))||(m==10&&(n==1||n==3||n==5||n==7||n==8||n==10||n==12))||(m==12&&(n==1||n==3||n==5||n==7||n==8||n==10||n==12)))
    {
       cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <climits>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <numeric>
#include <set>

#define INF 2000000000
#define MOD 1000000007
#define sp ' '
#define endl "\n"
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(YY, yy) for(long long yy = 0; yy < YY; ++yy)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef vector<pair<int, pair<int, int> > > vpip;
typedef vector<bool> vb;
typedef priority_queue<int> pqi;

vii A;

int main(int argc, char **argv)
{
    ios::sync_with_stdio(); cin.tie(0);
    int N; cin >> N; A.assign(N, ii());

    for(int i = 1; i <= N; ++i)
    {
        cin >> A[i-1].st;
        A[i-1].nd = i;
    }
    sort(A.begin(), A.end());
    for(int i = 0; i < N; ++i)
        cout << A[i].nd << sp;
    cout << endl;


    return 0;
}

//cikisir



Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
LL fact[200001];
LL inv[200001];
LL inv_fact[200001];
LL mod_pow(LL a, LL x) {
	if (x == 0) return 1;
	if (x % 2 == 0) {
		LL ret = mod_pow(a, x / 2);
		return (ret*ret) % MOD;
	}
	else {
		return (mod_pow(a, x - 1)*a) % MOD;
	}
}
LL comb(LL n, LL k) {
	if (n < k) return 0;
	LL ret = fact[n];
	ret = (ret*inv_fact[k]) % MOD;
	ret = (ret*inv_fact[n - k]) % MOD;
	return ret;
}
int main() {
	LL H, W, A, B;
	cin >> H >> W >> A >> B;
	fact[0] = 1;
	inv_fact[0] = 1;
	REP(i, 1, 200001) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv[i] = mod_pow(i, MOD - 2);
		inv_fact[i] = (inv_fact[i - 1] * inv[i]) % MOD;
	}
	LL ans = 0;
	REP(i, 1, H - A + 1) {
		LL add = (comb(B - 1 + i - 1, B - 1)*comb(W - B - 1 + H - i, W - B - 1)) % MOD;
		ans = (ans + add) % MOD;
	}
	cout << ans << endl;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

// struct fast_io {
	// fast_io(){
		// std::cin.tie(nullptr);
		// std::ios::sync_with_stdio(false);
	// };
// } fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	vector<int> conw, conh;
    map<pair<int,int>,int> mp;
    priority_queue<pair<int,int>> Q;
    int H, W, M;
    int ans = 0;
    
    cin>>H>>W>>M;
    
    conw.resize(W+1);
    conh.resize(H+1);
    
    for(int i = 0; i < M; i++){
        int h, w;
        
        cin>>h>>w;
        
        mp[{h, w}]++;
        // cout<<"h = "<<h<<" "<<conh.size()<<endl;
        conh[h]++;
        conw[w]++;
    }
	
    for(int i = 1; i <= H; i++){
        if(conh[i]) {
            Q.push({conh[i], i});
        }
    }
    
    for(int i = 1; i <= W; i++){
        priority_queue<pair<int,int>> Q2;
        pair<int,int> p = {-1, -1};
        pair<int,int> p2 = {-1, -1};
        
        while(Q.size()){
            p = Q.top();
            
            // cout<<"mp coutm "<<mp.count({p.second, i})<<" "<<p.second<<endl;
            if(mp.count({p.second, i})) {
                Q2.push(p);
                Q.pop();
                p = {-1,-1};
            } else {
                // cout<<p.first<<" <> "<<p.second<<endl;
                break;
            }
        }
         // cout<<p.first<<" <> "<<p.second<<endl;
        if(Q2.size()) {
            p2 = Q2.top();
        }
         // cout<<p.first<<" <> "<<p.second<<endl;
        // cout<<"i = "<<i<<" "<<conw[i]<<endl;
        // cout<<p.first<<" "<<p.second<<endl;
        // cout<<p2.first<<" "<<p2.second<<endl;
        // cout<<endl;
        
        if(p.first != -1) {
            ans = max(ans, conw[i] + p.first);
        } 
        if(p2.first != -1) {
            ans = max(ans, conw[i] + p2.first - 1);
        }
        
        while(Q2.size()){
            Q.push(Q2.top()); Q2.pop();
        }
    }
	
    cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 35076
#include<iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if(a % 2 == 0) {
      if(a % 3 == 0) {
      } else if(a % 5 == 0) {
      } else {
        cout << "DENIED\n";
        return 0;
      }
    }
  }
  cout << "APPROVED\n";
  return 0;
}



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

ll N;
vector<ll> E[100000];
vector<ll> ring;
bool used[100000];

ll dfs(ll v, ll p) {
  if (used[v]) {
    return v;
  }
  used[v] = true;

  for (ll u : E[v]) if (u != p) {
    ll k = dfs(u, v);
    if (k >= 0) {
      ring.push_back(v);
      if (k == v) return -1;
      return k;
    }
  }

  used[v] = false;

  return -1;
}

int main(void) {
  cin >> N;
  REP(i, 0, N) {
    ll U, V;
    cin >> U >> V;
    U--;
    V--;
    E[U].push_back(V);
    E[V].push_back(U);
  }
  ll Q;
  cin >> Q;
  vector<ll> A(Q), B(Q);
  REP(i, 0, Q) cin >> A[i] >> B[i], A[i]--, B[i]--;

  REP(i, 0, N) used[i] = false;
  dfs(0, -1);

  sort(ring.begin(), ring.end());

  REP(i, 0, Q) {
    if (binary_search(ring.begin(), ring.end(), A[i]) && binary_search(ring.begin(), ring.end(), B[i])) {
      cout << 2 << endl;
    } else {
      cout << 1 << endl;
    }
  }
}


Measured memory_bytes: 15484
#include <iostream>
using namespace std;
int main()
{
  // 整数の入力
  int a, b;
  cin >> a >> b;
  int area, peri;
  area = a * b;
  peri = (a + b) * 2;
  cout << area << " " << peri << endl;
  return 0;
}


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

vector<int> Eratosthenes(int MaxNumPlusOne) {
	vector<int> isPrimeArray(MaxNumPlusOne, 1);
	int MaxNum = MaxNumPlusOne - 1;
	isPrimeArray[0] = -1;
	isPrimeArray[1] = -1;
	for (int i = 2; i <= sqrt(MaxNum); i++) {
		if (isPrimeArray[i] == 1) {
			for (int j = 2; j <= MaxNum; j++) {
				if (i * j > MaxNum) break;
				isPrimeArray[i * j] = -1;
			}
		}
	}
	return isPrimeArray;
}

int main() {

	int q; cin >> q;
	const int p = 100001;
	vector<int> isPrimeNumber = Eratosthenes(p);
	vector<int> similarNumberNumAccum(p, 0);
	for (int i = 1; i < p; i++) {
		if (isPrimeNumber[i] == 1 && isPrimeNumber[(i + 1) / 2] == 1) {
			similarNumberNumAccum[i]++;			
		}
		similarNumberNumAccum[i] += similarNumberNumAccum[i - 1];
	}
	for (int i = 0; i < q; i++) {
		int ans = 0;
		int l, r; cin >> l >> r;
		ans += similarNumberNumAccum[r] - similarNumberNumAccum[l - 1];
		cout << ans << endl;
	}	
	return 0;
}

Measured memory_bytes: 4108
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 200010
#define LL long long
LL a[N],s1[N],s2[N];
int main()
{
    int i,j,k,n,l;
    LL ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    s1[0]=0;
    s2[0]=0;
    for(i=1;i<=n;i++)
    {
        s1[i]=s1[i-1]^a[i];
        s2[i]=s2[i-1]+a[i];
    }
    ans=0;
    l=0;
    for(i=1;i<=n;i++)
    {
        while(1)
        {
            j=s1[i]^s1[l];
            k=s2[i]-s2[l];
            if(j==k)
            {
            ans=ans+i-l;
            break;
            }
            l++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int a = count(begin(s), end(s), 'a');
  int b = count(begin(s), end(s), 'b');
  int c = count(begin(s), end(s), 'c');

  if (max({a, b, c}) - min({a, b, c}) >= 2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<'8'<<s[4]<<s[5]<<s[6]<<s[7]<<s[8]<<s[9]<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);
		int a,b;
		cin>>a>>b;
		cout<<a*b;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;

int const MOD = 1e9 + 7;
int n, k;
vector<vector<int>> v;

void read_input()
{
    cin >> n >> k;
    v.resize(n);
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            int x;
            cin >> x;
            v[i].push_back(x);
        }
    }
}

void print(vector<vector<int>>& mat) {
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }
}

vector<vector<int>> mat_mul(vector<vector<int>>& a, vector<vector<int>>& b) {
    vector<vector<int>> res(n);
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            int c = 0;
            for(int kk = 0; kk < n; ++kk) {
                c += a[i][kk] * b[kk][j];
                c %= MOD;
            }
            res[i].push_back(c);
        }
    }
    return res;
}

vector<vector<int>> mat_pow(vector<vector<int>>& mat, int p) {
    if(p == 1) return mat;
    vector<vector<int>> h1 = mat_pow(mat, p / 2);
    h1 = mat_mul(h1, h1);
    if(p & 1) h1 = mat_mul(h1, mat);

    return h1;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    read_input();
    vector<vector<int>> res = mat_pow(v, k);
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            ans += res[i][j];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

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

bool isGood(vector<vector<vector<int>>> &dp, int N, int C, int M) {

    bool good = false;

    for (int x = 0; x < N; x++) {
        for (int y = 0; y < N; y++) {
            for (int z = 0; z < N; z++) {
                for (int d = 0; d < 13; d++) {

                    int xx = x;
                    int yy = y;
                    int zz = z;
                    int count = 0;

                    while (xx >= 0 && xx < N && yy >= 0 && yy < N && zz >= 0 && zz < N && dp[xx][yy][zz] == C) {
                        count++;
                        xx += dx[d];
                        yy += dy[d];
                        zz += dz[d];
                    }
                    if (count >= M) good = true;

                }
            }
        }
    }

    return good;

}

int main() {

    while (true) {

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

        if (!(N | M | P)) break;

        vector<vector<vector<int>>> dp(N, vector<vector<int>>(N, vector<int>(N, -1)));

        vector<int> X(P), Y(P);
        for (int i = 0; i < P; i++) cin >> X[i] >> Y[i], X[i]--, Y[i]--;

        bool decide = false;

        for (int i = 0; i < P; i++) {
            int C = i % 2;

            int _X = X[i];
            int _Y = Y[i];

            for (int k = 0; k < N; k++) {
                if (dp[_X][_Y][k] == -1) {
                    dp[_X][_Y][k] = C;
                    break;
                }
            }

            if (isGood(dp, N, C, M)) {
                if (i % 2) {
                    cout << "White" << " " << (i + 1) << endl;
                } else {
                    cout << "Black" << " " << (i + 1) << endl;
                }
                decide = true;
                break;
            }

        }

        if (decide) continue;
        cout << "Draw" << endl;
    }

    return 0;
}














































Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll h, w;
    cin >> h >> w;
    ll c[10][10];
    rep(i, 10) {
        rep(j, 10) { cin >> c[i][j]; }
    }
    ll a[h][w];
    rep(i, h) {
        rep(j, w) { cin >> a[i][j]; }
    }

    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) { c[i][j] = min(c[i][j], c[i][k] + c[k][j]); }
        }
    }

    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            if (a[i][j] == 1 | a[i][j] == -1) {
                continue;
            } else {
                ans += c[a[i][j]][1];
            }
        }
    }
    cout << ans << endl;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> even;
	vector<int> odd;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		if(i%2==0)
			even.push_back(a[i]);
		else
			odd.push_back(a[i]);
	}
	sort(a.begin(),a.end());
	sort(even.begin(),even.end());
	sort(odd.begin(),odd.end());
	int cnt=0;
	int see=0;
	set<int> st;
	for(int i=0;i<n;i++)
	{
		if(i%2==0)
			st.insert(a[i]);
	}
	for(int i=0;i<even.size();i++)
		st.insert(even[i]);
	
	cout << st.size()-even.size() << endl;

}

Measured memory_bytes: 5756
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    vector<vector<int>> w(26);
    rep(i,s.length()){
        w[s[i]-'a'].push_back(i);
    }
    rep(i,26){
        w[i].push_back(1000000);
    }
    vector<int> state(26,0);
    ll cnt = 0,ans = 0,index = -1;
    rep(i,t.length()){
        int k = t[i]-'a';
        if (w[k][state[k]] != 1000000){
            if (index >= w[k][state[k]]){
                int g = upper_bound(all(w[k]),index)-w[k].begin();
                if (w[k][g] == 1000000) goto hello;
                state[k] = g;
            }
            if (i == t.length()-1) ans += w[k][state[k]]+1;
            index = w[k][state[k]];
            state[k]++;
        }
        else{
hello:
            cnt++;
            state.assign(26,0);
            if (w[k][state[k]] == 1000000){
                PRINT(-1);
                return 0;
            }
            if (i == t.length()-1) ans += w[k][state[k]]+1;
            index = w[k][state[k]];
            state[k]++;
        }
    }
    PRINT(ans+cnt*(ll)s.length());
}


Measured memory_bytes: 1228
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, K = MI()
P = LI()
C = LI()
loops = []
C_loop = []
for i in range(N):
    j = i
    loops.append([i])
    C_loop.append([0])

    while (P[i] - 1) != j:
        i = P[i] - 1
        C_loop[-1].append(C_loop[-1][-1] + C[i])
        loops[-1].append(i)

    C_loop[-1].append(C_loop[-1][-1] + C[P[i] - 1])


ans_list = [0] * N

for i in range(N):
    if K <= len(loops[i]):
        ans_list[i] = max(C_loop[i][j] for j in range(1, K + 1))
    else:
        if C_loop[i][-1] <= 0:
            ans_list[i] = max(C_loop[i])
        else:
            a = K // len(loops[i])
            ans_list[i] = max(a * C_loop[i][-1] + max(C_loop[i][j] for j in range(K % len(loops[i]) + 1)), (a - 1) * C_loop[i][-1] + max(C_loop[i]))

print(max(ans_list))


Measured memory_bytes: 507856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    long long a,b,c;
    cin >> a >> b >> c;

    long long d = c - a - b;

    if( d > 0 and 4*a*b < d*d ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[1000][100]; int ans[100]={0}; int srt[100]; int n,m ;
	while(cin >> n >> m ){
	if(m==0&&n==0) break;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++) cin >> a[i][j] ;
	int ptr=0;
	for(int j=0;j<m;j++){
		int cnt=0;
		for(int i=0;i<n;i++){
			if(a[i][j]==1) cnt++;
		};
		srt[ptr]=ans[ptr++]=cnt;
	};
	stable_sort(ans,ans+ptr);
	int cnt=0;
	for(int j=m-1;j>=0;j--){
		for(int i=0;i<m;i++){
			if(ans[j]==ans[j+1]) break;
			if(ans[j]==srt[i]) do{
				if(cnt++) cout<<' ';
				cout << i+1 ;
			}while(0);
		};
	};
	cout << '\n' ;
	};
}

Measured memory_bytes: 1616
#include<iostream>
#include<vector>
#include<algorithm>
int main(void){
    int x, y, a, b, c;
    std::cin >> x >> y >> a >> b >> c;
    std::vector<int> p(a), q(b), r(c);
    for(int i = 0; i < a; i++){
	std::cin >> p[i];
    }
    for(int i = 0; i < b; i++){
	std::cin >> q[i];
    }
    for(int i = 0; i < c; i++){
	std::cin >> r[i];
    }
    std::sort(p.rbegin(), p.rend());
    std::sort(q.rbegin(), q.rend());
    std::sort(r.rbegin(), r.rend());
    int ai = 0, bi = 0, ci = 0;
    int sum = x + y;
    long long ans = 0;
    while(true){
	int max = 0;
	max = std::max(p[ai], q[bi]);
	max = std::max(max, r[ci]);
	if(r[ci] == max){
	    ans += r[ci];
	    ci++;
	}else if(p[ai] == max){
	    if(ai == x){
		p[ai] = 0;
		continue;
	    }else{
		ans += p[ai];
		ai++;
	    }
	}else{
	    if(bi == y){
		q[bi] = 0;
		continue;
	    }else{
		ans += q[bi];
		bi++;
	    }
	}
	if(ai + bi + ci == sum){
	    break;
	}

    }
    std::cout << ans << std::endl;
    return 0;
}



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


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int totalCount = int.Parse(Reader.ReadLine());
        int baseCount = int.Parse(Reader.ReadLine());

        long plan1 = long.Parse(Reader.ReadLine());
        long plan2 = long.Parse(Reader.ReadLine());


        long ans = (Math.Min(totalCount, baseCount)) * plan1;
        ans += (Math.Max(totalCount - baseCount, 0)) * plan2;
        Console.WriteLine(ans.ToString("#########################0"));


    }








    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"
2
3
10000
9000



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 2776
char c;
int A, B, C, D, a, b;
char *s[]={"Right","Left","Balanced"};
int main(){
  scanf("%d%d%d%d", &A, &B, &C, &D);
  a=A+B;
  b=C+D;
  if(a<b){
    c=0;
  }else if(a>b){
    c=1;
  }else{
    c=2;
  }
  puts(s[c]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int ab,bc,ca;
  cin >> ab >> bc >> ca;
  cout << (ab*bc)/2 << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string> //文字列を使う
using namespace std;
int main(void){
    string s;
    while(true){
        cin >> s;
        if(s == "0") {
            break;
        }
        int sum = 0;
        for(int i = 0; i < s.size(); i++) {
            //TODO:文字コードを数値に変換する
            int n = s[i] - 48;   
            sum += n;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3164
from collections import defaultdict


def solve(input_s: str):
    ans = 0
    n = len(input_s)
    mod = 2019
    dp = defaultdict(int)
    cur = 0
    for i in range(n, -1, -1):
        if i == n:
            dp[0] += 1
        else:
            # cur += ((10 ** (n - i - 1)) * int(input_s[i])) % mod これはnがでかくなるとめちゃめちゃ遅い
            cur += pow(10, n - i - 1, 2019) * int(input_s[i]) % mod
            cur %= mod
            dp[cur] += 1
    for v in dp.values():
        if v > 1:
            ans += v * (v - 1) // 2
    return ans


if __name__ == '__main__':
    S = input()
    print(solve(S))

Measured memory_bytes: 9632
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;

signed main() {
    int A,B;
    cin >> A >> B;
    if(A > B) {
        int tmp = A;
        A = B;
        B = tmp;
    }
    if(A == 1 && B == 2) {
        cout << 3 << endl;
    }
    else if(A == 1 && B == 3) {
        cout << 2 << endl;
    }
    else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
program strings_with_the_same_length
  implicit none
  integer :: n, i
  character(100) :: s, t
  read(*,*) n
  read(*,*) s, t
  do i = 1, n
    write(*,'(a)',advance='no') s(i:i)//t(i:i)
  end do
  write(*,*)
end program strings_with_the_same_length

Measured memory_bytes: 640
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
       A: i64,
       B: i64,
    }

    // 消費税が100円ということは、1000円未満

    for money in 1..10000 {
        let a = (money as f64 * 0.08) as i64;
        let b = (money as f64 * 0.10) as i64;

        if a == A && b == B {
            println!("{}", money);
            return;
        }
    }

    println!("-1");
}


Measured memory_bytes: 2136
import collections
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
x = collections.Counter(a)
y = collections.Counter(b)
ans = 0
for i in x.keys():
    cnt = x[i]
    if i in y.keys(): cnt -= y[i]
    ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 38384
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int Q;

int main() {
  cin >> Q;

  while (Q--) {
    ll a, b;
    cin >> a >> b;

    if (a == b) {
      cout << 2*(a-1) << endl;
      continue;
    }

    ll lb = 0, ub = 1e9;
    while (ub-lb > 1) {
      ll mid = (ub+lb)/2;
      if (mid*mid >= a*b) ub = mid;
      else lb = mid;
    }
    if (lb*(lb+1) < a*b) {
      cout << 2*lb-1 << endl;
    } else {
      cout << 2*(lb-1) << endl;
    }
  }
}



Measured memory_bytes: 384
package main

import (
	"fmt"
)

func gcd(A int, B int) int {

	if B == 0 {
		return A
	}
	return gcd(B, A%B)
}

func lcm(A int, B int) int {

	return A * B / gcd(A, B)
}

func main() {
	// Code for C - Anti-Division
	var A, B, C, D int
	fmt.Scanf("%d %d %d %d", &A, &B, &C, &D)

	A--
	E := B - B/C - B/D + B/lcm(C, D)
	F := A - A/C - A/D + A/lcm(C, D)

	fmt.Println(E - F)
}


Measured memory_bytes: 1836
from sys import stdin
s = stdin.readline().rstrip()
si, ei = 0, 0
a_marked = False
for i, c in enumerate(s):
    if c == 'A':
        if a_marked:
            continue
        else:
            si = i
            a_marked = True
    if c == 'Z':
        ei = i
print(len(s[si:ei+1]))

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main(){
    IOS;
    int n;
    cin >> n;
    int ans = 0;
    int p = 100;
    while(1){
        if(p >= n)
            break;
        p += p/100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3652
x, y = list(map(int, input().split()))

gA = [1, 3, 5, 7, 8, 10, 12]
gB = [4, 6, 9, 11]
gC = [2]

flg = False
for g in [gA, gB, gC]:
    if x in g:
        if y in g:
            print("Yes")
            flg = True

if not flg:
    print("No")


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

int dp[40][1<<14];
int v[40];

inline int pnt(int c){
    return c>0?50+c*10:0;
}

int toBit(int c[7],int p){
    int bit=0;
    for(int i=1;i<7;i++){
        bit=(bit<<2)|c[i];
    }
    bit=(bit<<2)|(~v[p+7]?v[p+7]:0);
    return bit;
}

void solve(){
    memset(v,-1,sizeof(v));
    for(int i=0;i<25;i++)cin>>v[i],v[i]--;
    memset(dp,-1,sizeof(dp));
    int start=0;
    for(int i=0;i<7;i++)start=(start<<2)|(~v[i]?v[i]:0);
    dp[0][start]=0;
    for(int i=0;i<25;i++){

        for(int S=0;S<(1<<14);S++){
            if(dp[i][S]==-1)continue;
            int c[7];
            for(int j=0;j<7;j++)c[6-j]=S>>(j*2)&3;

            int to=toBit(c,i);
            if(i%5==4||i>=20){
                dp[i+1][to]=max(dp[i+1][to],dp[i][S]+pnt(c[0]));
                continue;
            }
            for(int j=0;j<4;j++){
                to=toBit(c,i);
                dp[i+1][to]=max(dp[i+1][to],dp[i][S]+pnt(c[0]));

                if(~v[i])c[0]=(c[0]+1)%4;
                if(~v[i+1])c[1]=(c[1]+1)%4;
                if(~v[i+5])c[5]=(c[5]+1)%4;
                if(~v[i+6])c[6]=(c[6]+1)%4;
            }

        }
    }

    int ans=0;
    for(int i=0;i<(1<<14);i++)ans=max(ans,dp[25][i]);

    cout<<ans<<endl;

}

int main(){
    int n;cin>>n;
    while(n--)solve();
    return 0;
}

Measured memory_bytes: 3724
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
char st[MAXN];
int main()
{
	int n=read(),k=read(),num=1;
	scanf("%s",st+1);
	for (int i=2;i<=n;i++) if (st[i]!=st[i-1]) num++;
	printf("%d\n",min(n-1,n-num+min(k,(num/2))*2));
	return 0;
}

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

int main(){
    int c[10010], n;
    long long w = 0;
    while(1){
        cin >> n;
        if(n == 0) break;
        for(int i = 0; i < n; i++){
            cin >> c[i];
        }
        sort(c, c + n);
        for(int i = 0; i < n; i++){
            w += c[i] * (n - i - 1);
        }
        cout << w << endl;
        w = 0;
    }
}

Measured memory_bytes: 3172
import java.util.Scanner;                                                   
import java.util.Arrays;
   
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        while(true) {
            int x = scan.nextInt(), y = scan.nextInt();
      
            if(x == 0 && y == 0) break;
            if(x < y) {
                System.out.println(x + " " + y);
            } else {
                System.out.println(y + " " + x);
            } 
        } 
    } 
}

Measured memory_bytes: 36500
import Foundation
let a = readLine()!.split(separator: " ").map({Int($0)!})
var count = 0
for i in 0 ... a[0] {

    for j in 0 ... a[0] {
    if i + j > a[1] {
        break
    }
        if a[1] - i - j >= 0 && a[1] - i - j <= a[0] {
            count += 1
        }
    }
}
print(count)

Measured memory_bytes: 13664
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	auto notPrime = new bool[](1000000);
	notPrime[0] = notPrime[1] = true;
	for(int i; i < notPrime.length; ++i) {
		if(!notPrime[i]) {
			for(int j = 2; i*j < notPrime.length; ++j) {
				notPrime[i*j] = true;
			}
		}
	}
	int[] primes;
	for(int i; i < notPrime.length; ++i) {
		if(!notPrime[i]) {
			primes ~= i;
		}
	}
	while(true) {
		auto adn = readInts();
		auto a = adn[0];
		auto d = adn[1];
		auto n = adn[2];
		if(a == 0 && d == 0 && n == 0) {
			return;
		}

		writeln(primes.filter!(x => (x-a) >= 0 && (x-a)%d == 0).array.assumeSorted.upperBound(a-1)[n-1]);
	}
}

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

using namespace std;

int main() {
   int N, K;
   cin >> N >> K;
   int x[N];

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

   int ans = 300000000;
   int tmp;
   for (int i = 0; i < N - K + 1; i++) {
      tmp = 0;
      tmp += abs(x[i] - x[i + K - 1]);
      tmp += abs(x[i]);
      if (tmp < ans) ans = tmp;
      tmp = 0;
      tmp += abs(x[i] - x[i + K - 1]);
      tmp += abs(x[i + K - 1]);
      if (tmp < ans) ans = tmp;
   }
   cout << ans << endl;
   return 0;
}


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

int main() {
    int n, d;
    cin >> n >> d;
    double x[30][30];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            double tmp = 0;
            for (int k = 0; k < d; k++) {
                tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            double g = floor(sqrt(tmp));
            if (g * g == tmp) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*lost it in the lonely highway*/
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define bump cout<<"bleh\n"
#define all(v) (v).begin(),(v).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define file freopen("input.txt", "r", stdin)
#define reset(x,n) memset(x,n,sizeof(x))

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
*/

/*
find_by_order(k): It returns to an iterator to the kth element (counting from zero)
order_of_key(k) : It returns to the number of items that are strictly smaller than our item k
*/

using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e8+7;
const int nmax=1e5+10;
const int eps=1e-8;
const ll infll=1e15;


int main()
{
    fastio;
    ll n,k;
    cin>>n>>k;

    ll x=n%k;
    ll ans=min(x,abs(x-k));

    cout<<ans<<"\n";

    return 0;
}

/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  int n=1;
  cin >>A>>B;
  
  while(true){
      if (1+(A-1)*(n-1)>=B)
      break;
      n++;
  }
  cout <<n-1<<endl;
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    print(ab[-1][0] + ab[-1][1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 56412
# 解説AC
N,A,B,C,D = map(int, input().split())

flag = False
for i in range(N):
    L = i * C + (i - (N - 1)) * D
    H = (i - (N - 1)) * C + i * D

    if L <= B - A <= H:
        flag = True

if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int ll
typedef long long ll ;
const int MAX=3e5+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;

void solve(){
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.size();i++){
        ans+=s[i]-'0';
    }
    if(ans%9==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    int table[10001] = {0}; rrep(i, 2, 10001) table[i] = 1;
    rrep(i, 2, 101) {
        rrep(j, i + 1, 10001) {
            if (table[j] == 0) continue;
            if (j % i == 0) {
                table[j] = 0;
            }
        }
    }
    vector<int> prime;
    rep(i, 10001) {
        if (table[i] == 1) {
            prime.push_back(i);
            //cout << i << endl;
        }
    }
    int n;
    while (cin >> n && n) {
        int c = 0;
        rep(i, prime.size()) {
            int sum = 0;
            rrep(j, i, prime.size()) {
                sum += prime[j];
                if (sum > n) {
                    break;
                }
                if (sum == n) {
                    c++;
                    break;
                }
            }
        }
        cout << c << endl;
    }
}



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

int main()
{
    int i = 1;
    int j = 1;
    for(;i <= 9; i++)
    {
        j=1;
        for(;j<=9;j++) cout << i << "x" << j << "=" << i*j << endl;
    }
    return 0;
}

Measured memory_bytes: 1116
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int main() {
    int k;
    string s;
    cin >> s >> k;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'a') {
            continue;
        } else {
            int dif = 'z' - s[i] + 1;
            if(dif <= k) {
                k -= dif;
                s[i] = 'a';
            }
        }
    }
    if(k >= 0) {
        int ch = s[s.size() - 1] - 'a' + k;
        ch = ch % 26;
        s[s.size() - 1] = 'a' + ch;
    }
    cout << s;
}


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

ll N,M,Q;
ll ans = -1;
vector<ll> A;
void dfs(ll len_A, vector<vector<ll> > &vec, ll current){
    if (len_A == N){
        ll sub_ans = 0;
        rep(i,Q){
            if (A[vec[i][1]] - A[vec[i][0]] == vec[i][2]) sub_ans += vec[i][3];
        }
        ans = max(ans, sub_ans);
        return;
    }
    
    for (ll i = current; i <= M; i++){
        A.push_back(i);
        dfs(len_A + 1,vec,i);
        A.pop_back();
    }
    return;
}

int main(){
    cin >> N >> M >> Q;
    vector<vector<ll> > vec(Q, vector<ll>(4));
    rep(i,Q){
        rep(j,4){
            cin >> vec[i][j];
        }
        vec[i][0]--;
        vec[i][1]--;
    }
    dfs(0,vec,1);
    cout << ans << endl;
}


Measured memory_bytes: 3640
import sys
input = sys.stdin.readline

def main():
    sa = input().strip()
    sb = input().strip()
    sc = input().strip()
    
    rest_a = 0
    rest_b = 0
    rest_c = 0
    next_ = sa[0]
    rest_a += 1
    while True:
        if next_ == "a":
            if rest_a == len(sa):
                print("A")
                break
            else:
                next_ = sa[rest_a]
                rest_a += 1
        elif next_ == "b":
            if rest_b == len(sb):
                print("B")
                break
            else:
                next_ = sb[rest_b]
                rest_b += 1
        elif next_ == "c":
            if rest_c == len(sc):
                print("C")
                break
            else:
                next_ = sc[rest_c]
                rest_c += 1

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int a, b, t;

signed main() {
    cin >> a >> b >> t;
    cout << t/a * b << endl;
}

Measured memory_bytes: 256