akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;


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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        System.out.println(a/b);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  int k;
  cin>>k;
  int c=0;
  for(int i=0;i<k;i++){
    int x;
    cin>>x;
    c|=1<<x;
  }
  for(int b=c;;b=(b-1)&c){
    int nb=c^b;
    cout<<nb<<":";
    for(int i=0;i<n;i++)
      if((nb>>i)&1) cout<<" "<<i;
    cout<<"\n";
    if(b==0) break;
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	cout << "ABC" << s << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
 
using namespace std;
 
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
 
namespace pb_ds {   
    namespace io {
        const int MaxBuff = 1 << 15;
        const int Output = 1 << 23;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush() {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }
 
    template<class Type = int> inline Type read() {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }
 }
 
using namespace pb_ds;
 
void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}
 
const int N = 5e5 + 1e3;
 
int n, d[N], pre[N], f[N];
 
int main () {
 
	n = read(); pre[0] = read(); f[n + 1] = 1;
 
	For (i, 1, n) 
		pre[i] = min(pre[i - 1], abs(pre[i - 1] - (d[i] = read())));
	Fordown (i, n, 1) 
		f[i] = f[i + 1] + ((f[i + 1] << 1) > d[i] ? d[i] : 0);
 
	using namespace io;
	For (i, 1, read()) {
		int x = read();
		if(pre[x - 1] >= f[x + 1]) *iter++ = 'Y', *iter++ = 'E', *iter++ = 'S';
		else *iter++ = 'N', *iter++ = 'O'; *iter++ = '\n';
	}
	flush();
 
	return 0;
 
}

Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;

const int INF = (1 << 29);
typedef pair<string ,int> psi;

int main(void) {

  int N, M; cin >> N >> M;
  string b = "";
  for (int i = 0; i < N; i++) {
    int t; cin >> t;
    b += t+'0';
  }
  string t1 = "", t2 = "";
  for (int i = 0; i < M; i++) {
    int p; cin >> p;
    for (int j = 0; j < p; j++) {
      if (i%2) {
        t1 += '0';
        t2 += '1';
      } else {
        t1 += '1';
        t2 += '0';
      }
    }
  }

  int ans1 = INF;
  if (count(t1.begin(), t1.end(), '0') == count(b.begin(), b.end(), '0')) {
    queue<psi> q1;
    set<string> used;
    q1.push(psi(t1,0));
    used.insert(t1);
    while (!q1.empty()) {
      psi s = q1.front(); q1.pop();
      if (s.first == b) {
        ans1 = s.second;
        break;
      }

      for (int i = 0; i < N-1; i++) {
        string tmp = s.first;
        swap(tmp[i], tmp[i+1]);
        if (used.find(tmp) == used.end()) {
          q1.push(psi(tmp, s.second+1));
          used.insert(tmp);
        }
      }
    }
  }

  int ans2 = INF;
  if (count(t2.begin(), t2.end(), '0') == count(b.begin(), b.end(), '0')) {
    queue<psi> q2;
    set<string> used;
    q2.push(psi(t2, 0));
    used.insert(t2);
    while (!q2.empty()) {
      psi s = q2.front(); q2.pop();
      if (s.first == b) {
        ans2 = s.second;
        break;
      }

      for (int i = 0; i < N-1; i++) {
        string tmp = s.first;
        swap(tmp[i], tmp[i+1]);
        if (used.find(tmp) == used.end()) {
          q2.push(psi(tmp, s.second+1));
          used.insert(tmp);
        }
      }
    }
  }

  cout << min(ans1, ans2) << endl;

  return 0;
}

Measured memory_bytes: 1844
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	string s;
    cin >> s;
    int n = s.size();
    int ans = n;
    for(int i = 0; i < n-1; i++){
        if(s[i] != s[i+1]){
            int t = max(i+1, n-i-1);
            if(t < ans) ans = t;
        }
    }
    cout << ans << endl;
}

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

int main(){
	int r ,d,x;
	cin >> r >> d >> x;
	
	for (size_t i = 0; i < 10; i++)
	{
		x = r*x - d;
		cout << x << endl;
	}
	

}

