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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
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 ll MOD = (ll) (1e9 + 7);
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#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 MT make_tuple
#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 dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    ll n;
    cin >> n;
    deque<ll> t;

    rep(i, n) {
        ll a;
        cin >> a;
        auto itr = lower_bound(all(t), a);
        if (itr == t.begin()) {
            t.push_front(a);
        } else {
            itr--;
            *itr = a;
        }
    }
    cout << (ll) t.size() << endl;
    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string abcd;
    int s[4];
    cin >> abcd;
    for(int i = 0;i < 4;i++){
     s[i] = abcd[i] - '0';
    }
    
    if(s[0]+s[1]+s[2]+s[3] == 7){
        cout << s[0] << "+" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
    }
    else if(s[0]+s[1]-s[2]+s[3] == 7){
        cout << s[0] << "+" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
    }
    else if(s[0]+s[1]+s[2]-s[3] == 7){
        cout << s[0] << "+" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
    }
    else if(s[0]+s[1]-s[2]-s[3] == 7){
        cout << s[0] << "+" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
    }
    else if(s[0]-s[1]+s[2]+s[3] == 7){
        cout << s[0] << "-" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
    }
    else if(s[0]-s[1]+s[2]-s[3] == 7){
        cout << s[0] << "-" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
    }
    else if(s[0]-s[1]-s[2]+s[3] == 7){
        cout << s[0] << "-" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
    }
    else if(s[0]-s[1]-s[2]-s[3] == 7){
        cout << s[0] << "-" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;


int main(){
    AC
    ll x;
    cin>>x;
    ll ans = 100;
    ll years = 0;
    while(ans<x){
        ans+=(ans/100);
        years++;
    }
    cout<<years<<endl;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
int a[3000],b[3000],d,e;
int c=0;
while(1){
scanf("%d %d",&a[c],&b[c]);
if(a[c]==0 && b[c]==0){
break;
}
c++;
}
for(d=0;d<c;d++){
if(a[d]>b[d]){
e=a[d];
a[d]=b[d];
b[d]=e;
}
printf("%d %d\n",a[d],b[d]);
}
return 0;
}





Measured memory_bytes: 2588
from collections import Counter
import string
import math
import sys
def array_int():
    return [int(i) for i in sys.stdin.readline().split()]
def vary(number_of_variables):
    if number_of_variables==1:
        return int(sys.stdin.readline())
    if number_of_variables>=2:
        return map(int,sys.stdin.readline().split()) 
def makedict(var):
    return dict(Counter(var))
mod=100000007
import math
fact=[1]
MAX=100001
mod=998244353
for i in range(1,MAX):
	fact.append((fact[-1]*i)%mod)
def ncr(n , k): 
    global mod,fact
    num=fact[n]
    den=((fact[n-k])*(fact[k]))%mod
    return (num*pow(den,mod-2,mod))%mod
k=vary(1)
print('ACL'*k)

    

        


    

      
    




    











            
        


        






                 

            
    

















        






        


        





Measured memory_bytes: 13764
#include<iostream>

using namespace std;

int main() {

	int K, X;
	cin >> K >> X;

	for (int i = X - K + 1; i <= X + K - 1; i++) {
		if (i < -1000000) continue;
		if (i > 1000000) break;
		cout << i << " ";
	}
	cout << endl;

	return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    bool ans = true;
    for(int i = 0; i < n/2; i++){
        if (s[i] != s[n/2+i])ans = false;
    }
    if (ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
	string s;
	while(getline(cin, s), s != "."){
		vector<int> a;
		for(int i = 0; i < s.size(); i++){
			switch(s[i]){
			case '(':
			a.push_back(0);
			break;
	
			case '[':
			a.push_back(1);
			break;
	
			case ')':
			if(a.empty()){
				a.push_back(-1);
				break;
			}
			else if(a.back() == 0){
				a.pop_back();
				break;
			}else{
				a.push_back(-1);
				break;
			}

			case ']':
			if(a.empty()){
				a.push_back(-1);
				break;
			}else if(a.back() == 1){
				a.pop_back();
				break;
			}else{
				a.push_back(-1);
				break;
			}
		
			default :
			break;
			}	
			if(!a.empty() && a.back() == -1) break;
		}
		if(a.empty()) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

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

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

	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++)
	{
		int a,b;
		a = dp[i-1]+abs(h[i] - h[i-1]);
		b=dp[i-2]+abs(h[i]-h[i-2]);
		dp[i]=min(a,b);
	}

	cout << dp[n-1] ;
	return 0;
}

Measured memory_bytes: 1024
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
			PrintWriter out=new PrintWriter(System.out);
	FastScanner fs=new FastScanner();
		int a=fs.nextInt();
		int b=fs.nextInt();
		int ans=a*b;
		out.println(ans);
		out.close();
	
	
	}
	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());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}
}


