akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n,kk;
  cin >> n >> kk;

  vector<long> a(n);
  // vector<long>row_sum( (n*(n+1) )/ 2);
  vector<long>row_sum;


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

  }

  for (int i = 0; i < n; ++i){
    for(int j=i;j<n;j++){
      row_sum.push_back(0);
      for(int k=j;k<n;k++){
        row_sum[row_sum.size()-1] += a[ n - k - 1 + i];
      }
    }
  }

  // 最大5*10^5こくらい

    for(int i =0;i<row_sum.size();i++){
      cerr << row_sum[i] <<",";
    }cerr << endl;

  sort(row_sum.begin(),row_sum.end(),[](long &l,long &r){return l>r;});


  long maxv = row_sum[0];
  long maxdig =0;
  for(long i=1;i<maxv;i*=2){
    maxdig++;
  }
  maxdig--;


  vector<long>row_sum2;

  long ans =0;
  //最大桁数
  for(int k=maxdig;k>=0;k--){
    long base = pow(2,k);
    

    long count =0;
    for(int i =0;i<row_sum.size();i++){
      cerr << row_sum[i] <<",";
      if ( (row_sum[i] & base) > 0 )count++;
    }cerr << endl;

    cerr << "base:" << base << "  count:" << count<<  endl;


    if (count >= kk){
      row_sum2.clear();
      for(int i =0;i<row_sum.size();i++){
        if ( (row_sum[i] & base)> 0  )row_sum2.push_back(row_sum[i]);
      }
      row_sum.clear();
      for(int i =0;i<row_sum2.size();i++){
        cerr << row_sum2[i] <<",";
        row_sum.push_back(row_sum2[i]);
      }
      cerr << endl;
      cerr << endl;
      ans += base;
    }
  }





  cerr <<maxdig <<endl;


  // for(int k=0;k<row_sum.size();k++){
  //   cerr << row_sum[k] <<endl;
  // }



  cout << ans << endl;
  // cout << "w:" << w << "  h:" << h << endl;


}




















Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)(N);i++)
#define ck(n,a,b) (a)<=(n)&&(n)<=(b)
#define p(s) cout<<(s)<<endl
#define F first
#define S second
typedef long long ll;
using namespace std;

bool prime[250001];
int main() {
	int n;
	REP(i, 0, 250001) prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2; i*i<250001; i++){
		for(int j=i*2; j<250001; j+=i){
			prime[j]=false;
		}
	}

	while(cin>>n, n){
		int cnt=0;
		REP(i, n+1, 2*n+1){
			if(prime[i]) cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int> 
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 1000000007LL

int n,m,par[(int)(2e5)+10];

int find (int x)
{
	if(par[x]!=x)
	{
		par[x]=find(par[x]);
		return par[x];
	}
	else
	{
		return x;
	}
}



int solve()
{
	int n,m;
	cin>>n>>m;

	for(int i=1;i<=n;i++)
	{
		par[i]=i;
	}

	for(int i=0;i<m;i++)
	{
		int t1,t2;
		cin>>t1>>t2;
		int p1=find(t1),p2=find(t2);
		if(p1!=p2)
			par[p1]=p2;
	}
	map<int,int> mp;
	int mx=0;
	for(int i=1;i<=n;i++)
	{
		mp[find(i)]++;
		mx=max(mx,mp[par[i]]);
	}
	cout<<mx<<"\n";

  return 0;
}


int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
  
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }
  return 0;
}

 

Measured memory_bytes: 13680
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef double ld;
typedef long long ll;
#define int ll
const ll mod=1e9+7;

