akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class DHandstand2 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    int cnt[10][10];
	    Fill(cnt, 0);
	    for(int i=1; i<=n; i++){
            string t = to_string(i);
            cnt[t[0]-'0'][t.back()-'0']++;
	    }

	    ll res = 0;
	    for(int i=1; i<10; i++){
	        for(int j=1; j<10; j++){
	            res += cnt[i][j] * cnt[j][i];
	        }
	    }

	    out << res << endl;
	}
};


int main() {
	DHandstand2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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



int main(){
  int N;
    cin>>N;
    vector<string> judge(N);
    for(int i=0;i<N;i++){
        cin>>judge.at(i);
    }
    int c0=0,c1=0,c2=0,c3=0;
    for(int i=0;i<N;i++){
        if(judge.at(i)=="AC"){
            c0++;
        }
        if(judge.at(i)=="WA"){
            c1++;   
        }
        if(judge.at(i)=="TLE"){
            c2++;  
        }
        if(judge.at(i)=="RE"){
            c3++;
        }
    }
    cout<<"AC x "<<c0<<endl<<"WA x "
    <<c1<<endl<<"TLE x "<<c2<<endl<<"RE x "<<c3<<endl;
    

}

Measured memory_bytes: 6360
from collections import Counter
def p_fact(n):
  m=n
  i=2
  a=[]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a
a=[]
for i in range(1,int(input())+1):
  a+=p_fact(i)
ans=1
mod=10**9+7
for i in list(Counter(a).values()):
  ans*=(i+1)
  ans%=mod
print(ans)

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

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

	int n;
	ll k;
	cin >> n >> k;

	const int MX = 60;

	vector<int> cnts(MX + 9, 0);

	for (int i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		for (int j = 0; j < MX; ++j)
			if (x & (1LL << j))
				++cnts[j];
	}

	++k;

	ll ans = 0;
	for (int i = 0; i < MX; ++i) {
		if (!(k & (1LL << i)))
			continue;

		ll res = 0;
		for (int j = 0; j < MX; ++j) {
			int temp = 0;
			if (j < i)
				temp = max(cnts[j], n - cnts[j]);
			else if (j == i)
				temp = cnts[j];
			else if (k & (1LL << j))
				temp = n - cnts[j];
			else
				temp = cnts[j];

			res += temp * (1LL << j);
		}
		ans = max(ans, res);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,q,x;cin>>a>>b>>q;
  ll sl,su,tl,tu,slpos,supos,tlpos,tupos;
  lvector S(a+2,0),T(b+2,0),ans(q,0);
  S[0]=-1e12;T[0]=-1e12;S[a+1]=1e12;T[b+1]=1e12;
  rep(i,a) cin>>S[i+1];rep(i,b) cin>>T[i+1];
  rep(i,q) {
    cin>>x;
    slpos=distance(S.begin(),lower_bound(ALL(S),x));
    supos=distance(S.begin(),upper_bound(ALL(S),x));
    tlpos=distance(T.begin(),lower_bound(ALL(T),x));
    tupos=distance(T.begin(),upper_bound(ALL(T),x));
    if(slpos==supos) slpos--;if(tlpos==tupos) tlpos--;
    sl=S[slpos],tl=T[tlpos],su=S[supos],tu=T[tupos];
    ll ans1=min(abs(x-min(sl,tl)),abs(x-max(su,tu)));
    ll ans2=2*min(abs(x-sl),abs(x-tu))+max(abs(x-sl),abs(x-tu));
    ll ans3=2*min(abs(x-su),abs(x-tl))+max(abs(x-su),abs(x-tl));
    ans[i]=min({ans1,ans2,ans3});
  }
  rep(i,q) print(ans[i]);
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n; cin >> n;
	ll a[n+1]; rep(i, 0, n)cin >> a[i];
	if(n == 0){
		print((a[0] == 1)? 1 : -1)
		return 0;
	}
	
	bool ans = true;
	ll r[n+1];
	r[0] = 1;
	rep(i, 1, n){
		r[i] = min(2*r[i-1]-a[i], ll(1e15));
		if(r[i] < 0)ans = false;
	}
	//printa(r, 0, n)
	
	if(!ans || a[0] != 0){
		print(-1)
	}else{
		ll res = 0;
		ll l = 0;
		
		rrep(i, n, 0){
			
			l += a[i];
			res += min(l, r[i]+a[i]);
		}
		print(res)
	}
	
	return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
	int n;	cin >> n;
  	vector<pair<int,int>> dc;
  	rep(i,n){
    	int tmp;	cin >> tmp;
      	dc.push_back({tmp,i+1});
    }
  	sort(dc.begin(), dc.end());	
  	rep(i,n){
      	if(i == n - 1) cout << dc.at(i).second << endl;
        else cout << dc.at(i).second << " ";
    }
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const ll MAX_N = ll(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i,n) for (int i = n; i >=0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, a[MAX_N], cum[MAX_N]{}, ans = 0, ma, L;

int main() {
    
    cin >> n;
    REP(i,n) cin >> a[i];
    REP(i,n*2){
        cum[i+1] = cum[i] + a[i%n];
    }
    L = cum[n];
    ma = cum[n]/3;
    ll l = 0, r = 0;
    while(l <= n){
        while(n-r+l > 2 && cum[r] - cum[l] < ma){
            r++;
        }
        ll s = cum[r] - cum[l];
        ll k = lower_bound(cum+r,cum+n+l,(L-s)/2+cum[r]) - cum;
        for(int i = -1; i <= 1; i++){
            ll tmp = LLINF;
            tmp = min(tmp, s);
            tmp = min(tmp, cum[k+i]-cum[r]);
            tmp = min(tmp, cum[n+l]-cum[k+i]);
            ans = max(ans, tmp);
        }
        l++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ARC_C
{
    class _100
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            int all = 1 << n;
            int[,][] dp = new int[all, 2][];
            for (int i = 0; i < all; i++)
            {
                dp[i, 0] = new int[2] { array[i], i };
                dp[i, 1] = new int[2] { 0, -1 };
            }
            for (int i = 0; i < all; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    int next = i | (1 << j);
                    if ( next > i)
                    {
                        int[][] vals = new int[4][] { dp[next, 0], dp[next, 1], dp[i, 0], dp[i, 1] };
                        Array.Sort(vals, (a, b) => a[0] - b[0]);
                        dp[next, 0] = vals[3];
                        if (vals[3][1] == vals[2][1])
                        {
                            dp[next, 1] = vals[1];
                        }
                        else
                        {
                            dp[next, 1] = vals[2];
                        }
                    }
                }
            }
            int max = 0;
            for(int i = 1; i < all; i++)
            {
                max = Max(max, dp[i, 0][0] + dp[i, 1][0]);
                WriteLine(max);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 49300
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("-1");exit(0);}

const int maxn=105;
const int maxm=20005;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
int n,m;
char c[maxn][maxn];

class max_flow{
public:
	int s,t;
	class EDGE{
	public:
		int to,cap,rev;
		EDGE(int _to,int _cap,int _rev){to=_to;cap=_cap;rev=_rev;}
	};
	vector<EDGE>edge[maxm];
	int lvl[maxm],nxt[maxm],q[maxm];
	void add_edge(int from,int to,int cap){
//		cout<<from<<" "<<to<<endl;
		edge[from].pb(EDGE(to,cap,edge[to].size()));
		edge[to].pb(EDGE(from,0,edge[from].size()-1));
	}
	void bfs(){
		int l=0,r=0;
		memset(lvl,-1,sizeof(lvl));
		lvl[s]=0;
		q[r++]=s;
		while(l<r){
			int x=q[l++];
			rep(i,edge[x].size()){
				EDGE &y=edge[x][i];
				if(y.cap&&lvl[y.to]<0){
					lvl[y.to]=lvl[x]+1;
					q[r++]=y.to;
				}
			}
		}
	}
	int dfs(int x,int f){
		if(x==t)return f;
		for(int &i=nxt[x];i<edge[x].size();i++){
			EDGE &y=edge[x][i];
			if(y.cap&&lvl[y.to]==lvl[x]+1){
				int d=dfs(y.to,min(f,y.cap));
				if(d>0){
					y.cap-=d;
					edge[y.to][y.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int mf(){
		int res=0;
		while(true){
			bfs();
			if(lvl[t]<0)return res;
			memset(nxt,0,sizeof(nxt));
			int f;
			while(true){
				f=dfs(s,INF);
				res+=f;
				if(!f)break;
			}
		}
	}
}M;

int get_id(int i,int j,int tp){
	return (i*m+j)*2+tp;
}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,n)scanf("%s",c[i]);
	M.s=n*m*2,M.t=n*m*2+1;
	rep(i,n)rep(j,m){
		if(c[i][j]=='X'){
			M.add_edge(get_id(i,j,0),get_id(i,j,1),INF);
			M.add_edge(get_id(i,j,1),M.t,INF);
			if(!i||i==n-1||!j||j==m-1){
				puts("-1");
				return 0;
			}
		}
		else M.add_edge(get_id(i,j,0),get_id(i,j,1),1);
		rep(k,4){
			int ni=i+dx[k],nj=j+dy[k];
			if(ni>=0&&ni<n&&nj>=0&&nj<m){
				M.add_edge(get_id(i,j,1),get_id(ni,nj,0),INF);
			}
			else M.add_edge(M.s,get_id(i,j,0),INF);
		}
	}
	printf("%d\n",M.mf());
	return 0;
}

/*
Input:
5 4
....
..X.
.XX.
..X.
....
-----------------
Output:
*/

Measured memory_bytes: 3072
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
vanceknowledgetoad
advance

vanceknowledgetoad
advanced
 */

reader.on('close', () => {
    var txt = lines[0];
    var str = lines[1];

    var txt2=txt + txt;
    var re=new RegExp(str);

    if (re.test(txt2)) {
	console.log("Yes");
    } else {
	console.log("No");
    }

});


Measured memory_bytes: 16460
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader( new InputStreamReader(System.in) );

		String[] data = br.readLine().split(" ");
		int n = Integer.parseInt(data[0]); // the number of w
		int k = Integer.parseInt(data[1]); // the number of tracks

		int[] w = new int[n];
		int max = 0; // max of w[i]
		for (int i=0; i < n; i++) {
			w[i] = Integer.parseInt( br.readLine() );
			if (max < w[i]) {
				max = w[i];
			}
		}

		int pmax = 0;
		if (n%k == 0) {
			pmax = n/k * max;
		} else{
			pmax = (n/k + 1) * max;
		}
//		int pmax = (int)Math.ceil((double)n/k) * max;
//		int[] pi = new int[pmax - max + 1]; // pi.length = pmax-max+1
//		for (int i=0; max + i <= pmax; i++) { // pi.length-1 = pmax-max
//			pi[i] = max + i; // pi = {max, max+1, max+2, ... , pmax}
//		}

		/**
		 * binarysearch
		 */
		int l = max; // left
		int r = pmax; // right
		while (l != r) {
			int mid = (l + r) / 2;
			if ( canload(mid, k , w) ) {
				r = mid;
			} else {
				l = mid+1;
			}
		}
		System.out.println(l);
	}

	/*
	 * max???????????????????????????k??°??§???????????????w??????????????????????????????
	 */
	static boolean canload(int max, int k, int[] w) {
		int count = 1; // ?????????????????°??°???k????¶????????????±???
		int p = 0; // ?????????????????????????????????????????????max????¶???????????????????????¬????????????????
		int n = w.length;
		int i = 0;

		while (true) {
			p += w[i];
			if (p > max) {
				count++;
				if (count > k) {
					return false;
				}
				p = 0;
			} else {
				i++;
				if (i == n) {
					return true;
				}
			}
		}

	}
}

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

    if(a <= 2*b){
        cout << 0;
    }
    else{
        cout << a-b*2;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n=s.nextInt(),x=s.nextInt(),t=s.nextInt();
        long sum = n/x;
        sum *= t;
        if(n%x!=0)sum+=t;
        System.out.println(sum);
 
    }
 
}
 
 
 
 
class Scanner
{
    StringTokenizer st;
    BufferedReader br;
 
    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
 
    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
 
    public int nextInt() throws IOException {return Integer.parseInt(next());}
 
    public long nextLong() throws IOException {return Long.parseLong(next());}
 
    public String nextLine() throws IOException {return br.readLine();}
 
    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }
 
    public boolean ready() throws IOException {return br.ready();}
 
 
}

Measured memory_bytes: 25256
n = int(input())
c = input()

r = 0
for v in c:
    if v == "R":
        r += 1
ans = min(r, n - r)
w = 0
for v in c:
    if v == "W":
        w += 1
    else:
        r -= 1
    ans = min(ans, max(w, r))
print(ans)


Measured memory_bytes: 79880
#include <iostream>

using namespace std;

int main(void)
{
	int n;

	int i1,i2;
	int check;
	int count;

	while(1){
		cin >> n;
		if (n==0) break;


		count=0;
		for(i1=n+1;i1<=2*n;i1++){
			check=0;
			for(i2=2;i2*i2<=i1;i2++){
				if(i1%i2==0){
					check = 1;
					break;
				}
			}
			if(check==0) count++;
		}

		cout << count << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		r=(r*a)%m;
		b=b/2;
		a=(a*a)%m;
	}
	return r%m;
}
vi arr;
ll n;
ll lis(vi arr, ll n)
{
    // 'max' to store the length of longest
    // increasing subarray
    // 'len' to store the lengths of longest
    // increasing subarray at diiferent
    // instants of time
    ll mx = 1, len = 1;

    // traverse the array from the 2nd element
    for (ll i=1; i<n; i++)
    {
        // if current element if greater than previous
        // element, then this element helps in building
        // up the previous increasing subarray encountered
        // so far
        if (arr[i] <= arr[i-1])
            len++;
        else
        {
            // check if 'max' length is less than the length
            // of the current increasing subarray. If true,
            // then update 'max'
            if (mx < len)
                mx = len;

            // reset 'len' to 1 as from this element
            // again the length of the new increasing
            // subarray is being calculated
            len = 1;
        }
    }

    // comparing the length of the last
    // increasing subarray with 'max'
    if (mx < len)
        mx = len;

    // required maximum length
    return mx;
}
int main(){
    cin>>n;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    //reverse(arr.begin(),arr.end());
    cout<<lis(arr,n)-1<<endl;
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    counter = 0
    for hh in h:
        if hh >= K:
            counter += 1
    print(counter)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 読み込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] ai = new int[100001];
		
		long sum = 0;
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			sum += a;
			ai[a] ++;
		}

		int Q = sc.nextInt();

		for (int i = 0; i < Q; i++) {
			int b = sc.nextInt();
			int c = sc.nextInt();

			long add_or_sub = 0;
			ai[c] += ai[b];
			add_or_sub = c * ai[b] - b * ai[b];
			ai[b] = 0;
			
			sum += add_or_sub;
			System.out.println(sum);
		}
	}
}


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

int main()
{
	int x; cin >> x;
	
	int sum = 0;
	for (int i = 1; i <= x; i++) {
		sum += i;
		if (sum >= x) {
			cout << i << endl;
			return 0;
		}
	}
}


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

int main(){
  int64_t a, b, x;
  cin >> a >> b >> x;
  
  if(a == 0){
    cout << b/x + 1 << endl;
  } else {
    cout << b/x - (a-1)/x << endl;
  }
} 


Measured memory_bytes: 256
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()
ret = N
for A in range(1,N):
  B = N-A
  ret = min(ret, sum(int(e) for e in str(A)) + sum(int(e) for e in str(B)))
print(ret)

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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;}

