akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int R,C,N;
    Scd3(R,C,N);


    auto oned = [&]( int x, int y ){
        if( x == 0 ) return y;
        else if( y == C ) return C+x;
        else if( x == R ) return C+R+C-y;
        else if( y == 0 ) return C+R+C+R-x;
        else return -1;
    };

    map<int,int> ed;
    int x1,y1,x2,y2;
    int t1,t2;
    Rep(i,N){
        Scd2(x1,y1);
        Scd2(x2,y2);
        t1 = oned(x1,y1);
        t2 = oned(x2,y2);
        if( t1 >= 0 && t2 >= 0 ){
            ed.insert({t1,i});
            ed.insert({t2,i});
        }
    }

    bool ans = true;

    stack<int> st;
    set<int> se;
    if( ed.size() > 2 ){
        for( pii t : ed ){
            int id = t.second;
            if( st.empty() ) st.push(id);
            else if( st.top() == id ) st.pop();
            else if( se.find(id) != se.end() ){
                ans = false;
                break;
            }else{
                st.push(id);
            }
            se.insert(id);
        }
    }

    YESNO(ans);

    return 0;
}



Measured memory_bytes: 14336
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll x; cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x -= (ans / 1000) * 500;
    ans += (x / 5) * 5;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;



int main() {
	int n, a[10000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			count++;
		}
	}
	cout << count << endl;


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using ull = unsigned long long;

ull GreatestCommonDivisor(ull a, ull b){
	ull r = b;
	while(a % b != 0){
		r = a % b;
		a = b;
		b = r;
	}
	return r;
}

int main(){
    unsigned N, M;
    scanf("%u %u", &N, &M);
    unsigned a[N];
    for(int i = 0; i < N; ++i){
        scanf("%u", a + i);
        a[i] >>= 1;
    }
    unsigned i = 0, lcm = 1;
    while(i < N && a[i]/GreatestCommonDivisor(a[i], lcm) <= M/lcm){
        lcm *= a[i]/GreatestCommonDivisor(a[i], lcm);
        i++;
    }
    if(i < N){
        printf("0\n");
        return 0;
    }
    i = 0;
    while(i < N && lcm/a[i] & 1u) i++;
    printf("%u\n", i < N ? 0 : M/lcm + 1 >> 1);
	return 0;
}

Measured memory_bytes: 512
//process.stdin.resume();
//process.stdin.setEncoding('utf8');
//process.stdin.on('data', function(chunk) {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//});

function main(chunk){
    var ans = [];
    var line = chunk.split("");
    for(var i in line){
        switch(line[i]){
        case 'S':
            ans.push('S');
            break;
        case 'T':
            if(ans.length>0 && ans[ans.length-1] == 'S'){
                ans.pop();
            }else{
                ans.push('T');
            }
            break;
        }
    }
    console.log(ans.length);
}



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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll dp[10][10] = {}; //先頭,末尾  
    ll n;
    ll dg = 1;
    cin >> n;
    rep(i,1,n+1){
        if(i/dg>9) dg *= 10;
        dp[i/dg][i%10]++;
    }
    ll sum = 0;
    rep(i,1,10){
        rep(j,1,10){
            sum += dp[i][j]*dp[j][i];
        }
    }
    cout << sum << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int M = 1000000007;
vector<string> grid;
int cache[1005][1005];

int solve(int h, int w, int i, int j) {
    if (i >= h || j >= w) return 0;
    if (grid[i][j] == '#') return 0;

    if (i == h-1 && j == w-1) {
        return 1;
    }

    if (cache[i][j] != -1) return cache[i][j];


    int p1 = solve(h, w, i+1, j);
    int p2 = solve(h, w, i, j+1);
    int ans = (p1 + p2)%M;
    cache[i][j] = ans;
    return ans;
}

int main() {
    int h, w;
    cin>>h>>w;
    grid.resize(h);
    for (int i = 0; i < h; i++) {
        cin>>grid[i];
    }

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cache[i][j] = -1;

    cout<<solve(h, w, 0, 0)<<endl;
}


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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

vector<P> f(vector<int> x){
  sort(ALL(x));
  vector<P> y;
  int tmp = x[0];
  int c = 1;
  for (int i = 1; i < x.size(); i++){
    if (x[i] == tmp){
      c++;
    } else {
      y.push_back(make_pair(c, tmp));
      tmp = x[i];
      c = 1;
    }
  }
  y.push_back(make_pair(c, tmp));
  sort(ALL(y));
  reverse(ALL(y));
  return y;
}


