akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); i++)
typedef pair<int, int> P;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    vector<ll> a(n+5);
    rep(i,n){
        cin >> a[i+1];
    }
    vector<ll> b(n+5);


    while(n>0){

        for(ll i = n; i > n/2; i--){
            if(i == 0) break;
            ll tmp = 0;
            for(ll j = 1; j*i <= N; j++){
                tmp += b[j*i];
            }
            if(tmp%2 == a[i]){
                b[i] = 0;
            }else{
                b[i] = 1;
            }
        }
        n /= 2;
        
    }

    ll ans = 0;

    rep(i,N){
        ans += b[i+1];
    }
    if(ans==0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
        rep(i,N){
            if(b[i+1]==1){
                cout << i + 1 << " ";
            }
        }
        cout << endl;
    }
    return 0;
}  


Measured memory_bytes: 3968
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,ans=1,tp=0;
  cin >> n;
  vector<ll> c(n);
  for(int i=0;i<n;i++){
    cin >> c[i];
    if(i!=0){
      ans *= 4;
      ans %= MOD;
    }
  }
  sort(c.begin(),c.end(),greater<ll>());
  for(int i=0;i<n;i++){
    tp += ((i+2)*(c[i]))%MOD;
    tp%=MOD;
  }
  cout << (ans*tp)%MOD<<endl;
}