string upper(string str){
    for(int i = 0;i < str.size();i++){
		if ('a' <= str[i] && str[i] <= 'z')
    	{
    		str[i] = (str[i] - 'a' + 'A');
    	}
    }
    return str;
}

int main(){
	string W,S,T = "";
	int j = 0;
    int b = 0;
    int i = 0;
	cin >> W;
	getline(cin,T);
	do{
		S += T;
		getline(cin,T);
		T += " ";
	}while(T != "END_OF_TEXT ");
	T = "";
	S = upper(S);
	W = upper(W);
	while(i < S.size()){
			while(S[i] != ' '){
				T += S[i];
				i++;
			}
			if(T == W){
				b++;
			}
			T = "";
			i++;
		}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 1204
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    string s;
    cin>>s;

    int cur=0;
    int n=sz(s);
    for(int i=0;i<n;++i)
        cur=(cur*10+(s[i]-'0'))%9;

    if(!cur)
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  string s;
  vector<int> v;
  int cnt = 0;
  cin >> s;
  for (int i = s.size()-1; i >= 0; i--) {
    if (s[i] == 'B')
      cnt++;
    else if (s[i] != 'B' && cnt <= 0)
      v.pb(i);
    else
      cnt--;
  }
  for (int i = v.size()-1; i >= 0; i--)
    cout << s[v[i]];
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int N;
int u, v;
vector<vector<int>> G;
vector<int> par;
vector<int> depth;

void dfs(int cur, int prv, int d){
    par[cur] = prv;
    depth[cur] = d;
    for(int nxt : G[cur]){
        if(nxt == prv) continue;
        dfs(nxt, cur, d+1);
    }
}

int main(){
    cin >> N >> u >> v;
    G.resize(N);
    par.resize(N);
    depth.resize(N);
    u--; v--;
    REP(i, N-1){
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dfs(v, -1, 0);
    int up = (depth[u]-1)/2;
    REP(i, up){
        u = par[u];
    }
    int d = depth[u];
    fill(depth.begin(), depth.end(), 0);
    dfs(u, par[u], 0);
    int maxd = *max_element(depth.begin(), depth.end());
    cout << maxd+d-1 << endl;
    return 0;
}


Measured memory_bytes: 10368
N = int(input())
line1 = list(map(int, input().split()))
a,max = 0,0
for i in range(len(line1) - 1):
    if line1[i] >= line1[i+1]:
        a += 1
        if max < a:
            max = a
            
    else:
        a = 0
        
print(max)
 


Measured memory_bytes: 14252
a=int(input())
b=int(input())
c=int(input())
x=int(input())
n=0
bcount=0

while x>=0 and a>=0:
  while x>=0 and b>=0:
    if x//50<=c:
      n+=1
    b-=1
    bcount+=1
    x-=100
  x+=100*bcount
  b+=bcount
  bcount=0
  a-=1
  x-=500  
print(n)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    ll n; cin >> n;
    if (n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    ll m = n / 2;
    ll ans=0;
    ll div=5;
    while(1){
        if(div>m)break;
        ans += m/div;
        div*=5;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    if(N%2==0){
        n=N/2;
        if (N!=4) cout<< 4*n <<endl;
        else cout << 4<<endl;
        for(int i=1;i<n+1;i++){
            int j;
            if (i==n) j=1;
            else j=i+1;
            cout <<i<<" "<<j<<endl;
            cout <<i<<" "<<N+1-j<<endl;
            cout <<N+1-i<<" "<<j<<endl;
            cout <<N+1-i<<" "<<N+1-j<<endl;
            if(N==4) return 0;
        }
    } else
    {
        n=(N+1)/2;
        if(N!=3) cout << 4*(n-1)<<endl;
        else cout <<2<<endl;
        for(int i=1;i<n-1;i++){
            int j;
            if (i==n) j=1;
            else j=i+1;
            cout <<i<<" "<<j<<endl;
            cout <<i<<" "<<N-j<<endl;
            cout <<N-i<<" "<<j<<endl;
            cout <<N-i<<" "<<N-j<<endl;
        }
        cout << n-1<<" "<<N<<endl;
        cout <<N-(n-1)<<" "<<N<<endl;
        if(N==3) return 0;
        cout <<1<<" "<<N<<endl;
        cout << N-1<<" "<<N<<endl;
    }
    return 0;
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
 
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(c,l,r) for(int c=(l);c<=(r);c++)
 
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
 
using ll = long long;
//#define int ll
 
const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int  dx[]  = {-1,   0,   1,   0,  1, -1, -1,  1};
const int  dy[]  = { 0,   1,   0,  -1,  1, -1,  1, -1};
const char dt[] = {'U', 'R', 'D', 'L'};

void solve() {	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == 12 and c == 5) {
		cout << "YES";	
	} else if (a + c == 12 and b == 5) {
		cout << "YES";
	} else if (b + c == 12 and a == 5) {
		cout << "YES";
	} else {
		cout << "NO";
	}
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
   	//cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}



Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
using namespace std;
char a[10005]; 
char b[30]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int n;
int main(){
cin>>n;
cin>>a;
for(int i=0;a[i]>='A'&&a[i]<='Z';i++){
cout<<b[(a[i]-'A'+n)%26];
}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const double eps = 1e-10;
const int MAX_N = 50;
const double g = 9.8;

int N, V, X, Y;
int L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

double position(double vy, double t) {
	return vy*t-g*t*t/2.0;
}

int cmp(double lb, double ub, double a) {
	return a < lb + eps?-1:a>ub-eps?1:0;
}

// 射出路径经过(qx,qy)时，能否击中猪
bool check(double qx, double qy) {
	double a = g*g/4.0, b=g*qy-V*V, c=qx*qx+qy*qy;
	double D = b*b-4*a*c;
	if (D < 0 && D > -eps) D = 0;
	if (D < 0) return false;
	for (int d = -1; d <= 1; d += 2) { // 验证解的循环
		double t2 = (-b + d*sqrt(D))/(2*a);
		if (t2 <= 0) continue;
		double t = sqrt(t2);
		double vx = qx/t, vy=(qy+g*t*t/2.0)/t;
		// 是否通过猪的正上方？
		double yt = position(vy, X/vx);
		if (yt < Y-eps) continue;

		bool ok = true;
		for (int i = 0; i < N; ++i) {
			if (L[i] >= X) continue;
			if (R[i] == X &&  Y <= T[i] && B[i] <= yt) ok = false;
			int yL = cmp(B[i], T[i], position(vy, L[i]/vx)); // 左侧相对位置
			int yR = cmp(B[i], T[i], position(vy, R[i]/vx)); // 右侧相对位置
			int xH = cmp(L[i], R[i], vx*(vy/g)); // 最高点相对位置
			int yH = cmp(B[i], T[i], position(vy, vy/g));
			if (xH == 0 && yH >= 0 && yL < 0) ok = false;
			if (yL * yR <= 0) ok = false;
		}
		if (ok) return true;
	}
	return false;
}

int main() {
	scanf("%d%d%d%d", &N, &V, &X, &Y);
	for (int i = 0; i < N; ++i) {
		scanf("%d%d%d%d", L+i, B+i, R+i, T+i);
	}
	for (int i = 0; i < N; ++i) {
		R[i] = min(R[i], X);
	}
	bool ok = check(X, Y);
	for (int i = 0; i < N; ++i) {
		ok |= check(L[i], T[i]);
		ok |= check(R[i], T[i]);
	}
	puts(ok?"Yes":"No");
	return 0;
}


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

int main() {
	int	a,b,c,d;
  	cin >> a >> b >> c >> d;
  	int times = 2 * max(a/d, b/c);
  	int answer = 0;
  	for (int i=0;i<times;i++) {
    	c -= b;
      	if (c <= 0) {
        	answer = 1;
          	break;
        }
      	a -= d;
      	if (a <= 0) {
          answer = 0;
          break;
        }

    }
  if (answer == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3640
using CompLib.Util;
using System;
using System.Linq;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();

        int[,] a = new int[3, 3];
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                a[i, j] = sc.NextInt();
            }
        }

        int n = sc.NextInt();
        var f = new bool[3, 3];
        for (int i = 0; i < n; i++)
        {
            int b = sc.NextInt();
            for (int j = 0; j < 3; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    if (a[j, k] == b)
                    {
                        f[j, k] = true;
                    }
                }
            }
        }
        bool ans = false;
        for (int i = 0; i < 3; i++)
        {
            ans |= f[i, 0] && f[i, 1] && f[i, 2];
            ans |= f[0, i] && f[1, i] && f[2, i];
        }

        ans |= f[0, 0] && f[1, 1] && f[2, 2];
        ans |= f[0, 2] && f[1, 1] && f[2, 0];

        Console.WriteLine(ans ? "Yes" : "No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

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

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        if (t == 0)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    mint inv() const
    {
        return pow(p - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

struct comb
{
    vector<mint> fact, invs;
    comb(int n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<int> c(n);
    rep(i, n) cin >> c[i];
    sort(c.begin(), c.end());

    vector<mint> pow2(n + 1);
    pow2[0] = 1;
    rep(i, n)
    {
        pow2[i + 1] = pow2[i] * 2;
    }

    mint ans = 0;
    rep(i, n)
    {
        int r = n - 1 - i;
        mint now = pow2[r] + pow2[r - 1] * r;
        now *= pow2[i];
        now *= c[i];
        ans += now;
    }
    ans *= pow2[n];

    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
struct node {
	int x, y;
}q[1000005];
queue<int> Q;
int n, tt, as, f[1000005];
char S[1000005], T[1000005];
int main() {
	scanf("%d", &n);
	scanf("%s", S + 1);
	scanf("%s", T + 1);
	rep(i, 1, n) {
		if(S[i] != T[i]) break;
		if(i == n) {puts("0"); return 0;}
	}
	int p = n;
	per(i, n, 1) {
		if(T[i] == T[i + 1] && i >= p) continue;
		while(i < p || (p > 1 && S[p] != T[i])) --p;
//		if(T[i] == T[i + 1] && i >= p) continue;
		if(S[p] != T[i]) {puts("-1"); return 0;}
		q[++tt] = (node) {p, i};
	}
	int S = 0;
	q[tt + 1].y = 0;
	rep(i, 1, tt) {
//		Q.push(q[i - 1].x - S);
		S--;
		while(Q.size() && Q.front() + S >= q[i + 1].y + 1) Q.pop();
		Q.push(q[i].x - S);
		while(Q.size() && Q.front() + S >= q[i + 1].y + 1) Q.pop();
		as = max(as, (int) Q.size());
	}
	
	cout << as + 1 << endl;
	return 0;


}


Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;
int P[10010]; // 0 から10000 までの頂点を取り扱い可能
 void init(int N) { // 初期化はじめは全ての頂点はバラバラ
	
	 for (int i = 0; i < N; ++i) P[i] = i;
	
}
 int root(int a) { // a のroot(代表元) を求める
	if (P[a] == a) return a; // a はroot
	 return (P[a] = root(P[a])); // a の親のroot を求め，a の親とする
	
}
 bool is_same_set(int a, int b) { // a とb が同じグループに属するか?
	 return root(a) == root(b);
	
}
 void unite(int a, int b) { // a とb を同一グループにまとめる
	 P[root(a)] = root(b);
	
}
 int main() 
 {
	 int n, q;
	 cin >> n >> q;
	 init(n);
	 for (int j = 0; j < q; j++)
	 {
		 int com, x, y;
		 cin >> com >> x >> y;
		 if (com == 0) unite(x, y);
		 else
		 {
			 cout << is_same_set(x, y) << endl;
		 }
			 
	 }
	 
		 return 0;
	 
 }


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<ll> a(n);
    read(a);
    V<ll> dp(n + 1, -INF);
    dp[0] = 1000;
    for (int i = 2; i <= n; i++) {
        ll mi = INF;
        for (int j = 0; j + 1 < i; j++) {
            if (dp[j] == -INF) continue;
            for (int k = j; k + 1 < i; k++) {
                chmax(dp[i], dp[j] % a[k] + a[i - 1] * ll(dp[j] / a[k]));
            }
        }
    }
    cout << *max_element(all(dp)) << newl;
}

Measured memory_bytes: 3616
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
  n,k = ints()
  print(1+int(math.log(n,k)))

      
if __name__ == '__main__':
  main()

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

int main(){
    int tate,yoko,k;
    cin >> tate >> yoko >> k;
    vector<vector<char>> table(tate,vector<char>(yoko));
    rep(i,tate){
        rep(j,yoko){
            cin >> table.at(i).at(j);
        }
    }
    int ans = 0;
    rep(i,1 << tate){
        bitset<6> V(i);
        rep(j,1 << yoko){
            bitset<6> H(j);
            int count = 0;
            rep(a,tate){
                rep(b,yoko){
                    if(V.test(a) && H.test(b)){
                        if(table.at(a).at(b) == '#') count++;
                    }
                }
            }
            if(count == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	int X, A, B;
	scanf("%d %d %d", &X, &A, &B);
	if(-(A-B)>X)
	printf("dangerous");
    else if(A-B>=0)
		 printf("delicious");
	else  
	     printf("safe");
		
		
	
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.regex.Pattern;
public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0) break;
			int [] mass = new int[n + 10];
			for(int i = 1; i <= n; i++){
				mass[i] = sc.nextInt();
			}
			int [] sai = new int[m];
			for(int i = 0;i < m; i++){
				sai[i] = sc.nextInt();
			}
			int now = 1;
			for(int i = 0; i < m; i++){
				now += sai[i];
				now += mass[now];
				if(now >= n){
					System.out.println(i + 1);
					break;
				}
				
			}
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
import java.util.*;

class Main{
  static int a,b,i,ans;
  static String op;
    
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    while (op != "?") {
    a = sc.nextInt();
    op = sc.next();
    b = sc.nextInt();
    if (op.equals("?")) {
      break;
    } else if (op.equals("+")) {
        ans = a + b;
        System.out.println(ans);
    } else if (op.equals("-")) {
        ans = a - b;
        System.out.println(ans);
    } else if (op.equals("*")) {
        ans = a * b;
        System.out.println(ans);
    } else if (op.equals("/")) {
        ans = a / b;
        System.out.println(ans);
    } else {
        break;
    }
  }
}
}



Measured memory_bytes: 26268
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

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

const int MAXT = 51, MAXP = 11;
int t, p ,r;

struct team
{
    int ac , pena , tid ;
    team(int ac, int pena, int tid):ac(ac), pena(pena), tid(tid){};
};

bool operator<(const team& t1,const team& t2)
{
    return (t1.ac > t2.ac || (t1.ac == t2.ac && t1.pena < t2.pena ) || (t1.ac == t2.ac && t1.pena == t2.pena && t1.tid < t2.tid));
};

int main()
{
    while(cin >> t >> p >> r && t)
    {
        vector<team> teams;
        rep(i,t) teams.push_back(team(0,0,i));

        int wa[MAXT][MAXP] = {};
        int tid, pid, time1;
        string s;
        
        REP(r)
        {
            cin >> tid >> pid >> time1 >> s;
            tid --; 
            if(s == "WRONG") wa[tid][pid]++;
            else {teams[tid].ac++; teams[tid].pena += wa[tid][pid] * 1200 + time1;}
        }

        sort(teams.begin(), teams.end() );
        REP(teams.size()) cout << teams[i].tid +1 << " "<< teams[i].ac << " " << teams[i].pena << endl;

    }
    return 0;
}

Measured memory_bytes: 928
factor | awk '{\
    N=split($0,A);
    for(i=2;i<=N;i++)D[A[i]]++;
    ans = 0
    for(i in D){
        k = 1
        while(1){
            D[i]-=k++
            if(D[i]<0)break;
            else ans++;
        }
    }
    print ans
}'


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

typedef long long ll;

using namespace std;

int main() {
    int n, q;
    cin >> n;
    vector<ll> S(n);
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    cin >> q;
    int count = 0;
    for (int j = 0; j < q; j++) {
        int t;
        cin >> t;
        int low = 0;
        int high = n - 1;
        while (low <= high) {
            int mid = (low + high) / 2;
            if (t == S[mid]) {
                count++;
                break;
            }
            if (t < S[mid]) {
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
    }
    cout << count << endl;
    return 0;
}




Measured memory_bytes: 3460