int main(){
  int n;
  cin >> n;
  vector<int> a, b;
  rep(i, n){
    int x;
    cin >> x;
    if (i%2) a.push_back(x);
    else b.push_back(x);
  }

  vector<P> a_pair = f(a);
  vector<P> b_pair = f(b);

  if (a_pair.size() == 1){
    a_pair.push_back(make_pair(0, 0));
  }
  if (b_pair.size() == 1){
    b_pair.push_back(make_pair(0, 0));
  }
  int ans;
  if (a_pair[0].second != b_pair[0].second){
    ans = n - a_pair[0].first - b_pair[0].first;    
  } else {
    int ans1 = n - a_pair[0].first - b_pair[1].first;
    int ans2 = n - a_pair[1].first - b_pair[0].first;
    ans = min(ans1, ans2);
  }

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


Measured memory_bytes: 2040
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

        int kushi = sc.nextInt();

        ArrayList<Integer> lengthList = new ArrayList<Integer>();
        for (int i = 0, max = kushi * 2; i < max; i++) {
            int n = sc.nextInt();
            lengthList.add(n);

        }
        Collections.sort(lengthList);

        int tot = 0;
        for (int i = 0; i < lengthList.size(); i+=2) {
            tot += lengthList.get(i);
        }

        System.out.println(tot);
    }
}

Measured memory_bytes: 9684
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] X = new int[M];
		Integer[] diff_X = new Integer[M - 1];
		for(int i = 0; i < M; i++) X[i] = sc.nextInt();
		Arrays.sort(X);
		for(int i = 1; i < M; i++) {
			diff_X[i - 1] = X[i] - X[i - 1];
		}
		Arrays.sort(diff_X);
		int ans = 0;
		for(int i = 0; i < Math.max(M - N, 0); i++) {
			ans += diff_X[i];
		}
		System.out.println(ans);
	}
}


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

