akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#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 pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    cin >> n;
    vll digi(4);
    rep(i,4){
        digi[i] = (int)(n/pow(10,3-i))%10;
        //cout << i << " " << digi[i] << endl;
    }
    if(digi[0]+digi[1]+digi[2]+digi[3] == 7)
        cout << digi[0] << '+' << digi[1] << '+' << digi[2] << '+' << digi[3] << "=7" << endl;
    else if(digi[0]+digi[1]+digi[2]-digi[3] == 7)
        cout << digi[0] << '+' << digi[1] << '+' << digi[2] << '-' << digi[3] << "=7" << endl;
    else if(digi[0]+digi[1]-digi[2]+digi[3] == 7)
        cout << digi[0] << '+' << digi[1] << '-' << digi[2] << '+' << digi[3] << "=7" << endl;
    else if(digi[0]-digi[1]+digi[2]+digi[3] == 7)
        cout << digi[0] << '-' << digi[1] << '+' << digi[2] << '+' << digi[3] << "=7" << endl;
    else if(digi[0]+digi[1]-digi[2]-digi[3] == 7)
        cout << digi[0] << '+' << digi[1] << '-' << digi[2] << '-' << digi[3] << "=7" << endl;
    else if(digi[0]-digi[1]+digi[2]-digi[3] == 7)
        cout << digi[0] << '-' << digi[1] << '+' << digi[2] << '-' << digi[3] << "=7" << endl;
    else if(digi[0]-digi[1]-digi[2]+digi[3] == 7)
        cout << digi[0] << '-' << digi[1] << '-' << digi[2] << '+' << digi[3] << "=7" << endl;
    else if(digi[0]-digi[1]-digi[2]-digi[3] == 7)
        cout << digi[0] << '-' << digi[1] << '-' << digi[2] << '-' << digi[3] << "=7" << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
	string str,search;
	int n,check,cnt=0;
	cin >> search >> n;
	for(int i=0;i<n;i++){
		cin >> str;
		str += str;
		check = str.find(search,0);
		if(check != -1){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
double a[10002],ANS=1,X=0;
int main() {
	int n;
	cin>>n;
	
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		X+=1.0/a[i];
	}
	
	ANS=1.0*ANS/X;
	
	printf("%.7f",ANS);
	
	return 0;
}

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

long long n, k;

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

	long long a = n/k, b = (n+(k/2))/k;
	if (k&1) cout << a*a*a;
	else cout << a*a*a+b*b*b;
}


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

using namespace std;


