akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		/*FOR LOOP BABY
		 * */
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int X = I.nextInt();
		int base = 2;
		int ans = 1; //Base value is 1 since 1^x is always just 1 (not 0 silly)
		while (true) {
			int cur = base*base;
			if (cur>X) break;
			ans=max(ans,cur);
			for (int i = 0;; i++) {
				cur*=base;
				if (cur>X) break;
				ans=max(ans,cur);
			}
			base++;
		}
		O.pln(ans);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


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

bool is_a_right_triangle(int a, int b, int c) {
        int a2 = a*a;
        int b2 = b*b;
        int c2 = c*c;

        if (a2 + b2 == c2) {
                return true;
        }

        if (a2 + c2 == b2) {
                return true;
        }

        if (b2 + c2 == a2) {
                return true;
        }

        return false;
}

int main(void) {
        int n;
        int a,b,c;

        cin >> n;
        while(n--) {
                cin >> a >> b >> c;
                if (is_a_right_triangle(a,b,c)) {
                        cout << "YES" << endl;
                } else {
                        cout << "NO" << endl;
                }
        }

        return 0;
}

Measured memory_bytes: 2984
#include <stdio.h>

long fact(int n);

int main(void)
{
    int n;
    scanf("%d", &n);

    long ans = fact(n);
    printf("%ld\n", ans);

    return 0;
}

long fact(int n)
{
    long ans = 1;
    while (n--) {
        ans *= (n + 1);
    }

    return ans;
}

Measured memory_bytes: 592
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

#include<bits/stdc++.h>
using namespace std;
#define ll long long int

#define pb push_back
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

ll n,m;
ll dp[100001];


ll cal(vector<ll>a[] , ll i)
{
    if(a[i].size()==0)
    {
        return 0;
    }
    else
    {
        if(dp[i]!=-1)
        {
            return dp[i];
        }
        else
        {
            ll maxi = 0;
            for(int j=0;j<a[i].size();j++)
            {
                maxi = max(maxi,1+cal(a,a[i][j]));
            }
            return dp[i]= maxi;
        }
    }
}



int main()
{

    cin>>n>>m;
    vector<ll> a[n+1];
    ll x,y;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        a[x].pb(y);
    }
    for(int i=1;i<=n;i++)
    {
        sort(a[i].begin(),a[i].end());
    }
   /*for(int i=1;i<=n;i++)
    {
        cout<<i<<": ";
        for(int j=0;j<a[i].size();j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;*/
    ll maxi = 0;
    for(int i=1;i<=n;i++)
    {
        maxi=max(maxi,cal(a,i));
    }
    cout<<maxi<<endl;

}



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

using namespace std;

int to_n(int n){
	if (n<=1){
		return 1;
	}else if (n==2){
		return 2;
	}
	return to_n(n-3)+to_n(n-2)+to_n(n-1);
}