int main(){
  long long X,N;
  cin >> X >> N;
  map<long long, long long> M;
  long long P;
  for (long long i = 0; i < N; i++){
    cin >> P;
    M[P]++;
  }
  long long ans = 0;
  for (long long i = 0; i < 100; i++){
    if (M[X - i] == 0){
      ans = X - i;
      break;
    }
    else if (M[X + i] == 0){
      ans = X + i;
      break;
    }
  }
  cout << ans;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define ALL(x) x.begin(),x.end()

const int maxdigit = 30;

int ones[maxdigit];

int N;

vector<int> va;
vector<int> vb;

int fro(int n,int num){
    return ((1<<(n+1))-1)&num;
}

int main()
{
    scanf("%d",&N);
    _for(i,0,N){
        int a;
        scanf("%d",&a);
        va.push_back(a);
    }

    //sort(ALL(va));

    _for(i,0,N){
        int b;
        scanf("%d",&b);
        vb.push_back(b);
    }

    int ret_val = 0;
    _for(i,0,maxdigit){
        vector<int> vva;
        _for(j,0,N) vva.push_back(fro(i,va[j]));
        sort(ALL(vva));

        _for(j,0,N){
            int b = fro(i,vb[j]);
            int k = 1<<i;
            int k1 = 1<<(i+1);
            int k2 = 1<<(i+2);
            auto it = lower_bound(ALL(vva),k1+k-b);
            auto ed = lower_bound(ALL(vva),k2-b);
            int cnt = (ed-it>0)?ed-it:0;
            it = lower_bound(ALL(vva),k-b);
            ed = lower_bound(ALL(vva),k1-b);
            cnt += (ed-it>0)?ed-it:0;
            ones[i] += cnt;
        }
    }

    _for(i,0,maxdigit){
        if(ones[i]%2) ret_val = ret_val | (1<<i);
    }

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

    return 0;
}


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

const ll mod = 1000000007;

//k^nを繰り返し二乗法により求める
ll modpow(ll k,ll n){
  if(n == 0) return 1;
  ll x = modpow(k,n/2);
  x *= x;
  x %= mod;
  if(n%2 == 1){
    x *= k;
    x %= mod;
  }
  return x;
}

//二項係数nCrを求める
ll choose(ll n,ll r){
  ll x = 1,y = 1;
  for(ll i=0;i<r;i++){
    x *= (n-i);
    y *= (i+1);
    x %= mod;
    y %= mod;
  }
  ll inv_y = modpow(y,mod-2);
  return x * inv_y % mod;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans;
  ans = modpow(2,n);
  ans %= mod;
  ans -= 1;
  ans %= mod;
  ans -= choose(n,a);
  ans %= mod;
  ans -= choose(n,b);
  ans %= mod;
  while(ans<0) ans+=mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a,b,c,d,e]
s = 0

Min = 10

for i in range(len(l)):
    s  = l[i] % 10 
    if ( 9>= s >=1 and Min > s):
        Min = s

for i in range(len(l)):   
    s  = l[i] % 10 

    if(s == Min):
        Min = 99
    elif(9>= s >=1):
        l[i] += 10 - s
    
print(sum(l))

Measured memory_bytes: 38256
def factorization(y):
    arr = []
    temp = y
    for i in range(2, int(-(-y**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([y, 1])
    return arr
n=int(input())
if n==1:
  print(0)
  exit()
ans=0
l=factorization(n)
for i,j in l:
    if j<=2:
      ans+=1
    else:
      t=1
      while j:
        if j<t:
          break
        ans+=1
        j-=t
        t+=1           
print(ans)

Measured memory_bytes: 9496
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
//define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
//ll p[mx],a[mx],b[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    faster();
    string s;
    string ans;
    cin>>s;
    int len=s.size();
    ans=s;
    reverse(all(ans));
    int c=0;
    if(s==ans)c++;
    int n=((len-1)/2);
    string ck,ck1;
    ck="";
    for(int i=0; i<n; i++)
        ck+=s[i];
    ck1=ck;
    reverse(all(ck1));
    if(ck1==ck)c++;
    string cmp,cmp1;
    cmp="";
    int m=(len+3)/2;
    for(int i=m-1; i<len; i++)
        cmp+=s[i];
    cmp1=cmp;
    reverse(all(cmp1));
    if(cmp1==cmp)c++;
    if(c==3)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return  0;
}


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

const int INF = 0x3f3f3f3f;
int n,a[303][303];
long long ans;

int main(){
    cin >> n;
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            scanf("%d",&a[i][j]);

    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j){
            bool flag = 1;
            for(int k = 1;k <= n;++k){
                if(k == i || k == j) continue;
                if(a[i][j] > a[i][k] + a[k][j]){
                    printf("-1\n");
                    return 0;
                }
                else if(a[i][j] == a[i][k] + a[k][j])
                    flag = 0;
            }
            if(flag) ans += a[i][j];
        }

    cout << ans / 2 << endl;

    return 0;
}

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

int N;

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

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


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

ll mod = 1000000007;


/*
c[4][2]
=c[3][2]+c[3][1]
=...

c[1][1]
c[2][1]
c[3][1]
c[4][1]
c[1][2]=0
c[2][2]
c[3][2]
c[4][2]

*/

ll dp[2019][2019]={};
ll C(ll n, ll r){
    //n = n+1;
    //r = r+1;
    if(dp[n][r]) return dp[n][r];
    /*
        rep1r(j,r){
            rep1(i,n){
                if(i<j) dp[i][j]=0;
                else if(i==j||j==0) dp[i][j]=1;
                else dp[i][j]=(dp[i-1][j] + dp[i-1][j-1]) % mod;
                //cout << "dp[" << i << "][" << j << "]:" << dp[i][j] << endl;
            }
        }
        */
    else{
        if(n<r) {
            dp[n][r]=0;
            return 0;}
        else if(n==r||r==0) {
            dp[n][r]=1;
            return 1;}
        else{
            ll tmp = (C(n-1,r) + C(n-1,r-1)) % mod;
            dp[n][r]=tmp;
            return tmp;
        }
    }
        //return dp[n][r];
}



void solve(){
    ll n,k;
    cin >> n >> k;
    for(ll i=1; i<=k; i++){
        ll ans;
        if(n-k+1<i) ans = 0;
        else{
        //ans = ((C(k-1,i-1)%mod)*(C(n-k+1,i)%mod)) % mod;
        ans = ((C(k-1,i-1))*(C(n-k+1,i))) % mod;
        }
    cout << ans << endl;
    }
}

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

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<long long> vll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

int main(){
    ll n;
    string s;

    cin >> n >> s;
    if(n%2==1){
        cc("No");
        return 0;
    }else{
        rep(i,n/2){
            if(s[i]!=s[i+n/2]){
                cc("No");
                return 0;
            }
        }
        cc("Yes");
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    int a=0;
    if(A>B){
        a+=B;
    }else{
        a+=A;
    }


     if(C>D){
        a+=D;
    }else{
        a+=C;
    }

    cout<<a<<endl;



    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
str_list = [input() for i in range(h)]
result_list = ['' for i in range(h)]

for i in range(h):
    for j in range(w):
        if str_list[i][j] == '.':
            cnt = 0
            for x in range(-1,2):
                for y in range(-1,2):
                    try:
                        if i+x >= 0 and j+y >= 0 and str_list[i+x][j+y] == '#':
                            cnt += 1
                    except IndexError:
                        pass
            result_list[i] += str(cnt)
        elif str_list[i][j] == '#':
            result_list[i] += '#'

for i in range(h):
    print(result_list[i])

Measured memory_bytes: 3188
<?php
fscanf(STDIN, "%d", $N);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
printf("%d", count(array_filter($a, function($v, $k) {
    return $k % 2 === 0 && $v % 2 === 1;
}, ARRAY_FILTER_USE_BOTH)));

Measured memory_bytes: 16092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(void) {
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    vector<int> r(A.begin(), A.end());
    for(int i=N-2; i>=0; i--) {
        r[i] = max(r[i], r[i+1]);
    }

    map<int,int> mp;
    for(int i=0; i<N-1; i++) {
        mp[r[i] - A[i]]++;
    }

    cout << (*mp.rbegin()).second << endl;
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int pow_mod(long long a, int b, int mod) {
  int result = 1;
  while (b) {
    if (b&1) result = (result * a) % mod;
    b >>= 1;
    a = (a*a)%mod;
  }
  return result;
}
int inverse_mod(int a, int prime) { return pow_mod(a, prime-2, prime); }

const int MOD = 1000000007;

int DP[2000][2000];
int fact[2000], invfact[2000];
int SN[2000][2000];
int main() {
  fact[0] = invfact[0] = 1;
  FOR(i,1,2000) {
    fact[i] = (fact[i-1]*(LL)i) % MOD;
    invfact[i] = inverse_mod(fact[i], MOD);
  }
  REP(i,2000) {
    SN[i][0] = SN[i][i] = 1;
    FOR(j,1,i) SN[i][j] = (SN[i-1][j-1] + SN[i-1][j]) % MOD;
  }

  int N, A, B, C, D;
  scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
  DP[A-1][0] = 1;
  FOR(i,A,B+1) {
    REP(p,N+1) {
      DP[i][p] = (DP[i][p] + DP[i-1][p]) % MOD;
      FOR(j,C,D+1) {
        int n = p + i * j;
        if (n > N) break;
        // printf("%d %d %d!\n", i, j, p);
        LL tmp = (DP[i-1][p] * (LL)SN[N-p][i*j]) % MOD;
        // printf("%lld\n", tmp);
        tmp = (tmp * fact[i*j]) % MOD;
        tmp = (tmp * invfact[j]) % MOD;
        tmp = (tmp * pow_mod(invfact[i], j, MOD)) % MOD;
        DP[i][n] = (DP[i][n] + tmp) % MOD;
      }
    }
  }

  printf("%d\n", DP[B][N]);
}


Measured memory_bytes: 21760
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int a;
    string s;
    cin >> a >> s;

    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>

using namespace std;

int main() {
	int n, y=0, i;
	char s[100];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", s);	
                if (s[0] == 'Y') {
			y++;
		}
	}
	if (y == 0) {
		printf("Three\n");
	}
	else {
		printf("Four\n");
	}
	return 0;
}

Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

dp = []
dp[0] = 0
dp[1] = (h[0] - h[1]).abs

1.upto(n-1) { |i|
  m = 10**12
  k.times { |_k|
    ind = i - 1 - _k
    if (ind >= 0)
      tmp = dp[ind] + (h[ind] - h[i]).abs
      if tmp < m
        m = tmp
      end
    end
  }
  dp[i] = m
}


puts dp[n-1]


Measured memory_bytes: 10244
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int N;
	int A[300][300];
	int exist[300][300];
	ll roadsum=0;
	scan(N);
	rep(i,N){
		rep(j,N){
			scan(A[i][j]);
			if(i<j) roadsum+=A[i][j];
		}
	}
	rep(i,N){
		rep(j,N){
			exist[i][j]=1;
		}
	}
	//prin(roadsum);
	int flag=1;
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			for(int k=0;k<N;k++){
				if(k==i||k==j) continue;
				//printf("i:%d j:%d k:%d A[i][j]:%d A[i][k]:%d A[k][j]:%d\n",i,j,k,A[i][j],A[i][k],A[k][j]);
				if(A[i][j]==A[i][k]+A[k][j]){
					if(exist[i][j]==1){
						roadsum-=A[i][j];
						exist[i][j]=0;
					}
				}
				else if(A[i][j]<A[i][k]+A[k][j]){

				}
				else{
					flag=0;
					break;
				}
			}
			if(flag==0) break;
		}
		if(flag==0) break;
	}
	if(flag) prin(roadsum);
	else prin(-1);
	return 0;
}


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

int main(){
  int N,c=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i]%2 == 1 && i%2 == 0) c++;
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;

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