Measured memory_bytes: 25392
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        String s = sc.next();

        if (a>=3200)
            System.out.println(s);
        else
            System.out.println("red");
    }
}


Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int f,q,x;
  string s;
  map<string,int>m;
  cin>>q;
  while(q--){
    cin>>f;
    if(f==0){
      cin>>s;
      cin>>x;
      m[s]=x;

    }
    else{
      cin>>s;
      cout<<m[s]<<endl;

    }

  }
return 0;
}


Measured memory_bytes: 27796
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct coin
{
    ll a, b, c;
};

bool cmp(const coin &p, const coin &q){
    if(p.a - p.c != q.a - q.c) return p.a - p.c > q.a - q.c;
    if(p.b != q.b) return p.b > q.b;
    return p.a > q.a;
}

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    int n = x + y + z;
    coin p[100005];
    for(int i = 0; i < n; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        p[i] = coin{a, b, c};
    }
    sort(p, p + n, cmp);
    priority_queue<P> quea, queb, quec;
    ll s = 0;
    int b[100005];
    for(int i = 0; i < x; i++){
        s += p[i].a;
        quea.push(P(p[i].b - p[i].a, i));
        b[i] = 0;
    }
    for(int i = x; i < n; i++){
        s += p[i].c;
        quec.push(P(p[i].b - p[i].c, i));
        b[i] = 2;
    }
    for(int i = 0; i < y; i++){
        P q = quec.top();
        quec.pop();
        s += q.first;
        queb.push(P(-q.first, q.second));
        b[q.second] = 1;
    }
    ll ans = s;
    for(int i = x; i < x + y; i++){
        if(b[i] == 1){
            b[i] = 0;
            s += p[i].a - p[i].b;
            quea.push(P(p[i].b - p[i].a, i));
            P q = quea.top();
            quea.pop();
            s += q.first;
            int j = q.second;
            b[j] = 1;
            queb.push(P(p[j].c - p[j].b, j));
        }
        else{
            b[i] = 0;
            s += p[i].a - p[i].c;
            quea.push(P(p[i].b - p[i].a, i));
            P q = quea.top();
            quea.pop();
            s += q.first;
            int j = q.second;
            b[j] = 1;
            queb.push(P(p[j].c - p[j].b, j));
            while(queb.size()){
                q = queb.top();
                queb.pop();
                j = q.second;
                if(b[j] == 1) break;
            }
            s += q.first;
            b[j] = 2;
            quec.push(P(p[j].c - p[j].b, j));
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5944
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int cnt=0;
  if((A<0&&abs(A)<abs(B))||(A>0&&abs(A)>abs(B))){
    A*=-1;
    cnt++;
  }
  cnt+=abs(abs(A)-abs(B));
  A+=abs(abs(A)-abs(B));
  if(A!=B)cnt++;
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
S=list(map(int,input().split()))
ans=0
t=0
temp=[]
for i in range(N):
	t = T-0.006*S[i] - A
	t = t*t
	temp.append(t)
print(temp.index(min(temp))+1)		

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
long long dp[303][303];

int main() {
	int N, K;
	cin >> N >> K;
	int M = N - K;
	vector<int>H(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> H[i + 1];
	}
	for (int i = 0; i < N + 1; ++i) {
		for (int j = 0; j < M + 1; ++j) {
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;

	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= M; ++j) {
			long long now = 1e18;
			for (int k = 0; k < i; ++k) {
				now = min(now, dp[k][j] + max(0, H[i] - H[k]));
			}
			dp[i][j + 1] = now;
		}
	}
	long long ans = 1e18;
	for (int i = 0; i <= N; ++i) {
		ans = min(ans, dp[i][M]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4288
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

int main() {
  char s[4];
  cin >> s[0] >> s[1] >> s[2] >> s[3];
  sort(s, s + 4);
  if(s[0] == s[1] && s[2] == s[3] && s[2] != s[1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int n,x;
scanf("%d %d",&n,&x);

int i,m[n+1],min;
scanf("%d",&m[0]);
min=m[0];

for(i=1;i<n;++i){
	scanf("%d",&m[i]);
	if(min>m[i]) min=m[i];
}

int count;
for(i=0;i<n;++i)
	x-=m[i];

count=x/min;

printf("%d\n",i+count);

return 0;
}

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


int main() {
	int a, b, c, d;
	string s;
	cin >> s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';

	for (int i=0; i<2; i++) {
		for (int j=0; j<2; j++) {
			for (int k=0; k<2; k++) {
				if (a + b *pow(-1, i) + c*pow(-1,j) + d*pow(-1, k)==7) {
					cout <<a<<(i ? "-" : "+")<<b<<(j ? "-" : "+")<<c<<(k ? "-" : "+") << d << "=7"<< endl;
					return 0;
				}
			}
		}
	}


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, Q;
const int INF = INT_MAX;
struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;
public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }

    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }

    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
    int find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        int vl = find(a, b, 2*k+1, l, (l+r)/2);
        int vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
    cin >> N >> Q;
    LazySegmentTree tate(vector<int>(N,N - 1));
    LazySegmentTree yoko(vector<int>(N,N - 1));
    tate.update(N - 1,N,0); yoko.update(N - 1,N,0);
    long long ans = (long long)(N - 2)*(long long)(N - 2);
    int d = N - 1,r = N - 1;
    for(int i=0; i<Q; i++) {
        int q,x; cin >> q >> x; x--;
        if(q==1){
            int y = tate.find(x,x + 1);
            ans -= y - 1;
            if(x<r) yoko.update(0,y,x);
            tate.update(x,x + 1,0);
            r = min(r,x);
        }
        if(q==2){
            int t = yoko.find(x,x + 1);
            ans -= t - 1;
            if(x<d) tate.update(0,t,x);
            yoko.update(x,x + 1,0);
            d = min(d,x);
        }
    }
    cout << ans << endl;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int m, n;

int main(){
  cin >> n >> m;
  if(abs(n-m)>=2){
    cout << "0" << endl;
  }else if (n==m){
    ll ans = 1;
    rep(i,1,n+1){
      ans *= i;
      ans = ans%(INTMAX);
    }
    cout <<(2*ans*ans)%INTMAX<<endl;
  }else{
    ll ans = 1;
    rep(i,1,n+1){
      ans *= i;
      ans = ans%(INTMAX);
    }
    rep(i,1,m+1){
      ans *= i;
      ans= ans%(INTMAX);
    }
    cout << ans << endl;
  }
  return 0;
}


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

string a(string s){
	string t;
	int l=s.size();
		int i=0;
		while(i<l){
			char r=s[i];
			int k=0;
			while(i<l && r==s[i]){
				i=i+1;
				k=k+1;
			}
			t=t+to_string(k);
			t=t+r;
			
		}
	return t;
	}


int main() {
	// your code goes here
	int n;
	while(cin>>n){
		if (n==0) break;
		
		string s;
		cin>>s;
		for(int ii=0;ii<n;ii++){
		s=a(s);
		}
		cout<<s<<endl;
		
		
	}
	return 0;
}

Measured memory_bytes: 1384
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

#define MOD 1000000007

int main()
{
	ios::sync_with_stdio(false);

	int n, m, k;
	cin >> n >> m >> k;
	
	bool ok = 0;
	for(int a=0; !ok && a<=n; ++a)
		for(int b=0; !ok && b<=m; ++b)
		{
			int x = a*(m-b) + b*(n-a);
			if(x == k)
				ok = 1;
		}
		
	cout << (ok ? "Yes":"No") << "\n";

	return 0;
}


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

int partition(vector<int>& A, int p, int r){
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] > A[r]) continue;
        swap(A[++i], A[j]);
    }
    swap(A[++i], A[r]);
    return i;
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto& a : A) cin >> a;
    int pos = partition(A, 0, n - 1);
    for (int i = 0; i < pos; i++) {
        cout << A[i] << " ";
    }
    cout << "[" << A[pos] << "] ";
    for (int i = pos + 1; i < n; i++) {
        cout << A[i] << (i < n - 1 ? " " : "\n");
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define F0R(i, a) for(ll i = 0; i < a; i++)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //

int main() {
  ios:: sync_with_stdio(0);
  cin.tie(0);
  ll n, d, x, y;
  cin >> n >> d;
  int count = 0;
  while(n--){
    cin >> x >> y;
    if (x * x + y * y <= d * d) count++;
  }
  cout << count << "\n";

  return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
int main(void){
int x,y,z,p,tan;
scanf("%d %d %d",&x,&y,&z);
	for(p=1;p<=3;p++){
		if(x>y){
			tan=y;
			y=x;
			x=tan;
			tan=0;
		}else if(y>z){
			tan=z;
			z=y;
			y=tan;
			tan=0;
		}	}
		printf("%d %d %d\n",x,y,z);



	return 0;
}

Measured memory_bytes: 2696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
int main(){
   vector<bool> prime (100002,true);
   vector<int> cnt(100002);
   prime[0]=false;
   prime[1]=false;
   prime[2]=true;
   for (int i=2;i < 100002;i++){
      if (prime[i]){
         int tmp;
         tmp=i;
         for (int j=i+tmp; j < 100002; j+=tmp){
            prime[j]=false;
         }
      }
   }
   cnt[0]=0;
   for (int i=1;i < 100001;i++) {
      if (prime[i] && prime[(i+1)/2] ) cnt[i]+=cnt[i-1]+1;
      else cnt[i]=cnt[i-1];
   }
   int q;
   cin >> q;
   rep(i,q){
      int l,r;
      cin >> l >> r;
      cout << cnt[r]-cnt[l-1] << endl;
   }
   //rep(i,10) cout << cnt[i];
   //printf("\n");
   //rep(i,10){
   //   if (prime[i]) cout << "o";
   //   else cout << "x";
   //}
   
   return 0;
}



Measured memory_bytes: 1024
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<int,int>
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005,Mo=1000000007;
struct list{
	int l,lt[MAXN],nt[MAXN*2],x[MAXN*2],y[MAXN*2];
	void clear(){ l=1; memset(lt,0,sizeof(lt)); }
	void addedge(int a,int b,int c){ l++; nt[l]=lt[a]; lt[a]=l; x[l]=b; y[l]=c; }
}E;
int n,m,a[MAXN],b[MAXN];
int main(){
	n=read(); m=0;
	FOR(i,1,n) a[i]=read();
	FOR(i,1,n) {
		if (a[i]==i&&i!=n) {
			swap(a[i],a[i+1]);
			m++;
		}
	}
	if (a[n]==n) swap(a[n],a[n-1]),m++;
	cout<<m<<endl;
	return 0;
}

/*
*/


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a= b; return true; } return false; }

int main(){
    vector<vector<long long>> dp(110, vector<long long>(1e5+10));
    int n,W; cin >> n >> W;
    vector<long long> w(110), v(110);
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

    for(int i = 0; i < n; i++){
        for(int sum_w = 0; sum_w <= W; sum_w++){
            
            //i番目の品物を選ぶ
            if(sum_w - w[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w-w[i]] + v[i]);
            }

            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 87296
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,d;
    cin >> n >> d;
    vvi x(n,vi(d));
    rep(i,n)rep(j,d)cin >> x[i][j];
    int ans = 0;
    rep(i,n)rep(j,i){
        int dist = 0;
        rep(k,d)dist += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        int a = sqrt(dist);
        if(a*a == dist)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() { T t; cin >> t; return t;}

using AB = pair<int, int>;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N = In<int>();
    vector<AB> vec(N);
    for(int i = 0; i < N; i++) {
        vec[i] = make_pair<int,int>(In<int>(), In<int>());
    }

    sort(vec.begin(), vec.end(), [](const AB &ab1, const AB &ab2) { 
        return ab1.second < ab2.second; });
    ll time = 0;
    for(const auto &ab: vec) {
        time += ab.first;
        if(time > ab.second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

bool my_compare(pair<int, string> a, pair<int, string> b) {
    if(a.first != b.first){
        return a.first > b.first; // 降順
    }
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, string>> str(n);
    vector<string> s(n);
    rep(i, n) {
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    int count = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            str.at(i).second = s.at(i);
            str.at(i).first = count;
            continue;
        }
        if (s.at(i) == s.at(i - 1)) {
            ++count;
            str.at(i).second = s.at(i);
            str.at(i).first = count;
        } else {
            str.at(i).second = s.at(i);
            str.at(i).first = 1;
            count = 1;
        }

    }
    sort(str.begin(), str.end(), my_compare);
    for(int i = 0; i < n; i++) {
       if (i == 0) {
            cout << str.at(i).second << endl;
            continue;
        }
        if (str.at(i).first == str.at(i - 1).first) {
            cout <<  str.at(i).second << endl;
        } else {
            return 0;
        }


    }
}



Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    vint A(N);
    cin >> A;
    ll score = 1000;
    for(int i=0; i<N-1; i++){
        ll stacks = 0;
        if(A[i+1] > A[i]){
            stacks = score/A[i];
        }
        score += (A[i+1]-A[i])*stacks;
    }
    cout << score << endl;
}

Measured memory_bytes: 3604
while gets
    xa,ya,xb,yb,xc,yc,xd,yd=$_.chomp.split(nil).map(&:to_f)
    xab=xb-xa;yab=yb-ya
    xcd=xd-xc;ycd=yd-yc
    if((xab*xcd+yab*ycd).abs<=1e-10)
        puts "YES"
    else
        puts "NO"
    end
end

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

int main() {
  int abcd;
  cin >> abcd;
  int a = abcd/1000;
  abcd-=1000*a;
  int b = abcd/100;
  abcd-=100*b;
  int c = abcd/10;
  int d = abcd % 10;
  for (int i=0; i < 8; ++i) {
    int sum = a;
    ostringstream ss;
    ss<<a;

    if(i & 0b100){
      sum+=b;
      ss<<"+"<<b;
    }else{
      sum-=b;
      ss<<"-"<<b;
    }
    if(i & 0b10){
      sum+=c;
      ss<<"+"<<c;
    }else{
      sum-=c;
      ss<<"-"<<c;
    }
    if(i & 0b1){
      sum+=d;
      ss<<"+"<<d;
    }else{
      sum-=d;
      ss<<"-"<<d;
    }
    if(sum==7){
      cout<<ss.str()<<"=7"<<endl;
      exit(0);
    }
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <limits.h>

#define ll long long

using namespace std;

int main(){

    int n,m;
    cin >> n >> m;

    vector<int> dp(100001,0);
    vector<int> broken(100001,0);

    dp[0] = 1;


    for(int i = 0; i < m; i++){
        int tmp;
        cin >> tmp;
        broken[tmp] = 1;
    }

    for(int i = 1; i < n + 1; i++){
        if(broken[i] != 1){
            if(i == 1){
                dp[1] = dp[0];
            }else{
                dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
            }
        }
    }

    cout << dp[n] << endl;


    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
char ar[1500000]={'0'};
int judge5(int i)
{
    if(ar[i]>='5') return 1;
    else  return 0;

}
int main()
{
    scanf("%s",&ar[1]);
    int cnt=0;
    for(int i=strlen(ar)-1;i>=0;i--)
    {
        if(ar[i]>'9') ar[i]-=10,ar[i-1]++;
        if(ar[i]<'5') cnt+=ar[i]-'0';
        else if(ar[i]=='5')
        {
            if(judge5(i-1)) ar[i-1]++;
            cnt+=5;
        }
        else ar[i-1]++,cnt+=10-(ar[i]-'0');
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 1280
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
    
    if ((a<c && b>c) || (a>c && b<c)) {
		System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>

using namespace std;

struct Team {
	int num;
	int min[4];
	int s[4];
	int total;
};

int compute(Team group);
bool compare(Team i, Team j) {
	return (i.total < j.total);
}

int main() {

	int n;
	while (cin >> n && n != 0) {

		Team *group = new Team[n];

		for (int i = 0; i < n; i++) {

			cin >> group[i].num;

			for (int j = 0; j < 4; j++)
				cin >> group[i].min[j] >> group[i].s[j];

			group[i].total = compute(group[i]);
		}

		sort(group, group + n, compare);
		cout << group[0].num << "\n"
			 << group[1].num << "\n"
			 << group[n - 2].num<< "\n";
	}

	

	return 0;

}

int compute(Team group) {

	int total = 0;
	for (int i = 0; i < 4; i++)
		total += (group.min[i] * 60 + group.s[i]);

	return total;
}




Measured memory_bytes: 3460
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll x,a;
	cin >> x >> a;
	if(x<a) cout << 0;
	else cout << 10;
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
import java.util.Scanner;

final class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);

        int a, b, c, d, e, k;

        a = stdIn.nextInt();
        b = stdIn.nextInt();
        c = stdIn.nextInt();
        d = stdIn.nextInt();
        e = stdIn.nextInt();
        k = stdIn.nextInt();

        if(e-a <= k){
            System.out.print("Yay!");
        }else{
            System.out.print(":(");
        }
    }
}

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

class Main
{
    public static void main (String[] args) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        String s[]=bu.readLine().split(" ");
        int k,i,c=0;
        for(i=0;i<n;i++)
        {
            k=Integer.parseInt(s[i]);
            if(k%2==1 && i%2==0) c++;
        }
        System.out.print(c);
    }
}

Measured memory_bytes: 32684
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)

int const MOD = 1e9 + 7;
int const N = 105;
int const MX = 1e5;
using namespace std;

int num[N], fn[N];

int wt[N], vl[N];
int dp[100010];
int32_t main(){
    memset(dp, -1, sizeof dp);
    int n, w;
    cin>>n>>w;
    
    for(int i = 1; i<=n; i++){
        cin>>wt[i]>>vl[i];
    }
    
    dp[0] = 0;
    for(int i = 1; i<=n; i++){
        int val = vl[i];
        int weight = wt[i];
        int b[100005];
        memset(b, -1, sizeof b);
        for(int j = 0; j<=MX-val; j++){
            if(dp[j] != -1){
                if(dp[j+val] == -1)
                    b[j+val] = dp[j] + weight;
                else{
                    b[j + val] = min(dp[j+val], dp[j] + weight);
                }
            }
        }
        for(int j = 1; j<=MX; j++){
            if(b[j] != -1)
                dp[j] = b[j];
        }
    }
    for(int i = MX; i>=0; i--){
        if(dp[i] != -1 && dp[i] <= w){
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;
const ll INF = 1e16;

void solve(){
	vll arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll k;
	cin >> k;
	cout << arr[k-1] << endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
K, N = map(int,input().split())
A = [int(_) for _ in input().split()]
B = [0]*N

for i in range(N-1):
    B[i] = A[i+1]-A[i]

B[N-1] = K-A[N-1]+A[0]

t = max(B)

print(K-t)

Measured memory_bytes: 78540
#include <map>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 2006
using namespace std;
char s[N][N];
int n,m,q,x1,x2,y1,y2,ans,g[N][N][3];
inline int read()
{
	int x=0,c=getchar();while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')x=x*10+c-48,c=getchar();return x;
}
void print(int x)
{
	if(x>9)print(x/10);putchar(x%10+48);
}
int main()
{
	n=read();m=read();q=read();
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(s[i][j]=='1'){
				g[i][j][0]=1;
				if(s[i-1][j]=='1')g[i][j][1]=1;
				if(s[i][j-1]=='1')g[i][j][2]=1;
			}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=0;k<3;k++)
				g[i][j][k]+=g[i-1][j][k]+g[i][j-1][k]-g[i-1][j-1][k];
	while(q--){
		x1=read();y1=read();x2=read();y2=read();
		ans=g[x2][y2][0]-g[x1-1][y2][0]-g[x2][y1-1][0]+g[x1-1][y1-1][0];
		ans-=g[x2][y2][1]-g[x1][y2][1]-g[x2][y1-1][1]+g[x1][y1-1][1];
		ans-=g[x2][y2][2]-g[x1-1][y2][2]-g[x2][y1][2]+g[x1-1][y1][2];
		print(ans);puts("");
	}
}

Measured memory_bytes: 52736
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;

const int maxN = 100 + 10; 
int a[2*maxN]; 

int main() {
	int n;
	cin >> n;
	for( int i = 0 ; i < 2 * n ; i++ ) 
		cin >> a[i]; 
	sort( a , a + 2 * n ) ; 
	int ans = 0; 
	for( int i = 0 ; i < 2 * n ; i+=2 ) 
		ans += a[i]; 
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int hitpoint = 0;
    int damage = 0;
    int hit_count = 0;

    scanf("%d %d", &hitpoint, &damage);

    hit_count = hitpoint / damage;

    if (hitpoint % damage != 0)
    {
        hit_count++;
    }

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

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DEBUG if(1)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n, k;
const lli mod = 1e9 + 7;
lli a[maxN];

lli fat[maxN + 1];
lli modPow(lli x, lli y)
{
  lli ans = 1;
  while (y)
  {
    if (y & 1LL) ans = (ans * x) % mod;
    x = (x * x) % mod, y >>= 1LL;
  }
  return ans;
}
lli inv(lli x)
{
  return modPow(x, mod - 2);
}
lli choose(lli nn, lli kk)
{
  return fat[nn] * inv(fat[kk]) % mod * inv(fat[nn - kk]) % mod;
}

int main()
{
  fat[0] = fat[1] = 1;
  for (lli i = 2; i <= maxN; i ++)
    fat[i] = (i * fat[i - 1]) % mod;

  while (scanf("%d %d", &n, &k) != EOF)
  {
    for (int i = 0; i < n; i ++)
      scanf("%lld", &a[i]);
    sort(a, a+n);

    if (k == 1)
    {
      printf("0\n");
      continue;
    }

    lli maximum = 0, minimum = 0;
    for (int i = 0; i < n - k + 1; i ++)
      minimum = (minimum + a[i] * choose(n - i - 1, k - 1) % mod) % mod;
    for (int i = k - 1; i < n; i ++)
      maximum = (maximum + a[i] * choose(i, k - 1) % mod) % mod;

    lli ans = (maximum - minimum + mod) % mod;
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// struct UnionFind {
// vector<int> par;
// UnionFind(int N) : par(N) {
// for (int i = 0; i < N; i++) par[i] = i;
// }

// int root(int x) {
// if (par[x] == x) return x;
// return par[x] = root(par[x]);
// }

// void unite(int x, int y) {
// int rx = root(x);
// int ry = root(y);
// if (rx == ry) return;
// par[rx] = ry;
// }

// bool same(int x, int y) {
// int rx = root(x);
// int ry = root(y);
// return rx == ry;
// }
// };

// union by size + path having
class UnionFind {
   public:
    vector<ll> par;  // 各元の親を表す配列
    vector<ll> siz;  // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;  // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i;  // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) {  // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]];  // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {  // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) {  // 素集合のサイズ
        return siz[root(x)];
    }
};

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

    UnionFind tree(N + 1);
    tree.merge(0, 0);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        tree.merge(a, b);
    }

    int output = 0;
    for (int i = 0; i < N; i++) {
        if (tree.size(i + 1) > output) {
            output = tree.size(i + 1);
        }
        // cout << tree.size(i + 1) << endl;
    }
    cout << output << endl;

    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  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: 3596
#include <bits/stdc++.h>
 
using namespace std;
  
int len[123];

int main(){
  int n, k;
  scanf("%d %d", &n, &k);
  
  for (int i = 0; i < n; i++){
  	scanf("%d", &len[i]);
  }

  sort(len, len + n);

  int sum = 0;
  for (int i = n - k; i < n; i++){
  	sum += len[i]; 
  }

  cout << sum << endl;

  return 0;
}

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

const int N = 1e6 + 10;
const int mod = 1e9 + 7;

int p[N], inv[N], f[N];

int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if (b != 0){
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else{
		x = 1;
		y = 0;
	}
	return d;
}

int mod_inverse(int a){
	int x, y, m;
	m = mod;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

void _init(int n){
	p[0] = 1;
	for (int i = 1; i <= n; i++) p[i] = 1LL * p[i - 1] * i % mod;
	for (int i = 0; i <= n; i++) inv[i] = mod_inverse(p[i]);
}

int C(int x, int y){
	if (x < y) return 0;
	int ret;
	ret = p[x];
	ret = 1LL * ret * inv[y] % mod;
	ret = 1LL * ret * inv[x - y] % mod;
	return ret;
}

int main(){
	int n, ans;
	scanf("%d",&n);
	if (n == 2){
		printf("1\n");
		return 0;
	}
	if (n == 3){
		printf("4\n");
		return 0;
	}
	_init(n);
	f[0] = 0;
	for (int i = 1; i <= n - 1; i++) 
		f[i] = 1LL * C(i - 1, n - i - 1) * p[i] % mod * p[n - i - 1] % mod;
	ans = 0;
	for (int i = 1; i <= n - 1; i++){
		ans += 1LL * (f[i] - f[i - 1] + mod) % mod * i % mod;
		ans %= mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>

int main(void){
	int n;
	int ans;

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

		while(1){
			ans = ans + n / 5;
			n = n / 5;
			if(n == 0) break;
		}

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

	return 0;
}

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

int n;
vector<ll> a;

int main() {
    cin >> n;
    a.assign(n, 0);
    ll m = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        m += abs(a[i]);
    }

    sort(a.begin(), a.end());
    if(a[0] > 0)
        cout << (m - 2 * a[0]) << endl;
    else if(a[n-1] < 0)
        cout << (m + 2 * a[n-1]) << endl;
    else
        cout << m << endl;
    
    if(a[0] > 0) {
        cout << a[0] << " " << a[1] << endl;
        a[0] -= a[1];
        a.erase(a.begin()+1);
    }

    for(int i = a.size()-2; i >= 0; i--) {
        if(a[i] > 0) {
            cout << a[0] << " " << a[i] << endl;
            a[0] -= a[i];
        }
        else {
            cout << a[a.size()-1] << " " << a[i] << endl;
            a[a.size()-1] -= a[i];
        }
    }
}

Measured memory_bytes: 2688
#include<cstdio>
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    int n;
    while(scanf("%d",&n),n){
        int stage[22][22]={{0}};
        char vis[22][22];
        for(int i = 0; i < 21; i++){
            for(int j = 0; j < 21; j++){
                vis[i][j] = '.';
            }
        }
        for(int i = 0; i < n; i++){
            int hx,hy;
            scanf("%d%d",&hx,&hy);
            stage[hy][hx] = 1;
            vis[hy][hx] = '*';
        }
        int m;
        scanf(" %d",&m);
        int nx = 10;
        int ny = 10;
        int gotten = 0;
        for(int i = 0; i < m; i++){
            //vis[ny][nx] = '#';
            if(i == 0){
                stage[10][10] == 1 ? gotten = 1 : gotten = 0;
            }
            char dir;
            int dist;
            cin >> dir >> dist;
            int fx = nx;
            int fy = ny;
            if(dir == 'N'){
                fy = ny+dist;
                while(ny != fy)if(stage[++ny][nx]-- == 1)gotten++;
            }
            if(dir == 'E'){
                fx = nx+dist;
                while(nx != fx)if(stage[ny][++nx]-- == 1)gotten++;
            }
            if(dir == 'S'){
                fy = ny-dist;
                while(ny != fy)if(stage[--ny][nx]-- == 1)gotten++;
            }
            if(dir == 'W'){
                fx = fx-dist;
                while(nx != fx)if(stage[ny][--nx]-- == 1)gotten++;
            }
        }
        if(stage[ny][nx] == 1)gotten++;
        /*for(int i = 0; i < 21; i++){
            for(int  j = 0; j < 21; j++){
                printf("%c",vis[i][j]);
            }
            puts("");
        }*/
        if(gotten == n)puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 1204
"use strict";
function Main(input) {
    let lines = input.split("\n");
    const nums = lines.shift().split(/\s/).map((v) => v - 0);
    const N = nums[0], Q = nums[1];
    let S = lines.shift().split(/\s/)[0];
    let lr = new Array(Q);
    let ans = new Array(Q).fill(0);
    for (let n = 0; n < Q; n++) {
        lr[n] = lines.shift().split(/\s/).map((v) => v - 0 - 1);
    }
    let T = new Array(N).fill(0);
    for (let m = 0; m < S.length-1; m++) {
        T[m + 1] = T[m] + ((S.substr(m, 2) == 'AC') ? 1 : 0);
    }
    lr.forEach(function(v, i) {
        ans[i] = T[v[1]] - T[v[0]];
    });
    console.log(ans.join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 55984
'use strict';
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  const N=input.shift();
  const K=input.shift();
  const A=input;
  const dp=new Array(K+2).fill('tbd');
  
  dp[K+1]=true;
  for(let i=K+1;i>=A[0];i--){
    if(dp[i])
      if(dp[i-1]===true){
        continue;
      }
      for(let j=1;j<=A[0];j++)
        if(i-j>=0)
          if(dp[i-j]==='tbd')
            dp[i-j]=false;
    if(!dp[i])
      for(let a=0;a<N;a++)
        if(i-A[a]>=0)
          dp[i-A[a]]=true;
  }
  
  if(dp[0]===true)console.log('First');
  else console.log('Second');
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 8396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  
  // 変数aで入力を受け取る
  cin >> a >> b;
 
  if((a*b)%2 == 0){
    cout << "Even" << endl;  
  }else{
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
struct Card {
  char suit,value;
};
 
void bubble(struct Card a[],int n){
  for (int i=0;i<n;i++){
    for (int j=n-1;i<j;j--){
      if(a[j].value<a[j-1].value){
        swap(a[j],a[j-1]);
      }
    }
  }
}
 
void selection(struct Card a[],int n){
  for(int i=0;i<n-1;i++){
    int minnum = i;
    for (int j=i+1;j<n;j++){
      if(a[minnum].value>a[j].value){
        minnum = j;
      }
    }
    swap(a[i],a[minnum]);
  }
}
         
void print(struct Card a[],int n){
  for (int i=0;i<n-1;i++){
    printf("%c%c ",a[i].suit,a[i].value);
  }
  printf("%c%c\n",a[n-1].suit,a[n-1].value);
}
 
int memo;
void judge(struct Card origin[],struct Card a[],int n){
  int finish=0;
  for (int i=0;i<n;i++){
    if(i==0){
      memo=0;
    }
    if(i<n && a[i-1].value!=a[i].value){
      memo=0;
    }
    if(finish!=0){
      break;
    }
    for (int j =memo;j<n;j++){
      if(a[i].value==origin[j].value){
        if(a[i].suit !=origin[j].suit){
          cout<<"Not stable"<<endl;
          finish++;
          break;
        }
        if(i<n-1 && a[i].value==a[i+1].value){
          memo=j+1;
          break;
        }
      }
    }
  }
  if(finish==0){
    cout<<"Stable"<<endl;
  }
}
 
int main(){
  int N;
  cin>>N;
  Card a[100],b[100],origin[100];
  for(int i=0;i<N;i++){
    cin>>a[i].suit>>a[i].value;
    b[i]=a[i];
    origin[i]=a[i];
  }
   
  bubble(a,N);
   
  selection(b,N);
   
  print(a,N);
  judge(origin,a,N);
   
  print(b,N);
  judge(origin,b,N);
}


Measured memory_bytes: 3204