Measured memory_bytes: 1792
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S;
int main() {
	cin>>S;

	for(int i=0;i<S.size();i++){
		if(i%2==0)cout<<S[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int a,b,c;cin>>a>>b>>c;
    int cnt=0;
    while(1){
        if(a%2==0&&(a==b&&b==c&&c==a)){co(-1);return 0;}
        if(a%2==1||b%2==1||c%2==1){co(cnt);return 0;}
        int aa=a/2,bb=b/2,cc=c/2;
        a = bb+cc;
        b = aa+cc;
        c = aa+bb;
        cnt++;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Date;
import java.math.BigDecimal;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	double  a,b,c,d,e,f,x,y;
	while(sc.hasNext()){
	    a=sc.nextDouble();	   
	    b=sc.nextDouble();
	    c=sc.nextDouble();
	    d=sc.nextDouble();
	    e=sc.nextDouble();
	    f=sc.nextDouble();
	    x=(c*e-b*f)/(a*e-d*b);
	    if(b!=0) y= (c-a*x)/b;
	    else y=(f-d*x)/e;
 BigDecimal bi = new BigDecimal(String.valueOf(x));
 BigDecimal bi2 = new BigDecimal(String.valueOf(y));
 double x3= bi.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
 double y3= bi2.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
	    System.out.printf("%.3f %.3f\n",x3+0,y3+0);
	}
    }
}

Measured memory_bytes: 12000
//wa&ac
#include<stdio.h>
#define N 5005
typedef long long ll;
int to[N][40];
ll sum[N][40],dp[N][40]; //dp[i][j]:i节点走2^j步得到的最大分 
#define mx(a,b) ((a)>(b)?(a):(b))
int main()
{
	int n,i,j,now,nex;
	ll k,ans=-1000000009,cnt,tot,packup;
	scanf("%d%lld",&n,&k);
	for(i=1;i<=n;++i)
		scanf("%d",to[i]);
	for(i=1;i<=n;++i)
		scanf("%lld",sum[i]);
	for(i=1;i<=n;++i)
		dp[i][0]=sum[i][0];
	for(i=0;i<33;++i)
	{
		for(j=1;j<=n;++j)
		{
			nex=to[j][i];
			to[j][i+1]=to[nex][i];
			sum[j][i+1]=sum[j][i]+sum[nex][i];
			dp[j][i+1]=mx(dp[j][i],sum[j][i]+dp[nex][i]);
		}
	}
	packup=k;
	for(i=1;i<=n;++i)
	{
		cnt=-1000000009;
		now=i;
		tot=0;
		for(j=0;k>0;++j)
		{
			if(k&1)
				ans=mx(ans,mx(dp[i][j],tot+dp[now][j])),tot+=sum[now][j],now=to[now][j];
			k/=2;
		}
		k=packup;
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

int main() {

	int n;
	scanf("%d", &n);
	
	int v[n];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	int cont = 0, mayor = 0;
	for (int i = 1; i < n; i++) {
		if(v[i] <= v[i-1]) {
			cont++;
		} else {
			cont = 0;
		}
		if(cont > mayor)
			mayor = cont;
	}
 	
	cout << mayor << endl;
	
	return 0;
}

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

int n; 
int w[310];
int memo[310][310];

int dfs(int l, int r){ 
  
  if( memo[l][r] != -1 ){ return memo[l][r];}
 
  int len = r-l+1;
  if( len <= 2 ){ 
    if( len == 1 ){ return 0;}
    if( len == 2 ){ 
      if(abs(w[l]-w[r]) <= 1 ){ return 2;}
      else{ return 0;}
    }
  }
  
  int val = 0;
  
  int judge = r-l-1;
  if( judge == dfs(l+1,r-1) && abs(w[l]-w[r]) <= 1 ){ val = r-l+1;}
  //この範囲は全部取り除ける
  else{
    //全部は取り除けない→左右に分割可能(必ず融合しないため)
    for(int k = l; k < r; k++){
      val = max(val, dfs(l,k)+dfs(k+1,r));
    }
    
  }
    
  return memo[l][r] = val;
}

signed main(void){ 
 while(cin>>n){
   
   if( n == 0 ){ return 0;}
   
   for(int i = 0; i < n; i++){ cin >> w[i];}
   
   for(int i = 0; i < 310; i++){
     for(int j = 0; j < 310; j++){
       memo[i][j] = -1;
     }
   }
   
   cout << dfs(0,n-1) << endl;
   
 }
  
  return 0;
}
     


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;


int main() {
  int a, b;
  cin >> a >> b;

  cout << (a-1) * (b-1) << endl;

  return 0;
}


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

int main(){
    
    int N, origN; cin >> N; origN = N;
    vector<int> div;
    for(int d = 2; d * d <= N; d++){
        if(N % d == 0){
            div.push_back(d);
            while(N % d == 0) N /= d;
        }
    }

    if(N != 1) div.push_back(N);

    int M = (int)div.size();
    int ans = 0;
    /*for(int i = 0; i < M; i++){
        cout << div[i] << endl;
    }*/

    for(int bit = 1; bit < (1 << M); bit++){
        int popcnt = __builtin_popcount(bit);
        int mul = 1;
        for(int i = 0; i < M; i++){
            if(bit & (1 << i)) mul *= div[i];
        }
        
        if(popcnt % 2 == 1) ans += origN / mul;
        else ans -= origN / mul; 
    }

    ans = origN - ans;
    cout << ans << endl;
    return 0;    
}


Measured memory_bytes: 3168
from queue import Queue
q = Queue()

k = int(input())

for i in range(9):
  q.put(i+1)
for _ in range(k-1):
    x = q.get()
    mod = x%10
    
    if x%10 != 0:
      q.put(10*x + mod - 1)
      
    q.put(10*x + mod)
    
    if x%10 != 9:
      q.put(10*x + mod + 1)
      
print(q.get())

Measured memory_bytes: 12476
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int gcd(int a, int b) {
    while (b != 0) {
        int c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ll n, lx;
    ll x[100010];
    cin >> n >> lx;
    imfor(i, n) {
        cin >> x[i];
    }
    ll tmp = abs(lx - x[0]);
    for (ll i = 1; i < n; i++) {
        tmp = gcd(tmp, abs(lx - x[i]));
    }
    cout << tmp << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans=0;
    for(int i=0; i<=a; i++) {
        for(int j=0; j<=b; j++) {
            for(int k=0; k<=c; k++) {
                if(i*500 + j*100 + k*50 == x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 #include <string.h>
 #define mxz 2e5+10
 char a[(int)mxz], b[(int)mxz];
  
 int main(void) {
 	int d = 0;
  
 	scanf("%s", a);
 	scanf("%s", b);
  	
  	int n=strlen(a);

 	if(strcmp(a, b) != 0){
 		for(int c = 0; c < n; c++){
 			if(a[c] != b[c]){
 				a[c] = b[c];
 				d++;
 			}
 		}
 		printf("%d", d);
 	}else{
 		printf("0");
 	}
  
 	return 0;
 }

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;

int main() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int N;
    int res = 100;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) {
        int cnt = 0;
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            cnt++;
        }
        res = min(res, cnt);
    }

    cout << res << endl;
}

Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>

using namespace std;

typedef pair<int, int> pii;
string S;

void solve() {
	cin >> S;
	int m = 0;
	for (int s = 0; s < S.size(); s++) {
		for (int e = s; e < S.size(); e++) {
			bool flag = true;
			for (int i = s; i <= e; i++) {
				if (S[i] != 'A' && S[i] != 'G' && S[i] != 'C' && S[i] != 'T') {
					flag = false;
					break;
				}
			}
			if (flag)m = max(m, e - s + 1);
		}
	}
	cout << m << endl;
	return;
}


Measured memory_bytes: 256
from collections import deque

s = deque(input(""))
Q = int(input())
c = 0

for i in range(Q):
    t = input("")
    if len(t) == 1:
        c += 1
    elif t[2] == "1":
        if c % 2 == 0:
            s.appendleft(t[4])
        else:
            s.append((t[4]))
    else:
        if c % 2 == 0:
            s.append(t[4])
        else:
            s.appendleft(t[4])

if c % 2 == 0:
    for i in s:
        print(i,end="")
else:
    for i in range(len(s)-1,-1,-1):
        print(s[i],end="")



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

vector < string > v;
long long A, B, C, K;
string s;
int main(){
	cin >> s>>K;
	for (int i = 0; i < s.size(); i++){
		for (int j = 1; j <= K; j++){
			v.push_back(s.substr(i, j));
		}
	}
	sort(v.begin(), v.end());
	unique(v.begin(), v.end());

	cout << v[K - 1] << endl;
	return 0;
}


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

int main(){
  long n;
  cin >> n;
  long mod = INF;
  long ans = 0;
  if(n<3){
    cout << 0;
    return 0;
  }
  long dp[700][n+10];
  rep(i,700)rep(j,n+10)dp[i][j] = 0;
  for(int i=3;i<=n;i++)dp[0][i] = 1;
  rep(i,690){
    long tmp = 0;
    for(int k=3;k<=n-3;k++){
      tmp += dp[i][k];
      tmp %= mod;
    }
    rep(j,n-2){
      dp[i+1][n-j] += tmp;
      dp[i+1][n-j] %= mod;
      tmp -= dp[i][n-3-j];
      if(tmp < 0)tmp += mod;
    }
  }
  rep(i,690){
    ans += dp[i][n];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14432
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 1;

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

  int32_t R,C,K;
  cin >> R >> C >> K;
  vector<vector<int64_t>> V(R+1, vector<int64_t> (C+1, 0));
  for (int i = 0; i < K; i++) {
    int r,c;
    cin >> r >> c;
    cin >> V[r][c];
  }


  vector<vector<vector<int64_t>>> dp(R+1, vector<vector<int64_t>> (C+1, vector<int64_t>(4, 0)));
  //int64_t dp[R+1][C+1][4] = {};
  for (int r = 1; r <= R; r++) {
    for (int c = 1; c <= C; c++) {

      // from left
      for (int nc = 0; nc < 4; nc++) {
        dp[r][c][nc] = max(dp[r][c][nc], dp[r][c-1][nc]);
        if (V[r][c] != 0 && nc != 0) {
          dp[r][c][nc] = max(dp[r][c][nc], dp[r][c-1][nc-1] + V[r][c]);
        }
      }

      // from top
      for (int np = 0; np < 4; np++) {
        dp[r][c][0] = max(dp[r][c][0], dp[r-1][c][np]);
        if (V[r][c] != 0) {
          dp[r][c][1] = max(dp[r][c][1], dp[r-1][c][np] + V[r][c]);
        }
      }
    }
  }

  int64_t res = 0;
  for (int i = 0; i < 4; i++) {
    res = max(res, dp[R][C][i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 707184
import bisect
n, x = map(int, input().split())
l = [int(i) for i in input().split()]
a = [0]
a.append(l[0])
for i in range(0, n - 1):
    a.append(a[i+1] + l[i+1])
ans = bisect.bisect_right(a, x)
print(ans)

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

const int _mx = 2e6;
int a[_mx+5];

int main() {
    // freopen("in.txt", "r", stdin);

    string s;
    LLI a, b, n, ans;
    stack <LLI> st;
    while (cin >> s) {
        if (s[0] == '+') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a + b);
        }
        else if (s[0] == '-') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(b - a);
        }
        else if (s[0] == '*') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a * b);
        }
        else {
            n = s[0] - '0';
            for (int j = 1; j < s.size(); j++) n = n * 10 + (s[j] - '0');
            st.push(n);
        }
    }
    cout << st.top() << endl;

    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define eb push_back
#define mp make_pair
#define hello cout<<"hello"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define it(s)	for(auto itr:s)
#define dvg(s) 	for(auto itr:s)	cout<<itr<<" ";cout<<endl;
#define dbg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;
typedef unsigned long long int ulli;
const int INF=INT_MAX;
const ulli MOD=1e9+7;


	

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout.precision(30);
	
	
	int n;cin>>n;
	vector<lli> v(n,0);
	forr(i,0,n)
	{
		cin>>v[i];
	}
	vector<lli> dp(n,0);
	
	dp[1]=abs(v[1]-v[0]);
	
	forr(i,2,n)
	{
		dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	
	cout<<dp[n-1]<<"\n";

		
	return 0;
	
}













Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ans=max(0,min(b,d)-max(a,c));
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

void dump(const vector<int> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

void dump2D(const vector<int> &v, int w, int h)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

int main()
{
	int r, c;
	cin >> r >> c;

	VI A((r+1) * (c+1));

	REP(j, r){
		REP(i, c){
			cin >> A[j * (c+1) + i];
		}
	}

	REP(i, c){
		int sum = 0;
		REP(j, r){
			sum += A[j * (c+1) + i];
		}
		A[r * (c+1) + i] = sum;
	}

	REP(j, r+1){
		int sum = 0;
		REP(i, c){
			sum += A[j * (c+1) + i];
		}
		A[j * (c+1) + c] = sum;
	}

	dump2D(A, c+1, r+1);

	return 0;
}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;


VI v[12];


int main() {

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

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

	VI p(m);
	REP(i, m)cin >> p[i];

	int ans = 0;

	REP(i, (1 << n)) {

		VI a(m, 0);

		REP(j, 11) {
			if (i & (1 << j)) {
				REP(k, m) {
					for (int l : v[k]) {
						if (l == j)a[k]++;
					}
				}
			}
		}

		bool b = true;
		REP(j, m) {
			if (a[j] % 2 != p[j])b = false;
		}

		if (b)ans++;

	}
	cout << ans << endl;
}




Measured memory_bytes: 256
from fractions import gcd


n = int(input())
a = list(map(int, input().split()))

# 累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (gcd(left[i], a[i]))
    right[n - i - 1] = (gcd(right[n - i], a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i + 1]))
print(ans)

Measured memory_bytes: 16136
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
const int maxn = 2000 + 10;
int fac[maxn], invfac[maxn];
void init() {
	int n = maxn - 1;
	fac[0] = 1;
	for (int i = 1; i <= n; ++i)
		fac[i] = 1ll * fac[i - 1] * i % mod;
	invfac[n] = qpow(fac[n], mod - 2);
	for (int i = n - 1; i >= 0; --i) {
		invfac[i] = 1ll * invfac[i + 1] * (i + 1) % mod;
	}
}
LL C(int n, int m) {
	if (n < m) return 0;
	return 1ll * fac[n] * invfac[m] % mod * invfac[n - m] % mod;
}
int main(void)
{
	init();
	int N, K;
	cin >> N >> K;
	for (int i = 1; i <= K; ++i) {
		cout << C(K - 1, i - 1)*C(N - K + 1, i) % mod << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int getDigitNum(int a){
	int k = 0;
	while(a > 0){
		a /= 10;
		k++;
	}
	return k;
}

int main(void){
	int argnum = 0;
	int a = 0;
	int b = 0;
	char c;
	while(1){
		c = getchar();
		if(c == EOF){break;}
		if(c == ' '){
			argnum++;
		}else if(c == '\n'){
			printf("%d\n",getDigitNum(a+b));
			argnum = 0;
			a = 0;
			b = 0;
		}else if(argnum == 0){
			a = a * 10 + (c - '0');
		}else if(argnum == 1){
			b = b * 10 + (c - '0');
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#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
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

vvi adj;
vi dp;

int f(int v)
{
    if(dp[v]!=-1)
    {
        return dp[v];
    }
    else
    {
        // dp[i] = 0;
        int maxi = 0;
        int out_deg = adj[v].size();
        if(out_deg<1) return dp[v] = 0;
        for (int i = 0; i < out_deg; i++)
        {
            int u = adj[v][i];
            maxi = max(maxi,f(u));
        }
        dp[v] = 1+ maxi;
        return dp[v];
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    int n,m;
    cin>>n>>m;
    adj.assign(n+1,vi());
    for (int i = 0; i < m; i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    dp.assign(n+1,-1);// dp[i] = len(longest path starting at vertex i)

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if(dp[i]==-1)
        {
            dp[i] = f(i);
        }
        ans = max(ans,dp[i]);
    }
    cout<<ans<<"\n";


     return 0;
}

Measured memory_bytes: 11088
n = int(input())
result = []
def check(x, y, remnant):
    return x % y == remnant

for i in range(1, n + 1):
    x = i
    if check(x, 3, 0):
        result.append(i)
        continue
    for j in range(len(str(x))):
        if check(x, 10, 3):
            result.append(i)
            break
        x //= 10
print(' ' + ' '.join(map(str, result)))

Measured memory_bytes: 8240
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    # a, b
    k, x = (map(int, input().split()))
    print(process(k, x))


def process(k, x):
    l = max(-1000000, x-(k-1))
    r = min(1000000, x+(k-1))
    result = list(map(str, range(l, r+1)))
    return ' '.join(result)


if __name__ == "__main__":
    main()


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

int my_abs(int x){
    if(x < 0){
        return -x;
    }
    return x;
}

int main() {

    int x1,y1,x2,y2;

    cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4;

    int x_abs = my_abs(x1 - x2);
    int y_abs = my_abs(y1 - y2);

    /*
     *      1
     *    2
     */
    if(x1 >= x2 && y1 >= y2){
        x3 = x2 + y_abs;
        y3 = y2 - x_abs;
        x4 = x1 + y_abs;
        y4 = y1 - x_abs;
    }
    /*
     *
     *   2
     *      1
     */
    else if(x1 >= x2 && y1 <= y2){
        x3 = x2 - y_abs;
        y3 = y2 - x_abs;
        x4 = x1 - y_abs;
        y4 = y1 - x_abs;
    }
    /*
     *
     *   1
     *     2
     */
    else if(x1 <= x2 && y1 >= y2){
        x3 = x2 + y_abs;
        y3 = y2 + x_abs;
        x4 = x1 + y_abs;
        y4 = y1 + x_abs;
    }
    /*
     *
     *    2
     *  1
     */
    else if(x1 <= x2 && y1 <= y2){
        x3 = x2 - y_abs;
        y3 = y2 + x_abs;
        x4 = x1 - y_abs;
        y4 = y1 + x_abs;
    }

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  ll a, b, c, k;
  cin>>a>>b>>c>>k;
  if(k<=a){
    cout<<k<<'\n';
  }
  else if(k<=a+b){
    cout<<a<<'\n';
  }
  else if(k<=a+b+c){
    cout<<a-(k-(a+b))<<'\n';
  }
  else{
    cout<<a-c<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<string.h>
#define ll long long int
#define SP ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main()
{
    SP;
    
    int x;
    int kyu;
    cin>>x;
    
    if(x>=400 && x<600)
    	kyu=8;
    else if(x>=600 && x<800)
    	kyu=7;
    else if(x>=800 && x<1000)
    	kyu=6;
    else if(x>=1000 && x<1200)
    	kyu=5;
    else if(x>=1200 && x<1400)
    	kyu=4;
    else if(x>=1400 && x<1600)
    	kyu=3;
    else if(x>=1600 && x<1800)
    	kyu=2;
    else if(x>=1800 && x<2000)
    	kyu=1;

    cout<<kyu;

	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
	string S;
	cin >> S;

	int x[3000] = {0};
	int out = 1;

	REP(S.length()){
		if(x[(int)S[i]] == 0){
			x[(int)S[i]] = 1;
		}
		else{
			out = 0;
			break;
		}
	}

	if(out == 1){
		cout << "yes" << endl;
	}
	else{
		cout << "no" << endl;
	}


}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

void printv(vector<int> v){
    rep(i,0,v.size())cout<<v[i]<<" ";
    cout<<endl;
}

int main(){
    int v[3];
    rep(i,0,3)cin>>v[i];
    sort(v,v+3);
    cout<<10*v[2]+v[1]+v[0]<<endl;
    
    
    




    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

vector<int> to[2510];
vector<int> rto[2510];
bool reachablefrom1[2510];
bool reachabletoN[2510];
bool ok[2510];

void dfs(int v){
  if(reachablefrom1[v]) return;
  reachablefrom1[v]=1;
  for(int nv:to[v]){
    dfs(nv);
  }
}
void rdfs(int v){
  if(reachabletoN[v]) return;
  reachabletoN[v]=1;
  for(int nv:rto[v]){
    rdfs(nv);
  }
}

int main(){
  int n,m,p;
  cin >> n >> m >> p;
  vector<tiii> edges;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--; b--; c-=p; c=-c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=reachablefrom1[i]&&reachabletoN[i];
  // bellman-ford
  vector<int> dist(n,inf);
  dist[0]=0;
  bool update=true;
  int step=0;
  while(update){
    update=false;
    rep(i,m){
      int a,b,c;
      tie(a,b,c)=edges[i];
      if(!ok[a]||!ok[b]) continue;
      if(dist[a]+c<dist[b]){
        update=true;
        dist[b]=dist[a]+c;
      }
    }
    step++;
    if(step>n){
      cout << -1 << endl;
      return 0;
    }
  }
  int ans=-dist[n-1];
  ans=max(ans,0);
  cout << ans << endl;
}

Measured memory_bytes: 2432
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>

int main() {
	u32 a, b, c;
	::std::cin >> a >> b >> c;
	asmin(c, a + b + 1);
	::std::cout << b + c << ::std::endl;
	return 0;
}


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

int main(){
    int m,d; cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 22; j <= d; j++){
            if((j/10)*(j%10) == i && j/10 >= 2 && j%10 >= 2){
                ans++;
                //cout << i << "月" << j << "日" << endl;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
	/*input*/
	int n;
    cin >> n;
    int l;
	cin >> l;

	/*calc*/
	int ans = 0;
	int taist[200];
	int flag_z=0;
	for(int i = 1; i <= n; i++){
		taist[i] = l + i - 1;
//		cout << taist[i] << " ";
		if(taist[i] == 0){
			flag_z = i;
			continue;
		}
		ans += taist[i];
	}
	if(flag_z != 0){
		cout << ans;
		return 0;
	}

	if(l > 0){
		ans -= taist[1];
	}
	else if(l < 0){
		ans -= taist[n];
	}
	/*output*/
   	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0,-1, 0, 1};
int dx[]={-1,0, 1, 0};
 
struct aaa{
    int maxi;
    int prime;
};
  
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
int hole[1000][1000],m,n;
bool isp[1000001];
aaa memo[1003][1000];
 
aaa search(int y,int x){
    if(memo[y][x].maxi >= 0)
        return memo[y][x];
 
    if((y > 999) || hole[y][x] > m){
        aaa ret;
        memo[y][x].maxi = memo[y][x].prime = 0;
        return memo[y][x];
    }
 
    aaa ret;ret.maxi = ret.prime = 0;
 
    for(int i = x - 1;i < x + 2;i++){
        if(i < 0 || i > 999)
            continue;
 
        aaa b = search(y + 1,i);
        if(b.maxi > ret.maxi || (b.maxi == ret.maxi && b.prime > ret.prime))
            ret = b;
    }
    if(ret.prime == 0 && isp[hole[y][x]])
        ret.prime = hole[y][x];
    ret.maxi += isp[hole[y][x]];
    return memo[y][x] = ret;
}
 
int main(){
    int d = 2;int x = 0;int y = 0;
    RFOR(i,1,1000001){
        hole[y][x] = i;
        if(x + dx[d] < 0 || x + dx[d] > 999  || y + dy[d] < 0 || y + dy[d] > 999 || hole[y + dy[d]][x + dx[d]] > 0){
            d = (d + 1) % 4;
        }
 
        x += dx[d]; y += dy[d];
    }
 
    memset(isp,true,sizeof(isp));isp[1] = false;
    FOR(i,2,10000){
        if(isp[i]){
            for(int j = i * 2;j < 1000001;j += i)
                isp[j] = false;
        }
    }
    while(1){
        scanf("%d%d",&m,&n);
        if(m == 0 && n == 0)
            break;
 
        aaa ans;
        REP(i,1003)
            REP(j,1000)
                memo[i][j].maxi = -1;
 
        REP(i,1000){
            REP(j,1000){
                if(hole[i][j] == n)
                    ans = search(i,j); 
            }
        }
        printf("%d %d\n",ans.maxi,ans.prime);
    }
    return 0;
}

Measured memory_bytes: 16000
from collections import Counter
n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
tmp = a[p-1]
ans = p
l = 0
r = n
if v <= p:
    for i in range(p, n):
        if a[i]+m >= tmp:
            ans += 1
    print(ans)
    exit()
while l<r-1:
    mid = (l+r)//2
    if mid<=p:
        l = mid
        continue
    if a[mid]+m<tmp:
        r = mid
    else:
        thresh = a[mid]+m 
        amari = (v-p)*m
        for i in range(p-1,n):
            if i==mid:
                continue
            amari-=min(m,thresh-a[i])
        if amari<=0:
            l = mid
        else:
            r=mid
print(l+1)

Measured memory_bytes: 62844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
    int n,m;
    cin >> n >> m;
    int pos[n],counter[n];
    for (int i = 0; i < n; i++){
        pos[i] = 0;
        counter[i] = 1;
    }
    pos[0] = 1;
    for (int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        if (pos[x]) pos[y] = true;
        counter[x]--;
        counter[y]++;
        if (!counter[x]) pos[x] = false;
    }
    int num = 0;
    for (int i = 0; i < n; i++) num += pos[i];
    cout << num;
}


Measured memory_bytes: 1024
# coding: utf-8


def solve(*args: str) -> str:
    x = int(args[0])
    dp = [0]*(x+200)
    dp[0] = 1
    for i in range(x):
        if not dp[i]:
            continue

        for k in range(6):
            dp[i+100+k] = 1

    return str(dp[x])


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3828
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];

        int result = sc.nextInt();
        for(int i=1;i<N;i++){
            int big =  sc.nextInt();
            int small = result;
            while(big % small != 0){
                int temp = big;
                big = small;
                small = temp % small;
            }
            result = Math.min(result,small);

        }
        System.out.println(result);

    }
}


Measured memory_bytes: 49784
#include <stdio.h>
#include <stdlib.h>
#define NUM 1000000007 //10^9+7
int main(void){
	int H,W,K;
	scanf("%d%d%d",&H,&W,&K);
	int A[101][8]={0},i,j,k,l;
	A[0][0] = 1;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			for(k=0;k<1<<(W-1);k++){//2^(W-1)通り調べる
				int ok = 1;
				for(l=0;l<W-2;l++){//W-2個調べる
					if(((k>>l)&1) && ((k>>(l+1))&1))ok=0;//(k>>l) = k/(2^l),&1で下1桁だけ見たい
				}
				//隣り合ったものがないパターンの時のを数える
				if(ok){
					if(j>=1 && ((k>>(j-1))&1)){
						A[i+1][j-1] += A[i][j];
						A[i+1][j-1] %= NUM;
					}else if(j<=W-2 && ((k>>j)&1)){
						A[i+1][j+1] += A[i][j];
						A[i+1][j+1] %= NUM;
					}
					else{
						A[i+1][j] += A[i][j];
						A[i+1][j] %= NUM;
					}
				}
			}
		}
	}
	printf("%d",A[H][K-1]);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

x,y,z,a = inpl()
n = inp()
b = min(x*4,y*2,z)
a,b = b,a
# print(a,b)
if n%2==0:
    print(min(b*(n//2),a*n))
else:
    print(min(b*(n//2)+a,a*n))

Measured memory_bytes: 40300
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 201
using namespace std;
typedef long long ll;
const ll INF  = 1000000000000;
ll d[MAX_N][MAX_N];
ll N, M, R;

void warshall_floyd() {
  for(int k = 0; k < N; k++)
    for(int i = 0; i < N; i++) 
      for(int j = 0; j < N; j++) 
	d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

    cin >> N >> M >> R;

    ll r[R];
    for (int i = 0; i < R; i++) cin >> r[i];
    for (int i = 0; i < R; i++) r[i]--;

    for (int i = 0; i < N; i++) fill(d[i], d[i] + N, INF);
    for (int i = 0; i < N; i++) d[i][i] = 0;
    
    ll A, B, C;
    for (int i = 0; i < M; i++) {
      cin >> A >> B >> C;
      A--; B--;
      d[A][B] = C;
      d[B][A] = C;  
    }
    
    warshall_floyd();

    ll ans = INF;
    sort(r, r + R);
    do {
      ll tmp = 0;
      for (int i = 0; i < R-1; i++) tmp += d[ r[i] ][ r[i+1] ];
      ans = min(ans, tmp);
    } while ( next_permutation(r, r + R) );

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


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


void solve(long long N, std::vector<long long> A){
  long long acc = 1;

  if(find(A.begin(), A.end(), 0) != A.end()) {
    cout << 0 << endl;
    return;
  }

  for(long long i = 0; i < N; i++){
    if(acc > 1000000000000000000ll / A[i]) {
      cout << -1 << endl;
      return;
    }

    acc *= A[i];
  }


  cout << acc << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4088
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n;
string s;
int now;
int ans;
int main(){
  cin >> n >> s;
  REP(i,n){
    if(s[i]=='I') now ++;
    else now--;
    ans = max(ans,now);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if(l[i]==l[j]||l[j]==l[k]||l[i]==l[k])continue;
                if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]){
                    ans++;
                }
                
            }
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int n,m;
    	cin>>n>>m;
    	ll sum=0;
    	int x;
    	for(int i=0;i<m;i++)
    	{
    		 
    		cin>>x;
    		sum+=x;
    	}

    	ll hang=n-sum;
    	// deb(hang)
    	if(hang>=0)
    	{
    		cout<<hang<<endl;
    	}
    	else
    	{
    		cout<<-1<<endl;
    	}

    	
    	
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int[][] ab = new int[m][2];
		for(int i = 0; i < m; i++){
		    ab[i][0] = sc.nextInt()-1;
		    ab[i][1] = sc.nextInt()-1;
		}
		int[][] cd = new int[k][2];
		for(int i = 0; i < k; i++){
		    cd[i][0] = sc.nextInt()-1;
		    cd[i][1] = sc.nextInt()-1;
		}
		
		// 計算
		int[] result = new int[n];
		UnionFind uf = new UnionFind(n);
		for(int i = 0; i < m; i++){
		    uf.union(ab[i][0], ab[i][1]);
		    result[ab[i][0]]--;
		    result[ab[i][1]]--;
		}
		for(int i = 0; i < k; i++){
		    if(uf.same(cd[i][0], cd[i][1])){
		        result[cd[i][0]]--;
		        result[cd[i][1]]--;
		    } 
		}
		for(int i = 0; i < n; i++){
		    result[i] += uf.cnt(i)-1;
		}
		/*
		for(int i = 0; i < n; i++){
		    System.out.print(uf.cnt(i) +" ");
		}*/
		//System.out.println("");
		//System.out.println(Arrays.toString(uf.parent));
		//System.out.println(Arrays.toString(uf.rank));
		//System.out.println(Arrays.toString(uf.cnt));
		
		// 出力
		//System.out.println(result);
		for(int i = 0; i < n; i++){
		    System.out.print(result[i] + " ");
		}
	}
}

class UnionFind {
    int[] parent;
    int[] rank;
	int[] cnt;
    
    UnionFind(int n){
        this.parent = new int[n];
        this.rank = new int[n];
        this.cnt = new int[n];
        for(int i = 0; i < n; i++){
            parent[i] = i;
            rank[i] = 0;
            cnt[i] = 1;
        }
    }
    
    public int find(int i){
        if(i == parent[i]) return i;
        parent[i] = find(parent[i]);
        return parent[i];
    }
    
    public void union(int x, int y){
        int xRoot = find(x);
        int yRoot = find(y);
        if(same(x, y)) return;
        if(rank[xRoot] < rank[yRoot]){
            parent[xRoot] = yRoot;
            cnt[yRoot] += cnt[xRoot];
        }else if(rank[xRoot] > rank[yRoot]){
            parent[yRoot] = xRoot;
            cnt[xRoot] += cnt[yRoot];
        }else{
            parent[yRoot] = xRoot;
            rank[xRoot]++;
            cnt[xRoot] += cnt[yRoot];
        }
    }
    
    public boolean same(int x, int y){
        return find(x) == find(y);
    }

    public int cnt(int x){
        return cnt[find(x)];
    }
}


Measured memory_bytes: 127512