int main(){
    int N,K;
    cin >> N >> K;
    long long int ans=K;
    REP(i,N-1){
        ans *= K-1;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
char s[N];
int main() {
	scanf("%s", s + 1);
	if (s[3] == s[4] && s[5] == s[6])puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner scanner = new Scanner(System.in);
    Integer Haiku[] = new Integer[3];
    int sum = 0;
    
    for(int i = 0; i < Haiku.length; i++){
      Haiku[i] = scanner.nextInt();
      sum += Haiku[i];
    }
    
    String ans = "NO";
    
    if(sum == 17 && Arrays.asList(Haiku).contains(5) && Arrays.asList(Haiku).contains(7)){
      ans = "YES";
    }
    System.out.println(ans); 
  }
}

Measured memory_bytes: 21584
N = int(input())
AU = list(map(int, input().split()))
AD = list(map(int, input().split()))
S, T = AU[0] + sum(AD), AU[0] + sum(AD)
for i in range(1, N):
  S += AU[i] - AD[i-1]
  if T < S:
    T = S
print(T)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    long long int l,i,j,cnt=0;
    string s,str="ABC";
    cin>>l>>s;
    for (i=0;i<l;i++)
    {
       if (s[i]=='A' && s[i+1]=='B'&& s[i+2]=='C')
        cnt++;
    }
    cout<<cnt<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] food = new int [5];

		for (int i = 0; i < 5; i++) {
			food[i] = sc.nextInt();
		}
		
		int sum = 0;
		
		// 自分より一番近くて大きい10の倍数にしてすべて足す
		for (int i = 0; i < 5; i++) {
			sum += (food[i] + 9) / 10 * 10; 
		}
		
		// 1の位が1より大きく一番近い料理の分引く
		
		int min = 10;
		
		for (int i = 0; i < 5; i++) {
			if (food[i]%10 == 0) {
				continue;
			}
			
			min = Math.min(min, food[i] % 10);
		}
		
		System.out.println(sum - (10 - min));
		
	}
	
	


}





Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long
#define pii pair<int, int>