int32_t main()
{
    SPEED;
    int n;
    cin>>n;
    ld p[n+1];
    for (int i = 1; i <= n; ++i)
    {
        cin>>p[i];
    }
    ld dp[n+1][n+1];
    dp[1][1]=p[1];
    dp[1][0]=1-p[1];
    for (int i = 2; i <= n; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if(j==0)
            {
                dp[i][0]=dp[i-1][0]*(1-p[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    ld ans=0;
    for (int i = n/2+1; i <= n; ++i)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}



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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String S = sc.next();
    
    if (N % 2 != 0) {
      System.out.println("No");
      return;
    }
    
    String T = S.substring(0, N/2);
    String TT = T+T;

    if (TT.equals(S)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23124
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

struct p {
  int cnt, v;
};

bool cmp(const p &p1, const p &p2) { return p1.cnt > p2.cnt; }

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

  int N;
  cin >> N;
  vector<p> odd_vec(100002); // with sentinel
  fill(odd_vec.begin(), odd_vec.end(), p{0, 0});
  vector<p> even_vec(100002); // with sentinel
  fill(even_vec.begin(), even_vec.end(), p{0, 0});

  for (int i = 1; i <= N; i++) {
    int vi;
    cin >> vi;
    if (i % 2 == 1) {
      odd_vec[vi].v = vi;
      odd_vec[vi].cnt++;
    } else {
      even_vec[vi].v = vi;
      even_vec[vi].cnt++;
    }
  }

  sort(odd_vec.begin(), odd_vec.end(), cmp);
  sort(even_vec.begin(), even_vec.end(), cmp);

  int odd_idx = 0;
  int even_idx = 0;
  if (odd_vec[odd_idx].v == even_vec[even_idx].v) {
    if (odd_vec[odd_idx].cnt > even_vec[even_idx].cnt) {
      even_idx++;
    } else if (odd_vec[odd_idx].cnt < even_vec[even_idx].cnt) {
      odd_idx++;
    } else {
      if (odd_vec[odd_idx + 1].cnt > even_vec[even_idx + 1].cnt) {
        odd_idx++;
      } else if (odd_vec[odd_idx + 1].cnt < even_vec[even_idx + 1].cnt) {
        even_idx++;
      } else {
        even_idx++;
      }
    }
  }

  int ans = 0;
  for (int i = 0; odd_vec[i].cnt != 0; i++) {
    if (i == odd_idx) {
      continue;
    }
    ans += odd_vec[i].cnt;
  }
  for (int i = 0; even_vec[i].cnt != 0; i++) {
    if (i == even_idx) {
      continue;
    }
    ans += even_vec[i].cnt;
  }
  cout << ans << endl;

  return 0;
}

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

#pragma GCC diagnostic warning "-std=c99"

int dd[500];

int div(int n)
{
	if (dd[n]) return dd[n];
	int c = 1;
	int temp = n;
	if (temp%2 == 0) c++;
	for (int i = 3; i <= n; i++)
	{
		if (temp%i == 0) c++;
	}
	return dd[n] = c;
}

int main()
{
	int n, c = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i+=2)
	{
		if (div(i) == 8) c++;
	}
	printf("%d\n", c);
			
	return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    if (A == B)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<stack>
#include<string>
 
using namespace std;
 
stack<string> dfs;
 
int main()
{
    string c;
    while (cin >> c) {
        if (c != "+"&&c != "-"&&c != "*")
            dfs.push(c);
        else {
            int num[2], r;
            for (int i = 0; i < 2; ++i) {
                stringstream sstr;
                sstr << dfs.top(); dfs.pop();
                sstr >> num[i];
            }
            if (c == "+")r = num[0] + num[1];
            else if(c == "-")r = num[1] - num[0];
            else r = num[0] * num[1];
            dfs.push(to_string(r));
        }
    }
    cout << stoi(dfs.top()) << endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    vl a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    if(a[2] == a[0] + a[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static int[] ar;

    public static void main(String[] args) {

    	Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));

    	int n,sum,max;
    	while((n = sc.nextInt()) != 0){
    		max = Integer.MIN_VALUE;
    		ar = new int[n];
    		for(int i=0;i<n;i++){ar[i] = sc.nextInt();}
    		for(int i=0;i<n;i++){
   				sum = 0;
   				for(int j=i;j<n;j++){
   					sum += ar[j];
   	   				if(max < sum){max = sum;}
   				}
    		}
    		System.out.println(max);
    	}
	}
}

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
const int MOD=1e9+7;
 
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

const int N=1e6+5;

int n,w;
int a[N][3];
int dp[105][N];

int go(int pos,int wei)
{
    if(wei>w) return -1e15;
    if(pos==n+1)
        return 0;
    int &ans=dp[pos][wei];
    if(ans!=-1)
        return ans;
  	ans=0;
    ans=max(go(pos+1,wei),a[pos][2]+go(pos+1,wei+a[pos][1]));
    return ans;

}

int32_t main()
{
    IOS;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
    {
        for(int j : {1,2})
            cin>>a[i][j];
    }
    memset(dp,-1,sizeof(dp));
    cout<<go(1,0)<<endl;
    
}


Measured memory_bytes: 821504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

//		StackArray sa = new StackArray(1);
//		try {
//			sa.push(1);
//		} catch (Exception e) {
//			System.out.println("catch");
//		} finally {
//			System.out.println("final");
//		}
//		System.out.println("owari");

		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");

		StackArray sa = new StackArray(data.length);

		int ans = 0;
		try
		{
			for (int i = 0; i < data.length; i++)
			{
				switch (data[i])
				{
				case "+":
					ans = sa.pop() + sa.pop();
					sa.push(ans);
					break;
				case "-":
					ans = - sa.pop() + sa.pop();
					sa.push(ans);
					break;
				case "*":
					ans = sa.pop() * sa.pop();
					sa.push(ans);
					break;
				default:
					sa.push( Integer.parseInt(data[i]) );
					break;
				}
			}
			System.out.println(sa.pop());
		}
		catch (Exception e)
		{
			System.out.println(e);
		}

	}

	static class StackArray {
		int[] S;

		int top = 0;

		StackArray(int length) {
			this.S = new int[length];
		}

		StackArray initialize() {
			this.top = 0;
			return this;
		}

		boolean isEmpty() {
			return this.top == 0;
		}

		boolean isFull() {
			return this.top >= this.S.length - 1;
		}

		StackArray push(int x) throws Exception {
			if (this.isFull()) {
				throw new Exception();
			}
			this.top++;
			S[this.top] = x;
			return this;
		}

		int pop() throws Exception {
			if (this.isEmpty()) {
				throw new Exception();
			}
			int x = S[top];
			top--;
			return x;
		}

	}
}

Measured memory_bytes: 26272
# C - Monsters Battle Royale
# https://atcoder.jp/contests/abc118/tasks/abc118_c

N = int(input())
A = set(map(int, raw_input().split()))

while len(A) != 1:

    # minimum number of A
    minA = min(A)

    # next round A
    nA = set()
    nA.add(minA)

    for Ai in A:
        if Ai == minA: continue
        if Ai % minA != 0:
            nA.add(Ai%minA)

    # update for next round
    A = nA

print '{}'.format( list(A)[-1])


Measured memory_bytes: 12624
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long double dp[31][31][31] = {};
int visited[31][31][31] = {};
vector<tuple<int, int,double>> vertexs[31];
int main() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return 0;
		REP(i, 31) {
			vertexs[i].clear();
			REP(q, 31) {
				REP(j, 31) {
					dp[i][q][j] = LONG_INF;
					visited[i][q][j] = 0;
				}
			}
		}
		int s, g;
		cin >> s >> g;
		s--;
		g--;
		REP(i, m) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			a--;
			b--;
			vertexs[a].push_back(make_tuple(b, d, c));
			vertexs[b].push_back(make_tuple(a, d, c));
		}
		priority_queue<tuple<long double, int, int, int>> next;
		for (int q = 0; q < vertexs[s].size(); ++q) {
			dp[get<0>(vertexs[s][q])][s][1] = get<2>(vertexs[s][q]);
			next.push(make_tuple(-get<2>(vertexs[s][q]), get<0>(vertexs[s][q]), s, 1));
		}
		while (next.empty() == false) {
			tuple<long double, int, int, int> now = next.top();
			next.pop();
			if (visited[get<1>(now)][get<2>(now)][get<3>(now)] == 1) continue;
			visited[get<1>(now)][get<2>(now)][get<3>(now)] = 1;
			int now_here = get<1>(now);
			int now_back = get<2>(now);
			int speed = get<3>(now);
			REP(i, vertexs[now_here].size()) {
				int next_go = get<0>(vertexs[now_here][i]);
				long double lengthen = get<2>(vertexs[now_here][i]);
				int limit_speed = get<1>(vertexs[now_here][i]);
				if (next_go == now_back) continue;
				for (int q = -1; q <= 1; ++q) {
					int now_speed = speed + q;
					if (now_speed >= 1 && now_speed <= limit_speed) {
						long double costs = -get<0>(now) + lengthen / (long double)now_speed;
						if (dp[next_go][now_here][now_speed] > costs) {
							dp[next_go][now_here][now_speed] = costs;
							next.push(make_tuple(-costs, next_go, now_here, now_speed));
						}
					}
				}
			}
		}
		long double ans = LONG_INF;
		REP(q, 31) {
			ans = min(ans, dp[g][q][1]);
		}
		if (ans == LONG_INF) {
			cout << "unreachable" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
}


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

int main() {
    vector<int> a1(3), a2(3), a3(3);
    vector<bool> f1(3, false), f2(3, false), f3(3, false);
    
    cin >> a1.at(0) >> a1.at(1) >> a1.at(2);
    cin >> a2.at(0) >> a2.at(1) >> a2.at(2);
    cin >> a3.at(0) >> a3.at(1) >> a3.at(2);
    
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) cin >> b.at(i);
    
    rep(i, n) {
        rep(j, 3) {
            if (a1.at(j) == b.at(i)) f1.at(j) = true;
            if (a2.at(j) == b.at(i)) f2.at(j) = true;
            if (a3.at(j) == b.at(i)) f3.at(j) = true;
        }
    }

    if (f1.at(0) && f1.at(1) && f1.at(2)) {
        cout << "Yes" << endl;
        return 0;
    }
    if (f2.at(0) && f2.at(1) && f2.at(2)) {
        cout << "Yes" << endl;
        return 0;
    }
    if (f3.at(0) && f3.at(1) && f3.at(2)) {
        cout << "Yes" << endl;
        return 0;
    }

    if (f1.at(0) && f2.at(0) && f3.at(0)) { 
        cout << "Yes" << endl;
        return 0;
    }
    if (f1.at(1) && f2.at(1) && f3.at(1)) {
        cout << "Yes" << endl;
        return 0;
    }
    if (f1.at(2) && f2.at(2) && f3.at(2)) {
        cout << "Yes" << endl;
        return 0;
    }

    if (f1.at(0) && f2.at(1) && f3.at(2)) {
        cout << "Yes" << endl;
        return 0;
    }
    if (f1.at(2) && f2.at(1) && f3.at(0)) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}


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