Measured memory_bytes: 256
//disco2019_c.cpp
//Sat Nov 23 20:40:31 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w,k;
	cin >> h >> w >> k;

	string s[h];
	for (int i=0;i<h;i++){
		cin >> s[i];
	}

	int berry[h];
	fill(berry,berry+h,0);

	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			if (s[i][j]=='#'){
				berry[i]++;
			}
		}
	}

	int ans[h][w];
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			ans[i][j] = 0;
		}
	}

	int prev = -1;
	int accum = 0;
	int piece = 0;
	for (int i=0;i<h;i++){
		if (berry[i] == 0){
			if (prev == -1){
				accum++;
				continue;
			}else {
				for (int j=0;j<w;j++){
					ans[i][j] = ans[prev][j];
//					cout << ans[prev][j] << " ";
				}
				continue;
			}
		}
		piece++;
		for (int j=0;j<w;j++){
			prev = i;
			ans[i][j] = piece;
//			cout << piece << " ";
			if (s[i][j]=='#'){
				berry[i]--;
				if (berry[i]>0){
					piece++;
				}
			}
		}
		while (accum){
			for (int j=0;j<w;j++){
				ans[i-accum][j] = ans[i][j];
			}
			accum--;
		}
	}

	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cout << ans[i][j] << " ";
		}
		printf("\n");
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<UL> X(N); rep(i, N) cin >> X[i];
		UL ans = 100000000;
		rep(i, 100) {
			UL ansbuf = 0;
			rep(j, N) {
				UL d = max(X[j], i) - min(X[j], i);
				ansbuf += d * d;
			}
			ans = min(ans, ansbuf);
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        ArrayList<Integer> rlist = new ArrayList<Integer>();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int checksum = 0;
        for(int i = 0 ; i < n ;  i++){
            int a = sc.nextInt();
            checksum += a;
            if(checksum > k){}
            else rlist.add(a);
        }
        for(int i = rlist.size()-1 ; i >= 0 ;  i--){
            list.add(rlist.get(i));
        }
        checksum = 0;
        for(int i = 0 ; i < m ; i++){
            int b = sc.nextInt();
            checksum += b;
            if(checksum > k){}
            else list.add(b);
        }
        
        Monmo momo = new Monmo(k,list);
        for(int i = 0 ; i < list.size() ; i++){
            momo.sum(i);
            momo.check();
            momo.cmax();
        }
        momo.check();
        momo.cmax();
        momo.getc();
    }
}

class Monmo {
    ArrayList<Integer> mlist = new ArrayList<Integer>();
    int k;
    int sum;
    int c;
    int mx_c;
    int left;
    
    Monmo(int k,ArrayList<Integer> list){
        mlist = list;
        this.k = k;
        sum = 0;
        c = 0;
        mx_c = 0;
        left = 0;
    }
    
    void check(){
        if(k < sum){
            sum -= mlist.get(left++);
            c--;
        }
    }
    
    void sum(int n){
        sum += mlist.get(n);
        c++;
    }
    
    void cmax(){
        if(mx_c < c)mx_c=c;
    }
    
    void getc(){
        System.out.println(mx_c);
    }
}



Measured memory_bytes: 72072
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk,n,k,e;
  vector<int> a;
  bitset<32> m;
  bitset<32> t;
  bitset<32> tmp;
  int b[32];
  cin >> n;

  cin >> k;

  memset(b,0,sizeof(b));

  for(ii=0;ii<k;ii++){
    cin >> e;
    t.set(e);
    b[ii] = e;
  }
  
  int cnt;
  for(ii=0;ii<pow(2,k);ii++){
    cnt = 0;
    tmp = ii;

    for(jj=0;jj<k;jj++){
      if(tmp.test(jj)){
        //cout << "b[]" << jj << endl;
        cnt += pow(2,b[jj]);
      }
    }
    cout << cnt << ":" ;

    for(jj=0;jj<k;jj++){
      if(tmp.test(jj)){
        cout << " " << b[jj] ;
      }
    }

    cout << endl;
  }
  //for(ii=0;ii<pow(2,n);ii++){
  //  m = ii;
  //
  //  tmp = ~m  | t;
  //
  //  //cout << tmp << endl;
  //                        
  //  //cout << "ii:" << ii << endl;
  //  //cout << m << endl;
  //  //cout << t << endl;
  //  if(tmp.all()){
  //    cout << ii << ":";
  //
  //    for(jj=0;jj<n;jj++){
  //      if(m.test(jj)){
  //        cout << " " << jj;
  //      }
  //    }
  //  
  //    cout << endl;
  //  }
  //  
  //}

  
  return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define M 1000000007

using namespace std;

ll go(ll h[],ll l,ll r,ll dp[])
{
    if(l==r)
    return 0;
    else if(dp[l]!=-1)
    return dp[l];
    else
    {
        ll ans=INT_MAX;
        for(ll i=l+1;i<=l+2&&i<=r;++i)
        {
            ans=min(ans,abs(h[l]-h[i])+go(h,i,r,dp));
        }
        dp[l]=ans;
        return ans;
    }
}
int main() 
{
	IOS	
	ll n;
	cin>>n;
	ll h[n];
	ll dp[n];
	memset(dp,-1,sizeof dp);
	for(ll i=0;i<n;++i)cin>>h[i];
	cout<<go(h,0,n-1,dp);
}