const ll llf = (signed ll) (~0ull >> 3);

const int N = 2e5 + 5, bzmax = 20;

int n;
int X[N];
ll dep[N];
vector<pii> G[N];

ll H[N];
boolean ban[N];
ll dis[bzmax][N];
int fG[N], sz[N], Gd[N];

int get_sz(int p, int fa) {
	sz[p] = 1;
	for (auto _ : G[p]) {
		int e = _.first;
		if (!ban[e] && (e ^ fa))
			sz[p] += get_sz(e, p);
	}
	return sz[p];
}
int get_grav(int p, int fa, int lim) {
	for (auto _ : G[p]) {
		int e = _.first;
		if (!ban[e] && (e ^ fa) && sz[e] > lim) {
			return get_grav(e, p, lim);
		}
	}
	return p;
}

void dfs(int p, int fa, int dep, ll dist) {
	dis[dep][p] = dist + X[p];
	for (auto _ : G[p]) {
		int e = _.first;
		int w = _.second;
		if ((e ^ fa) && !ban[e]) {
			dfs(e, p, dep, dist + w);
		}
	}
}

void dividing(int layer, int p, int fg) {
	get_sz(p, 0);
	int g = get_grav(p, 0, sz[p] >> 1);
	ban[g] = true;
	Gd[g] = layer, fG[g] = fg;
	dis[layer][g] = X[g];
	for (auto _ : G[g]) {
		int e = _.first;
		int w = _.second;
		if (!ban[e]) {
			dfs(e, g, layer, w);
		}
	}
	for (auto _ : G[g]) {
		int e = _.first;
		if (!ban[e]) {
			dividing(layer + 1, e, g);
		}
	}
}

void enable(int p) {
	for (int q = p; q; q = fG[q]) {
		H[q] = min(H[q], dis[Gd[q]][p]);
	} 
}
ll query(int p) {
	ll ret = llf;
	for (int q = p; q; q = fG[q]) {
		ret = min(ret, H[q] + dis[Gd[q]][p]);
	}
	return ret;
}