using namespace std;

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define _parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mp make_pair
#define F first
#define S second
#define pb push_back

typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 2e5 + 22;
const double eps = 1e-10;

int n, m;
bool vis[25][25];
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};

bool _ok(int i, int j) {
	return (i >= 0 && i < n && j >= 0 && j < m);
}
int _bfs(vector< string> &v, int i, int j) {
	if(!_ok(i, j)) return 0;
	if(vis[i][j] || v[i][j] == '#') return 0;
	queue< pair< ii, int>> q;
	q.push({{i, j}, 0});
	int res = 0;
	while(!q.empty()) {
		auto tp = q.front();
		q.pop();
		int x = tp.F.F, y = tp.F.S, dis = tp.S;
		if(!_ok(x, y)) continue;
		if(vis[x][y] || v[x][y] == '#') continue;
		res = max(res, dis);
		vis[x][y] = 1;
		fr(k, 0, 4) q.push({{x + dx[k], y + dy[k]}, dis + 1});
	}
	//cout << res << '\n';
	return res;
}
void _solve() {
	cin >> n >> m;
	vector< string> v(n);
	fr(i, 0, n) cin >> v[i];
	int ans = 0;
	fr(i, 0, n) {
		fr(j, 0, m) {
			memset(vis, 0, sizeof vis);
			ans = max(ans, _bfs(v, i, j));
		}
	}
	cout << ans;
}