int main()
{
long long int n;
set<long long int>arr;
cin>>n;


for (int i=1; i<=sqrt(n); i++) 
	{ 
		if (n%i == 0) 
		{ 
			if (n/i == i)
			{
				arr.insert(i);
			}
			else
			{
				arr.insert(i);
				arr.insert(n/i);
			} 
	} 
	}

int j = ceil(arr.size()/2);

//cout<<endl<<j;

std::set<long long int>::iterator it = arr.begin();
std::advance(it, j);
long long int x = *it;
cout<<(x-1)+((n/x)-1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	priority_queue<ll>a;
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push(x);
	}
	for(ll i=0;i<m;i++){
		ll now=a.top();
		a.pop();
		now=now/2;
		a.push(now);
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans+=a.top();
		a.pop();
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1400
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private static final int INF = Integer.MAX_VALUE / 2;

    private int A, B, C, D, E, F;

    private void solve(Scanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        D = sc.nextInt();
        E = sc.nextInt();
        F = sc.nextInt();

        Set<Integer> water = new HashSet<>();
        for (int i = 0; 100 * i * A <= F; ++i) {
            for (int j = 0; 100 * j * B <= F; ++j) {
                if (100 * i * A + 100 * j * B <= F) {
                    water.add(100 * i * A + 100 * j * B);
                }
            }
        }
        Set<Integer> sugar = new HashSet<>();
        for (int i = 0; i * C <= F; ++i) {
            for (int j = 0; j * D <= F; ++j) {
                if (i * C + j * D <= F) {
                    sugar.add(i * C + j * D);
                }
            }
        }
        int ans1 = 1, ans2 = -1;
        for (int w : water) {
            for (int s : sugar) {
                if (w + s <= F && 100 * s <= w * E && ans1 * s > ans2 * w) {
                    ans1 = w;
                    ans2 = s;
                }
            }
        }

        _out.println((ans1 + ans2) + " " + ans2);
    }
    private boolean okW(int a, int A, int B) {
        for (int i = 0; 100 * A * i <= a; ++i) {
            for (int j = 0; 100 * B * j <= a; ++j) {
                if (a == 100 * A * i + 100 * B * j) {
                    return true;
                }
            }
        }
        return false;
    }
    private boolean okS(int b, int C, int D) {
        for (int i = 0; C * i <= b; ++i) {
            for (int j = 0; D * j <= b; ++j) {
                if (b == C * i + D * j) {
                    return true;
                }
            }
        }
        return false;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 26824
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	char a, b;
	cin >> a >> b;
	set <char> s;
	s.insert('1');
	s.insert('2');
	s.insert('3');
	s.erase(a);
	s.erase(b);
	cout << *s.begin();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int n;
   cin>>n;
   int a[n];
   map<int,int> m;
   for(int i=0;i<n;i++){
    cin>>a[i];
   }
   int allgcd=a[0];
   for(int i=1;i<n;i++){
    allgcd=__gcd(a[i],allgcd);
   }
   const int N=1000001;
   vector<char> is_prime(N+1, true);
   is_prime[0] = is_prime[1] = false;
   for (int i = 2; i <= N; i++) {
    if (is_prime[i] && (long long)i * i <= N) {
        for (int j = i * i; j <= N; j += i)
            is_prime[j] = false;
    }
   }
   vector<int> c;
   for(int i=0;i<=N;i++){
       if(is_prime[i]){
           c.emplace_back(i);
       }
   }
  // cout<<(int)is_prime[6]<<"\n";
   for(int i=0;i<n;i++){
       int l=a[i];
       if(is_prime[l]){
           m[l]++;
          // cout<<l<<"\n";
       }else{
      for(int j=0;j<(int)c.size();j++){
          if(is_prime[l]){
              m[l]++;
              break;
          }
        if(l%c[j]==0){
          m[c[j]]++;
          while(l%c[j]==0){
               l=l/c[j];
          }
        }
        if(l<c[j]){
            break;
        }
        
      }
       }
   }
   int g=1;
   for(auto i:m){
    if(i.second==1){
      g=1;
      //cout<<i.first<<"\n";
    }else{
      g=0;
      break;
    }
   }
   if(g){
    cout<<"pairwise coprime"<<"\n";
    return 0;
   }
   if(allgcd==1){
      cout<<"setwise coprime"<<"\n";
      return 0;
   }
   cout<<"not coprime"<<"\n";
   return 0;


   
}


Measured memory_bytes: 11992
n = int(input())
def fib(n):
    m = [1,1]
    if n==0 or n==1:
        m=[1]
    else:
        for k in range(2,n+1):
            m.append(m[-1]+m[-2])
    return m

if n==0:
    l = fib(n)[n]
elif n==1:
    l = fib(n)[n-1]
else:
    l = fib(n)[n]
print(l)


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

int main() {
  int n; double sum=0;
  cin>>n;
  for(int i=0; i<n; i++){
    double a; string b;
    cin>>a>>b;
    if(b=="BTC") a *= 380000.0;
    sum += a;
  }
  cout<<setprecision(13)<<sum;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut q = std::collections::VecDeque::new();
    for i in 0..n {
        if i % 2 == 0 {
            q.push_back(a[i]);
        } else {
            q.push_front(a[i]);
        }
    }

    let mut q: Vec<i64> = q.iter().cloned().collect();
    if n % 2 > 0 {
        q.reverse();
    }

    print!("{}", q[0]);
    for i in 1..n {
        print!(" {}", q[i]);
    }
    println!("");
}


Measured memory_bytes: 12412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vll a(n+1);
    a[0] = 2;
    a[1] = 1;
    rep(i, 2, n+1){
        a[i] = a[i-1] + a[i-2];
    }
    cout << a[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
    int N;
    cin >> N;
    vector<ll> L(2*N);
    REP(i,2*N){
        cin >> L[i];
    }

    sort(ALL(L));
    reverse(ALL(L));

    ll ans = 0;

    REP(i,N){
        ans += min(L[2*i],L[2*i+1]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
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 divisor(int n) {
  int count = 0;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      count++;
      if(i * i != n) count++;
    }
  }
  return count;
}


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

    int ans = 0;
    rep(i,N){
        if((i+1)%2 == 1 && divisor(i+1) == 8) ans++;
    }
    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int d = 1000000;
		for(int n = sc.nextInt(); n !=0; n = sc.nextInt()) {
			int[] score = new int[n];
			for(int i = 0;i<n;i++) {
				score[i] = sc.nextInt();
			}
			for(int i=0; i<n-1;i++) {
				for(int j=i+1;j<n;j++) {
					if(Math.abs(score[i]-score[j])<d) {
						d = Math.abs(score[i]-score[j]);
					}
				}
			}
			System.out.println(d);
			d=1000000;
		}
	}
}



Measured memory_bytes: 47040
N = int(input())
s = input()

c_R = 0
c_B = 0
for string in s:
    if string == 'R':
        c_R+=1
    else:
        c_B+=1

if c_R > c_B:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
int main(){
string s;
cin>>s;
int k;
cin>>k;
REP(i,s.size()){
char c = s[i];
if(c=='a')continue;
int po = 'z'-c+1;
if(po<=k){
  k-=po;
  s[i]='a';
}
}
int n = s.size();
char c = s[n-1];
int yo = (c-'a'+k)%26;
s[n-1]='a'+yo;
cout<<s<<endl;
}

Measured memory_bytes: 640
from sys import stdin
n = int(stdin.readline())
a = stdin.readline().strip()
ans = 0
b = "abcdefghijklmnopqrstuvwxyz"
for i in xrange(n):
 x = a[:i]
 y = a[i:]
 cur = 0
 for i in b:
  if i in x and i in y:
   cur += 1
 ans = max(ans,cur)
print ans

Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define ull            unsigned long long int
#define ll             long long int
#define pb(x)          push_back(x)
#define mp(a,b)        make_pair(a,b)
#define li(ini)        for(ull i=ini;;i++)
#define lfi(i,ini,r)   for(ull i=ini;i<r;i++)
#define lfd(i,ini,r)   for(ull i=ini;i>=r;i--)
#define lit(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define l(v)           for(ull b:v)
#define sorta(v)       sort(v.begin(),v.end())
#define sortd(v)       sort(v.begin(),v.end(),greater<>())
#define vf(i)          v[i].first
#define vs(i)          v[i].second
#define fast_io        ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define en             "\n"

using namespace std;

vector<ll>v;
vector<ll>s;

int main()
{
    fast_io

    ll x=0,res=0,t=0,i=0,j=0,m=0,n=0,a=0,b=0,c=0,d=0,sum=0,flag=0,flag1=1,cont=0,k=0;
    //cout<<INT_MIN<<en;

    cin>>n>>m;
    ll proM=0,proN=0;
    proN=(n*(n-1))/2;
    proM=(m*(m-1))/2;
    cout<<proN+proM<<en;

    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
        
    int n,m,x;
    cin>>n>>m>>x;

    int cost[n];
    int a[n][m];
    bool exist = false;
    int ans = big;

    repa(i,0,n-1)
    {
        cin>>cost[i];
        repa(j,0,m-1)
            cin>>a[i][j];
    }

    int val = (1<<n);

    repa(i,0,val-1)
    {
        int cur_cost = 0;
        vector<int>bitmask;
        int buf = i;
        while(buf)
            bitmask.pb((buf%2)), buf/=2;
        int diff = n - bitmask.size();
        repa(j,1,diff)
            bitmask.pb(0);

        int skills[m]={0};

        repa(j,0,n-1)
        {
            if ( bitmask[j]==1 )
            {
                repa(jj,0,m-1) 
                    skills[jj]+=a[j][jj];
                cur_cost+=cost[j];
            }
        }

        repa(j,0,m-1)
            if (skills[j]<x)
                cur_cost = -1;

        if (cur_cost!=-1)
        {
            exist = true;
            ans = min(cur_cost,ans);
        }
    }

    if (!exist)
        cout<<-1<<endl;
    else
        cout<<ans<<endl;

}

Measured memory_bytes: 3624
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

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

if X == Y:
    ans = min(A*X+B*Y, C*X*2)
elif X > Y:
    ans = min(A*X+B*Y, C*X*2, 2*C*Y+A*(X-Y))
else:
    ans = min(A*X+B*Y, C*Y*2, 2*C*X+B*(Y-X))

print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

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

    int M = scanner.nextInt();
    int K = scanner.nextInt();
    int[] ans = solve(M, K);
    if (ans == null) {
      System.out.println("-1");
      return;
    }
    StringBuilder sb = new StringBuilder();
    for (int n : ans) sb.append(n).append(' ');
    sb.setLength(sb.length() - 1);
    System.out.println(sb.toString());
  }

  private static int[] solve(int M, int K) {
    if (K >= (1 << M)) return null;
    if (M == 0) {
      if (K == 0) return new int[]{0, 0};
      return null;
    } else if (M == 1) {
      if (K == 0) return new int[]{0, 0, 1, 1};
      return null;
    } else {
      int[] res = new int[1 << (M + 1)];
      int p = 0;
      for (int i = 0; i < (1 << M); i++) {
        if (i != K) {
          res[p++] = i;
        }
      }
      res[p++] = K;
      for (int i = (1 << M) - 1; i >= 0; i--) {
        if (i != K) {
          res[p++] = i;
        }
      }
      res[p] = K;
      return res;
    }
  }
}


