akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

int dp[9][(1<<8)]={};
vector<int> v;
int n,m,s;
int d[201][201];
int r[201]={};


int calc(int s1,int d1){
	if(dp[s1][d1]>0)return dp[s1][d1];
	if(d1==(1<<s1))return 0;
	int d2=d1-(1<<s1);
	dp[s1][d1]=200000001;
	for(int i=0;i<s;++i){
		int k=(1<<i);
		if((d2&k)==k)dp[s1][d1]=min(dp[s1][d1],d[r[s1]][r[i]]+calc(i,d2));
	}
	return dp[s1][d1];
}
int main() {
	for(int i=0;i<201;++i){
		for(int j=0;j<201;++j){
			d[i][j]=200000001;
		}
	}
	cin>>n>>m>>s;
	bool flg=true;
	int a,b,c;
	int ct=0;;
	for(int i=0;i<s;++i){
		cin>>r[i];
		ct+=(1<<i);
	}
	for(int i=0;i<m;++i){
		cin>>a>>b>>c;
		d[a][b]=c;
		d[b][a]=c;
	}
	while(flg){
		flg=false;
		for(int i=1;i<n+1;++i){
			for(int j=1;j<n+1;++j){
				for(int k=1;k<n+1;++k){
					if(d[i][j]>(d[i][k]+d[k][j])){
						flg=true;
						d[i][j]=d[i][k]+d[k][j];
					}
				}
			}
		}
	}

	int t=200000001;

	for(int i=0;i<s;++i){
		t=min(t,calc(i,ct));
	}
	cout<<t<<endl;

	return 0;
}


Measured memory_bytes: 384
#n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
x,t = list(map(int,input().split(" ")))
#string = input()
if x - t >= 0:
  print(x - t)
else:
  print(0)

Measured memory_bytes: 2940
A, B, C, X, Y = map(int, input().split())

ans = float("inf")

if X > Y:
    ab = 2 * X
    while ab >= 0:
        a = X - (ab / 2)
        if ab / 2 < Y:
            b = int(Y - ab / 2)
        else:
            b = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
else:
    ab = 2 * Y
    while ab >= 0:
        b = Y - (ab / 2)
        if ab / 2 < X:
            a = int(X - ab / 2)
        else:
            a = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
print(int(ans))


Measured memory_bytes: 69056
n = gets.to_i
a = gets.split.map(&:to_i).sort

x = a[-1]

hv = x/2.0
dmin = 10e9
y = 0
a.each{|t|
  if (t-hv).abs < dmin
    dmin = (t-hv).abs
    y = t
  end
}

puts [x,y]*' '

Measured memory_bytes: 11912
N = int(input())
L=[]
i = 0
s = 0
M2 = 0
a = 0
for i in range (0,N):
    L.append(int(input()))
M = L[0]
for s in range(1,N):
    if  L[s] > M:
        M = L[s]
for s in range(0,N):
    if L[s] == M:
        a += 1
    else:
        if L[s] > M2:
            M2 = L[s]
for i in range(0,N):
    if L[i] == M and a < 2:
        print(M2)
    else:
        print(M)


Measured memory_bytes: 68952
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)
#define all(v) v.begin(), v.end()

using namespace std;
 
ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}
 
int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}
 
ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}
 
ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
 
// bool isprime[100001];
// void makesieve() {
// 	memset(isprime, true, sizeof(isprime));
// 	for (int i = 2; i <= sqrt(200000); ++i)
// 	{
// 		if(isprime[i]) {
// 			for (int j = i*i; j <= 200000; j+=i)
// 			{
// 				isprime[j]=false;
// 			}
// 		}
// 	}
// }
// 
// 1 2 4 5 8
vvll D = {{-1,-1}, {1,1}, {1,-1}, {-1,1}};
void solve() {
	ll l,r,d; cin>>l>>r>>d;
	cout << r/d - (l-1)/d;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int c = 0;
        int total = 0;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            total += a[i];
        }
        for(int i = 0; i < n; i++){
            if((a[i] * 4 * m ) >= total){
                c++;
            }
        }
        System.out.println((c >= m) ? "Yes" : "No");
    }
}