void dfs(int p, int fa) {
	for (auto _ : G[p]) {
		int e = _.first;
		int w = _.second;
		if (e ^ fa) {
			dep[e] = dep[p] + w;
			dfs(e, p);
		}
	}
	if (fa)
		dep[p] += X[p];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", X + i);
	}
	for (int i = 1, u, v, w; i < n; i++) {
		scanf("%d%d%d", &u, &v, &w);
		G[u].emplace_back(v, w);
		G[v].emplace_back(u, w);
	}
	dfs(1, 0);
	vector<int> ord (n - 1);
	for (int i = 0; i < n - 1; i++)
		ord[i] = i + 2;
	sort(ord.begin(), ord.end(), [&] (int x, int y) {	return dep[x] < dep[y];	});
	dividing(0, 1, 0);
	for (int i = 1; i <= n; i++)
		H[i] = llf;
	enable(1);
	ll ans = 0;
	for (auto p : ord) {
		ans += query(p);
		enable(p);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 56960
import bisect

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

i0 = bisect.bisect_left(A,0)
if i0 >= N-1:
  print(-sum(A[:N-1])+A[N-1])
  a = A[N-1]
  for i in range(N-1):
    print(a,A[i])
    a = a-A[i]
elif i0 <= 1:
  print(-A[0]+sum(A[1:]))
  a = A[0]
  for i in range(1,N-1):
    print(a,A[i])
    a = a-A[i]
  print(A[N-1],a)
else:
  print(-sum(A[:i0])+sum(A[i0:]))
  a = A[i0-1]
  for i in range(i0,N-1):
    print(a,A[i])
    a = a-A[i]
  print(A[N-1],a)
  a = A[N-1]-a
  for i in range(i0-1):
    print(a,A[i])
    a = a-A[i]


Measured memory_bytes: 61324
n,m=map(int,input().split())
l=[]
r=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
    
start=0
end=100000
for i in range(m):
    if start<l[i]:
        start=l[i]
    if end>r[i]:
        end=r[i]

if start<=end:
    print(end-start+1)
else:
    print(0)

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

string s[10000], b[10001];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		cin >> s[i];
	}
	string t; cin >> t;
	//t->'a',s->'z'
	string a = t;
	for (char&c : a) {
		if (c == '?')c = 'a';
	}
	rep(i, n) {
		b[i] = s[i];
		for (char&c : b[i]) {
			if (c == '?')c = 'z';
		}
	}
	b[n] = a; sort(b, b + n + 1);
	int Min;
	rep(i, n + 1) {
		if (b[i] == a) {
			Min = i; break;
		}
	}
	a = t;
	for (char&c : a) {
		if (c == '?')c = 'z';
	}
	rep(i, n) {
		b[i] = s[i];
		for (char&c : b[i]) {
			if (c == '?')c = 'a';
		}
	}
	b[n] = a; sort(b, b + n + 1);
	int Max;
	for (int i = n; i >= 0; i--) {
		if (b[i] == a) {
			Max = i; break;
		}
	}
	for (int i = Min + 1; i <= Max + 1; i++) {
		if (i != Min + 1)printf(" ");
		printf("%d", i);
	}
	printf("\n");
}

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, d[100009];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> d[i];
    sort(d, d + n);
    int ans = d[n/2] - d[n/2 - 1];
    cout << ans << "\n";
    //system("pause");
    return 0;
}

Measured memory_bytes: 640
dp = [0 for i in range(1000000)]
N = int(input())
for i in range(2,1000):
  if i**2>N:
    break
  if dp[i]!=0:
    continue
  for j in range(i,1000000,i):
    dp[j] = 1
while dp[N]!=0:
  N += 1
print(N)

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n;
    cin1(n);
    string s;
    cin1(s);

    lli ans = 0;
    REP(i,0,n-1) {
        if (s[i] == s[i+1])
            continue;
        ans++;
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))

freqs = [0 for i in range(100003)]

for a in A:
  freqs[a] += 1

res = 0
for i in range(1,100002):
  res = max(res, freqs[i-1] + freqs[i] + freqs[i+1])

print(res)


Measured memory_bytes: 13964
import java.io.*;
import java.util.*;
 
public class Main{
	int H;
	int W;
	boolean[][] S;
	int[][] tate;
	int[][] yoko;
	void solve() {
		H = nextInt();
		W = nextInt();
		S = new boolean[H + 1][W + 1];
		tate = new int[H + 1][W + 1];
		yoko = new int[H + 1][W + 1];
		for(int r = 0; r < H; r++) {
			String str = next();
			for(int c = 0; c < W; c++) {
				if(str.charAt(c) == '.') {
					S[r][c] = true;
				}else {
					S[r][c] = false;
				}
			}
		}
		
		for(int r = 0; r < H; r++) {
			int si = 0;
			for(int c = 0; c <= W; c++) {
				if(!S[r][c]) {
					int len = c - si;
					for(int i = c - 1; i >= si; i--) {
						yoko[r][i] = len;
					}
					yoko[r][c] = 0;
					si = c + 1;
				}
			}
		}
		
		for(int c = 0; c < W; c++) {
			int si = 0;
			for(int r = 0; r <= H; r++) {
				if(!S[r][c]) {
					int len = r - si;
					for(int i = r - 1; i >= si; i--) {
						tate[i][c] = len;
					}
					tate[r][c] = 0;
					si = r + 1;
				}
			}
		}
		
		int max = 0;
		for(int r = 0; r < H; r++) {
			for(int c = 0; c < W; c++) {
				max = Math.max(max, tate[r][c] + yoko[r][c] - 1);
			}
		}
		out.println(max);
	}
	
	
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 106608
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<string>
#include<sstream>
#include<math.h>
using namespace std;
//char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main(){