Measured memory_bytes: 11264
from bisect import bisect_right
N = int(input())
S = input().strip()
R = []
G = []
B = []
Ron = [0 for _ in range(len(S))]
Gon = [0 for _ in range(len(S))]
Bon = [0 for _ in range(len(S))]
for i in range(N):
    if S[i]=="R":
        R.append(i)
        Ron[i]=1
    elif S[i]=="G":
        G.append(i)
        Gon[i]=1
    else:
        B.append(i)
        Bon[i]=1
cnt = 0
for i in range(N):
    if Ron[i]==1:
        #RGB
        indr = i
        ind0 = bisect_right(G,indr)
        for j in range(ind0,len(G)):
            indg = G[j]
            if len(B)>0:
                ind1 = bisect_right(B,indg)
                if 2*indg-indr>B[-1] or Bon[2*indg-indr]==0 or Bon[2*indg-indr]==1 and 2*indg-indr<B[ind1]:
                    cnt += len(B)-ind1
                else:
                    cnt += len(B)-ind1-1
        #RBG
        ind0 = bisect_right(B,indr)
        for j in range(ind0,len(B)):
            indb = B[j]
            if len(G)>0:
                ind1 = bisect_right(G,indb)
                if 2*indb-indr>G[-1] or Gon[2*indb-indr]==0 or Gon[2*indb-indr]==1 and 2*indb-indr<G[ind1]:
                    cnt += len(G)-ind1
                else:
                    cnt += len(G)-ind1-1
    elif Gon[i]==1:
        #GBR
        indg = i
        ind0 = bisect_right(B,indg)
        for j in range(ind0,len(B)):
            indb = B[j]
            if len(R)>0:
                ind1 = bisect_right(R,indb)
                if 2*indb-indg>R[-1] or Ron[2*indb-indg]==0 or Ron[2*indb-indg]==1 and 2*indb-indg<R[ind1]:
                    cnt += len(R)-ind1
                else:
                    cnt += len(R)-ind1-1
        #GRB
        ind0 = bisect_right(R,indg)
        for j in range(ind0,len(R)):
            indr = R[j]
            if len(B)>0:
                ind1 = bisect_right(B,indr)
                if 2*indr-indg>B[-1] or Bon[2*indr-indg]==0 or Bon[2*indr-indg]==1 and 2*indr-indg<B[ind1]:
                    cnt += len(B)-ind1
                else:
                    cnt += len(B)-ind1-1
    elif Bon[i]==1:
        #BRG
        indb = i
        ind0 = bisect_right(R,indb)
        for j in range(ind0,len(R)):
            indr = R[j]
            if len(G)>0:
                ind1 = bisect_right(G,indr)
                if 2*indr-indb>G[-1] or Gon[2*indr-indb]==0 or Gon[2*indr-indb]==1 and 2*indr-indb<G[ind1]:
                    cnt += len(G)-ind1
                else:
                    cnt += len(G)-ind1-1
        #BGR
        ind0 = bisect_right(G,indb)
        for j in range(ind0,len(G)):
            indg = G[j]
            if len(R)>0:
                ind1 = bisect_right(R,indg)
                if 2*indg-indb>R[-1] or Ron[2*indg-indb]==0 or Ron[2*indg-indb]==1 and 2*indg-indb<R[ind1]:
                    cnt += len(R)-ind1
                else:
                    cnt += len(R)-ind1-1
print(cnt)

Measured memory_bytes: 78600
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 int main(){
   int n;
   double sum=0;
   cin >> n;
   vector<double>x(n);
   vector<string>u(n);
   for(int i=0; i<n; i++){
     cin >> x.at(i) >> u.at(i);
     if(u.at(i)=="JPY"){
       sum+=x.at(i);
     }
     else{
       sum+=x.at(i)*380000.0;
     }
   }
   cout << sum << endl;

 }


Measured memory_bytes: 256
from collections import deque

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)[:x]

Q = sorted(Q, reverse=True)[:y]

P.extend(Q)
R.extend(P)

T = sorted(R, reverse=True)[:x+y]
print(sum(T))