int main() {
    fastio;
    //t_times
    _solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
#include <cmath>
#include <cstring>
#include <numeric>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <complex>
#include <list>
#include <cassert>
#include <deque>

#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}

using namespace std;
using ll = long long;

/*
struct UnionFind {
    // union tree
    // used for tracking a set of elements partitioned into a number of disjoint subsets
    // rankなしでの実装

    vector<int> par;
    // par[i] means i's parent
    // (ex) par[3] = 2 means 2 is a parent of 3

    UnionFind(int N) : par(N) {
      //used for initialization
      for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
      // データxが属する木の根を再帰で得る
      // root(x) = {xの木の根}
      if (par[x] == x) return x;
      return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
      // xとyのtreeのmerge
      int rx = root(x); //xの根をrx
      int ry = root(y); //yの根をry
      if (rx == ry) return; //同じ時はそのままに
      par[rx] = ry; //xの根rxをyの根ryにつける
    }

    bool same(int x, int y) {
      // 2つのデータx, yが属する木が同じならtrueを返す
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
    }
};

template<typename T>
struct SegTree {
  //segment tree

  //木は配列で表現
  vector<T> seg;
  //木の1/2の大きさ
  int size;
  //単位元
  const T unit;
  //比較関数の型
  using F = function<T(T,T)>;
  //mergeする関数
  const F f;

  //単位元がaで大きさnのsegtreeの初期化を行う
  //大きさnとはすなわち葉の数がnであることをいう
  SegTree(int n, const T a, const F f) : unit(a), f(f) {
    size = 1;
    while(size < n) size <<= 1;
    seg.assign(2*size, unit);
    size--;
  }

  //k番目にtを代入する
  void set(int k, const T& t) {
    seg[k + size] = t;
  }

  //関数fによって木を構築する
  void build(){
    for (int i = size - 1; i >=0; i--){
      seg[i] = f(seg[i*2+1],seg[i*2+2]);
    }
  }

  //i番目の要素を返す
  T operator[](const int i){
    return seg[i + size];
  }

  //k番目の値をaに更新する
  void update(int k, T a){
    k = k + size;
    //必要ならばここを変えても良い
    seg[k] = a;
    //自分の親の情報を再帰的に更新していく
    while(k>0){
      k = ((k-1) >> 1);
      seg[k] = f(seg[k*2+1],seg[k*2+2]);
    }
  }

  //[a,b)についてfをした結果を返す
  //例えば、fがminだったらどうなるかを考えるとわかりやすい
  //unitについては足し算なら0,掛け算なら1,minならinf,どんな値が来てもその値を返すもの
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return unit;
    } else if (a <= l && r <= b) {
      return seg[k];
    } else {
      T lch = query(a, b, k * 2 + 1, l, (l + r) / 2);
      T rch = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return f(lch, rch);
    }
  }
  T query(int a, int b) { return query(a, b, 0, 0, size+1); }
};
*/

/* --- ここからコード --- */


int N;

void dfs(string s, char maxc){
  if(s.length() == N){
    cout << s << endl;
    return ;
  }
  else{
    for(char c = 'a'; c <= maxc+1; c++){
      string t = s + c;
      dfs(t,max(maxc,c));
    }
    return;
  }
}

int main(){
  cin >> N;
  dfs("a",'a');
  return 0;
}

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

class Dice{
public:
  int face[6];
  Dice(){}

  void roll_x(){ roll(0,3,5,2);}
  void roll_y(){ roll(0,1,5,4);}
  void roll_z(){ roll(1,2,4,3);}
  void roll(int i, int j, int k, int l){
    int t = face[i]; face[i] = face[j]; face[j] = face[k]; face[k] = face[l]; face[l] = t;
  }

  void move(char ch){
    if (ch == 'S'){
      for(int i = 0; i < 3; i++) roll_y();
    }
    else if (ch == 'W'){
      for(int i = 0; i < 3; i++) roll_x();
    }
    else if (ch == 'N'){
      roll_y();
    }
    else if (ch == 'E'){
      roll_x();
    }
  }
};

int main(){
  Dice d1;
  for(int i = 0; i < 6; i++){
    cin >> d1.face[i];
  }

  int q, up, front;
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> up >> front;

    for(int j = 0; j < 6; j++){
      for(int k = 0; k < 4; k++){
        if( d1.face[0] == up && d1.face[1] == front) break;
        d1.roll_z();
      }

      if( d1.face[0] == up && d1.face[1] == front) break;
      if (j == 2) d1.roll_y();
      else d1.roll_x();
    }

  cout << d1.face[2] << endl;
  }

  return 0;
}

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