		char a[200000];
		memset(a,'\0',sizeof(a));
		cin>>a;
		int ans=1;int mark,last;int light=0;
		for(int i=0;i<strlen(a);i++){
			if(a[i]=='A'&&light==0){light++;mark=i;}
			if(a[i]=='Z'&&light==1){last=i;}
		}
		cout<<last-mark+1<<endl;
	}

Measured memory_bytes: 384
import sys
read = sys.stdin.read
def main():
    n, *a = map(int, read().split())
    a.sort(reverse=True)
    r = a[0]
    end = int((n - 2) // 2)
    r += sum(a[1:end+1]) * 2
    if n % 2 == 1:
        r += a[end+1]
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 97440
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cmath>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
#define downint greater<int>()
#define downchar greater<char>()
#define downstring greater<string>()
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  cin >> n;
  for(i=1;i<=9;i++){
    if(n%i==0 && n/i<=9){
      result=1;
      break;
    }
  }
  cout << (result==1 ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 10;
int N, A[maxn];
int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d", &A[i]);
    }
    sort(A + 1, A + N + 1, greater<int>());
    int cnt = 1;
    LL ans = 0;
    for(int i = 1; i <= N; i++)
    {
        if(i == 1 || cnt == N - 1)
        {
            ans += A[i];
            cnt += 1;
        }
        else
        {
            ans += A[i] * 2;
            cnt += 2;
        }
        if(cnt == N)
            break;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4504
//Copyright(c)2018 Mstdream
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
char s[N];
void add(int x,int y){printf("%d %d\n",x,y);}
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++)s[i]-='0';
	bool flag=1;
	if(s[1]==0||s[n-1]==0||s[n]==1)flag=0;
	for(int i=1;i<=n;i++)if(s[i]^s[n-i])flag=0;
	if(!flag)puts("-1"),exit(0);
	int p=1,pre=0;
	for(int i=2;i<=n;i++){
		if(s[i]){
			if(pre)add(pre,i);
			for(int j=pre+1;j<i;j++)add(i,j);
			pre=i;
		}
	}
	for(int i=pre+1;i<=n;i++)add(pre,i);
}


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

long long n, ans=0;
pair<string, long long>s[100];
string x;

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> s[i].first >> s[i].second;
	cin >> x;
	bool cek=0;
	for (int i=0;i<n;i++){
		if (cek) ans+=s[i].second;
		if (s[i].first==x) cek=1;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
from queue import Queue
K=int(input())

q = Queue()

for i in range(1,10):
  q.put(i)
  
for n in range(K):
  if n==K-1:
    print(q.get())
  num=q.get()
  if num%10 !=0:
    q.put(10*num+(num%10)-1)
  q.put(10*num+num%10)
  
  if num%10 !=9:
    q.put(10*num+(num%10)+1)

Measured memory_bytes: 12452
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxn = 1e5;
const ll mod = 1e9 + 7;
 
ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
 
const int siz = 5e5+20;
ll fact[siz], inv[siz];
void pre(){
	fact[0] = 1;
	inv[0] = pow(fact[0], mod-2);
	for(int i=1;i<siz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}
 
int spf[10];
void sieve(){
    spf[1]=1;
    for(int i=2;i<mxn;i++) spf[i]=i;
    for(int i=4;i<mxn;i+=2) spf[i]=2;
    for(int i=3;i*i<mxn;i++){
    }
}

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

    string s;
    cin>>s;

    int n = s.size();

    if(s[n-1]=='s') s+="es";
    else s+="s";

    cout<<s<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;


int main(){
  int n,m;cin>>n>>m;
  vip q;
  int a,b;
  fol(i,n){
    cin >>a >> b;
    q.pb(make_pair(a,b));
  }
  sort(q.begin(),q.end());
  ll ans = 0;
  int buf = m;
  int index = 0;
  while(buf>0){
    ans += 1LL * q[index].first*min(q[index].second,buf);
    buf -= q[index].second;
    index++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

class MainClass
{
    public static void Main()
    {
        int width = 10;
        int height = 15;
        int n = int.Parse(Console.ReadLine());
        string[] infoArray = new string[n];
        string[,] allArray = new string[height, width];

        //Init allArray, infoArray
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                if ((i + 1) % 4 == 0)
                {
                    allArray[i, j] = "##";
                }
                else
                {
                    allArray[i, j] = " 0";
                }
            }
        }

        //Decide infoArray
        for (; n > 0; n--)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int[] nums = Array.ConvertAll(inputs, int.Parse);
            int b = nums[0], f = nums[1], r = nums[2], v = nums[3];
            int i = (b * 4 - 4) + f - 1;
            int j = r - 1;
            infoArray[n - 1] = i + " " + j + " " + v;
        }

        //Caluc v
        for (int i = 0; i < infoArray.Length; i++)
        {
            int[] xyArray = Array.ConvertAll(infoArray[i].Split(' '), int.Parse);
            int allArrayV = int.Parse(allArray[xyArray[0], xyArray[1]]);
            allArrayV += xyArray[2];
            allArray[xyArray[0], xyArray[1]] = " " + allArrayV.ToString();
        }

        //Display allArray
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                Console.Write(allArray[i, j]);
            }
            Console.WriteLine();
        }
    }
}

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