Measured memory_bytes: 23616
#include <iostream>
using namespace std;
int main(void){
    int n; //お菓子の数
    int s[1010]; //お菓子の番号
    int p[1010], q[1010], r[1010]; 
    //左から順番に各お菓子のたんぱく質の重量、脂質の重量、炭水化物の重量
    int P, Q, R;
    //摂取できる各栄養素重量の最大値。
    //左から順番にたんぱく質の重量、脂質の重量、炭水化物の重量
    int C;
    //摂取できるカロリーの最大値

    while(true){
        cin >> n;
        if(n == 0) break;
        
        for(int i = 0; i < n; i++){
            cin >> s[i];
            cin >> p[i] >> q[i] >> r[i];
        }
        cin >> P >> Q >> R >> C;

        int kcal[1010] = {0}; //お菓子のカロリー
        for(int i = 0; i < n; i++)
            kcal[i] = 4 * p[i] + 9 * q[i] + 4 * r[i];
        
        int count = 0; //食べてはいけないお菓子の個数
        for(int i = 0; i < n; i++){
            if(p[i] <= P && q[i] <= Q && r[i] <= R && kcal[i] <= C)
                cout << s[i] << endl;
            else 
                count++;
        }
        if(count == n) cout << "NA" << endl;
    }
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vvi s(n, vi(26, 0));
  rep(i, n){
    string str;
    cin >> str;
    rep(j, (int)(str.length())){
      s[i][(int)str[j]-(int)'a']++;
    }
  }
  rep(i, 26){
    int min_count = 100;
    rep(j, n){
      min_count = min(s[j][i], min_count);
    }
    rep(k, min_count) cout << (char)((int)'a'+i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int M[100][100];
  int n,u,v,k,i,j;



  scanf("%d",&n);


  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)   M[i][j]=0;
  }



  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
    scanf("%d",&v);
    v--;
    M[u][v]=1;
  }
}
for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    if(j>0) printf(" ");
    printf("%d",M[i][j]);
  }
  printf("\n");
 }
return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