Measured memory_bytes: 36152
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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 upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}


ll pr[1000000]={};
// ll pr2[10000],pma=0;
void makelcm(ll n){
    ll a=0;
    while(n%2==0){
        n/=2;
        a++;
    }
    pr[2]=max2(pr[2],a);
    // printf("%lld ",pr[2]);
    repp(i,3,min2(n,999)+2,2){
        if(n<i) break;
        if(n%i==0){
            a=0;
            while(n%i==0){
                n/=i;
                a++;
            }
            pr[i]=max2(pr[i],a);
        }
    }
    // if(n<=1000){
    //     printf("%lld ",n);
    // }
    if(n>1000){
        // printf("%lld ",n);
        // pr2[pma]=n;
        // pma++;
        pr[n]=1;
    }
}

/*aのb進数時の桁数*/
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
/*nをa進数にしたときの、i桁目の数*/
ll placenai(ll n, ll a, ll i){return i==1?n%a:placenai(n/a,a,i-1);}
/*aのn乗(mod)*/
ll modpow(ll a, ll n, ll mod){
    ll i,s[digits(n,2)],ans=1;
    for(i=0;i<digits(n,2);i++){
        s[i]= i==0 ? a : s[i-1]*s[i-1]%mod ;
        ans*=placenai(n,2,i+1)==1?s[i]:1; ans%=mod;}
    return n==0?1:ans;
}
// ll modpow(ll a, ll n, ll mod){
//     ll ans=1;
//     rep(i,0,n){
//         ans*=a;
//         a%=mod;
//     }
//     return ans;
// }

ll inv[1000005];
void makeinv(ll n){
    inv[1]=1;
    for(ll i=2;i<=n;i++){
        inv[i]=MOD1 - inv[MOD1%i] * (MOD1 / i) % MOD1;
        // finv[i] = finv[i - 1] * inv[i] % MOD1;
        }
}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
        makelcm(a[i]);
    }
    makeinv(maxn(n,a));
    ll lcms=1;
    rep(i,0,1000000){
        if(pr[i]!=0){
            lcms = lcms*modpow(i,pr[i],MOD1)%MOD1;
        }
    }
    // rep(i,0,pma){
    //     lcms = lcms*pr2[i]%MOD1;
    // }
    // printf("%lld\n",lcms);
    ll b[n];
    rep(i,0,n){
        b[i]=lcms*inv[a[i]];
        b[i]%=MOD1;
        // printf("%lld ",b[i]);
    }
    rep(i,0,n){
        ans+=b[i];
        ans%=MOD1;
    }
    // rep(i,0,100){
    //     printf("%lld ",pr[i]);
    // }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 15744
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	string X;
	cin >> X;
	stack<char> st;

	for (char c: X) {
		if (st.empty()) {
			st.push(c);
			continue;
		} 
		if (st.top() == 'S' && c == 'T') {
			st.pop();
			continue;
		}
		st.push(c);
	} 
	cout << st.size() << endl;
	return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const ll INF = 1e18;
const int N = 5050;

int n;
struct elem {
    int h,p;
    bool operator<(const elem &o) const { return h+p < o.h + o.p; }
} a[N];

int sz;
ll dp[N]; 

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

    cin >> n;
    forn(i,n) cin >> a[i].h >> a[i].p;
    sort(a, a+n);

    dp[sz++] = 0;
    forn(i,n) {
        dforsn(j,0,sz) if (dp[j] <= a[i].h) {
            if (j+1 >= sz) dp[sz++] = INF;
            dp[j+1] = min(dp[j+1], dp[j] + a[i].p);
        }
    }
    cout << sz-1 << endl;


    return 0;
}


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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

const int dx[]={1,-1,0,0},
		  dy[]={0,0,1,-1};

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N];