using lint = long long;

// lint knapsack(int limit, vector<int> &v, vector<int> &w) {
//     vector<lint> dyn(limit+1, -1); int n = w.size();
//     dyn[0] = 0;
//     for (int i = 0; i < n; ++i)
//         for (int j = limit; j >= w[i]; --j)
//             if (dyn[j - w[i]] >= 0)
//                 dyn[j] = max(dyn[j], dyn[j - w[i]] + v[i]);
//     lint result = 0;
//     for (int i = 0; i <= limit; ++i) 
//         result = max(result, dyn[i]);
//     return result;
// }

vector<int> Knapsack(int limit, vector<int> &v, vector<int> &w) {
    vector<vector<lint>> dyn(v.size()+1);
    dyn[0].resize(limit+1);
    for (int i = 0; i < v.size(); ++i) {
        dyn[i+1] = dyn[i];
        for (int j = 0; j <= limit - w[i]; ++j)
            dyn[i+1][w[i]+j] = max(dyn[i+1][w[i]+j], dyn[i][j] + v[i]);
    }
    vector<int> result;
    for (int i = v.size()-1; i >= 0; --i)
        if (dyn[i][limit] != dyn[i+1][limit]) {
            limit -= w[i];
            result.push_back(i);
        }
    return result;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n,w;
    cin >> n >> w;
    vector<int> v(n), c(n);
    for (int i = 0; i < n; ++i) 
    	cin >> c[i] >> v[i];
    //cout << knapsack(w, v, c) << '\n';
    auto res = Knapsack(w, v, c);
    lint total = 0;
    for (int u : res) 
    	total += v[u];
    cout << total << '\n';
}

Measured memory_bytes: 79488
import itertools
import functools
import math
from collections import Counter
from itertools import combinations

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

flg = 0
for i in range(1,1200+1):
    CHK_A= (i * 8) // 100
    CHK_B= (i * 10) // 100
    if A == CHK_A and B == CHK_B:
        print(i)
        exit()

print(-1)


Measured memory_bytes: 9592
#include <stdio.h>

int main()
{
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	int sum = a[0] + a[1];
	for (int i = 0; i < 3; i++) {
		for (int j = i+1; j < 3; j++) {
			if (a[i] + a[j] < sum) {
				sum = a[i] + a[j];
			}
		}

	}

	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S;
const ll MOD = (1e+9) + 7;
const ll INF = 1000;//1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>W;
    ll w0;
    vec wplus(N,0), v(N);
    cin>>w0>>v[0];
    reps(i,1,N){
        cin>>wplus[i]>>v[i];
        wplus[i] -= w0;
    }
    vector<mat> dp(N+1,mat(N+1, vec(400,-INF)));
    dp[0][0][0] = 0;
    rep(i,N){
        rep(j,N){
            rep(k,400) {
                if (dp[i][j][k] != -INF) {
                    dp[i + 1][j + 1][k + wplus[i]] = max(dp[i + 1][j + 1][k + wplus[i]], dp[i][j][k] + v[i]);
                }
                dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
            }
        }
    }
    ll ans = -INF;
    rep(j,N+1){
        rep(k,400){
            if(j*w0 + k <= W) ans = max(ans, dp[N][j][k]);
        }
    }
    /*rep(i,N){
        rep(j,N){
            rep(k,5) cout<<dp[i][j][k]<<' ';
            cout<<endl;
        }
        cout<<endl;
    }*/
    cout<<ans<<endl;
}

Measured memory_bytes: 32896
n = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if P[i] != i+1:
        continue
    else:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1
if P[n-1] == n:
    ans += 1
print(ans)


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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
const ll INF=1e17L+5;

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

    int n;cin>>n;
    vector<double> dp(n+1,0.0);
    dp[0]=1;
    f(i,1,n+1){
        double p;cin>>p;
        for(int j=i;j>=0;j--){
            dp[j]=(j==0 ? 0:dp[j-1]*p)+dp[j]*(1.0-p);
        }
    }
    double ans=0;
    for(int h=n/2+1;h<=n;h++){
        ans+=dp[h];
    }cout<<fixed<<setprecision(9)<<ans<<endl;
    

  }


Measured memory_bytes: 3872