int main(int argc, char *argv[]) {
	int x, y;
	scanf("%d%d", &x, &y);
	if(x == 2 && y == 2){
		printf("Yes\n");
	}
	else if((x==1 || x == 3 || x==5|| x == 7 || x == 8 || x == 10 || x == 12) && (y==1 || y == 3 || y==5||y == 7 || y == 8 || y == 10 || y == 12)){
		printf("Yes\n");
	}
	else if((x == 4 || x == 6|| x == 9 || x == 11) && (y == 4 || y == 6|| y == 9 || y == 11)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    V<V<ll>> a(26);
    ll ns=s.size();
    ll nt=t.size();
    rep(i,ns)a[s[i]-'a'].push_back(i);
    ll ans=0;
    bool ok=1;
    ll pos=-1;//0-indexed
    ll cnt=0;
    rep(i,nt){
        if(a[t[i]-'a'].empty()){
            ok=0;
            break;
        }
        ll m=t[i]-'a';
        ll cur=ub(a[m].begin(),a[m].end(),pos)-a[m].begin();
        if(cur==a[m].size()){
            cnt++;
            ans=cnt*ns+a[m][0]+1;
            pos=a[m][0];
        }else{
            ans=cnt*ns+a[m][cur]+1;
            pos=a[m][cur];
        }
    }
    if(ok)cout<<ans<<endl;
    else cout<<-1<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 4612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int l = scanner.nextInt();
//		double result = 0;
//		for(int i = 1; i <= l-2; i++){
//			for(int j = l-i-1; j >= 1; j--){
//				int k = l - i - j;
//				result = Math.max(result, i*j*k);
////				System.out.println(i+","+j+","+k+" : " + result);
//			}
//		}
		double rrr = 0d;
		double a = 0.1d;
		while(a <= l - 0.2d){
			double b = l - a;
			while(b > 0){
				double c = l - a - b;
				rrr = Math.max(rrr, a * b * c);
				b -= 0.1d;
			}
			a += 0.1d;
		}
		float ll = l;

		System.out.println(ll/3*(ll/3)*(ll/3));
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <map>
#define debug(x) std::cerr << #x << " = " << (x) << std::endl 

using namespace std;
typedef long long LL;

typedef long long LL;
typedef pair<int, int>PII;
const int maxn = 1e5 + 10;
const int inf = 1e9 + 10;
LL d, ans, G;
int vis[15];

struct point{
	LL x, c, i;
	LL pos;
}num[15];

bool cmp(point a, point b)
{
	if(a.pos == b.pos) return a.x < b.x;
	return a.pos > b.pos;
}
void Dfs(LL x)
{
	if(G <= 0)
	{
		if(x) ans = min(ans, x);
		return;
	}
	for(int i = 1; i <= d; i++)
	{
		if(!vis[num[i].i])
		{
			LL ind = G / (num[i].i * 100);
			if(G % num[i].i) ind++;
			vis[num[i].i] = 1;
			G -= num[i].pos;
			Dfs(x + min(ind, num[i].x));
			vis[num[i].i] = 0;
			G += num[i].pos;
		}
	}
}
int main()
{
	scanf("%lld%lld", &d, &G);
	for(int i = 1; i <= d; i++)
	{
		scanf("%lld%lld", &num[i].x, &num[i].c);
		num[i].pos = num[i].x * 100 * i + num[i].c;
		num[i].i = i;
	}
	ans = inf;
	memset(vis, 0, sizeof(vis));
	Dfs(0);
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
    int n,d;
    cin >> n >> d;
    double dist=0;
    int count=0;
    vector<vector<double>> x(n, vector<double>(d));
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x.at(i).at(j);
        }
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            for(int k=0; k<d; k++){
                dist+=pow(x.at(i).at(k)-x.at(j).at(k),2);
            }
            for(int k=1; k<201; k++){
                if(dist==k*k){
                    count++;
//                    cout << dist << endl;
                }
                if(dist<=k*k) break;
            }
            dist=0;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3768
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	class MyTuple<T, U>
	{
		public T Item1;
		public U Item2;

		public MyTuple(T item1, U item2)
		{
			Item1 = item1;
			Item2 = item2;
		}
	}

	static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(new char[] {' '});
		int n = int.Parse(firstLine[0]);
		int q = int.Parse(firstLine[1]);

		// 入力の取得
		Queue<MyTuple<string, int>> queue = new Queue<MyTuple<string, int>>();
		for (int i = 0; i < n; i++)
		{
			string[] line = Console.ReadLine().Split(new char[] {' '});
			queue.Enqueue(new MyTuple<string, int>(line[0], int.Parse(line[1])));
		}

		int time = 0;

		while (queue.Count > 0)
		{
			MyTuple<string, int> tuple = queue.Dequeue();
			tuple.Item2 -= q;
			time  = time + q;
			if (tuple.Item2 > 0)
			{
				queue.Enqueue(tuple);
			}
			else
			{
				time += tuple.Item2;
				System.Console.WriteLine(tuple.Item1 + " " + time);
			}
		}
	}
}



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