char s[N];

pair<int,int> p[N];

double avg;

void permutation(int idx){
	if (idx==n-1){
		for(int i=1;i<n;i++){
			double x=p[i].first-p[i-1].first;
			double y=p[i].second-p[i-1].second;
			avg+=(double)sqrt(x*x + y*y);
		}
		return ;
	}
	for(int i=idx;i<n;i++){
		swap(p[i],p[idx]);
		permutation(idx+1);
		swap(p[i],p[idx]);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d %d",&p[i].first,&p[i].second);
	permutation(0);
	for(int i=2;i<=n;i++)
		avg/=i;
	printf("%.9lf\n",avg);
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader bfr = new BufferedReader(isr);
		String s = bfr.readLine();
		StringTokenizer st = new StringTokenizer(s, " ");
		
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		System.out.print(a * b);
		System.out.print(" ");
		System.out.println((a + b) * 2 );
		
		
	}

}

Measured memory_bytes: 16860
#include <iostream>
using namespace std;
using ll = long long;

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

    ll A[N + 1];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    // N+1は0枚あるとすると実装しやすい
    A[N] = 0;

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        // i同士のペアを作れるだけ作る
        ans += A[i] / 2;
        A[i] %= 2;

        // iとi+1のペアを作れれば作る
        if (A[i] > 0 && A[i + 1] > 0) {
            ++ans;
            --A[i];
            --A[i + 1];
        }
    }

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

Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	ll ans=1LL<<60;
	fr(i,1,1e6+1)
	{
		if(n%i==0)
		{
			ll j=n/i;
			ans=min(ans,i+j-2);
		}
	}
	wl(ans);
	NL;
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int A = int.Parse(imp[0]);
            int B = int.Parse(imp[1]);
            if (A == 1 && B != 1)
            {
                Console.Write("Alice");
            }
            else if (B == 1 && A != 1)
            {
                Console.Write("Bob");
            }
            else if (A == B)
            {
                Console.Write("Draw");
            }
            else if (A != 1 && A < B)
            {
                Console.Write("Bob");
            }
            else
            {
                Console.Write("Alice");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
    int i, N;
    int d = 0, min = 0, max = 0;
    char buf[4096];
    int rate[9] = {0};

    scanf("%d\n", &N);
    fgets(buf, sizeof(buf), stdin);

    for ( i = 0; i < N; i++ ){
        d = atoi( strtok(i==0?buf:NULL, " \n") );
        if ( d < 400 ){
            rate[0]++;
        } else if ( d < 800 ){
            rate[1]++;
        } else if ( d < 1200 ){
            rate[2]++;
        } else if ( d < 1600 ){
            rate[3]++;
        } else if ( d < 2000 ){
            rate[4]++;
        } else if ( d < 2400 ){
            rate[5]++;
        } else if ( d < 2800 ){
            rate[6]++;
        } else if ( d < 3200 ){
            rate[7]++;
        } else {
            rate[8]++;
        }
    }
    for ( i = 0; i < 8; i++ ){
        if ( rate[i] > 0 ){
            min++;
        }
    }
    max = min + rate[8];
    if ( min == 0 ){
        min = 1;
    }
    printf("%d %d\n", min, max);
    return 0;
}


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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[100000], appear[100000];
int mod = 1e9 + 7;

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        appear[A[i]]++;
    }
    if (appear[0] >= 2) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) {
        if (appear[A[i]] > 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 1;
    for (int i = 0; i < N / 2; i++) {
        ans = ans * 2 % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n,k,d,m;
	cin>>n>>k>>d;
	n=abs(n);
	m=min(k,abs(n)/d);
	k=k-m;
	n=n-m*d;
	if(k%2==0)
	{
		cout<<n<<endl;
		return;
	}
	else
	{
		cout<<d-n<<endl;return;
	}



}





int main()
{
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

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

	while (t--)
	{
		solve();
	}


	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

int main(){
	int firstinput;
	int nextinput;
	scanf("%d %d",&firstinput,&nextinput);
	
	if(firstinput % 2  == 0|| nextinput % 2 == 0){
		printf("Even\n");
	}else{
		printf("Odd\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
H = list(map(int, input().split()))

count = 0
for i in range(N-1, 0, -1):
    icount = 0
    for j in range(0, i):
        if H[i] >= H[j]:
            icount += 1
        else:
            break
    if icount == i:
        count += 1

print(count+1)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

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

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD


int main() {
    int n;
    cin>>n;
    vi x(n), y(n), h(n);
    REP(i,n){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i] == 0) continue;

    }

    int ansx,ansy,ansh;
    bool flg = false;
    REP(cx,100+1){
        REP(cy,100+1){
            flg = false;
            ansx = cx;
            ansy = cy;
            ansh = -1;
            int tmph;
            REP(i,n){
                if(h[i] == 0) continue;
                tmph = h[i] + abs(x[i]-cx) + abs(y[i]-cy); //h=0では解が一意にならない
                break;
            }

            REP(i,n){
                int tmp = max(tmph - abs(x[i]-cx) - abs(y[i]-cy), 0);
                if(h[i] != tmp){
                    flg=true;
                    break;
                }
                ansh = tmph;
            }
            
            if(!flg) break;
        }
        if(!flg) break;
    }
    cout << ansx << " " << ansy << " " << ansh << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

map<long long,long long> prime_factor(long long n) {
    map<long long,long long> ret;
    for(long long i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main()
{
	ll a,b;
	cin >> a >> b;
	map<ll,ll> m=prime_factor(gcd(a,b));
	cout << m.size()+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;

    cout<<arr[k-1]<<endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
LS1 =[]
LS2 =[]
S1 = 0
S2 = 0
ans = []

for T in range(1, N):
  S1 = 0
  S2 = 0
  for i in range(0, N):
    if i+1 <= T:
      S1 += W[i]
    elif i+1 > T:
      S2 += W[i]
  LS1.append(S1)
  LS2.append(S2)

for j in range(0,len(LS1)):
  ans.append(abs(LS1[j] - LS2[j]))

print(min(ans))  


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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = N - 1; i >= 0; i -= 2) cout << a[i] << " ";
	for (int i = 0 + N % 2; i < N; i += 2) cout << a[i] << " ";
	cout << endl;
}

Measured memory_bytes: 2944
import sys

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))
    A = int(next(tokens))

    solve(H, A)

def solve(H: int, A: int):
    count = 0
    while 0 < H:
        count = count + 1
        H = H - A

    print(count)

    return


 
if __name__ == "__main__":
    propare()

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <utility>
using namespace std;

typedef pair<int, int> pii;

int main(void) {

    while (1) {
        int N; cin >> N;
        if (N == 0) break;
        int masu[21][21];
        memset(masu, 0, sizeof(masu));

        for (int i = 0; i < N; i++) {
            int x, y; cin >> x >> y;
            masu[y][x] = 1;
        }

        int M; cin >> M;
        pii pos = pii(10, 10);      // ???????????????????????????
        for (int i = 0; i < M; i++) {
            char dir;
            int dis;
            cin >> dir >> dis;

            switch (dir) {
            case 'N':
                for (int j = 0; j < dis; j++) {
                    pos.second++;
                    if (masu[pos.second][pos.first] == 1) {
                        masu[pos.second][pos.first] = -1;
                        N--;
                    }
                }
                break;
            case 'E':
                for (int j = 0; j < dis; j++) {
                    pos.first++;
                    if (masu[pos.second][pos.first] == 1) {
                        masu[pos.second][pos.first] = -1;
                        N--;
                    }
                }
                break;
            case 'S':
                for (int j = 0; j < dis; j++) {
                    pos.second--;
                    if (masu[pos.second][pos.first] == 1) {
                        masu[pos.second][pos.first] = -1;
                        N--;
                    }
                }
                break;
            case 'W':
                for (int j = 0; j < dis; j++) {
                    pos.first--;
                    if (masu[pos.second][pos.first] == 1) {
                        masu[pos.second][pos.first] = -1;
                        N--;
                    }
                }
                break;
            }
        }

        if (N > 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3088
N = int(input())


def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1

    return table

Sum = 0
hoge = num_divisors_table(N-1)
Sum = sum(hoge)

print(Sum)

Measured memory_bytes: 75612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

int main() {
	int x;
	cin >> x;
	int ans;
	for (ans = 1; ans*(ans + 1)/2 < x; ans++);
	//int ans = ceil((-1 + sqrt(1 + 8 * x)) / 2);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Analyzing Login/Logout Records
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			boolean[][] log = new boolean[m+1][1261];
			List<int[]> list = new ArrayList<int[]>();
			int r = sc.nextInt();
			while(r--!=0){
				int t = sc.nextInt();
				int N = sc.nextInt();
				int M = sc.nextInt();
				int s = sc.nextInt();
				if(s==1){
					list.add(new int[]{N, M, t});
				}
				else{
					int st = -1;
					for(int i=0;i<list.size();i++){
						int[] a = list.get(i);
						if(a[0]==N&&a[1]==M){
							st = a[2];
							list.remove(i);
							break;
						}
					}
					for(int i=st;i<t;i++)log[M][i]=true;
				}
			}
			int q = sc.nextInt();
			while(q--!=0){
				int s = 0;
				int ts = sc.nextInt();
				int te = sc.nextInt();
				int M = sc.nextInt();
				for(int i=ts;i<te;i++)if(log[M][i])s++;
				System.out.println(s);
			}
		}
	}
}

Measured memory_bytes: 0
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())

D=N()
c=[0]+L()
s=[[0]*27]+[[0]+L() for i in range(D)]

dp=[]
T=[0]
ld=[0]*(27)
for i in range(1,D+1):
    ma=0
    t=0
    for j in range(1,27):
        tmp=s[i][j]+(i-ld[j])*(D-i+1)*c[j]
        if tmp>ma:
            ma=tmp
            t=j
    T.append(t)
    ld[t]=i
        
sc=sum(c)
def point():
    ld=[0]*(27)
    score=-sc*((D+1)*D//2)
    for i in range(1,D+1):
        t=T[i]
        score+=s[i][t]+(i-ld[t])*(D-i+1)*c[t]
        ld[t]=i
    return score

now=point()
import random
for i in range(500000):
    d1,q1=random.randrange(1,D+1),random.randrange(1,27)
    d2,q2=random.randrange(1,D+1),random.randrange(1,27)
    old1=T[d1]
    old2=T[d2]
    T[d1]=q1
    T[d2]=q2
    new=point()
    if new>now:
        now=new
    else:
        T[d1]=old1
        T[d2]=old2

for i in T[1:]:
    print(i)

Measured memory_bytes: 84016
#include<stdio.h>

int main(){

int n,s,f;
int w;

//while(1){
scanf("%d",&n);

for(int i=0;i<n;i++){
scanf("%d %d",&s,&f);

if(s<=5){
 if(s<f){
for(int i=s;i<=f;i++)
{
if(i!=s)printf(" ");
printf("%d",i);
}
     }
else if(s>f){
for(int i=s;i>=f;i--)
{
if(i!=s)printf(" ");
printf("%d",i);
}
}
}
if(s>5){
 if(f>s){
for(int i=s;i<=f;i++)
{
if(i!=s)printf(" ");
printf("%d",i);
}
}
 else if(5<f&&f<s){
	 for(int i=s;i<=9;i++)
{
if(i!=s)printf(" ");
printf("%d",i);
}

for(int i=5;i>=0;i--)
{
printf(" ");
printf("%d",i);
}

for(int i=1;i<=f;i++)
{
printf(" ");
printf("%d",i);
}

}
 else if(f<=5){
for(int i=s;i<=9;i++)
{
if(i!=s)printf(" ");
printf("%d",i);
}

for(int i=5;i>=f;i--)
{
printf(" ");
printf("%d",i);
}

}
}printf("\n");
}

return 0;
}

Measured memory_bytes: 1032
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, m, Deg[101000], vis[101000];
vector<int>E[101000];
void DFS(int a, int pp, int st, int nev) {
	for (auto &x : E[a]) {
		if (!vis[x] && x != pp && x != nev) {
			vis[x] = 1;
			DFS(x, a, st, nev);
		}
	}
}
int main() {
	vector<int>T;
	int i, a, b, ck = 0;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= m; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
		Deg[a]++, Deg[b]++;
	}
	for (i = 1; i <= n; i++) {
		if (Deg[i] % 2 == 1) {
			puts("No");
			return 0;
		}
		if (Deg[i] >= 6) ck = 1;
		if (Deg[i] == 4) {
			T.push_back(i);
		}
	}
	if (m >= n + 3)ck = 1;
	if (ck) {
		puts("Yes");
		return 0;
	}
	else {
		if (T.size() == 2) {
			DFS(T[0], -1, T[0], T[1]);
			if (vis[T[0]]) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, ans;
    ans = 0;
    cin >> n;
    vll a;
    for (ll i = 1; i * i <= n-1; i++){//n-1の約数を求める。K>2
        if ((n - 1) % i == 0){
            if (i * i != (n-1)){
                ans += 2;
            }else{
                ans ++;
            }
            if(i == 1) ans --;
        }
    }
    for (ll i = 1; i * i <= n; i++){//nの約数を求める。K>2
        if (n % i == 0){
            a.push_back(i);
            if (i * i != n) a.push_back(n / i);
        }
    }

    for(ll x : a){
        if(x == 1) continue;//1は範囲外
        ll tmp = n;
        while(tmp % x == 0){
            tmp = tmp / x;
        }
        if(tmp % x == 1) ans ++;
    }

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

Measured memory_bytes: 384
N = int(input())
s = input()
t = input()
mx = 0
for i in range(0,N):
    cnt = 0
    for j in range(0,N):
        if i+j >= N: break
        if s[i+j] == t[j]:
            cnt += 1
    mx = max(mx,cnt)
print(len(s+t[mx:]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int k,s,cnt;
int main()
{
    cin>>k>>s;
    for(register int x=0;x<=k;x++)for(register int y=0;y<=k;y++) if(s-x-y>=0&&s-x-y<=k) cnt++;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) < sum(B):
	print(-1)
	exit()

diff = []
for i in range(N):
	diff.append(A[i] - B[i])

diff.sort()
ans = 0
total = 0
for i in range(N):
	if diff[i] >= 0:
		break
	total += diff[i]
	ans += 1

for i in range(N - 1, -1, -1):
	if total < 0:
		ans += 1
		total += diff[i]
	else:
		break

print(ans)

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

using namespace std;

#define endl "\n"
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define f first
#define s second
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;



void solve()
{
    string n1,n2;
    cin>>n1>>n2;
    if(n1.size()>n2.size()){
        cout<<"GREATER"<<endl;
    }
    else if(n1.size()<n2.size()){
        cout<<"LESS"<<endl;
    }
    else{
        for(ll i=0;i<n1.size();++i){
            if(n1[i]>n2[i]){
                cout<<"GREATER"<<endl;
                return;
            }
            else if(n1[i]<n2[i]){
                cout<<"LESS"<<endl;
                return;
            }
        }
        cout<<"EQUAL"<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    a,b,k = LI()
    b = max(0,b-max(0,(k-a)))
    a = max(0,a-k)

    return JA([a,b]," ")


print(main())




Measured memory_bytes: 6484
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

ary = require('fs')
	.readFileSync(config.input, 'ascii')
	.trim()
	.split('');

ary.reverse();

console.log(ary.join(''));

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

// nPnの順列に対して処理を実行する//
//  https://kamino.hatenablog.com/entry/cpp-permutation-combination
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

ll Fact(int n)//n階乗を求める関数 オーバーフローするのでnが小さい値しか使えないよ
{
  if(n==0) return 1;
  return n * Fact(n-1);
}

double get_distance(int x1, int y1, int x2, int y2)//2点間の距離を求める関数
{
  double distance;
  distance = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
  return sqrt(distance);
}

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for(int i = 0; i<N; i++) 
  {
    cin >> x.at(i);
    cin >> y.at(i);
  }
  double ans = 0;
  
  //解1↓↓
  ll n_fact = Fact(N);
  //cout << "Fact("<<N<<") : "<< n_fact << endl;
  foreach_permutation(N, [&](int *indexes){
    for(int j=0; j<N-1; j++) 
    {
      ans += get_distance(
        x.at(indexes[j]), y.at(indexes[j]), x.at(indexes[j+1]), y.at(indexes[j+1]));    
    }
  });
  
  ans /= n_fact;
  cout << fixed;//小数点を確実に8桁で表示するためのもの
  cout << setprecision(8) <<ans << endl; 
  //解1↑↑

  /*解2↓↓
  for(ll i=0; i<N; i++)//各町間の道路の長さを2回ずつ足す
  {
    for(ll j=0; j<N; j++){
      if(i==j) continue;
      ans += get_distance(x.at(i), y.at(i), x.at(j), y.at(j));
    }    
  }

  ans = ans / N;
  cout << fixed;//小数点を確実に8桁で表示するためのもの
  cout << setprecision(8) <<ans << endl; 
  *///解2↑↑
}


Measured memory_bytes: 256
s = [int(i) for i in input()]
n = len(s)

p1 = [i for i in map(lambda n: n%2, range(n))]
p2 = [i for i in map(lambda n: (n+1)%2, range(n))]

s1,s2 = 0,0

for i in range(n):
    if s[i] != p1[i]:
        s1 += 1
    if s[i] != p2[i]:
        s2 += 1

print(min(s1, s2))

Measured memory_bytes: 5532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll OO = 1e18+7;
const int MOD = 1e9+7;
const int N = 100+7;
const int V = 1e5+7;

ll dp[N][V];
ll w[N];int v[N];
int n;
ll W;

int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    scanf("%d %lld",&n,&W);

    REP(i,0,n-1) scanf("%lld %d",&w[i],&v[i]);

    // dp[i][j] = min weight with value j for prefix i
    REP(j,0,V-1) dp[0][j] = OO;
    dp[0][v[0]] = w[0];
    dp[0][0] = 0;

    REP(i,1,n-1)
    {
        REP(j,0,V-1)
        {
            dp[i][j] = dp[i-1][j];
            if (j-v[i] >= 0) dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
            //cerr << i << ' ' << j << ' ' << dp[i][j] << endl;
        }
    }
    int ans = 0;
    REPI(j,V-1,0)
    {
        if (dp[n-1][j] <= W) {ans = j;break;}
    }
    //cerr << dp[n-1][17] << endl;
    printf("%d\n",ans);
    return 0;
}


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

int main(void){
   int N;
   cin>>N;
   vector<int> X(N);
   for(int i=0;i<N;i++){
      cin>>X[i];
   }
   vector<pair<int,int>> result(N);
   for(int i=0;i<N;i++){
      result[i]=make_pair(X[i],i);
   }
   sort(result.begin(),result.end());
   vector<int> ans(N);
   for(int i=0;i<N;i++){
      if(i<N/2){
         ans[result[i].second]=result[N/2].first;
      }else{
         ans[result[i].second]=result[N/2-1].first;
      }
   }
   for(int i=0;i<N;i++){
      cout<<ans[i]<<endl;
   }
   return 0;
}

Measured memory_bytes: 5376
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		StringBuffer S = new StringBuffer(sc.next());
		char v[]= {49,48};
		//97
		int ans=0;
		for(int i=1;i<S.length();i++) {
			if(S.charAt(i)==S.charAt(i-1)) {
				S.setCharAt(i, v[S.charAt(i)-48]);
				ans++;
			}
			//p("a"+a);
		}
		p(ans);
		//p(S.toString());
		//setCharAt(int a, char s)
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 27024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    vector<pair<int,int> > ans(0);
    ans.push_back(pair<int,int> (vec[0],1));
    rep(i,N - 1){
        if (vec[i] != vec[i + 1]){
            ans.push_back(pair<int,int> (vec[i + 1], 1));
        }
        else{
            int len_ans = ans.size();
            ans[len_ans - 1].second++;
        }
    }
    int count = 0;
    int len_ans = ans.size();
    rep(i,len_ans){
        if (ans[i].second % 2 == 1) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 1784
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char const *argv[])
{
    /* code */
    int N = 0;
    scanf("%d", &N);
    //printf("N = %ld\n", N);
    int i = 0;
    double money = 0;
    char type[3];
    double total = 0;
    for(i = 0; i < N; i ++)
    {
        scanf("%lf %s", &money, &type);
        //printf("money = %lf, type = %s, %d\n", money, type, i);
        if(type[0] == 'J')
        {
            //printf("J\n");
            total += money;
        }else{
            //printf("B\n");
            total += money * 380000;
        }
    }
    printf("%lf\n", total);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=3005,mo=1e9+7,iv2=5e8+4;
int n,a[N];
ll f[N][N],tf[N][N];
void inc(ll &x,ll y){x=(x+y)%mo;}
int main()
{
	n=read();int Q=read();
	fo(i,1,n) a[i]=read();
	fo(i,1,n)
		fo(j,1,n) f[i][j]=(a[i]>a[j]);
	fo(k,1,Q)
	{
		int x=read(),y=read();
		fo(i,1,n)
			if(i!=x && i!=y)
				f[i][x]=f[i][y]=(f[i][x]+f[i][y])*iv2%mo,f[x][i]=f[y][i]=(f[x][i]+f[y][i])*iv2%mo;
		f[x][y]=f[y][x]=(f[x][y]+f[y][x])*iv2%mo;
	}
	ll ans=0;
	fo(i,1,n-1)
		fo(j,i+1,n) inc(ans,f[i][j]);
	fo(i,1,Q) ans=ans*2%mo;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 71680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define tiii tuple<int, int, int>
#define pb push_back
#define F first
#define S second
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(args...)                           \
	{                                            \
		string _s = #args;                       \
		replace(_s.begin(), _s.end(), ',', ' '); \
		stringstream _ss(_s);                    \
		istream_iterator<string> _it(_ss);       \
		err(_it, args);                          \
	}

void err(istream_iterator<string> it)
{
}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main()
{
	string s;
	cin >> s;
	int ans = 1;
	bool flg = 0;
	for (int i = 1; i < s.size(); i++)
	{
		if (!flg && s[i] == s[i - 1])
		{
			i++;
			flg = 1;
		}
		else
			flg = 0;
		if (i < s.size())
			ans++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
x = int(input())
flag = False
while True:
    if flag:
        break
    for i in range(x):
        if flag:
            break
        for j in range(x):
            if i ** j == x:
                print(i ** j)
                flag = True
                break
            if i ** j > x:
                break
    x -= 1

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll MOD;

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  string s; cin>>s;
  s = "0" + s;
  string t = s;
  reverse(all(t));
  if(s != t){
    cout<<-1<<endl;
    return 0;
  }
  if(s[1] == '0'){
    cout<<-1<<endl;
    return 0;
  }
  int base = 1;
  int next = 2;
  vector<Pii> ans;
  rep(i,s.size()){
    if(s[i] == '0') continue;
    while(next <= i){
      ans.push_back({base, next});
      next++;
    }
    ans.push_back({base, next});
    base = next;
    next++;
  }
  rep(i,ans.size()){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }
  return 0;
}

Measured memory_bytes: 2532