akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;

vector<bool> IsPrime;
void sieve(ll max){
  if(max + 1 > IsPrime.size()){     // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for(ll i = 2; i * i <= max; ++i) {     // 0からsqrt(max)まで調べる
    if(IsPrime[i]) {                     // iが素数ならば
      for(ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は
        IsPrime[i * j] = false;          // 素数ではない
      }
    }
  }
}

int main(){
  int n;
  cin >> n;
  sieve(n + 1);
  vector<int> a(n + 1, 0);
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= i; j++){
      if(i % j == 0 && IsPrime[j]){
        int tmp = i;
        while(tmp % j == 0){
          a[j]++;
          tmp /= j;
        }
      }
    }
  }
  int four = 0, two = 0, sf = 0, tf = 0,fo = 0, one = 0;
  for(int i = 1; i <= n; i++) {
    //cout << a[i] << " ";
    if(a[i] >= 74){
      sf++;
    }
    if(a[i] >= 24) {
      tf++;
    }
    if(a[i] >= 14) {
      fo++;
    }
    if(a[i] >= 4) {
      four++;
    }
    if(a[i] >= 2) {
      two++;
    }
    if(a[i] >= 1){
      one++;
    }
  }
  /*
  cout << endl;
  cout << one << " " << two << " " << four << " " << fo << " ";
  cout << tf << " " << sf << endl;
  */
  if(four <= 1 || two == 0) {
    cout << 0 << endl;
  } else {
    int ans = (two - four) * (four - 1) * four/ 2;   // 5 5 3
    ans += four * (four - 1) * (four - 2) / 2;       // 5 5 5
    ans += fo * (four - 1);            // 15 5
    ans += tf * (two - 1);             // 25 3
    ans += sf;         //75
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
int main(){
  long long int N,D,count,i,dis;
  count=0;
  scanf("%lld %lld",&N,&D);
  long long int X[N+1],Y[N+1];
  for(i=0;i<N;i++){
    scanf("%lld %lld",&X[i],&Y[i]);
    dis=(X[i]*X[i])+(Y[i]*Y[i]);
    if(dis<=D*D) count++;
  }
  printf("%lld",count);
  return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
using namespace std;
	
    string cadena;
    bool N,S,E,W;
    int sum;

int main() {
    cin>>cadena;

    for(int i=0;i<cadena.size();i++)
    {
        switch(cadena[i])
        {
            case 'N':
                if(N == false)
                {
                    N = true;
                    sum +=1;
                }
            break;
            case 'W':
                if(W == false)
                {
                    W = true;
                    sum +=5;
                }
            break;
            case 'S':
                if(S == false)
                {
                    S = true;
                    sum -=1;
                }
            break;
            case 'E':
                if(E == false)
                {
                    E = true;
                    sum -=5;
                }
            break;
        }
    }

    if( sum == 0){
        cout<<"Yes"<<endl;
    } else 
    {
        cout<<"No"<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define scani(i) scanf("%d", &(i))
#define scanc(c) scanf("%c", &(c))
#define scand(d) scanf("%lf", &(d))

#define printi(i) printf("%d\n", (i))

#define NUM (100)

int main(int argc, char** argv){
    int i, j, x;
    scani(x);

    rep(i, 10){
        rep(j, 10){
            if(i * j == x){
                printf("Yes\n");
                return 0;
            }
        }
    }

    printf("No\n");

    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int ans;
bool check(int x){
    int dig=0;
    while(x>0){
        dig++;
        x/=10;
    }
    return dig%2;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        if(check(i))
            ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double db;

#define ft first
#define sd second
#define flag bool fl=true

#define mod 1000000007
#define N 100001
#define MX 1000000001
#define MXX 1000000000000000001

#define pb push_back
#define For(i, a, b) for(int i=a;i<=b;i++)
#define T int t, qq=0; cin>>t; while(qq++<t)
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define scarr(array, size) for(int i=0;i<size;i++) cin>>array[i]

#define deg(rad) (rad*180.0)/pi
#define pi acos(-1)
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)


/*
//----------useful_functions----------

long long extended_euclid(ll a, ll b, ll &x, ll &y){//ax+by=c
    if(b==0)
    {
        x=1, y=0;
        return a;
    }

    ll x1, y1;
    ll d=extended_euclid(b, a%b, x1, y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
long long bigMod(ll a, ll b){//(a^b)%mod
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans%mod;
}
long long modInverse(ll a, ll b){//a*x=1 mod b
    ll x, y;
    ll gcd=extended_euclid(a, b, x, y);

    if(gcd==1) return ((x%b)+b)%b;
    else return 1;
}
long long nCr(ll n, ll r){//n<=1e6
    //declare globally-> ll fact[1000001];
    fact[1]=1;
    for(ll i=2;i<1000001;i++)
        fact[i]=(i*fact[i-1])%mod;

    return (fact[n]*modInverse(fact[r], mod)*modInverse(fact[n-r], mod))%mod;
}
long long josephus(ll n, ll k){//k'th person is killed out of n in the circle
    if(n==1) return 1;
    else return (josephus(n-1, k)+k-1)%n+1;
}

vector<int> sieve(ll n){
    bool fl[n+1];
    vector<int> primes;
    for(int i=0;i<=n;i++) fl[i]=false;

    for(int i=3;i*i<=n;i+=2)
        for(int j=i+i;j<=n;j+=i)
            fl[j]=true;

    primes.pb(2);
    for(int i=3;i<=n;i+=2) if(!fl[i]) primes.pb(i);
    return primes;
}
*/

int main()
{
    db w, h, x, y;
    cin>>w>>h>>x>>y;

    cout<<setprecision(10)<<fixed<<(w*h)/2;
    if(x==w/2 && y==h/2) cout<<" 1";
    else cout<<" 0";

//        cout<<"Case "<<qq<<": ";
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(){
 ll arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 ll a;
 cin>>a;
        cout<<arr[a-1]<<endl;

    }


Measured memory_bytes: 256
//2?????¢?´¢????????£????§£????????????????????????????????§??????
#include<cstdio>
#include<iostream>

using namespace std;

int gcd(int m, int n)
{
	if ((0 == m) || (0 == n))
		return 1;
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}




int main(void) {

	while (1) {

		int floor, n, book[102] = { 0 };
		cin >> floor >> n;

		if (floor == 0)return 0;

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

		//?????§??¬?´???°????±???????
		int m = book[0];
		int w_avr = book[0];
		for (int i = 1; i < n; i++) {
			m = gcd(m, book[i]);
			w_avr += book[i];
		}
		//?????????????????§?????¬??????????????????????????°??§?????£?????°??????????????¬????????§?????????
		int ans = w_avr / floor;

		for (int i = 0; i < n; i++) {
			if (ans < book[i]) {
				ans = book[i];
			}
		}
		while (ans%m != 0) {
			ans=ans-1;
		}
		while (1) {
			int count = floor;
			int length = ans;
			int i = 0;
			while (count != 0 && i < n) {
				if (length >= book[i]) {
					length -= book[i];
					i++;
				}
				else {
					length = ans;
					count = count - 1;
				}
			}
			if (count != 0) {
				break;
			}
			ans += m;
		}
		cout << ans << endl;

	}
}

Measured memory_bytes: 1160
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	printf("%d",min(x*y,z));
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);

    REP(i, N)
    cin >> a[i];

    int max_i = max_element(ALL(a)) - a.begin();
    int min_i = min_element(ALL(a)) - a.begin();

    vector<pair<int, int>> ops;

    if (abs(a[max_i]) >= abs(a[min_i])) {
        REP(i, N)
        ops.emplace_back(max_i, i);

        for (int i = 1; i < N; i++) ops.emplace_back(i - 1, i);
    } else {
        REP(i, N)
        ops.emplace_back(min_i, i);

        for (int i = N - 1; i != 0; i--) {
            ops.emplace_back(i, i - 1);
        }
    }

    cout << ops.size() << endl;

    REP(i, ops.size()) {
        //        a[ops[i].second] += a[ops[i].first];
        cout << ops[i].first + 1 << " " << ops[i].second + 1 << endl;
    }

    //    REP(i, N)
    //    cout << a[i] << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = list(map(int, input().split()))
ans = 0

i = 0
while i < n - 2:
  j = i + 1
  while j < n - 1:
    k = j + 1
    while k < n:
      d = ls[i] + ls[j] + ls[k]
      mx = max(ls[i], max(ls[j], ls[k]))
      if ls[i] == ls[j] or ls[j] == ls[k] or ls[k] == ls[i]:
        k += 1
        continue
      if mx < d - mx:
        ans += 1
        # print(ls[i], ls[j], ls[k])
      k += 1
    j += 1
  i += 1

print(ans)

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

const int N=100100;
vector<int>g[N];
int n;
int dfs(int x,int fa=-1){
	int ret=0;
	for(int i:g[x])if(i!=fa){
		ret+=dfs(i,x);
		if(ret==2){
			cout<<"First\n";
			exit(0);
		}
	}
	return !ret;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cout<<(dfs(1)?"First\n":"Second\n");
	return 0;
}


Measured memory_bytes: 5888
#include<iostream>
#include<string>
using namespace std;
int main()
{

    int a,b,c,x;
    cin >> a >> b >> c >> x;

    int i,j,k,count;
    count = 0;

    for (i = 0; i*500 <= x && i<=a; i++){
        for (j = 0; i*500+j*100<= x && j<=b;j++){
            for(k = 0; i*500+j*100+k*50 <=x && k<=c;k++){
                if(i*500+j*100+k*50 == x) count++;
            }
        }
    }
 
    cout << count;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int e[n][n];
  memset(e,0,sizeof(e));
  for(int i=0,u,k;i<n;i++){
    cin>>u>>k;
    for(int j=0,v;j<k;j++){
      cin>>v;
      e[u-1][v-1]=1;
    }
  }
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cout<<e[i][j]<<" \n"[j==n-1];
  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int flag = 0;
    srep(i,1,10){
        srep(j,1,10){
            if(i * j == n)flag = 1;
        }
    }
    if(flag)yn;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,k,p;
    double exvalue,exvalsum[200001];
    int i,j;

    scanf("%d %d",&n,&k);
    exvalsum[0] = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d",&p);
        exvalue = (double)(1 + p) / 2;
        exvalsum[i + 1] = exvalsum[i] + exvalue;
    }

    double max = 0;
    for (i = 0; i < n + 1 - k; i++)
    {
        if(max < exvalsum[k + i] - exvalsum[i])max = exvalsum[k + i] - exvalsum[i];
    }

    printf("%lf",max);
}

Measured memory_bytes: 1664
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int cnt = 0;
        for(int i =0; i*r<=n; i++){
            for(int j=0; i*r+j*g<=n; j++){
                int all = n -  i*r - j*g;
                if(all%b==0) cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,m;
  cin>>n;
  int t[n],tsum=0;
  rep(i,n){
    cin>>t[i];
    tsum+=t[i];
  }
  cin>>m;
  int p[m][2];
  rep(i,m){
    cin>>p[i][0]>>p[i][1];
  }
  rep(i,m){
    cout<<tsum-t[p[i][0]-1]+p[i][1]<<endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;


int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if ((b-a)%2==0){
        cout << min(min((b-a)/2,b-1),min(b-1,n-a)) << endl;
    }else{
        cout << min(min(b-1,n-a),min(a+(b-a-1)/2-1,n-b+(b-a-1)/2)+1) << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
#define PIB pair<int,bool>
typedef long long ll;
using namespace std;
const int maxn=1e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=1e9;
const double ep=1e-10;
int main()
{
	char s[maxn];
	scanf("%s",s+1);
	if(s[3]==s[4]&&s[5]==s[6])puts("Yes");
	else puts("No");
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		@SuppressWarnings("unused")
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();

		int max = 0;
		int x = 0;
		for (char c : s) {
			if (c == 'I') {
				x++;
			} else {
				x--;
			}

			max = Math.max(max, x);
		}

		pr.println(max);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9800
#include <bits/stdc++.h>
 
using namespace std;
#define LL long long
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int qq = 2e5 + 10;
char st[105];
int cnt = 0;
int n;
deque<char>	Q;
queue<char> t;
 
int main(){
	scanf("%d", &n);
	scanf("%s", st + 1);
	int p = 0;
	REP(i, 1, n){
		if(st[i] == ')'){
			if((int)t.size() == 0){
				Q.push_front('(');
				Q.push_back(')');
			}
			else{
				p++;
				t.push(')');
			}
		}
		if(st[i] == '('){
			t.push('(');
		}
		int x = (int)t.size();
		if(x == 0 || p == 0)	continue;
		if(x - p == p){
			while(!t.empty())	Q.push_back(t.front()), t.pop();
			p = 0;
		}
	}
	int cnt = (int)t.size() - p;
	cnt = cnt - p;
	while(!t.empty()){
		Q.push_back(t.front());
		t.pop();
	}
	while(cnt--){
		Q.push_back(')');
	}
	deque<char>::iterator it;
	for(it = Q.begin(); it != Q.end(); ++it){
		printf("%c", *it);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    bool dp[100007][2];
    memset(dp,false,sizeof(dp));
    int n,k;
    cin>>n>>k;
    VII arr(n);
    for(auto &x:arr)
    {
        cin>>x;
        dp[x][0]=dp[x][1]=true;
    }
    for(int i=0;i<=k;++i)
    {
        for(auto x:arr)
        {
            if(i-x>0)
            {
                dp[i][0]|=(!dp[i-x][1]);
                dp[i][1]|=(!dp[i-x][0]);
            }
        }
    }
    if(dp[k][0])
    cout<<"First";
    else
    cout<<"Second";

    return 0;
}

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

int main(){
  int N;cin>>N;
  int A[N];
  int B[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[A[i]-1]=i+1;
  }
  for(int i=0;i<N;i++){
    cout<<B[i]<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1536
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

"""
・二部グラフが必要
・最長の最短距離 + 1 で上からbound
・2部グラフならbfs木が満たすのでよい
"""

N = int(readline())
S = np.frombuffer(read(),'S1').reshape(N,-1)[:,:N].astype(np.int64)

graph = csgraph_from_dense(S)

dist_mat = floyd_warshall(graph).astype(np.int32)

max_d = dist_mat.max()

# 二部グラフの判定
A = np.where(dist_mat[0]%2 == 0)
B = np.where(dist_mat[0]%2 == 1)
bl = (S[A][:,A] == 0).all() and (S[B][:,B] == 0).all()

answer = max_d + 1 if bl else -1
print(answer)

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

int main(void){
   long long A,B,C,X,Y;
   cin>>A>>B>>C>>X>>Y;
   long long result1=A*X+B*Y;
   long long result2=C*2*max(X,Y);
   long long temp=min(X,Y);
   X=X-temp;
   Y=Y-temp;
   long long result3=C*2*temp+A*X+B*Y;
   cout<<min(result1,min(result2,result3))<<endl;
   return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int d[500];
int main()
{
	string s;
	cin >> s;
	if (s.size() < 26)
	{
		for (int i = 0; i < s.size(); i++)d[s[i]]++;
		for (char c = 'a'; c <= 'z'; c++)
		{
			if (d[c] == 0)
			{
				s.push_back(c);
				break;
			}
		}
		cout << s << endl;
	}
	else
	{
		if (s == "zyxwvutsrqponmlkjihgfedcba")printf("-1\n");
		else
		{
			for (int i = s.size() - 1; i >= 1; i--)
			{
				d[s[i]]++;
				if (s[i - 1] < s[i])
				{
					string r;
					for (int j = 0; j <= i - 2; j++)r.push_back(s[j]);
					for (char c = s[i - 1] + 1; c <= 'z'; c++)
					{
						if (d[c] == 1)
						{
							r.push_back(c);
							break;
						}
					}
					cout << r << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 384
import math


def f(n):
    r = dict()
    while n != 1:
        for i in range(2, n+1):
            while n % i == 0:
                r[i] = r.get(i, 0) + 1
                n //= i
    return r


def main():
    N = int(input())
    ds = []
    for i in range(2, N+1):
        x = f(i)
        ds.append(x)
    # print(ds)

    d = {}
    for di in ds:
        for k in di.keys():
            v = di.get(k)
            # print(k, d)
            d[k] = d.get(k, 0) + v

    ans = 1
    for v in d.values():
        ans *= v + 1
        ans = ans % (10 ** 9 + 7)
    print(ans)



if __name__ == "__main__":
    main()

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

ans = 0
if N == 1:
    print(ans)
else:
    tmp_max = A[0]
    for a in A[1:]:
        if a < tmp_max:
            ans += tmp_max-a
        else:
            tmp_max = a

    print(ans)


Measured memory_bytes: 105076
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    a += (x - a % x) % x;
    b -= b % x;
    if (a <= b)
        cout << (b - a) / x + 1 << endl;
    else 
        cout << "0" << endl;

    return 0;
}


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

    public class Program
    {
        public static void Main(string[] args)
        {
            new A().test();
        }
    }

	public class A
	{
		public void test()
		{
			// スペース区切りの整数の入力
			var input = CommonRead.ReadInt();

			// 2*半径*円周率
			Console.WriteLine(2 * input * Math.PI);

		}
	}

static class CommonRead
{
    public static string ReadStr()
    {
        return Console.ReadLine();
    }
    public static string[] ReadStrA()
    {
        return ReadStr().Split(' ');
    }
    public static List<string> ReadStrL()
    {
        return ReadStrA().ToList();
    }
    public static int ReadInt()
    {
        return Convert.ToInt32(ReadStr());
    }
    public static int[] ReadIntA()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntL()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
    }
    public static long ReadLong()
    {
        return Convert.ToInt64(ReadStr());
    }
    public static long[] ReadLongA()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
    }
    public static List<long> ReadLongL()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
    }

    public static decimal ReadDecimal()
    {
        return Convert.ToDecimal(ReadStr());
    }
    public static decimal[] ReadDecimalA()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
    }
    public static List<decimal> ReadDecimalL()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
    }

    public static double ReadDouble()
    {
        return Convert.ToDouble(ReadStr());
    }
    public static double[] ReadDoubleA()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
    }
    public static List<double> ReadDoubleL()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
    }

}


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

int main(){
    int a,b;
    cin >> a >> b;
    if (a >= 13){
        cout << b << endl;
    }else if(a <= 5){
        cout << 0 << endl;
    }else{
        cout << b/2 << endl;
    }
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;

int n,q;
int br[200005];
int bsum[200005];
pi R[200005];
vector<int> Rend[200005];


int dp[200005];
int count0(int l,int r){
  return r-l-(bsum[r]-bsum[l]);
}
struct segtree{
  int val[800005];
  int n;
  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    REP(i,n*2) val[i]=INF;
  }
  void set(int k,int a){
    a+=count0(k,::n);
    k+=n-1;
    chmin(val[k],a);
    while(k>0){
      k=(k-1)/2;
      chmin(val[k],a);
    }
  }
  int query(int a,int b,int i,int l,int r){
    if(a<=l && r<=b) return val[i];
    if(b<=l || r<=a) return INF;
    int md=(l+r)>>1;
    return min(query(a,b,i*2+1,l,md),query(a,b,i*2+2,md,r));
  }
  int query(int l,int k){
    int res=query(l,k+1,0,0,n);
    return res-count0(k,::n);
  }
};


segtree seg;
int main(){
  cin>>n;
  REP(i,n){
    scanf("%d",&br[i]);
    bsum[i+1]=br[i]+bsum[i];
  }
  cin>>q;
  REP(i,q){
    scanf("%d%d",&R[i].fr,&R[i].sc);
    --R[i].fr;
    Rend[R[i].fr].pb(R[i].sc);
  }
  seg.init(n);
  REP(i,n+1) dp[i]=INF;

  dp[0]=0;
  seg.set(0,0);
  REP(i,n+1){
    for(auto r:Rend[i]){
      int tmp=seg.query(i,r);
      int val=min(dp[i]+count0(i,r),tmp);
      chmin(dp[r],val);
      seg.set(r,val);
    }
    chmin(dp[i+1],dp[i]+(br[i]));
  }
  cout<<dp[n]<<endl;
  return 0;
}





Measured memory_bytes: 15872
from heapq import heappop,heappush,heapify
n,m=map(int,input().split())
A=list(map(int,input().split()))
A_m=list(map(lambda x: -x,A))
heapify(A_m)
pop=lambda: -heappop(A_m)
push=lambda x: heappush(A_m,-x)
for _ in range(m):
    x=pop()
    push(x//2)
print(-sum(A_m))

Measured memory_bytes: 14180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int a, b, h, ans;

  cin >> a >> b >> h;

  ans = (a + b) * h / 2;

  cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll two = 0;
    rep(i, n) {
        while (a[i] % 2 == 0) {
            two++;
            a[i] /= 2;
        }
    }

    cout << two << "\n";
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<set>
using namespace std;

typedef long long ll;

const int NIL = -1;
const int MAX = 2147483647;
const int INF = -10001;
const int N = 1000001;
clock_t START, END;
bool debug = false;

int setv[N];

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in18.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int n, K, i, _size = MAX;
	set<int> S;
	queue<int> Q;
	scanf("%d%d", &n, &K);
	vector<int> V(K + 1);
	for (i = 0; i < n; i++)
		scanf("%d", &setv[i]);
	i = 0;
	V[0] = 1;
	Q.push(setv[0]);
	if (setv[0] >= 1 && setv[0] <= K) {
		V[setv[0]]++;
	}
	while (i < n) {
		if (find(V.begin(), V.end(), 0) == V.end()) {
			_size = min(_size, static_cast<int>(Q.size()));
			if (Q.front() >= 1 && Q.front() <= K) {
				V[Q.front()]--;
			}
			Q.pop();
		}
		else {
			i++;
			Q.push(setv[i]);
			if (setv[i] >= 1 && setv[i] <= K) {
				V[setv[i]]++;
			}
		}
	}
	if (_size == MAX)
		printf("0\n");
	else
		printf("%d\n", _size);
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


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

int main(){
  int N;
  double S;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  	cin >> A[i];
    S+=(double)1/A[i];
  }
  cout << (double)1/S << endl;
}


Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let w: usize = s.trim().parse().unwrap();
    let mut dp = vec![false; w + 1];
    dp[0] = true;
    for a in 0..6 {
        let b = 100 + a;
        for i in b..(w + 1) {
            dp[i] |= dp[i - b];
        }
    }
    let ans = if dp[w] {1} else {0};
    println!("{}", ans);
}

fn main() {
    run();
}

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

const int N = 4e5 + 5, Mod = 1e9 + 7;
#define ll long long

ll fac[N], inv[N];

ll Power(ll p, ll q) {
	ll cur = 1;
	while (q) {
		if (q & 1) cur = cur * p % Mod;
		p = p * p % Mod;
		q >>= 1;
	}
	return cur;
}

void Pre() {
	fac[0] = 1; for (int i = 1; i <= N - 10; ++ i) fac[i] = fac[i - 1] * i % Mod;
	inv[N - 10] = Power(fac[N - 10], Mod - 2);
	for (int i = N - 11; i >= 0; -- i) inv[i] = inv[i + 1] * (i + 1) % Mod;
}

ll Calc(int x, int y) {
	return fac[x] * inv[y] % Mod * inv[x - y] % Mod;
}

const int M = 2e6 + 10;

int n, a[M], b[M], dp[5000][5000];

int main(void) {
	Pre();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		scanf("%d%d", &a[i], &b[i]);
		dp[2001 - a[i]][2001 - b[i]] ++;
	}
	for (int i = 1; i <= 4001; ++ i) {
		for (int j = 1; j <= 4001; ++ j) {
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % Mod;
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % Mod;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++ i) ans = (ans + dp[2001 + a[i]][2001 + b[i]]) % Mod;
	for (int i = 1; i <= n; ++ i) ans = (ans - Calc(a[i] * 2 + b[i] * 2, a[i] + a[i]) + Mod) % Mod;
	printf("%lld\n", ans * Power(2, Mod - 2) % Mod);
	return 0;
}

Measured memory_bytes: 93184
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  _, move = map(int, input().split())
  remains = [(i, v) for i, v in enumerate(map(int, input().split()))]
  remains.sort(key=lambda x:x[1])

  lasts = [remains[0][0]]
  remains = [(i, v - 1) for i, v in remains]

  for _ in range(move):
    remains.sort(key=lambda x:x[1])

    if remains[0][0] == lasts[-1]:
      lasts.append(remains[1][0])
    else:
      lasts.append(remains[0][0])

    remains = [(i, v - 1 if i != lasts[-2] else v) for i, v in remains]

  remains.sort(key=lambda x:x[1])

  if remains[0][1] < 0:
    print('-1', flush=True)
    return

  opens = []
  last = -1

  for i in range(len(lasts)):
    opens.extend(j for j in range(len(remains)) if j != lasts[i] and j != last)
    opens.append(lasts[i])
    last = lasts[i]

  print(len(opens), flush=True)
  print(' '.join(str(v + 1) for v in opens), flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const ll INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 7;
const int maxm = 1e5 + 7;
const int mod = 192600817;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
map<int,int>num;
int a[maxn];
int main()
{
    IO;
    int n;
    cin>>n;
    for (int i=1;i<=n;++i)
    {
        cin>>a[i];
        num[i-a[i]]++;
    }
    ll ans=0;
    for (int i=1;i<=n;++i)
    {
        ans+=num[i+a[i]];
    }
    cout<<ans<<endl;
    return 0;
}

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

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

return 0;
}


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

ll ans = 0;
void rec(int i, int n, ll sum, ll tmp, string S){
    if(i == n-1){
        ans += sum + (S[i] - '0') + tmp * 10;
    }
    else{
        rec(i + 1, n, sum + (S[i] - '0') + tmp * 10, 0, S);
        rec(i + 1, n, sum, 10 * tmp + (S[i] - '0'),  S);
    }
}

int main(){
    string S;
    cin >> S;
    int n = S.size();
    rec(0, n, 0, 0, S);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const ll INF=1e18;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    ll ans=0;
    for(int i=0;i<n-3;i++)
    {
        map<char,int> c;

        for(int j=i+1;j<n;j++)
        {
            if(s[i]=='R')
            {
                if(s[j]=='G' && j-i>2)
                {
                    ans+=c['B'];
                    if((j-i)%2==0 && s[(i+j)/2]=='B')
                    {
                        ans--;
                    }
                    
                }
                else if(s[j]=='B' && j-i>2)
                {
                    ans+=c['G'];
                    if((j-i)%2==0 && s[(i+j)/2]=='G')
                    {
                        ans--;
                    }
                    
                }

            }
            else if(s[i]=='G')
            {
                if(s[j]=='R' && j-i>2)
                {
                    ans+=c['B'];
                    if((j-i)%2==0 && s[(i+j)/2]=='B')
                    {
                        ans--;
                    }
                    
                }
                else if(s[j]=='B' && j-i>2)
                {
                    ans+=c['R'];
                    if((j-i)%2==0 && s[(i+j)/2]=='R')
                    {
                        ans--;
                    }
                    
                }
                
            }
            else
            {
                if(s[j]=='G' && j-i>2)
                {
                    ans+=c['R'];
                    if((j-i)%2==0 && s[(i+j)/2]=='R')
                    {
                        ans--;
                    }
                    
                }
                else if(s[j]=='R' && j-i>2)
                {
                    ans+=c['G'];
                    if((j-i)%2==0 && s[(i+j)/2]=='G')
                    {
                        ans--;
                    }
                    
                }
                
            }
            c[s[j]]++;
            
            
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3632
n = int(input())
lst = list(map(int, input().split()))

cnt = 0
for i in range(n):
	for j in range(i+1, n):
		for k in range(j+1, n):
			if lst[i] != lst[k] and lst[i] != lst[j] and lst[j] != lst[k] and lst[i] + lst[j] > lst[k] and lst[i] + lst[k] > lst[j] and lst[j] + lst[k] > lst[i]:
				cnt += 1
print(cnt)

Measured memory_bytes: 9108
N = int(input())
T = [int(input()) for i in range(N)]

def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def lcm(a, b):
  return(a*b//gcd(a,b))

t = T[0]
for i in range(N-1):
   t = lcm(t,T[i+1])
print(t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 200005

ll i=0,j=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll n;
    cin>>n;
    ll arr[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[2]);
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<dp[n]<<endl;
}



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

using namespace std;

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    vector<int> f(m, 0);
    for (int i = 0; i < n; i++)
    {
        int k;
        scanf("%d", &k);
        for (int j = 0; j < k; j++)
        {
            int a;
            scanf("%d", &a);
            f[a - 1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        if (f[i] == n)
            ans++;
    }

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

    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,Q;
  cin >> n >> Q;
  atcoder::dsu d(n);
  while(Q--){
    int T;cin >> T;
    int u,v;cin >> u >> v;
    if(!T){
      d.merge(u,v);
    }else{
      cout << d.same(u,v) << "\n";
    }
  }

  


  return 0;
}

Measured memory_bytes: 4044
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    if 0 in A:
        return print(0)
    prod = 1
    for n in A:
        prod *= n
        if prod > 1000000000000000000:
            return print(-1)
    return print(prod)

main()

Measured memory_bytes: 21484
#include<iostream>
using namespace std;
int main(){
    int H,W;
    
    while(1){
    cin>>H>>W;
    if(H ==0 && W ==0)break;
for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
        if((i+j)%2==0){
            cout<<"#";
        }else{
            cout<<".";
        }
    }
    cout<<"\n";
}
cout<<endl;
    }
    return 0;
    }


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

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << #x << ": " << (x) << " (L" << __LINE__ << ")" << endl;
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

void setmin(int& a, int b) {
  if (a > b) a = b;
}

const int INF = 1000000;

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> grid(H);
  REP(i, H) cin >> grid[i];

  vector<vector<int>> dp(H + 1, vector<int>(W + 1, INF));
  dp[1][1] = grid[0][0] == '.' ? 0 : 1;

  int dr[] = {-1, 0};
  int dc[] = {0, -1};
  REP(r, H) REP(c, W) REP(dir, 2) {
    int pr = r + dr[dir];
    int pc = c + dc[dir];
    if (dp[pr + 1][pc + 1] == INF) continue;
    int changed = grid[r][c] != grid[pr][pc];
    setmin(dp[r + 1][c + 1], dp[pr + 1][pc + 1] + changed);
  }
  DBG(dp[H][W]);
  cout << (dp[H][W] + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int k;
    string s;
    cin >> k >> s;
    if ((int)(s.length()) > k)
    {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    }
    else
    {
        cout << s;
    }

    return 0;
}

Measured memory_bytes: 3628
S = input()

former = int(S[:2])
latter = int(S[2:])

if 1 <= former <= 12 and 1 <= latter <= 12:
    print('AMBIGUOUS')
elif 1 <= former <= 12:
    print('MMYY')
elif 1 <= latter <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,q;
vector <pair <int,pair <int,int> > > a;
multiset <int> s;

int main()
{
    scanf("%d %d", &n, &q);
    int t,ss,x;
    for(int i = 1;i <= n;i++)
    {
        scanf("%d %d %d", &ss, &t, &x);
        a.push_back({ss-x,{1,x}});
        a.push_back({t-x,{-1,x}});
    }
    int i = 0;
    sort(a.begin(),a.end());
    while(q--)
    {
        int d;
        scanf("%d",&d);
        while(a[i].first <= d&&i < a.size())
        {
            if(a[i].second.first == 1)
            {
                s.insert(a[i].second.second);
            }
            else
            {
                s.erase(a[i].second.second);
            }
            i++;
        }
        if(s.size() > 0) printf("%d\n",*s.begin());
        else printf("-1\n");
    }
}

#endif // 1++


Measured memory_bytes: 15596
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;

int main(){
    long int N;cin>>N;
    long int ans = 0;
    REP(i, N){
        long int a;cin >> a;
        FOR(j, 1, 31){
            if(a % (long int)pow(2, j) != 0L){
                ans += j-1;
                break;
            }
        }
    }

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

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

int sum_digit( int n ){
  int wa = 0;
  while( n > 0 ){
    wa += n%10;
    n /= 10;
  }
  return wa;
}
    
int main(){
  int a, b, n, sum, min = 1000;
  cin >> n;
  
  for( a = 1; a <= n/2; a++ ){
    b = n-a;
    sum = sum_digit(a) + sum_digit(b);
//	cout << a << " " << b << " " << sum << endl;
    if( sum < min ){
      min = sum;
    }
  }
  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
object Main extends App {
	import scala.math._

	val n = scala.io.StdIn.readInt
	val a1 = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val a2 = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	var ans = 0

	if(n==1) ans = a1.sum + a2.sum

	for(i<-1 until n){
		ans = max(ans, a1.dropRight(n-i).sum + a2.drop(i-1).sum)
	}

	println(ans)
}


Measured memory_bytes: 26152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll X;
    cin >> X;

    for(int i = -200; i <= 200; i++) {
        for(int j = -200; j <= 200; j++) {
            if (binpow(i, 5)-binpow(j, 5) == X) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3568
# frozen_string_literal: true

A, B, N = gets.chomp.split.map(&:to_i)

max_num = if (B - 1) <= N
            (B - 1) * A / B
          else
            (A * N / B.to_f).floor - A * (N / B.to_f).floor
          end

puts max_num

Measured memory_bytes: 14260
def resolve():
    N = int(input())

    # そのnode配下で条件を満たす値のパターン数を返す
    def rec(svalue, maximum):
        add = 0
        if svalue != "":
            if int(svalue) <= maximum: 
                if ('7' in svalue and '5' in svalue and '3' in svalue):
                    add = 1
            else:
                return 0

        
        sevens = rec(svalue + '7', maximum)
        fives = rec(svalue + '5', maximum)
        threes = rec(svalue + '3', maximum)
        return sevens + fives + threes + add
    
    print(rec("", N))
        

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


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

    int a,b,c,d;
    cin >> a>> b >> c >> d;
    while(1){
        c-=b;
        if(c<=0) {
            cout << "Yes" << endl;
            break;
        }
        a-=d;
        if(a<=0) {
            cout << "No" << endl;
            break;
        }
    }

}
 

Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

ll p, n;
ll x, y, v, u;

void SternBrocot(ll pl = 0, ll ql = 1, ll pr = 1, ll qr = 0)
{
    ll pm = pl + pr, qm = ql + qr;
    if (pm > n || qm > n)
        return;
    if (p * (qm * qm) < pm * pm)
    {
        x = pm;
        y = qm;
        SternBrocot(pl, ql, pm, qm);
    }
    else if (p * (qm * qm) > pm * pm)
    {
        u = pm;
        v = qm;
        SternBrocot(pm, qm, pr, qr);
    }
    else
    {
    }
}

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

    while (cin >> p >> n, p || n)
    {
        SternBrocot();
        cout << x << "/" << y << " " << u << "/" << v << endl;
    }
}



Measured memory_bytes: 3020
s = input()
t = input()


ss = []

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] == t[j] or s[i+j]== '?':
            if j == len(t)-1:
                sss = s[:i]+t+s[i+j+1:]
                sss = sss.replace('?', 'a')
                ss.append(sss)
        else:
            break

ss.sort()

print('UNRESTORABLE' if ss==[] else ss[0])


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

int main(){
	int k,x; cin >> k >> x;
	ll mn = x-k+1;
	ll mx = x+k-1;
	FOR(i,mn, mx) cout << i << ' ';
    return 0;
}


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

using namespace std;

#define int long long

const double pi = 3.1415926536;

void solve() {
    int n;
    cin >> n;
    cout.precision(10);
    cout << (2 * pi) * n;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3808