ll gcd(ll x, ll y){
  return x ? gcd(y%x,x) : y;
}

ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
int main(){
  int n,i;
  cin >> n;
  ll ret=1,t;
  for(i=0;i<n;i++){
    cin >> t;
    ret = lcm(ret,t);
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n; cin >> n;
    string a, b; cin >> a >> b;
    for(ll i = 0; i < n; ++i){
        cout << a[i] << b[i];
    }
    cout << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()

lst = list()
i = 0
while i < N:
    num = A[i]
    cnt = 1
    while i < (N - 1) and A[i] == A[i+1]:
        cnt += 1
        i += 1
    i += 1
    lst.append((num, cnt))
ans = 0
for x in lst:
    if x[0] > x[1]:
        ans += x[1]
    elif x[0] < x[1]:
        ans += x[1] - x[0]
print(ans)

Measured memory_bytes: 65448
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll x,k,l,d,ans;
  cin>>x>>k>>d;
  x=abs(x);
  l=x/d;
  if(l>k){
    ans=x-k*d;
  }else{
    if((k-l)%2==0){
      ans=x-l*d;
    }else{
      ans=abs(x-(l+1)*d);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
#define N 300005
struct node{ll x,y;};
int fa[N],dep[N],son[N][2],n,va[N];
vector<node>v[N];
bool cmp(node n1,node n2){return n1.x<n2.x;}
void dfs(int te,ll X)
{
	if(!son[te][0]){node nd;nd.x=nd.y=0;v[te].push_back(nd);return;}
	int z1=0,z2=0,ls=son[te][0],rs=son[te][1];
	dfs(ls,X);dfs(rs,X);
	while(z1<v[ls].size()&&z2<v[rs].size())
	{
		if(v[ls][z1].y+v[rs][z2].x+va[ls]+va[rs]<=X)
		{
			node nd;nd.x=v[ls][z1].x+va[ls];nd.y=v[rs][z2].y+va[rs];
			v[te].push_back(nd);z2++;
		}
		else z1++;
	}
	swap(ls,rs);z1=z2=0;
	while(z1<v[ls].size()&&z2<v[rs].size())
	{
		if(v[ls][z1].y+v[rs][z2].x+va[ls]+va[rs]<=X)
		{
			node nd;nd.x=v[ls][z1].x+va[ls];nd.y=v[rs][z2].y+va[rs];
			v[te].push_back(nd);z2++;
		}
		else z1++;
	}
	sort(v[te].begin(),v[te].end(),cmp);
	for(int i=0;i<v[te].size();i++)
	{
		int j=i+1;while(j<v[te].size()&&v[te][i].y<=v[te][j].y)v[te][j].x=1e18,j++;
		j=i;
	}
	sort(v[te].begin(),v[te].end(),cmp);
	while(!v[te].empty()&&v[te][(int)v[te].size()-1].x==1e18)v[te].pop_back();
}
bool che(ll x)
{
	for(int i=1;i<=n;i++)v[i].clear();
	dfs(1,x);return v[1].size()>0;
}
int main()
{
	scanf("%d",&n);
	ll l=0,r=0,mid,ans;
	for(int i=2;i<=n;i++)
	{
		scanf("%d%d",&fa[i],&va[i]);
		if(!son[fa[i]][0])son[fa[i]][0]=i;
		else son[fa[i]][1]=i;r+=va[i];
	}
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(che(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 38912
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int N;
double bt=0,jp=0,x;
string u;
int main(){
    cin>>N;
    rep(i,N){
        cin>>x>>u;
        if(u=="JPY"){
            jp+=x;
        }
        else{
            bt+=x;
        }
    }
    out(jp+bt*380000);
}


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

int main(int argc, char const *argv[])
{
  int r, c;
  cin >> r >> c;
  vector< vector<int> > matrix(r+1, vector<int>(c+1));

  for(int i = 0; i < r; i++)
  {
    for(int j = 0; j < c; j++)
      cin >> matrix[i][j];
  }

  for(int i = 0; i < r; i++)
  {
    int row = 0;
    for(int j = 0; j < c; j++)
    {
      row += matrix[i][j];
    }
    matrix[i][c] = row;
  }

  for(int j = 0; j < c+1; j++)
  {
    int column = 0;
    for(int i = 0; i < r; i++)
    {
      column += matrix[i][j];
    }
    matrix[r][j] = column;
  }

  for(int i = 0; i < r+1; i++)
  {
    for(int j = 0; j < c+1; j++)
    {
      if(j != 0)
      {
        cout << " " << flush;
      }
      cout << matrix[i][j] << flush;
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
  int a,b,c;
    
    cin >> a;
    cin >> b;
    if(a==1)
    {
      if(b==2)
      {
        c=3;
      }
      else
      {
        c=2;
      }
    }
  if(a==2)
    {
      if(b==1)
      {
        c=3;
      }
      else
      {
        c=1;
      }
    }
  
  if(a==3)
    {
      if(b==2)
      {
        c=1;
      }
      else
      {
        c=2;
      }
    
    }
  
  cout << c;
  
  return 0;
}
  

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , du[N] , ans;
vi g[N];

int dfs(int c,int fa=0) {
  int a = 0 , b = 0;
  for(auto t : g[c]) if(t != fa) {
    int gt = dfs(t , c);
    if(gt > a) swap(a , b) , a = gt;
    else if(gt > b) b = gt;
  }
  if(du[c] == 2) ans = max(ans , ++a);
  else ans = max(ans , a + b);
  return a;
}

int main(){
  scanf("%d",&n);
  rep(i,1,n) {
    int u,v;
    scanf("%d%d",&u,&v);
    g[u].pb(v);
    g[v].pb(u);
    du[u]++;
    du[v]++;
  }
  int t = max_element(du + 1 , du + 1 + n) - du;
  if(du[t] <= 2) return printf("%d\n",n) , 0;
  dfs(t);
  rep(i,1,n+1) ans += du[i] == 1;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 6272
import Data.List (sort)
import Control.Applicative ((<$>))

main :: IO ()
main = do
  queries <- map (map read . words) . lines <$> getContents
  putStrLn $ solve queries
  
solve :: [[Int]] -> String
solve = go 0 0 0 0
  where
    go n x y z (q:qs)
      | (b - a) ^ 2 < c ^ 2 && c ^ 2 < a ^ 2 + b ^ 2
        = go (n + 1) (x + 1) y z qs
      | c ^ 2 == a ^ 2 + b ^ 2
        = go (n + 1) x (y + 1) z qs
      | a ^ 2 + b ^ 2 < c ^ 2 && c ^ 2 < (a + b) ^ 2
        = go (n + 1) x y (z + 1) qs
      | otherwise
        = unwords $ map show [n, y, x, z]
      where
        [a, b, c] = sort q


Measured memory_bytes: 4216
n, m = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
x.sort()

def play(n, m, x):
    if n >= m:
        return 0

    a = []
    for i in range(len(x) - 1):
        a.append(x[i+1] - x[i])

    # 右から左に動くように統一することで、うまく計算できるか
    # x = [1, 2, 10, 12, 14, 15]
    # a = [1, 8, 2, 2, 1]
    b = []
    for i, j in enumerate(a):
        b.append((j, i))
    b.sort(reverse=True)

    index = []
    for i in range(n):
        if i == 0:
            index.append(len(x) - 1)
        else:
            index.append(b[i-1][1])

    index.sort()
    move = []
    for i in range(len(index)):
        if i == 0 and index[i] == 0:
            move.append(0)
        elif i == 0:
            move.append(x[index[i]] - x[0])
        else:
            move.append(x[index[i]] - x[index[i-1] + 1])

    #debug
    #print('x =', x)
    #print('a =', a)
    #print('index =', index)
    #print('move =', move)
    return sum(move)

print(play(n, m, x))


Measured memory_bytes: 19320
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1){
		if(b==1){
			cout<<"Draw"<<endl;
			return 0;
		}
		cout<<"Alice"<<endl;
	}
	else if(b==1){
		cout<<"Bob"<<endl;
	}
	else if(a<b){
		cout<<"Bob"<<endl;
	}
	else if(b<a){
		cout<<"Alice"<<endl;
	}
	else cout<<"Draw"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000

typedef long long ll;
int weightsNumber, truckNumber;
ll weights[MAX];

int Check(ll P) {
	int i = 0;
	for (int j = 0; j < truckNumber; j++) {
		ll s = 0;
		while (s + weights[i] <= P) {
			s += weights[i];
			i++;
			if (i == weightsNumber) return weightsNumber;
		}

	}
	return i;
}

int Solve() {
	ll left = 0;
	ll right = MAX * MAX;
	ll mid;
	
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = Check(mid);
		if (v >= weightsNumber) {
			right = mid;
		}
		else {
			left = mid;
		}
	}

	return right;
}

int main() {

	scanf("%d %d", &weightsNumber, &truckNumber);

	for (int i = 0; i < weightsNumber; i++) {
		scanf("%d", &weights[i]);
	}

	ll ans = Solve();

	printf("%d\n", ans);

	return 0;
}


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

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

  vector<int> a(N + 1, 0);

  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    L--;
    a[L]++;
    a[R]--;
  }

  for (int i = 0; i < N; i++) {
    a[i + 1] += a[i];
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] == M) {
      ans++;
    }
  }

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

Measured memory_bytes: 1024
s = input()
s_r = s[::-1]
res = []
for i in range((int(len(s) - 1) // 2)):
    if s[i] != s_r[i]:
        print("No")
        exit()
    res.append(s[i])

res = "".join(res)
res_r = res[::-1]
for i in range(len(res)):
    if res[i] != res_r[i]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int count = 0;
		char ls = 0;
		char [][] s =  new char [n][];
		char [][] hozon = new char [1][l];
	    for(int i = 0; i < n; i++){
		s [i] = sc.next().toCharArray();}
	    
	    for(int o = 0; o < l; o++){
	    for(int i = 0; i < n - 1; i++){
	    for(int j = i + 1; j < n; j++){
	    	
	    for(int k = 0; k < o; k++){	
	    if(s[i][k] == s[j][k]){ count++;} else {}
	    }
	    
	    if(count == o && s[i][o] > s[j][o]){ 
		for(int m = 0; m < l; m++){
		hozon[0][m] = s[i][m];
		s[i][m] = s[j][m];
		s[j][m] = hozon[0][m];}
		}
	    count = 0;
	    }}}
	    
	    for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
		System.out.print(s[i][j]);
		}}
		    			
	}}

Measured memory_bytes: 25472
#include <iostream>

using namespace std;

int n, q;
int* S;
int* T;

int solve() {
  int count = 0;
  for (int i = 0; i < q; i++) {
    int key = T[i];
    for (int j = 0; j < n; j++) {
      if (S[j] == key) {
        count++;
        break;
      }
    }
  }
  return count;
}

int main() {
  cin >> n;
  S = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  
  cin >> q;
  T = new int[q];
  for (int i = 0; i < q; i++) {
    cin >> T[i];
  }

  int res = solve();
  cout << res << endl;

  return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int a, b, c; cin >> a >> b >> c;
    if(a +b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    vector<int> a(N, 0);
    for(int i = 0; i < N; ++i) {
        cin >> a.at(i);
    }

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

    cout << a.at(N-1) - a.at(0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf(), getc()
#include <cctype>           // isdigit()
#include <algorithm>        // lower_bound()

using namespace std;
static const int MAX_N = 100000;

int A[MAX_N + 1];
int L[MAX_N];
int n;

int
lis()
{
	L[0] = A[0];
	int length = 1;
	for (int i = 1; i < n; ++i)
	{
		if (L[length - 1] < A[i])
			L[length++] = A[i];
		else
			*lower_bound(L, L + length, A[i]) = A[i];
	}

	return length;
}

int
main(int argc, char** argv)
{
	int x;
	int c;

	scanf("%d", &n);
	c = getc(stdin);
	for (int i = 0; i < n; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		x = 0;
		while (isdigit(c))
		{
			x = x * 10 + c - '0';
			c = getc(stdin);
		}

		A[i] = x;
	}

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

Measured memory_bytes: 3396
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
signed main(){
    int n;cin>>n;
    int ok[114514];
    rep(i,0,114514)ok[i]=false;
    int cnt=0;
    while(1){
        if(ok[n]){
            cout<<++cnt<<endl;
            return 0;
        }
        ok[n]=true;
        if(n%2==0)n/=2;
        else n=3*n+1;
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 1152
package main

import (
	"fmt"
)

func gcd(x,y int) int {
		if y == 0{
			return x
		} else {
			return gcd(y,x%y)
		}
}

func main() {
	var n int

	fmt.Scan(&n)
	a:= make([]int,n)
	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
	}

	l:= make([]int,n)
	l[0] = 0
	l[1] = a[0]
	for i:=2;i<n;i++ {
		l[i] = gcd(l[i-1],a[i-1])
	}

	r:= make([]int,n)
	r[n-1] = 0
	r[n-2] = a[n-1]
	for i:=n-3;i>=0;i-- {
		r[i] = gcd(r[i+1],a[i+1])
	}
	c:= make([]int,n)
	c[0] = r[0]
	c[n-1] = l[n-1]
	for i:=1;i<n;i++ {
		c[i]=gcd(r[i],l[i])
	}
	max := c[0]
	for i:=1;i<n;i++ {
		if max < c[i] {
				max = c[i]
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;

bool isPalin(string str){
    ll len = str.length(); 
    for(ll i = 0; i < len; i++){
        if(str[i] != str[len - i - 1]){
            return false;
        }
    }
    return true;
}

int main()
{
    fast;
    string str;
    cin >> str;
    ll len = str.length();
    string str2 = "", str3 = "";
    str2 = str.substr(0, (len - 1) / 2);
    str3 = str.substr(((len + 3) / 2) - 1);
    // cout << "st2: " << str2 <<  " str3: " << str3 << endl;
    if(isPalin(str3) && isPalin(str3) && isPalin(str)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
/*    
                                                                             
	1. Practice makes a man perfect.
	2. Let go of the past.
	3. Without pain, without sacrifice, we would have nothing.
	4. Great things never come from comfort zones.
	5. Turn your wounds into wisdom.
	6. No pain ... no palm, no throne, no glory,no cross, no crown.
	7. You never know how strong you are until being strong is your only choice.
	8. Smooth seas do not make skillful sailors.
	9. I am not what happened to me, I am what I choose to become.
	10. No matter how fail life pushes you down, No matter how much you hurt,You can always bounce back.
		
		
	--> This lines keep me motivated.		

	Author:- Gaurang_Kothiya
	
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;


 
void Solve()
{	
	string s;
	cin>>s;
	string ans="";
	fe(x,s)
	{
		if(x=='0') ans +='0';
		else if(x=='1') ans +='1';
		else
		{
			if(ans.sz ==0);
			else ans.erase(ans.length()-1,1);
		}
	}
	cout<<ans;
}
 
signed main() 
{
	speed		

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

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, T;
    cin >> N >> T;
    vint A(N), B(N);
    vector<pair<int, int>> AB(N);
    rep(i, N)
    {
        cin >> A[i] >> B[i];
        AB[i] = {A[i], B[i]};
    }
    sort(all(AB));

    auto dp = make_v<int>(N + 1, T + 1); //dp[i][j] := i番目までの品物で得られる最大の満足度
    rep(i, N)
    {
        rep(j, T + 1)
        {
            if (j < AB[i].first)
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - AB[i].first] + AB[i].second);
            }

        }
    }
    int ans = 0;
    rep(i, N + 1)
    {
        int M = 0;
        rep2(j, i, N)
        {
            chmax(M, AB[j].second);
        }
        chmax(ans, dp[i][T - 1] + M);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vl points(N,Q);
    rep(i,Q) {
        int A;
        cin >> A; A--;
        points[A]--;
    }
    rep(i,N) {
        if (points[i] < K) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4040
#include <iostream>

using namespace std;

int L[101]{};

int main() {
    int N;
    int ans = 0;

    cin >> N;

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

    if (N >= 3) {
        for (int i = 0; i < N - 2; i++) {
            for (int j = i + 1; j < N - 1; j++) {
                for (int k = j + 1; k < N; k++) {
                    if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
                    if (L[i] + L[j] <= L[k] || L[j] + L[k] <= L[i] || L[k] + L[i] <= L[j]) continue;
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

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

int main(void){
  int i,n,s,to;

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

    if(n == 1){
      s = to = 0;
    }
    else{
      s = 1;
      to = sqrt(n);
    }

    for(i = 2; i <= to; i++){
      if(n % i == 0){
	s += i;
	s += n / i;
      }
    }
    if(to * to == n){
      s -= to;
    }

    if(n > s){
      printf("deficient number\n");
    }
    else if(n == s){
      printf("perfect number\n");
    }
    else{
      printf("abundant number\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
n,x,y = map(int,input().split())
a = [0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        ans = min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
        a[ans-1] += 1
for k in range(0,n-1):
    print(a[k])

Measured memory_bytes: 3444
N, K = map(int,input().split())

l = []

for i in range(N):
    a, b = map(int, input().split())
    l.append((a,b))
def c(x):
    return  x[0]
l = sorted(l, key=c)
t = 0
for a,b in l:
    t2 = t
    t += b
    if t2 <= K and t >= K:
        break

print(a)

Measured memory_bytes: 18984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a,b,k,xx,yy,jc[10000100];
const int mod = 998244353;
inline int ksm(ll t,ll kk)
{
	ll ans=1;
	while(kk)
	{
		if(kk&1) ans*=t,ans%=mod;
		kk>>=1;
		t*=t;t%=mod;
	}
	return ans%mod;
}
int main()
{
	cin>>n>>a>>b>>k;
	if(k==0)
	{
		cout<<1<<endl;
		return 0;
	}
	if((a+b)*n<k)
	{
		cout<<0<<endl;
		return 0;
	}
	jc[0]=1;
	jc[1]=1;
	for(register int i=2;i<=n+100;++i)
	{
		jc[i]=jc[i-1]*i%mod;
	}
	ll res=0;
	for(register int i=0;i<=n;++i)
	{
		ll tmp=1ll*a*i;
		ll t=k-tmp;
		if(t%b) continue;
		ll cc=t/b;
		if(cc>n||cc<0) continue;
		res+=jc[n]%mod*ksm(jc[i],mod-2)%mod*ksm(jc[n-i],mod-2)%mod*jc[n]%mod*ksm(jc[cc],mod-2)%mod*ksm(jc[n-cc],mod-2)%mod;res%=mod;
	}
	cout<<res%mod;
	return 0;
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		int n; cin >> n;
		int ans=0;
		vi v; v.clear();
		for(int i=0;i<n;i++)
		{
			int val; cin >> val;
			v.pb(val);
		}
		for(int i=0;i<n;i++)
		{
			int val; cin >> val;
			ans += max(0,v[i]-val);
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x_) cerr << #x_ << ":" << x_ << endl;
#define debug2(x__) for(auto a__ : x__) cerr << a__ << " "; cerr << endl;
#define debug3(x___ , sx___) rep(i, sx___) cerr << x___[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

set<ll> make_primes(ll s = limit) {
    set<ll> primes;

    REP(i, 2, s) {
        bool is_prime = true;
        for (auto p : primes) {
            if (i % p == 0) {
                is_prime = false;
                break;
            }
        }
        if (is_prime) primes.insert(i);
    }
    return primes;
}

const ll MAX_N = 2 * limit;
ll fact[MAX_N];
ll fact_inv[MAX_N];

ll pow_mod(ll x, ll y, ll m = MOD) { //x^y mod m
    if (x == 0) return 0;
    ll prod = 1;
    while (y > 0) {
        if (y % 2 == 1) prod = (prod * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return prod % m;
}

void init_fact() {
    fact[0] = fact_inv[0] = 1;

    REP(i, 1, MAX_N) {
        fact[i] = (fact[i - 1] * i) % MOD;
        fact_inv[i] = pow_mod(fact[i], MOD - 2);
    }
}

ll comb_mod(ll n, ll r) {
    if (n < r) return 0;
    else return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    set<ll> primes = make_primes((ll) (sqrt(1e9 + 10)));
    set<ll> m_fac;
    map<ll, ll> fac_cnt;
    init_fact();
    for (auto p : primes) {
        while (m % p == 0) {
            m /= p;
            m_fac.insert(p);
            fac_cnt[p]++;
        }
    }
    if (m != 1) { //mが素数
        m_fac.insert(m);
        fac_cnt[m] = 1;
    }
    ll ans = 1;
    for (auto p : m_fac) {
        ll c = fac_cnt[p];
        ans *= comb_mod(n + c - 1, c);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
  int N[4];
  int cnt_1=0, cnt_7=0, cnt_9=0, cnt_4=0;
  for(int i=0; i<4; i++) cin >> N[i];
  for(int j=0; j<4; j++){
    if(N[j]==1) cnt_1++;
    if(N[j]==7) cnt_7++;
    if(N[j]==9) cnt_9++;
    if(N[j]==4) cnt_4++;
  }
  if(cnt_1==1 && cnt_7==1 && cnt_9==1 && cnt_4==1){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
set <long long int> s1,s2,s3;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,a,b,c,x,y,z,i,j,k,t,ans,m;
    cin>>n;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	ans=0;
	x=1;
	for (i=0;i<n;i++)
	{
		if (arr[i]>x)
		{
			if (arr[i]%x==0)
			{
				ans=ans+ (arr[i]/x) -1;
				if (x==1)
				{
					x++;
				}
			}
			else
			{
				ans=ans+ (arr[i]/x);
			}
		}
		else if (arr[i]==x)
		{
			x++;
		}
		else
		{
			continue;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024