int main(void)
{
	int in;
	
	while (cin >> in && in){
		cout << (to_n(in)+3649)/3650 << endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
int main() {
  string ans = "No";
  vector<int> bingo(9);
  for (int i = 0; i < 9; i++) {
    cin >> bingo.at(i);
  }
  int N;
  cin >> N;
  for (int j = 0; j < N; j++) {
    int b;
    cin >> b;
    for (int k = 0; k < 9; k++) {
      if (b == bingo.at(k)) {
        bingo.at(k) = 0;
      }
    }
  }
  if (bingo.at(0) == 0 && bingo.at(1) == 0 && bingo.at(2) == 0) {
    ans = "Yes";
  }
  if (bingo.at(3) == 0 && bingo.at(4) == 0 && bingo.at(5) == 0) {
    ans = "Yes";
  }
  if (bingo.at(6) == 0 && bingo.at(7) == 0 && bingo.at(8) == 0) {
    ans = "Yes";
  }
  if (bingo.at(0) == 0 && bingo.at(3) == 0 && bingo.at(6) == 0) {
    ans = "Yes";
  }
  if (bingo.at(1) == 0 && bingo.at(4) == 0 && bingo.at(7) == 0) {
    ans = "Yes";
  }
  if (bingo.at(2) == 0 && bingo.at(5) == 0 && bingo.at(8) == 0) {
    ans = "Yes";
  }
  if (bingo.at(0) == 0 && bingo.at(4) == 0 && bingo.at(8) == 0) {
    ans = "Yes";
  }
  if (bingo.at(2) == 0 && bingo.at(4) == 0 && bingo.at(6) == 0) {
    ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

int main() {
	string s; cin >> s;
	if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

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

    ll set[n];
	for(int i=0;i<n;i++)
		cin>>set[i];
		
    sort(set,set+n);
    int dp[pile+1];
    
    
    for(ll k=0;k<set[0];k++)
    dp[k]=0;
    
    for(ll u=set[0];u<=pile;u++)
    {
        int res=0;
        for(int v=0;v<n;v++)
        {
            if(set[v]>u)
            break;
            
            if((dp[u-set[v]])==0)
            {
                res=1;
                break;
            }
        }
    
        dp[u]=res;
    }
    
    if(!dp[pile])
       cout<<"Second";
   else
      cout<<"First";
    return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int k, s; cin >> k >> s;

    ll ans = 0;
    for(int i=0; i<=k; ++i){
        for(int j=0; j<=k; ++j){
            int z = s-i-j;
            if(0 <= z && z <= k) ++ans;
        }
    }

    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0, x = 0;
    rep(i, n) {
        cin >> a[i];
        s += a[i];
        if(i % 2 == 1) x += a[i];
    }
    vector<int> ans(n);
    ans[0] = s - x * 2;
    rep(i, n - 1){
        ans[i + 1] = 2 * a[i] - ans[i];
    }
    rep(i, n)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 2048
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    VII arr(5);
    for(auto &x:arr)
        cin >> x;

    for (int i = 0; i < 5;++i)
    if(arr[i]==0)
        cout << i + 1;

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3608
n=int(input())
a=sorted([int(input())for i in range(n)])
def f(x):
    p,q=1,n-2
    l,r=[a[0]],[a[n-1]]
    c=a[n-1]-a[0]
    t=0
    while p<=q:
        if t==x:
            r.append(a[q])
            c+=a[q]-l[0]
            q-=1
            l.pop(0)
        else:
            l.append(a[p])
            c+=r[0]-a[p]
            p+=1
            r.pop(0)
        t=(t+1)%2
    return c
print(max(f(0),f(1)))

Measured memory_bytes: 8284
/*
	Author: houtaru
	Create: 24.12.2017 11:16:38
*/
#include <bits/stdc++.h>
using namespace std;

long long a, b;

int main() {
	cin >> a >> b;
	int cnt = 0;
	for (long long i = a; i <= b; i *= 2) cnt++;
	cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
 
int main() {

int a;cin>>a;
  int b;b=a-(a/100)*100;
  if(a/100==7||a%10==7||b/10==7){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m,x,y;
	cin >>n>>m >>x>>y;
	vector<int> xx(n+1),yy(m+1);
	for(int i = 0; i < n; i++){
		cin >> xx[i];
	}
	xx[n]= x;
	for(int i = 0; i < m; i++){
		cin >> yy[i];
	}
	yy[m] = y;

	sort(all(xx));
	sort(all(yy));

	cout << ((xx[n]<yy[0])?"No War" :"War" ) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int[] A = in.ii();
        boolean f = true;
        for(int i = 0; i < N; i++){
            if(A[i] % 2 == 0){
                if(A[i] % 3 != 0 && A[i] % 5 != 0){
                    f = false;
                    break;
                }
            }
        }
        out.println(f ? "APPROVED" : "DENIED");
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int N, A, B, c = 0, d = 0;
	string S;
	cin >> N >> A >> B >> S;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'c')cout << "No" << endl;
		if (S[i] == 'a') {
			if (A + B > c) {
				c++;
				cout << "Yes"<<endl;
			}
			else cout << "No"<<endl;
		}
		if (S[i] == 'b') {
			d++;
			if (B >= d&&A + B > c) {
				c++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 896
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(*A)

N = int(input())
A = list(map(int, input().split()))
print(*A)
insertionSort(A, N)



Measured memory_bytes: 5980
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;

void fill(int x, int y, int island[14][14]){
	if(island[x][y] == 0){
		return;
	}
	island[x][y] = 0;
	fill(x-1, y, island);
	fill(x, y-1, island);
	fill(x+1, y, island);
	fill(x, y+1, island);
}

int main(){
	int island[14][14] = {0};
	int n;
	string s;

	while(cin >> s){
		bool f = true;
		for(int i = 0; i < 12; i++){
			if(!f){
				cin >> s;
			}
			for(int j = 0; j < 12; j++){
				island[i+1][j+1] = s[j]-'0';
			}
			f = false;
		}

		int count = 0;
		for(int i = 1; i < 13; i++){
			for(int j = 1; j < 13; j++){
				if(island[i][j] == 1){
					fill(i, j, island);
					count++;
				}
			}
		}

		cout << count << endl;
		getline(cin, s);
	}

    return 0;
}

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

using namespace std;

typedef long long ll;

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

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

	vector<vector<int>> v(M, vector<int>());
	vector<int> p(M);

	rep(i, M){
		int k;
		cin >> k;

		rep(j, k){
			int s;
			cin >> s;
			v[i].push_back(s-1);
		}
	}

	rep(i, M){
		cin >> p[i];
	}

	int ans = 0;
	for(int b = 0; b < (1 << N); b++){
		bool ok = true;
		for(int i = 0; i < M; i++){
			int t = 0;
			for(int x : v[i]){
				if((b >> x) & 1) t++;
			}
			if(t % 2 != p[i]) ok = false;
		}
		if(ok) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
void solve(){
	ll n;
	cin>>n;
	vl deg(n);
	for(int i=1;i<n;i++){
		int x;
		cin>>x;
		x--;
		deg[x]++;
	}
	for(int i=0;i<n;i++) cout<<deg[i]<<endl;
	
	
	
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    
 

Measured memory_bytes: 4788
#include <iostream>
#include <algorithm>
#include <utility>
#include <limits>
using namespace std;

int w[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    int l, r, m;
    int truck, weight;
    int wm=numeric_limits<int>::min();
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>w[i];
    l=0;
    r=numeric_limits<int>::min();
    m=(n+k-1)/k;
    weight=0;
    for(int i=0; i<n; i++) {
        l+=w[i];
        wm=max(wm, w[i]);
        if(i%m==0) {
            r=max(r, weight);
            weight=w[i];
        } else {
            weight+=w[i];
        }
    }
    r=max(r, weight);
    l=max((l+n-1)/n, wm);
    
    bool f;
    while(r>l) {
        m=(l+r)/2;
        truck=weight=0;
        f=true;
        for(int i=0; i<n; i++) {
            if(weight+w[i]<=m) weight+=w[i];
            else {
                truck++;
                if(truck>=k) {
                    f=false;
                    break;
                }
                weight=w[i];
            }
        }
        if(f) r=m;
        else l=m+1;
    }
    cout<<r<<'\n';
    return 0;
}

Measured memory_bytes: 1584
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K, D;

  std::cin >> N >> K;

  std::vector<int> b(K);

  for (auto& i : b)
    std::cin >> i;

  std::sort(ALL(b));

  for (int i = N; ; i ++) {
    std::string s(std::to_string(i));

    std::vector<int> a, c;

    for (const auto& c : s)
      a.push_back(c - '0');

    std::sort(ALL(a));

    a.erase(std::unique(ALL(a)), std::end(a));

    std::set_intersection(ALL(a), ALL(b), std::back_inserter(c));

    if (c.empty()) {
      std::cout << i << std::endl;

      return 0;
    }
  }

  return 0;
}


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

namespace AtTest.NothingToLearn
{
    class CodeFestival_2016_C
    {
        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[] kt = ReadInts();
            int k = kt[0];
            int t = kt[1];
            int[] array = ReadInts();
            Array.Sort(array);
            int sum = array.Sum();
            WriteLine(Max(array[t - 1] - (sum - array[t - 1]) - 1, 0));
        }

        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: 11732
#include <stdio.h>
 
int main(){
    double a,b,c,d,e,f;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)>0){
            f=(f-c/a*d)/(e-b/a*d);
            c=c/a-f*b/a;
            printf("%.3f %.3f\n",c,f);
    }
    return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    auto s = in.read<std::string>();
    for (auto&& c : s) c = 'x';
    out(s);
}

int main()
{
    prog();
    return 0;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 410;

int indeg[N], outdeg[N], fa[N];

int find(int x){
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int n, H;

int main(){
	scanf("%d%d", &n, &H);

	For(i, 1, 2 * H) fa[i] = i;
	For(i, 1, n){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int u = !c ? a : H + c, v = !d ? H + b : d;
		fa[find(u)] = find(v);
		++outdeg[u], ++indeg[v];
	}

	bool flag = true;
	For(i, 1, 2 * H) if(i == fa[i] && (indeg[i] || outdeg[i])){
		bool differ = false;
		For(j, 1, H) if(find(j) == i){
			if(outdeg[j] < indeg[j]) flag = false;
			if(outdeg[j] ^ indeg[j]) differ = true;
		}

		For(j, H + 1, 2 * H) if(find(j) == i){
			if(indeg[j] < outdeg[j]) flag = false;
			if(indeg[j] ^ outdeg[j]) differ = true;
		}

		if(!flag || !differ){
			flag = false;
			break;
		}
	}

	puts(flag ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ans = 0;
  if (K % 2 == 0) {
    ans = A - B;
  }
  else {
    ans = B - A;
  }
  if (abs(ans) > 1000000000000000000) {
    cout << "Unfair" << endl;
  }
  else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
'use strict';
const main = input => {
  const num = input[0].split(' ').map(val => parseInt(val)), N = num[0], M = num[1], X = num[2], Y = num[3], x = input[1].split(' ').map(val => parseInt(val)), y = input[2].split(' ').map(val => parseInt(val));
  // console.log(N, M, X, Y, x, y);
  const xMax = Math.max(...x), yMin = Math.min(...y);
  // console.log(xMax, yMin);
  let ans = 0;
  for(let z=X+1; z<=Y; z++) {
    if (xMax < z && yMin >= z) {
      ans = 1;
      break;
    }
  }
  console.log(ans==1?'No War':'War');
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
struct node{
	double x,y;
	node operator+(node b){return (node){x+b.x,y+b.y};}
	node operator-(node b){return (node){x-b.x,y-b.y};}
	node operator*(double b){return (node){x*b,y*b};}
	double len(){return sqrt(x*x+y*y);}
};
double cross(node a,node b){return a.x*b.y-a.y*b.x;}
double dot(node a,node b){return a.x*b.x+a.y*b.y;}
node projection(node p1,node p2,node p){node v=p2-p1;return p1+v*(dot(v,p-p1)/dot(v,v));}
node reflection(node p1,node p2,node p){node P=projection(p1,p2,p);P=P*2-p;return P;}
int main(){
	node p1,p2,p;
	p1.x=gi();p1.y=gi();p2.x=gi();p2.y=gi();
	int Q=gi();
	while(Q--){
		p.x=gi();p.y=gi();
		node P=reflection(p1,p2,p);
		printf("%.8lf %.8lf\n",P.x,P.y);
	}
	return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <map>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    map<int, ll> a;
    ll sum = 0;
    REP(i, 0, n) {
        int x;
        cin, x;
        a[x]++;
        sum += x;
    }
    int q;
    cin, q;
    REP(i, 0, q) {
        int b, c;
        cin, b, c;
        ll cnt = a[b];
        sum -= b * cnt;
        a.erase(b);
        a[c] += cnt;
        sum += c * cnt;
        print(sum);
    }

    return 0;
}


Measured memory_bytes: 7612
import math
X = int(input())
n = math.ceil(X**0.5+1)
lst = []
if X == 1 or X == 2 or X == 3:
  print(1)
  exit()
for i in range(2, n):
  a = 2
  while i**a <= X:
    lst.append(i**a)
    a += 1
lst.sort()
print(lst[-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	vecll a;
	map<int, int> map_;
	rep(i, n)
	{
		int tmp;
		cin >> tmp;
		map_[tmp]++;
	}
	vector<ll> xxx;
	for (auto itr = map_.begin(); itr != map_.end(); itr++)
	{
		if (itr->second > 1)
		{
			xxx.push_back(itr->first);
			continue;
		}
		else
		{
			a.push_back(itr->first);
		}
	}
	vecb x;
	sort(all(a));
	if (a.size() > 0)
	{
		x.resize(a[a.size() - 1] + 10, false);
	}
	rep(i, a.size())
	{
		x[a[i]] = true;
	}
	ll ans = 0;
	for (int i = 0; i < a.size(); i++)
	{
		if (x[a[i]])
		{
			for (int j = 2; j * a[i] <= a[a.size() - 1] + 1; j++)
			{
				x[j * a[i]] = false;
			}
		}
	}
	sort(all(xxx));
	for (int i = 0; i < xxx.size(); i++)
	{
		if (a.size() > 0)
			for (int j = 2; j * xxx[i] <= a[a.size() - 1] + 1; j++)
			{
				x[j * xxx[i]] = false;
			}
	}
	rep(i, a.size())
	{
		if (x[a[i]])
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int H, W;
int N;
vector<int>a;

int main(void)
{
	cin >> H >> W;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		int aa; cin >> aa;
		a.push_back(aa);
	}
	int plus = 0;
	vector<vector<int>>vec(H, vector<int>(W));
	for (int j = 0; j < N; ++j)
	{
		int aa = a[j];
		for (int i = 0; i < aa; ++i)
		{
			int h = plus / W;
			int w = -1;
			if (h % 2 == 0)
			{
				w = plus % W;
			}
			else
			{
				w = plus % W;
				w = W - 1 - w;
			}
			vec[h][w] = j + 1;
			++plus;
		}
	}
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cout << vec[i][j] << " \n"[j == W - 1];
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 500005
#define pii pair<int,int>
using namespace std;

int a,b,c,nr;

bool divide(int &a, int &b, int &c){
    if (a % 2 || b % 2 || c % 2) return 0;
    int A = b / 2 + c / 2, B = a / 2 + c / 2, C = a / 2 + b / 2;
    a = A; b = B; c = C;
    return 1;
}

int main()
{
    cin >> a >> b >> c;
    while (divide(a,b,c) && nr < 100000) nr++;
    if (nr >= 100) cout << -1 << '\n';
    else cout << nr << '\n';
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

char b[510][510];
bitset<510> bits[510];
int dp[2][1 << 22], nums[510];
signed main() {
    int N, M;
    while(cin >> N >> M, N || M) {
        for(int i=0; i<N; i++) {
            for(int j=0; j<M; j++) {
                scanf(" %c", &b[i][j]);
            }
        }

        int ans = 0;
        if(N <= 22) {
            for(int i=0; i<N; i++) {
                bits[i].set().flip();
                for(int j=0; j<M; j++) {
                    bits[i][j] = (b[i][j] - '0');
                }
            }
            
            for(int bit=0; bit<(1<<N); bit++) {
                bitset<510> bb;
                for(int i=0; i<N; i++) {
                    if(!(bit >> i & 1)) continue;
                    bb ^= bits[i];
                }

                bool ok = bb.flip().all();
                if(ok) ans = max(ans, (int)__builtin_popcountll(bit));
            }
            cout << ans << endl;
        }
        else {
            for(int i=0; i<N; i++) {
                nums[i] = 0;
                for(int j=0; j<M; j++) {
                    nums[i] |= (b[i][j] - '0') << j;
                }
            }

            fill(dp[0], dp[2], -1);
            dp[0][0] = 0;
            for(int i=0; i<N; i++) {
                int c = i % 2 , n = 1 - c;
                for(int bit=0; bit<(1<<M); bit++) {
                    if(dp[c][bit] < 0) continue;
                    
                    // 使わない
                    chmax(dp[n][bit], dp[c][bit]);

                    // 使う
                    int nbit = bit ^ nums[i];
                    chmax(dp[n][nbit], dp[c][bit] + 1);

                    dp[c][bit] = -1;
                }
            }
            cout << dp[N%2][0] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 68952
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    long long int A, B, K;
    cin >> A >> B >> K;
    
    if(A>=K) {
        cout << A-K << " " << B << endl;
    } else {
        cout << 0 << " " << max(B-K+A, (long long int)0) << endl;
    }



    return 0;
    
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

ll N;

bool solve() {
	rep(i, 100)rep(j, 100) {
		if (N == 4 * i + 7 * j) { return true; }
		
	}
	return false;
}


int main() {
	cin >> N;
	if (solve()) { cout << "Yes"; }

	else { cout << "No"; }
	
	system("PAUSE");
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;

#define MAX 300001

bool msprime[300001];
int main(){
	
	msprime[0] = false;
	// 月曜土曜数
	for(int i = 1; i <= 300000; i += i % 7 == 1 ? 5:2){
			msprime[i] = true;
		
	}


	msprime[1] = false;

	// 月曜土曜素数
	for(int i = 13; i <= 300000; i += i % 7 == 1 ? 5:2){
		if(msprime[i]){
			for(int j = 6; j <= (int)sqrt(i); j+=7){
				if(i % j == 0){
					msprime[i] = false;
					break;
				}
			}
			if(msprime[i]){
				for(int j = 8; j <= (int)sqrt(2 * i); j+=7){
					if(i % j == 0){
						msprime[i] = false;
						break;
					}
				}
			}
		}
	}

	int x;
	cin >> x;
	while(x != 1){
		set<int> ans;
		ans.clear();
		for(int i = 6; i <= x; i++){
			if(msprime[i] && x % i == 0){
				ans.insert(i);
			}
		}

		cout << x << ':' ;
		set<int>::iterator it = ans.begin();
		while(it != ans.end()){
			cout << ' ' << *it ;
			it++;
		}
		cout << endl;
		cin >> x;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, d, a;
    cin >> n >> d >> a;

    vector<pair<int, int>> v(n);
    vector<int> c(n);
    int ans = 0;
    for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());
    for (int i = 0, j = 0; i < n; i++) {
        while (j < n and v[j].first <= v[i].first + 2 * d)j++;
        int nd = max(0ll, (v[i].second - c[i] * a + a - 1) / a);
        c[i] += nd;
        c[j] -= nd;
        c[i + 1] += c[i];
        ans += nd;
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <set>

int main()
{
  int s, t; //number of integers for S and T

  int count = 0; // number of integers of T in S
  
  std::set<int> S; // set S to be checked against

  scanf("%d", &s);
  
  for (int i = 0; i < s; ++i) {
    int input;
    scanf("%d", &input);
    S.insert(input);
  }

  scanf("%d", &t);

  for (int i = 0; i < t; ++i) {
    int input;
    scanf("%d", &input);
    if ( S.find(input) != S.end() ) ++count; // increment count if found in S
  }

  printf("%d\n", count);
}
    

Measured memory_bytes: 4836
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] A = new int[N], B = new int[M];
		int X = sc.nextInt(), Y = sc.nextInt();
		for (int i=0; i<A.length; i++){
			A[i] = sc.nextInt();
		}
		for (int i=0; i<B.length; i++){
			B[i] = sc.nextInt();
		}
		Arrays.sort(A);
		Arrays.sort(B);
		boolean ok = false;
		if (X<B[0] && Y>=B[0]){
			if (B[0]>A[A.length-1]){
				ok = true;
				System.out.println("No War");
			}
		}
		if (!ok){
			System.out.println("War");
			
		}

	}

}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 2 * 1e5;
  int a[max_n + 1];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];

  long long s = 0;
  for(int i = 0; i < n; i++){
    s = s ^ a[i];
  }

  for(int i = 0; i < n; i++){
    long long ans = s ^ a[i];
    if(i == n - 1) cout << ans << endl;
    else {
      cout << ans;
      cout << " ";
    }
  }

  return 0;
}

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

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

    ll n;
    cin >> n;

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    ll res = 0;
    ll curr = 0;
    for(int i = n-1; i >= 0; --i){
        if((a[i]+ curr)%b[i] == 0) continue;
        res += b[i] - (a[i] + curr) % b[i];
        curr += b[i] - (a[i] + curr) % b[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

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

int compare(const void *a, const void *b) {
  return *(long int *)a - *(long int *)b;
}

int main() {
  long int N, X, x[100000];

  long int i, g;

  scanf("%ld %ld", &N, &X);

  for (i = 0; i < N; i++) {
    scanf("%ld", &x[i]);
    x[i] = x[i] - X;
    if (x[i] < 0) {
      x[i] *= -1;
    }
  }
  if (N == 1) {
    printf("%ld\n", x[0]);
    return 0;
  }

  qsort(x, N, sizeof(long int), compare);

  g = gcd(x[1], x[0]);
  for (i = 2; i < N; i++) {
    g = gcd(x[i], g);
  }

  printf("%ld\n", g);

  return 0;
}


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

signed main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  
  string T = S;
  if( C < D ){
    //Bについて
    bool fg = true;
    bool mae = false;
    for( int i = B-1; i < N; i++ ){
      if( mae == true && S.at(i) == '#' ){
        fg = false;
        break;
      }else if( mae == false && S.at(i) == '#' ){
        mae = true;
      }
      if( S.at(i) == '.' ) mae = false;
      if( i == D-1 ){
        break;
      }
    }
    mae = false;
    for( int i = A-1; i < N; i++ ){
      if( mae == true && S.at(i) == '#' ){
        fg = false;
        break;
      }else if( mae == false && S.at(i) == '#' ){
        mae = true;
      }
      if( S.at(i) == '.' ) mae = false;
      if( i == C-1 ){
        break;
      }
    }
    if( fg == true ){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if( C > D ){
    bool san = false;
    bool fg = true;
    bool mae = false;
    for( int i = A-1; i < N; i++ ){
      if( B-1 <= i && i < D ){
        if( S.at(i-1) == '.' && S.at(i) == '.' && S.at(i+1) == '.' ) san = true;
      }
      if( mae == true && S.at(i) == '#' ){
        fg = false;
        break;
      }else if( mae == false && S.at(i) == '#' ){
        mae = true;
      }
      if( S.at(i) == '.' ) mae = false;
      if( i == C-1 ){
        break;
      }
    }
    if( fg == true && san == true ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

const int mod = 998244353;

using ll = long long;

int add(int a, int b) {
    return((ll)a+b)%mod;
}

int sub(int a, int b) {
    return ((ll)a + mod - b)%mod;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> seg(k);
    for(int i = 0; i < k; i++) {
        cin >> seg[i].first >> seg[i].second;
    }
    vector<int> ways(n+1, 0), pref(n+1, 0);
    ways[1] = pref[1] = 1;
    for(int i = 2; i <= n; i++) {
        for(int j = 0; j < k; j++) {
            int l = i - seg[j].second - 1, r = i - seg[j].first;
            l = max(l, 0);
            r = max(r, 0);
            ways[i] = add(ways[i], sub(pref[r], pref[l]));
        }
        pref[i] = add(pref[i-1], ways[i]);
        //cout << ways[i] << ' ' << pref[i] << endl;
    }
    cout << ways[n];
}

Measured memory_bytes: 4780