int main() {
	char a[51][51], b[51][51];
	int n, m;
	bool flag = false;
	cin >> n >> m;
	if(n<m){
		cout << "No" << endl;
		return 0;
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin >> a[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			cin >> b[i][j];
		}
	}
	for(int i=0;i<n-m+1;i++){
		for(int j=0;j<n-m+1;j++){
			int tmp_i = i;
			int tmp_j = j;
			int cnt = 0;
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(a[tmp_i][tmp_j] == b[k][l]){
						cnt++;
					}
					tmp_j++;
				}
				tmp_i++;
				tmp_j = j;
			}
			if(cnt == m*m){
				flag = true;
			}
		}
	}
	if(flag == true){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		String[] strArray;
        int a, b;
        String op;

		while(true) {
			strArray = br.readLine().split(" ");
	        a = Integer.parseInt(strArray[0]);
	        b = Integer.parseInt(strArray[2]);
	        op = strArray[1];

	        if(op.equals("?")) {
	        	break;
	        }

	        switch(op) {
	        case "+":
	        	sb.append(a+b + "\n");
	        	break;
	        case "-":
	        	sb.append(a-b + "\n");
	        	break;
	        case "*":
	        	sb.append(a*b + "\n");
	        	break;
	        case "/":
	        	if(a==0) {
	        		sb.append("0" + "\n");
	        		break;
	        		}
	        	sb.append(a/b + "\n");
	        	break;
	        }
		}
        System.out.print(sb);
	}
}

Measured memory_bytes: 24356
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long t=0,i=0,j=0,N,M;
  double sum=0;
  string ans="No";

  cin >> N >> M;
  vector<int> A(N);
  for ( i = 0; i < N; i++)
  {
    cin >> A[i];
    sum=sum+A[i];
  }
  sum=sum/(4*M);
  i=0;
  
  while (j<M&&i<N)
  {
    if (A[i]>=sum)
    {
      j++;
    }
    if (j==M)
    {
      ans="Yes";
    }
    i++;
  }
  
  cout << ans << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
# [] = list(map(int, input().split()))

[x, k, d] = list(map(int, input().split()))
x = abs(x)
howMany = x // d
remainder = x % d
stepLeft = k - howMany
if k < howMany:
    print(abs(x) - k * d)
elif stepLeft % 2 == 0:
    print(remainder)
elif stepLeft % 2 == 1:
    print(abs(d - remainder))


Measured memory_bytes: 9180
'use strict'