Measured memory_bytes: 40148
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a_ij: Vec<Vec<usize>> = (0..3).map(|_| (0..3).map(|_| read()).collect()).collect();
    let n: usize = read();
    let bi: Vec<usize> = (0..n).map(|_| read()).collect();

    let mut c_ij: Vec<Vec<bool>> = (0..3).map(|_| (0..3).map(|_| false).collect()).collect();

    for b in bi {
        for i in 0..3 {
            for j in 0..3 {
                if a_ij[i][j] == b {
                    c_ij[i][j] = true;
                }
            }
        }
    }

    let mut ans = "No";

    for i in 0..3 {
        if c_ij[i][0] && c_ij[i][0] == c_ij[i][1] && c_ij[i][1] == c_ij[i][2] {
            ans = "Yes";
            break;
        }
        if c_ij[0][i] && c_ij[0][i] == c_ij[1][i] && c_ij[1][i] == c_ij[2][i] {
            ans = "Yes";
            break;
        }
    }
    if c_ij[0][0] && c_ij[0][0] == c_ij[1][1] && c_ij[1][1] == c_ij[2][2] {
        ans = "Yes";
    } else if c_ij[0][2] && c_ij[0][2] == c_ij[1][1] && c_ij[1][1] == c_ij[2][0] {
        ans = "Yes";
    }

    println!("{}", ans);
}


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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char smax(A &a, const B &b) {return a < b ? a = b, 1 : 0;}
template<typename A, typename B> inline char smin(A &a, const B &b) {return b < a ? a = b, 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I> inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 1000 + 7;

int n, m, A, B;
int a[N][N];

inline void work() {
	for (int i = 1; i <= B; ++i) {
		for (int j = 1; j <= A; ++j) a[i][j] = 0;
		for (int j = A + 1; j <= m; ++j) a[i][j] = 1;
	}
	for (int i = B + 1; i <= n; ++i) {
		for (int j = 1; j <= A; ++j) a[i][j] = 1;
		for (int j = A + 1; j <= m; ++j) a[i][j] = 0;
	}
	for (int i = 1; i <= n; ++i, puts(""))
		for (int j = 1; j <= m; ++j)
			printf("%d", a[i][j]);
}

inline void init() {
	read(n), read(m), read(A), read(B);
}

int main() {
#ifdef hzhkk
//	freopen("hkk.in", "r", stdin);
#endif
	init();
	work();
	fclose(stdin), fclose(stdout);
	return 0;
}

Measured memory_bytes: 5120
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
A, B, Q = map(int, input().split())
a = [-10 ** 18] + [int(input()) for _ in range(A)] + [10 ** 18]
b = [-10 ** 18] + [int(input()) for _ in range(B)] + [10 ** 18]
for _ in range(Q):
  x = int(input())
  ra = bl(a, x)
  rb = bl(b, x)
  la = ra - 1
  lb = rb - 1
  res = 10 ** 18
  res = min(res, max(abs(a[ra] - x), abs(b[rb] - x)))
  res = min(res, max(abs(a[la] - x), abs(b[lb] - x)))
  res = min(res, max(abs(a[la] - x), abs(b[rb] - x)) + min(abs(a[la] - x), abs(b[rb] - x)) * 2)
  res = min(res, max(abs(a[ra] - x), abs(b[lb] - x)) + min(abs(a[ra] - x), abs(b[lb] - x)) * 2)
  print(res)

Measured memory_bytes: 95784
#include <cstdio>

int pow(int x,int r)
{
	return r==0?1:x*pow(x,r-1);
}

int main()
{
	for(int n;~scanf("%d",&n);){
		if(n&1)
			printf("%d\n",2*pow(3,n/2)-1);
		else
			printf("%d\n",pow(3,n/2)-1);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <locale.h>
void ler_array(int i,int n,char a[])
{
if (i == n)
{
  return;
}
else
{
scanf(" %c",&a[i]);
//printf("%c",a[i]);
ler_array(i+1,n,a);
}
}
void imprimir_array(int i,int n,char a[],char b[])
{
if (i == n)
{
  return;
}
else
{
printf("%c",a[i]);
printf("%c",b[i]);
imprimir_array(i+1,n,a,b);
}
}
int main(void)
{
int n;
scanf("%d",&n);
char a[n];
char b[n];
ler_array(0,n,a);
ler_array(0,n,b);
imprimir_array(0,n,a,b);

}


Measured memory_bytes: 128
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N, Ma, Mb = l_inpl()
    abc = []
    for _ in range(N):
        abci = l_inpl()
        abc.append(abci)

    max_ab = 40*10

    # dp[i][j][k]: i番目までの薬品の組み合わせで，物質aがjグラム，物質bがkグラムのときのコスト
    dp = [[[INF for _ in range(max_ab+1)] for _ in range(max_ab+1) ] for _ in range(N+1)]
    dp[0][0][0] = 0

    for i in range(N):
        for j in range(max_ab+1):
            for k in range(max_ab+1):
                # ここでのINFはNoneと同じ意味なので
                if dp[i][j][k] == INF:
                    continue
                # i番目の薬品を加えない
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
                # i番目の薬品を加える
                dp[i+1][j+abc[i][0]][k+abc[i][1]] = min(dp[i+1][j+abc[i][0]][k+abc[i][1]], dp[i][j][k] + abc[i][2])
                
    ans = INF
    for ca in range(1, max_ab+1):
        for cb in range(1, max_ab+1):
            if ca*Mb == cb*Ma:
                ans = min(ans, dp[N][ca][cb])
    
    if ans == INF:
        print(-1)
    else:
        print(ans)

    
if __name__ == "__main__":
    main()


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

int main() {
	int N, M, C, b[25], a[25][25], ans=0, value;
	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < N; i++) {
		value = 0;
		for (int j = 0; j < M; j++) {
			value += a[i][j] * b[j];
		}
		value += C;
		if (value > 0) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from operator import itemgetter

n, m = map(int, input().split())
pair = []

for _ in range(n):
    a, b = map(int, input().split())
    pair.append((a, b))

pair = sorted(pair, key=itemgetter(0))

cnt = 0
ans = 0

for i in pair:
    if m - cnt >= i[1]:
        ans += i[0] * i[1]
        cnt += i[1]
    else:
        ans += i[0] * (m - cnt)
        break

print(ans)

Measured memory_bytes: 18960
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
const ll MOD=1000000007;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<pair<int,int>>A;
    int a;
    REP(i,N){
        cin>>a;
        A.pb(make_pair(a,i+1));
    }
    sort(ALL(A));
    REP(i,N-1){
        cout<<A[i].second<<" ";
    }
    cout<<A[N-1].second<<endl;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string cnt,cnt1;
    cnt.push_back(s[0]);
    cnt.push_back(s[1]);
    cnt1.push_back(s[2]);
    cnt1.push_back(s[3]);
    int x=stoi(cnt);
    int y=stoi(cnt1);
    if(1<=x && x<=12 && 1<=y && y<=12){
      cout<<"AMBIGUOUS"<<endl;
    }else if(1<=x && x<=12 && (y>=13 || y==0)){
      cout<<"MMYY"<<endl;
    }else if((x>=13||x==0) && 1<=y && y<=12){
      cout<<"YYMM"<<endl;
    }else{
      cout<<"NA"<<endl;
    }
}

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

using namespace std;
using ll = long long;

int main() {
    int N, M;
    ll S;
    cin >> N >> M >> S;
 
    vector<vector<tuple<int, int, ll>>> E(N);
    vector<pair<ll, ll>> B(N);

    int amax = 0;
    for(int i = 0; i < M; i++) {
        int u, v, a;
        ll b;
        cin >> u >> v >> a >> b;
        E[u-1].push_back(make_tuple(v-1,a,b));
        E[v-1].push_back(make_tuple(u-1,a,b));
        amax = max(a, amax);
    }
    ll C = amax * (N - 1);
    vector<vector<ll>> dp(N, vector<ll>(C + 1, LLONG_MAX >> 4));
    for(auto & [c, d]: B) cin >> c >> d;

    for(int i = 0; i <= min(C, S); i++) dp[0][i] = 0;


    using qtype = tuple<ll, int, int>;
    priority_queue<qtype, vector<qtype>, greater<qtype>> q;
    q.push(make_tuple(0, min(C, S), 0));

    while(!q.empty()) {
        auto [t_sum, coin, node] = q.top();
        q.pop();
        if(t_sum > dp[node][coin]) continue;
        for(auto [to, c, t]: E[node]) {
            if(coin < c) continue;
            ll nt = t_sum + t;
            if(nt < dp[to][coin - c]) {
                dp[to][coin - c] = nt;
                q.push(make_tuple(nt, coin - c, to));
            }
        }
        auto [b_num, b_time] = B[node];
        for(int i = 1;;i++) {
            int nc = min(C, b_num * i + coin);
            ll nt = t_sum + i * b_time;
            if(nt < dp[node][nc]) {
                dp[node][nc] = nt;
                q.push(make_tuple(nt, nc, node));
            }
            if(nc == C) break;
        }
    }
    for(int i = 1; i < N; i++) {
        cout << *min_element(dp[i].begin(), dp[i].end()) << endl;
    }
}

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

int main(){
    int r,c;
    cin>>r>>c;
	int a[101][101]={};
	for(int i=0;i<r;i++){
	    for(int j=0;j<c;j++){
	        cin>>a[i][j];
	    }
	}
	for(int i=0;i<r;i++){
	    for(int j=0;j<c;j++){
	        a[i][c]+=a[i][j];
	    }
	}
	for(int i=0;i<c;i++){
	    for(int j=0;j<r;j++){
	        a[r][i]+=a[j][i];
	    }
	}
	for(int i=0;i<r;i++){
	    a[r][c]+=a[i][c];
	}
	for(int i=0;i<=r;i++){
	    for(int j=0;j<=c;j++){
			if(j)cout<<" ";
			cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3128
bingo = []
for i in range(3):
    bingo.append(input().split())

n = int(input())
for i in range(n):
    num = input()
    try:
        for y, row in enumerate(bingo):
            try:
                pos = (y, row.index(num))
                break
            except:
                pass
        bingo[pos[0]][pos[1]] = False
    except:
        pass

for i in range(3):
    if not any(bingo[i]):
        print("Yes")
        exit()
for i in range(3):
    if not (bingo[0][i] or bingo[1][i] or bingo[2][i]):
        print("Yes")
        exit()
if not(bingo[0][0] or bingo[1][1] or bingo[2][2]):
    print("Yes")
    exit()
if not(bingo[0][2] or bingo[1][1] or bingo[2][0]):
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define N 1005
using namespace std;
typedef long long ll;

ll n, a, b, c, d, M=1e9+7, dp[N]={1}, fac[N]={1}, fiv[N]={1};

ll pow(ll p, ll q) {
	return q ? pow(p*p%M, q/2) * (q&1 ? p : 1) % M : 1;
}

int main() {
	ll i, j, k;
	cin >> n >> a >> b >> c >> d;
	for(i=1; i<=n; i++) {
		fac[i] = fac[i-1] * i % M;
		fiv[i] = pow(fac[i], M-2);
	}
	for(i=a; i<=b; i++) for(j=n; j>=0; j--) for(k=c; k<=d && j-k*i>=0; k++) {
		dp[j] = (dp[j] + dp[j-k*i] * pow(fiv[i], k) % M * fiv[k]) % M;
	}
	cout << dp[n] * fac[n] % M;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n, W, best, w[110], v[110], dp[110][100005];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> W;
    for(long long int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    for(long long int i=0;i<=n;i++){
        for(long long int j=0;j<=W;j++){
            if(i==0 or j==0){
                dp[i][j]=0;
            }
            else{
                best=dp[i-1][j];
                if(j>=w[i]){
                    best=max(best, dp[i-1][j-w[i]]+v[i]);
                }
                dp[i][j]=best;
            }
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 80128
cnt = 0
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    for i in range(1, n+1):
        for j in range(1, i+1):
            for k in range(1, j+1):
                if i + j + k == x and not(i==j or j==k or k==i):
                    cnt+=1
    print(cnt)
    cnt = 0


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    int2(a, b);
    int2(c, d);

    for (int m = 0; m < n-1; m++) {
        if ( (n-1-m) * c - d * m <= a - b && 
                a - b <= (n - 1 - m) * d - c * m) {
            std::cout << "YES" << std::endl;
            return 0;
        }
    }
    std::cout << "NO" << std::endl;


    return 0;
}



Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int r, g, b; cin >> r >> g >> b;

	int num = r * 100 + g * 10 + b;
	if (num % 4 == 0)cout << "YES" << endl;
	else cout << " NO" << endl;
}

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

int main()
{
    long i, N;
    long long ans = 0;
    scanf("%ld", &N);
    for (i = 1; i * i + i < N; i++)
    {
        if (N % i == 0)
        {
            ans += N / i - (long)(1);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    S = input()
    T = input()
    if S == T[:-1]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 68916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

const ll p = 10e8 + 7;

vector<ll> pows(2 * 10e5 + 7, -1);

ll pow2(ll x)
{
    if (pows[x] >= 0)
        return pows[x];
    ll a = 1;
    rep(i, x)
    {
        a = (a * 2) % p;
        pows[i + 1] = a;
    }
    return a;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> c(n);
    rep(i, n) cin >> c[i];
    sort(c.begin(), c.end());

    vector<ll> facts(n);
    rep(i, n)
    {
        ll r = n - 1 - i;
        if (r == 0)
        {
            facts[i] = pow2(i);
            break;
        }
        facts[i] = pow2(i) * (pow2(r) + (pow2(r - 1) * (r)) % p);
        facts[i] %= p;
    }

    ll ans = 0;
    rep(i, n)
    {
        ll add = (c[i] * facts[i]) % p;
        ans += add;
        ans %= p;
    }
    ans *= pow2(n);
    ans %= p;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  
  int n, m, a;
  cin >> n >> m;
  int sum = 0;
  rep(i,m) {
    cin >> a;
    sum += a;
  }
  if (sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
}

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

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int n;
	cin >> n;
	vector<int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(), s.end());
	if (n % 2 == 0) {
		for (int i = 0; i < n; i = i + 2) {
			for (int j = i; j < i + 2; j++) {
				if (s[j] != i+1) {
					cout << 0;
					return 0;
				}
			}
		}
	}
	else {
		if (s[0] != 0) {
			cout << 0;
			return 0;
		}
		for (int i = 1; i < n; i = i + 2) {
			for (int j = i; j < i + 2; j++) {
				if (s[j] != i + 1) {
					cout << 0;
					return 0;
				}
			}
		}
	}
	long long int ans = 1;
	for (int i = 0; i < n/2; i++) {
		ans = ans * 2;
		ans = ans % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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


int main() {
    
    int n;
    cin >> n;
    cout << pow(n, 3) << '\n';
    
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int main()
{
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans;
	if (n == m) {
		ans = 2;
	}
	if (abs(n - m) == 1) {
		ans = 1;
	}
	for (int i = 1; i <= n; i++) {
		ans = ans * i %mod;
	}
	for (int i = 1; i <= m; i++) {
		ans = ans * i% mod;
	}
	cout << ans << endl;

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc153() {
	ll h;
	ll ans = 0;

	cin >> h;

	ll now = 1;
	while (h > 0) {
		if (h == 1) {
			ans += now;
			break;
		}
		else {
			h /= 2;
			ans += now;
			now *= 2;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc153();

	return 0;
}

Measured memory_bytes: 256
import sys

class Node:
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    def insert(self, key):
        x, y = self.root, None
        while x != None: x, y = x.left if key < x.key else x.right, x
        if y == None: self.root = Node(key)
        elif key < y.key: y.left = Node(key)
        else: y.right = Node(key)
    def print_tree(self):
        def inorder(node):
            return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
        def preorder(node):
            return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''
        print(inorder(self.root))
        print(preorder(self.root))

tree = BST()
input()
for e in sys.stdin:
    if e[0] == 'i': tree.insert(int(e[7:]))
    else: tree.print_tree()


Measured memory_bytes: 115000
#include <iostream>
using namespace std;
int main()
{
    int N, A[100];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int count1 = 0, count2 = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] % 2 == 0)
        {
            count1++;
            if (A[i] % 3 == 0 || A[i] % 5 == 0)
            {
                count2++;
            }
        }
    }
    if (count1 == count2)
    {
        cout << "APPROVED";
    }
    else
    {
        cout << "DENIED";
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s; cin >> s;
    reverse(ALL(s));

    vll cnt(2019, 0);
    cnt[0]++;
    ll num = 0, d = 1;
    for (auto c : s) {
        num = (num + (c - '0') * d) % 2019;
        cnt[num]++;
        d = (d * 10) % 2019;
    }

    ll total = 0;
    rep(i, 2019) {
        total += cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;

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

    private static void solve(Scanner sc) {
        String cache = null;
        String[] str = sc.next().split("");

        for (int i = 0; i < str.length; i++) {
            if ("?".equals(str[i])) {
                System.out.print("D");
                cache = "D";
            } else {
                System.out.print(str[i]);
                cache = str[i];
            }
        }
    }
}


Measured memory_bytes: 68276
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>

using namespace std;

#define rep(countName, left, right) for (int countName = left; countName < right; countName++)

long long GCD(long long a, long long b)
{
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return GCD(b, a % b);
    }
}

int main(void)
{
    int n;
    cin >> n;
    long long ans = 0;

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

    rep(i, 0, n)
    {
        //まず正面の敵を倒してもらう
        if (a[i] >= b[i])
        {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
        else
        {
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }

        /*debug
        cout << "===========================================" << endl;
        rep(i, 0, n + 1) { cout << a[i] << "\t"; }
        cout << endl;
        rep(i, 0, n) { cout << b[i] << "\t"; }
        cout << endl;
        cout << "===========================================" << endl;
        */

        //余力があれば、右隣の町に行ってもらう
        if (b[i] != 0)
        {
            if (a[i + 1] >= b[i])
            {
                ans += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
            else
            {
                ans += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    
    /*debug
    cout << "===========================================" << endl;
    rep(i, 0, n + 1) { cout << a[i] << "\t"; }
    cout << endl;
    rep(i, 0, n) { cout << b[i] << "\t"; }
    cout << endl;
    cout << "===========================================" << endl;
    */

    cout << ans << endl;

    return 0;
}

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


int main(){

  int n, t=0, h=0, i, j, len;
  char ta[100], ha[100];

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%s %s", ta, ha);
    if(strlen(ta)>strlen(ha)) len=strlen(ta);
    else len=strlen(ha);

    for(j=0;j<len;j++){
      if(ta[j]>ha[j]){
        t+=3;
        break;
      }else if(ta[j]<ha[j]){
        h+=3;
        break;
      }
    }
      if(j==len){
        if(strcmp(ta, ha)==0){
          t++;
          h++;
        }else if(strcmp(ta, ha)>0) t+=3;
        else h+=3;
      }
  }

  printf("%d %d\n", t, h);


  return 0;
}

Measured memory_bytes: 604