const main = (input) => {
    input = input.split('\n').map(v => parseInt(v))
    const N = input[0]
    const K = input[1]
    const X = input[2]
    const Y = input[3]
    if(N <= K){
        console.log(N * X)
    }else{
        const over = N - K
        console.log(K * X + Y * over)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
const int maxn = 100050;

int a, b, c, d, ans;

int main()
{
	cin >> a >> b >> c >> d;
	fo(i,0,100)
		if(a<i&&i<=b&&c<i&&i<=d) ++ ans;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u64,
    }
    if let Some(v) = (1..n).take_while(|x| x * x <= n).filter(|x| n % x == 0).map(|x| x + n / x - 2).min() {
        println!("{}", v);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
char s[N];int n,cnt[210];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	long long ans=1ll*n*(n+1)/2+1;
	for (int i=1;i<=n;i++) cnt[s[i]-'a']++;
	for (int i=0;i<26;i++) ans-=1ll*cnt[i]*(cnt[i]+1)/2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        int[] l1 = {c/1000, (c/100)%10, (c/10)%10, c%10};
        String[] l2 = {"+", "-"};
        for(int i = 0;i < 2;i++){
            for(int j = 0;j < 2;j++){
                for(int k = 0;k < 2;k++){
                    int a = l1[0];
                    if(i == 0)  a += l1[1];
                    else    a -= l1[1];
                    if(j == 0)  a += l1[2];
                    else    a -= l1[2];
                    if(k == 0)  a += l1[3];
                    else    a -= l1[3];
                    if(a == 7){
                        System.out.println(l1[0]+l2[i]+l1[1]+l2[j]+l1[2]+l2[k]+l1[3]+"=7");
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    vector<ll> l(n);
    rep2(i, n) cin(l[i]);

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

    ll result = 0;
    rep2(i, n) {
        rep3(j, i + 1, n) {
            if (l[i] == l[j]) continue;

            rep3(k, j + 1, n) {
                if (l[j] == l[k]) continue;
                if (l[i] + l[j] <= l[k]) break;

                ++result;
            }
        }
    }

    print(result);
    return 0;
}

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

int main() {
	ios** sync_with_stdio(false);
	cin.tie(0);
	long long s;
	cin >> s;
	const long v = (long long)1e9;
	int x = (v - s % v) % v;
	int y = (s + x) / v;

	cout << "0 0 1000000000 1 " << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n,k=map(int,input().split())
ans = [0]*n
for _ in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for x in a:
        ans[x-1] += 1
cnt = 0
for i in range(n):
    if ans[i] == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 67732
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

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

    int pos = 0, ans = 1;
    for (int i = 0; i < N; ++i) {
        int L;
        cin >> L;
        pos += L;
        if (pos <= X) ++ans;
    }

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


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

#define ll long long

int q;
ll a[100001];
map<ll, ll> mp;

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

	cin >> a[0] >> q;
	for(int i=1; i<=q; ++i)
		cin >> a[i];
	mp[a[q]]=1;
	for(int i=q-1; ~i; --i) {
		auto it=mp.end();
		while((--it)->first>a[i]) {
			mp[a[i]]+=it->first/a[i]*it->second;
			mp[it->first%a[i]]+=it->second;
			it=mp.erase(it);
		}
	}
	for(int i=a[0]; i; --i)
		mp[i-1]+=mp[i];
	for(int i=1; i<=a[0]; ++i)
		cout << mp[i] << "\n";
}

Measured memory_bytes: 8704
th = 0.00001

ans :: [Float] -> String
ans (x1:y1:x2:y2:x3:y3:x4:y4:_)
  | y2 == y1  = if y4 == y3 then "YES" else "NO"
  | x4 == x3  = if x2 == x1 then "YES" else "NO"
  | otherwise = if (y2-y1) / (x2-x1) == (y4-y3) / (x4-x3)
                then "YES"
                else "NO"

main = do
  c <- getContents
  let i = map (map read) $ map words $ drop 1 $ lines c :: [[Float]]
      o = map ans i
  mapM_ putStrLn o

Measured memory_bytes: 4300
from math import sqrt
N,D = list(map(int, input().split()))
P = []
for i in range(N):
  P.append( list(map(int, input().split())) )
  
def dist(a,b):
  ret = 0
  for i in range(D):
    ret += (a[i] - b[i]) ** 2
  return ret

ans = 0
for i in range(N):
  for j in range(i+1,N):
    work = sqrt(dist(P[i], P[j]))
    if abs(int(work) - work) < 1e-11:
      ans += 1
      
print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;


class Process{
	
	private String name;
	private int time;
	public Process(String name,int time){
		this.name = name;
		this.time = time;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getTime() {
		return time;
	}
	public void setTime(int time) {
		this.time = time;
	}
	
	
}

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p = sc.nextInt();
		
		ArrayList<Process> ar = new ArrayList<Process>();
		ArrayList<Process> result = new ArrayList<Process>();
		
		for (int i = 0; i < n; i++) {
			ar.add(new Process(sc.next(),sc.nextInt()));
		}
		
		int totalTime=0,i=0;
		Process process;
		while(true){
			if(i<n){
				if((process=ar.get(i)).getTime()<=p){
					totalTime += process.getTime();
					result.add(new Process(process.getName(), totalTime));
					ar.remove(i);
					n--;
				}
				else{
					totalTime += p;
					int temp =ar.get(i).getTime()-p;
					ar.get(i).setTime(temp);
					i++;
				}
			}
			else{
				i=0;
			}
			if(ar.size()==0){
				break;
			}
		}
		
		for(Process rProcess:result){
			System.out.println(rProcess.getName()+ " "+rProcess.getTime());
		}
		
	}
	
}

Measured memory_bytes: 68604
#include <bits/stdc++.h>
#define N 1003
using namespace std;
const int Mod = 1e9 + 7;

int n, m, f[N][N];
char s[N][N];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        scanf("%s", s[i] + 1);
    f[1][1] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            if (s[i][j] == '#' || (i == 1 && j == 1)) continue;
            f[i][j] = 0;
            if (i - 1 > 0) f[i][j] = (f[i][j] + f[i - 1][j]) % Mod;
            if (j - 1 > 0) f[i][j] = (f[i][j] + f[i][j - 1]) % Mod;
        }
    cout << f[n][m] << endl;
    return 0;
}


Measured memory_bytes: 5120
from collections import defaultdict

N, M = [int(x) for x in input().split()]
a = []

for _ in range(M):
    a.append(int(input()))

MOD = 1000000007

dict = defaultdict(int)

for i in range(M):
    if i >= 1 and a[i] - a[i - 1] == 1:
        print("0")
        exit()

dict[0] = 1
a_s = set(a)
for i in range(N):
    if not i in a_s:
        dict[i + 1] += dict[i]
        dict[i + 2] += dict[i]


print(dict[N] % MOD)




Measured memory_bytes: 471528
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[55];

void Main() {
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  double cur = (a[0] + a[1]) * 0.5;
  for(int i = 2; i < n; i++) {
    cur = (cur + a[i]) * 0.5;
  }
  cout << fixed << setprecision(10) << cur << "\n";
}


Measured memory_bytes: 256
import fractions

n,x = map(int,input().split())

L = list(map(int,input().split()))
y = []
for i in range(n):
  y.append(abs(L[i]-x))
tmp = y[0]

for i in range(n-1):
  tmp = fractions.gcd(tmp,y[i+1])
print(tmp)

Measured memory_bytes: 16244
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    ll H,ans=0;
    cin>>H;
    cout<<ll(pow(2,ll(log2(H))+1))-1;
}

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

int main() {
    long N, i, sign = 1, num, min = __LONG_MAX__;
    cin >> N;
    vector<long> A(N);

    for(i = 0; i < N; i++) {
        cin >> num;
        if(num < 0) sign = sign * -1;
        A[i] = abs(num);
        if(A[i] < min) min = A[i];
    }

    long sum = 0;
    for(i=0; i<N; i++) sum = sum + A[i];

    (sign==1) ? cout << sum : cout << sum - min * 2;
    cout << endl;
}


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


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


    vector<int> dp(N, 0);  // dp[i]: minimum cost to reach i
    dp[1] = abs( h[1] - h[0] );
    for( int i = 2; i < N; ++i ){
        dp[i] = min( abs(h[i] - h[i-2]) + dp[i-2], abs(h[i] - h[i-1]) + dp[i-1] );
    }
    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

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

  vi x(n);
  int max_num = 0;
  rep(i, n) {
    cin >> x[i];
    max_num = max(max_num, x[i]);
  }

  int ans = -1;

  rep_s(i, 1, max_num + 1) {
    int _ans = 0;
    rep(j, n) {
      _ans += (x[j] - i) * (x[j] - i);
    }
    if (ans == -1) {
      ans = _ans;
    } else {
      ans = min(ans, _ans);
    }
  }

  cout << ans << endl;
}


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

string f(long long n){
  if(n == 0) return "";
  n--;
  return f(n/26) + string(1, 'a' + n%26);
}

int main(){
  long long n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define inf 99999999
using namespace std;
typedef double db;
typedef long long ll;
string s;
int main()
{
	cin>>s;
	if(s[0]==s[s.size()-1])
		if(s.size()&1)
			cout<<"Second"<<endl;
		else
			cout<<"First"<<endl; 
	else
		if(s.size()&1)
			cout<<"First"<<endl;
		else
			cout<<"Second"<<endl;
	return 0;
}



Measured memory_bytes: 512
using System;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var S = Console.ReadLine();
            if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3])
            {
                Console.WriteLine("Bad");
            }
            else
            {
                Console.WriteLine("Good");
            }
        }
    }
}


Measured memory_bytes: 13140