akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<edge> edges;
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int n;
	cin >> n;
	REP(x, n)
	{
		string s;
		int cntout = 0;
		int run = 0;
		int score = 0;
		while (cin >> s)
		{
			if (s == "OUT") cntout++;
			if (cntout == 3)
			{
				cout << score << endl;
				break;
			}
			if (s == "HIT")
			{
				run <<= 1;
				run += 1;
				if (run >= 8)
				{
					score++;
					run %= 8;
				}
			}
			if (s == "HOMERUN")
			{
				score++;
				while (run > 0)
				{
					if (run & 1) score++;
					run >>= 1;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string S;
    int flag = 0;
    cin >> S;
    for (int count = 0; count < 3; count++)
    {
        if (S.at(count) == S.at(count + 1))
        {
            flag = 1;
        }
    }
    if (flag)
    {
        cout << "Bad" << endl;
    }
    else
    {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mp make_pair

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k-1];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 10e9 + 7;
typedef long long ll;
const double rate = 380000.0;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int S = a * b / 2;
	cout << S << endl;
}

Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split()))
#set型にしてからlistにキャストすることで，複数存在するものを省いている
unq = list(set(nums))

#違う数字が4個以上存在したら，正しい答えは存在しない
if len(unq) > 3:
  print("No")

if len(unq) == 3:
    #list,unqをアンパックしてa,b,cにいれている
    a,b,c = unq
    if a ^ b ^ c == 0:
      if nums.count(a) == nums.count(b) == nums.count(c):
        print("Yes")
      else:
        print("No")
    else:
      print("No")

if len(unq) == 2:
    a,b = sorted(unq)
    if a == 0:
      if nums.count(a) * 2 == nums.count(b):
        print("Yes")
      else:
        print("No")
    else:
      print("No")

if len(unq) == 1:
    a = unq[0]
    if a != 0:
      print("No")
    else:
      print("Yes")


Measured memory_bytes: 14704
#include <stdio.h>

int main(void){
  int a, b;
  int c, ans=0;
  while(scanf("%d %d", &a, &b) != EOF){
    c = a + b;
    if(c==0){
      ans = 1;
    }else {
      while(c > 0){
        ans++;
        c = c / 10;
      }
    }
    printf("%d\n", ans);
    ans = 0;
  }
  return 0;
}

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

typedef long long int ll;

const ll mod = 1e9+7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int h, w;
  cin >> h >> w;
  vector<string> mat(h+1);
  for(int i=1;i<=h;++i)
  {
    cin >> mat[i];
    mat[i] = '\0' + mat[i];
  }
  vector<vector<ll>> dp(h+1, vector<ll> (w+1, 0));
  dp[1][1] = 1;
  
  for(int i=1;i<=h;++i)
    for(int j=1;j<=w;++j)
    {
      if(mat[i][j] == '#') continue;
      if(mat[i-1][j] == '.')  dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
      if(mat[i][j-1] == '.')  dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;
    }
  
  cout << dp[h][w] << endl;  
  
  return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  string s;cin>>s;
  vector<ll>dp1(10),dp2(100),dp3(1000);
  rep(i,n){
    ll no=s[i]-'0';
    rep(i,100){
      if(dp2[i]&&dp3[i*10+no]==0)dp3[i*10+no]=1;
    }
    rep(i,10){
      if(dp1[i]&&dp2[i*10+no]==0)dp2[i*10+no]=1;
    }
    if(!dp1[no])dp1[no]=1;
    
  }
  ll res=0;
  rep(i,1000)res+=dp3[i];
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;

int dp[2][1000002];

int main(){
	int a,b,n,x,y;
	while(cin>>a>>b,a||b){
        set<int> koji;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>x>>y;
            koji.insert(y*100002+x);
        }
        for(int i=0;i<2;i++)for(int j=1;j<=a;j++) dp[i][j]=0;
        dp[1][1]=1;
        for(int i=1;i<=b;i++){
            for(int j=1;j<=a;j++){
                set<int>::iterator itr=koji.find(i*100002+j);
                if(!(itr==koji.end())){
                    dp[i&1][j]=0;
                    //printf("0 ");
                    continue;
                }

                //printf("%d %d\n",i,j);
                //dp[i&1][j]%=100000;
                dp[(i+1)&1][j]+=dp[i&1][j]/*%100000*/;
                dp[i&1][j+1]+=dp[i&1][j]/*%100000*/;
                //printf("%d ",dp[i&1][j]);
                if(i!=b || j!=a){
                    dp[i&1][j]=0;
                }
            }//puts("");
        }
        printf("%d\n",dp[b&1][a]/*%100000*/);
	}
	return 0;
}

Measured memory_bytes: 3220
mod = 10**9+7
K = input()
n = len(K)
D = int(input())
dp = [[[0]*2 for i in range(D)] for _ in range(n)]
for i in range(int(K[0])):
    dp[0][i%D][0] += 1
dp[0][int(K[0])%D][1] += 1
for i in range(n-1):
    for j in range(D):
        for d in range(10):
            dp[i+1][(j+d)%D][0]+=dp[i][j][0]
            dp[i+1][(j+d)%D][0]%=mod
        for d in range(int(K[i+1])):
            dp[i+1][(j+d)%D][0]+=dp[i][j][1]
            dp[i+1][(j+d)%D][0]%=mod
        dp[i+1][(j+int(K[i+1]))%D][1] += dp[i][j][1]
        dp[i+1][(j+int(K[i+1]))%D][1]%=mod
print((dp[-1][0][0]+dp[-1][0][1]-1)%mod)




Measured memory_bytes: 129500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

vector<int> divisor(int n){
    vector<int> d;
    for(int i=1; i*i<=n; ++i)if(n%i==0){
        d.pb(i);
        if(n/i != i) d.pb(n/i);
    }
    return d;
}

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

    vector<ll> a(s+1);
    for(int i=1; i<=s; ++i){
        int now = 0;
        for(int j=i; j<=s; ++j){
            now += j;
            if(now > s) break;
            ++a[now];
        }
    }

    ll ans = 0;
    for(int x:divisor(s)) ans += a[x]*a[s/x];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3508
/**
 *    author:  morato
 *    created: 19.09.2020 17:29:39
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  int f = 0;
  for (int i = 0; i < n - 2; i++) {
    if (a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]) {
      f = 1;
    }
  }
  cout << (f ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
double ans;
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	while(n--){
		double x;
		string s;
		cin>>x>>s;
		if(s=="BTC") x*=380000;
		ans+=x; 
	}
	cout<<ans;
	re 0;
}

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

const ll MAX = 500001;
const ll MOD = 1000000007;

vector<ll> fac(MAX);
vector<ll> finv(MAX);
vector<ll> inv(MAX);

void comp_init()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll 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;
  } 
}

ll bin_mod(ll n, ll k)
{
  if ( n<k ) return 0;
  if ( n<0 || k<0 ) return 0;
  return fac[n] * (finv[k]*finv[n-k]%MOD)%MOD;
}

int main()
{
  comp_init();
  ll n,k;
  cin >> n >> k;

  if ( k==1 )
  {
    cout << "0" << endl;
    return 0;
  }

  vector<ll> v(n);
  rep(n) cin >> v[i];
  sort(v.begin(),v.end());

  ll plus = 0;
  ll minus = 0;

  for (ll i = 0; i < n; i++)
  {
    plus = plus + v[i] * bin_mod(i,k-1) % MOD;
    minus = minus + v[i] * bin_mod(n-i-1,k-1) % MOD;
  }

  ll tmp = plus - minus;
  if ( tmp >= 0 ) tmp = tmp % MOD;
  else tmp += MOD;
  
  cout << tmp << endl;

  return 0;
}

Measured memory_bytes: 12800
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	l := c - a + b
	if l >= 0 {
		fmt.Println(l)
		return
	}
	fmt.Println(0)
}


Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$result = $a[0];
$pow = 10 ** 18;

if (in_array(0, $a)) {
    echo "0\n";
    exit;
}

for ($i = 1; $i < $n; $i++) {
    $result = $result * $a[$i];
}

if ($result > $pow) {
    echo "-1\n";
    exit;
}

echo "{$result}\n";


Measured memory_bytes: 25428
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int a,b,c,d;
int ok(int x){
	int hop=(c*d)/__gcd(c,d);
	int sum=x/c;
	int sum2=x/d;
	int sum3=x/hop;
	return sum+sum2-sum3;
}
main(){
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	int trol=ok(b)-ok(a-1);
	printf("%lld",b-a+1-trol);
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    ll H,W;cin>>H>>W;
    if(H>W) swap(H,W);
    if(H==1) cout<<1<<endl;
    else if(H%2==0||W%2==0) cout<<H*W/2<<endl;
    else cout<<(H/2)*(W/2)+((H+1)/2)*((W+1)/2);
}


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


int main(){
    string s;
    cin >> s;
    int l = stoi(s.substr(0, 2));
    int r = stoi(s.substr(2, 2));

    if(l > 12 && r > 12) cout << "NA" << endl;
    else if(l == 0 && r == 0) cout << "NA" << endl;
    else if(l > 12 && r == 0) cout << "NA" << endl;
    else if(r > 12 && l == 0) cout << "NA" << endl;
    else if(l > 12 || l == 0) cout << "YYMM" << endl;
    else if(r > 12 || r == 0) cout << "MMYY" << endl;
    else cout << "AMBIGUOUS" << endl;
}

Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())

k = 60*h + m

import math

if m <= 15:
    by = b * math.sin(math.radians(90-(6*m)))
    bx = b * math.cos(math.radians(90-(6*m)))
elif m > 15 and m <= 30:
    by = b * -(math.sin(math.radians(6*(m-15))))
    bx = b * math.cos(math.radians(6*(m-15)))
elif m > 30 and m <= 45:
    by = b * -(math.sin(math.radians(90-((6*m)-180))))
    bx = b * -(math.cos(math.radians(90-((6*m)-180))))
else:
    by = b * math.sin(math.radians((6*m)-270))
    bx = b * -(math.cos(math.radians((6*m)-270)))
    
if k <= 180:
    ay = a * math.sin(math.radians(90-((1/2)*k)))
    ax = a * math.cos(math.radians(90-((1/2)*k)))
elif k > 180 and k <= 360:
    ay = a * -(math.sin(math.radians(((1/2)*k)-90)))
    ax = a * math.cos(math.radians(((1/2)*k)-90))
elif k > 360 and k <= 540:
    ay = a * -(math.sin(math.radians(90-(((1/2)*k)-180))))
    ax = a * -(math.cos(math.radians(90-(((1/2)*k)-180))))
else:
    ay = a * math.sin(math.radians(((1/2)*k)-270))
    ax = a * -(math.cos(math.radians(((1/2)*k)-270)))

ans = math.sqrt((ax-bx)**2 + (ay-by)**2)
print('{:.11f}'.format(ans))

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


int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(auto& p : P){
    cin >> p;
  }
  int ans = 0;
  for(int ii=0; ii<N-2; ii++){
    if((P[ii]<P[ii+1] && P[ii+1]<P[ii+2])|| (P[ii+2]<P[ii+1] && P[ii+1]<P[ii])) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}



int main()
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int h=abs(ty-sy),w=abs(tx-sx);
    string t1,t2;
    for(int i=0;i<h;i++)t1.push_back('U');
    for(int i=0;i<w;i++)t1.push_back('R');
    for(int i=0;i<t1.length();i++)
    {
         if(t1[i]=='U')t2.push_back('D');
         else if(t1[i]=='R')t2.push_back('L');
    }
    string t3,t4;
    t3.push_back('L');
    for(int i=0;i<h;i++)t3.push_back('U');
    t3.push_back('U');t3.push_back('R');
    for(int i=0;i<w;i++)t3.push_back('R');t3.push_back('D');
    t4.push_back('R');
    for(int i=0;i<h;i++)t4.push_back('D');t4.push_back('D');
    t4.push_back('L');
    for(int i=0;i<w;i++)t4.push_back('L');
    t4.push_back('U');
    cout<<t1<<t2<<t3<<t4;
}















 














 
 

















Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


vector<int> sm;
vector<int> buf;


ll merge_(int st, int m, int e) {
    for (int i = st; i < e; ++i) {
        swap(buf[i], sm[i]);
    }
    int i1 = st, i2 = m;
    int i = st;
    ll res = 0;
    while ((i1 < m) || (i2 < e)) {
        if (i1 == m) {
            sm[i] = buf[i2];
            ++i, ++i2;
            continue;
        }
        if (i2 == e) {
            sm[i] = buf[i1];
            ++i, ++i1;
            continue;
        }
        if (buf[i1] < buf[i2]) {
            sm[i] = buf[i1];
            ++i, ++i1;
            res += e - i2;
        }
        else {
            sm[i] = buf[i2];
            ++i, ++i2;
        }
    }
    return res;
}

ll countInv() {
    ll res = 0;
    int n = sm.size();
    for (int l = 1; l < n; l *= 2) {
        for (int i = 0; i + l < n; i += 2 * l) {
            res += merge_(i, i + l, min(i + 2 * l, n));
        }
    }
    return res;
}

ll solve(vector<int> a, int m) {
    int n = a.size();
    for (int i = 0; i < n; ++i) {
        a[i] = (a[i] <= m);
        //cerr << a[i] << " ";
    }
    sm[0] = 0;
    for (int i = 0; i < n; ++i) {
        sm[i + 1] = sm[i] + a[i];
    }
    for (int i = 0; i < n + 1; ++i) {
        sm[i] = 2 * sm[i] - i;
    }
    return countInv();
    
}

void solve() {
    ll n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sm.resize(n + 1);
    buf.resize(n + 1);
    vector<int> b(a.begin(), a.end());
    sort(b.begin(), b.end());
    int low = -1, up = n - 1;
    ll t = n * (n + 1) / 4 + 1;
    while (up - low > 1) {
        int mid = (up + low) / 2;
        ll cur = solve(a, b[mid]);
        //cerr << b[mid] << " " << cur << endl;
        if (cur >= t) {
            up = mid;
        }
        else
            low = mid;
    }
    cout << b[up] << endl;
    


}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 2180
n = gets.to_i
der = 0
k = 1
while k <= n
  j = 1
  s = 0
  while j <= k
    if k%j==0
      s += 1
    end
    j += 1
  end
  if s == 8
    der += 1
  end
  k += 2
end
puts der

Measured memory_bytes: 14136
#include <stdio.h>
int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)break;
        for(i=1;i<=H;i++){
        for(j=1;j<=W;j++){
            if(i!=1 && i!=H && j!=1 && j!=W){
                printf(".");
            }else{
            printf("#");
            }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;

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

	string s;
	cin >> s;
	char c;
	if (s.size() < 26){
		bool used[26] = {};
		REP(i, s.size()){
			used[(int)s[i] - 'a'] = true;
		}
		REP(i, 26){
			if (!used[i]){
				cout << s + (char)((int)'a' + i) << "\n";
				return 0;
			}
		}
	}
	int m = 26;
	if (s.size() == 26){
		REPR(i, s.size()-2){
			if (s[i] > s[i+1]){
				m--;
			}else{
				break;
			}
		}
	}
	if (m == 1){
		cout << "-1" << "\n";
		return 0;
	}
	while (s.size() > m-2){
		c = s[s.size()-1];
		s.pop_back();
	}
	bool used[26] = {};
	REP(i, s.size()){
		used[(int)s[i] - 'a'] = true;
	}
	FOR(i, ((int)c-'a')+1, 26){
		if (!used[i]){
			cout << s + (char)((int)'a' + i) << "\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans;
	cin >> n;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];

	vector<vector<long long>> dp(n, vector<long long>(n, -(1LL << 60)));

	for (k = 0; k < n; k++) {
		for (i = 0; i + k < n; i++) {
			j = i + k;

			if (k == 0) dp[i][j] = a[i];
			else {
				dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
			}
		}
	}

	ans = dp[0][n - 1];
	cout << ans << "\n";


	return 0;
}




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

using namespace std;
struct wow
{
    int x,y;
}v[105];
long long din[100005],n,val,maxim,j,i;
int main()
{
    cin>>n>>val;
    for (i=1;i<=n;i++)
    {
        cin>>v[i].x>>v[i].y;
    }
    for (i=1;i<=val;i++)
    {
        din[i]=-1;
    }
    for (i=1;i<=n;i++)
    {
        for (j=val;j>=v[i].x;j--)
        {
            if (din[j-v[i].x]!=-1)
            {
                din[j]=max(din[j],din[j-v[i].x]+v[i].y);
            }
        }
    }
    for (j=val;j>=1;j--)
    {
        maxim=max(maxim,din[j]);
    }
    cout<<maxim;
    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<bool> to(N+1, false);
    vector<bool> from(N+1, false);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (a == 1) {
            if (from[b]) {
                cout << "POSSIBLE\n";
                return 0;
            }
            to[b] = true;
        }
        if (b == N) {
            if (to[a]) {
                cout << "POSSIBLE\n";
                return 0;
            }
            from[a] = true;
        }
    }
    cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 256
def read_image(size)
  size.times.inject([]){|img, x|
    img + [gets.chop]
  }
end

def sub_image(image, x, y, size)
  image[y, size].map{|row|
    row[x, size]
  }
end

N, M = gets.split.map(&:to_i)
imageA = read_image(N)
imageB = read_image(M)

N.times{|y|
  N.times{|x|
    if imageB == sub_image(imageA, x, y, M)
      puts "Yes"
      exit
    end
  }
}

puts "No"


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

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        long K = sc.nextLong();
        long[] a = new long[50];
        Arrays.fill(a, 49 + K / 50 - K % 50);
        for (int i = 0; i < K % 50; i++) {
            a[i]+=51;
        }
        System.out.println(50);
        for(int i=0;i<49;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println(a[49]);

    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
   
int mas[3][3];
int cpy[3][3];
  
   
int main() {
  input();
  printf("%d\n", solve());
  return 0;
}
void input() {
  int i, j;
  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++)
      scanf("%d", &mas[i][j]);
}
   
void output() {
  int i, j;
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3; j++) printf("%3d", mas[i][j]);
    puts("");
  }
}
   
void copy(int m[3][3], int t[3][3]) {
  int i, j;
   
  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++) m[i][j] = t[i][j];
}
   
int calc() {
  int i, sum = 0;
  for(i = 0; i < 9; i++) {
    int v = mas[i/3][i%3];
    if(v) {
      v--;
      sum += abs(i/3-v/3)+abs(i%3-v%3);
    }
  }
  return sum;
}
   
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
   
void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
   
int is_in(int x, int y) {
  return 0<=x&&x<3&&0<=y&&y<3;
}
   
int dfs(int x, int y, int p, int dep, const int lim) {
  int i, h = calc();
  //output();
  if(h == 0) return dep;
  //printf("%d %d %d\n", h, lim, p);
  if(dep+h > lim) return -1;
   
  for(i = 0; i < 4; i++) {
    int nx = x+dx[i], ny = y+dy[i], res;
    if(~p && i == (p+2)%4) continue;
    if(!is_in(nx, ny)) continue;
    swap(&mas[y][x], &mas[ny][nx]);
    res = dfs(nx, ny, i, dep+1, lim);
    if(~res) return res;
    swap(&mas[y][x], &mas[ny][nx]);
  }
   
  return -1;
}
   
void get_empty(int *x, int *y) {
  int i, j;
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3; j++) {
      if(!mas[i][j]) {
    *x = j;
    *y = i;
    return;
      }
    }
  }
}
   
int solve() {
  int x, y, lim, ans;
  get_empty(&x, &y);
  for(lim = 0; lim < 50; lim++) {
    copy(cpy, mas);
    if((ans = dfs(x, y, -1, 0, lim)) != -1) return ans;
    copy(mas, cpy);
  }
  return -1;
}



Measured memory_bytes: 2108
n=int(input())
n = n % 10

if (n == 2 or n == 4 or n == 5 or n == 7 or n == 9):
  print('hon')
elif (n == 0 or n == 1 or n == 6 or n == 8):
  print('pon')
else:
  print('bon')


Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<limits.h>
#include<queue>

using namespace std;


int main()
{
    int p[20];
    int i,ans,num,a;
    for(i=0,ans=10,num=0; i<5; ++i)
    {
        scanf("%d",&p[i]);
        a=p[i]%10;
        if(a!=0)
            ans=min(a,ans);
        if(a)
            num+=p[i]+10-a;
        else
            num+=p[i];
    }
    if(ans!=0)
        num=num-10+ans;
    printf("%d\n",num);
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

def main():
    N, Q = map(int, input().split())
    S = input()
    count = [0]
    for i in range(N-1):
        if S[i] == 'A' and S[i+1] == 'C':
            count.append(count[i]+1)
        else:
            count.append(count[i])
    for _ in range(Q):
        l, r = map(int, input().split())
        print(count[r-1] - count[l-1])
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 6460
x_1, y_1, x_2, y_2 = map(int, input().split())

x_1to2 = x_2 - x_1
y_1to2 = y_2 - y_1

rot = complex(0, 1)
vec_1to4 = complex(x_1to2, y_1to2) * rot
x_1to4 = vec_1to4.real
y_1to4 = vec_1to4.imag

x_4 = x_1to4 + x_1
y_4 = y_1to4 + y_1

x_3 = x_4 + x_1to2
y_3 = y_4 + y_1to2

print(str(int(x_3)), str(int(y_3)), str(int(x_4)), str(int(y_4)))


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=a+b;
	
	if(c==5){
		printf("1");
	}
	else if(c==4){
		printf("2");
	}
	else if(c==3){
		printf("3");

	}
		
	
}

Measured memory_bytes: 1620
import Control.Applicative ((<$>))

main :: IO ()
main = solve <$> map read <$> words <$> getLine >>= putStrLn
  
solve :: [Int] -> String
solve [e, y] | e == 1 = show $ y + 1867
             | e == 2 = show $ y + 1911
             | e == 3 = show $ y + 1925
             | e == 4 = show $ y + 1988
             | y < 1912 = 'M' : show (y - 1867)
             | y < 1926 = 'T' : show (y - 1911)
             | y < 1989 = 'S' : show (y - 1925)
             | otherwise = 'H' : show (y - 1988)



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		vector<pair<int,int> > data;
		int c1,m1,m2,m3,m4,s1,s2,s3,s4;
		while(n--){
			cin>>c1>>m1>>s1>>m2>>s2>>m3>>s3>>m4>>s4;
			int sum=(m1+m2+m3+m4)*60+s1+s2+s3+s4;
			data.push_back(make_pair(sum,c1));
		}
		sort(data.begin(),data.end());
		cout<<data[0].second<<endl;
		cout<<data[1].second<<endl;
		cout<<data[data.size()-2].second<<endl;
	}
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

int n;
ll ans[2010];
ll mod = 1e9 + 7;

inline void solve(int T) {
    cin >> n;
    ans[0] = 1;
    ans[1] = ans[2] = 0;
    rep(i, 3, n) ans[i] = (ans[i - 1] + ans[i - 3]) % mod;
    cout << ans[n];
}
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
 
int main(){
  int n[5];
  int ans;
  
  for(int i=0;i<5;i++){
    cin >> n[i];
  }
  
  for(int i=0;i<5; i++){
    if(n[i] == 0){
      ans = i +1;
      }
  }
      cout<<ans<<endl;
  }

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  vi A(N);
  int s = 0;
  rep(i,N) {
    cin >> A[i];
    s += A[i];
  }
  sort(rng(A));
  reverse(rng(A));
  if(A[M-1]*4*M<s) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>

#define REP(i,j,k) for( int i=j; i<k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef long int LI;

int main(){
	
	
	int n;
	cin >> n;
	vector<int> v(n),c(n);
	
	rep(i,n) cin >> v[i];
	rep(i,n) cin >> c[i];
	
	int ans = 0;
	
	rep(i,n) ans += max( v[i]-c[i] , 0 );
	
	cout << ans << endl;
	
	
	return 0;
	
}


Measured memory_bytes: 256
import Control.Monad
solv :: (Int, Int) -> [String] -> (Int, Int)
solv res [] = res
solv (t, s) (x:xs) = case tw `compare` sw of
                        LT -> solv (t, (s+3)) xs
                        EQ -> solv ((t+1), (s+1)) xs
                        GT -> solv ((t+3), s) xs

  where
    (tw:sw:_) = words x
main = do
  n <- getLine
  l <- replicateM (read n) getLine
  putStrLn . (\(t, s) -> show t ++ " " ++ show s) $ solv (0, 0) l

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    string S, T;
    cin >> S >> T;
    cout << (S == T.substr (0, T.length() - 1) ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

const int maxn = 100000;
long long x[maxn+5], y[maxn+5];
const int p = 1e9+7;

long long mult(long long x, long long y) {
    return (x*y)%p;
}

long long add(long long x, long long y) {
    return (x+y)%p;
}

int main() {
    int n, m;
    cin>>n>>m;
    for (int i = 0; i < n; ++i)
        cin>>x[i];
    for (int i = 0; i < m; ++i)
        cin>>y[i];
    sort(x, x+n);
    sort(y, y+m);
    
    /*for (int i = 0; i < n-1; ++i) {
        for (int j = 0; j < m-1; ++j) {
            long long count = (i+1)*(n-1-i)*(j+1)*(m-1-j) % p;
            long long area = (x[i+1]-x[i])*(y[j+1]-y[j])%p;
            ans = (ans + area*count)%p;
        }
    }*/
    long long ans_x = 0;
    for (int i = 0; i < n-1; ++i)
        ans_x = add(ans_x, mult(mult(i+1, n-1-i), x[i+1]-x[i]));
    long long ans_y = 0;
    for (int i = 0; i < m-1; ++i)
        ans_y = add(ans_y, mult(mult(i+1, m-1-i), y[i+1]-y[i]));
    
    cout<<mult(ans_x,ans_y)<<endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
HT = list(map(lambda x: T - x*0.006, H))
answer = 0
for i in range(len(HT)):
    if abs(HT[i] - A) < abs(HT[answer]-A):
        answer = i
print(answer + 1)

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

#define INF 1e+9
#define MAX_V 1000000

// <最短距離, 頂点の番号>
using P = pair<int64_t, int64_t>;

int64_t V;
vector<int64_t> G[MAX_V];
int64_t d[MAX_V];
int64_t nextv[MAX_V];

void dijkstra(int64_t s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int64_t v = p.second;
        if (d[v] < p.first) continue;

        for (int64_t i=0; i<G[v].size(); ++i) {
            int64_t e = G[v][i];
            if (d[e] > d[v] + 1) {
                d[e] = d[v] + 1;
                nextv[e] = v+1;
                que.push(P(d[e], e));
            }
        }
    }
}

int main() {
    cin >> V;
    int64_t E;
    cin >> E;
    for (int64_t i=0; i<E; ++i) {
        int64_t a, b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dijkstra(0);
    cout << "Yes\n";
    for (int64_t i=1; i<V; ++i) {
        if(d[i] != INF)
            cout << nextv[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 36044
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<vector<vector<int> > > v(4, vector<vector<int> >(3, vector<int>(10)));
	for (int i = 0; i < n; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		v[a - 1][b - 1][c - 1] += d;
	}
	for (int i = 0; i < 4; i++) {
		if (i != 0) {
			for (int j = 0; j < 20; j++)cout << "#";
			cout << endl;
		}
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << v[i][j][k];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<int> a(n);
  REP(i, 0, n) cin >> a[i];

  sort(ALL(a));
  int m = 10;
  VEC<int> c(m, 0);
  REP(i, 0, n) {
    bool free = true;
    for (int rate = 400; rate <= 3200; rate += 400) {
      if(a[i]<rate){
        c[rate / 400]++;
        free = 0;
        break;
      }
    }
    if(free)
      c[m-1]++;
  }
  int sum = 0;
  REP(i, 0, m-1) sum += c[i]>0?1:0;
  DUMP(c, sum);
  cout << (sum > 0 ? sum : c[m-1] > 0) << " " << sum + c[m-1] << 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 dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    int x, n;
    cin >> x >> n;
    set<int> p;
    rep(i,n){
        int num;
        cin >> num;
        p.insert(num);
    }
    
    if(!p.count(x)){
        dunk(x);
        return 0;
    }
    
    int x_min = x;
    int x_max = x;
    
    while(1){
        x_min--;
        x_max++;
        if(!p.count(x_min)){
            dunk(x_min);
            break;
        }
        else if(!p.count(x_max)){
            dunk(x_max);
            break;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long w[51];
int main() {
	int i;
	long long n;
	scanf("%lld", &n);
	if (n <= 50) {
		printf("%d\n", 50);
		for (i = 1; i <= 50; i++) {
			if (i <= n)printf("%d ", 50);
			else printf("%d ", 0);
		}
		printf("\n");
		return 0;
	}
	for (i = 1; i <= 50; i++)w[i] = 50-i+(n/50);
	for (i = 1; i <= (n % 50); i++)w[i]++;
	printf("%d\n", 50);
	for (i = 1; i <= 50; i++)printf("%lld ", w[i]);
}

Measured memory_bytes: 128
n = int(input())
C = list(input())
l = 0
r = n-1
ans = 0
while l < r:  
  while C[l] == 'R' and l<r:
    l += 1    
  while C[r] == 'W' and l<r:
    r -= 1
  if C[l]=='W' and C[r] == 'R':
    ans += 1
    l += 1
    r -= 1
    
print(ans)    

Measured memory_bytes: 10708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int a = 1;
  for(int i = 0; i < N; i++){
    if(a < K){
      a *= 2;
    }else{
      a += K;
    }
  }
  cout << a << endl;

}

Measured memory_bytes: 3604
#include <stdio.h>
int main(){
    int r;
    int D;
    int x[11];
    scanf("%d",&r);
    scanf("%d",&D);
    scanf("%d",&x[0]);
    int i;
    for(i=1;i<=10;i++){
        x[i]=r*x[i-1]-D;
        printf("%d\n",x[i]);
    }
}

Measured memory_bytes: 128
n, k = map(int, input().split())
w = []
for _ in range(n):
    w.append(int(input()))
imax = 100000 * 1000000
imin = 1
while imin < imax:
    imid = (imin + imax) // 2
    track_num = 0
    current = 0
    for i in range(n):
        if w[i] > imid:
            track_num = k
            break
        elif w[i] + current > imid:
            track_num += 1
            current = w[i]
        else:
            current += w[i]
    if track_num < k:
        imax = imid
    else:
        imin = imid + 1
print(imax)

Measured memory_bytes: 11596
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

int basis[64] = {0};
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    int n;cin >> n;
    vector<int> in(n);
    FOR(i, n)cin >> in[i] ;
    int xorr = 0;
    FOR(i, n)xorr ^= in[i];
    FOR(i, n){
        for(int j = 0; j <= 59; j++){
            if((xorr & (1LL << j)) && (in[i] & (1LL << j))){
                in[i] ^= (1LL << j);
                assert((in[i] & (1LL << j)) == 0);
            } 
        }
    }
    int xorr2 = 0;
    FOR(k, n)xorr2 ^= in[k];
    assert(xorr2 == 0);
    int ans = 0;
    FOR(i, n){
        for(int j = 59; j >= 0; j--){
            if((in[i] & (1LL << j)) == 0)continue;
            if(!basis[j]){
                basis[j] = in[i];
                break;
            }
            in[i] ^= basis[j];
        }
    }
    for(int j = 59; j >= 0; j--){
        if(ans & (1LL << j))continue;
        ans ^= basis[j];
    }
    cout << xorr + ans * 2;
}




Measured memory_bytes: 1024
import sys
import math
import collections
from collections import deque
import heapq
#n = int(input())
n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))


x = n % k
y = k - x

print(min(x, y))

    


Measured memory_bytes: 3436
N,Q=map(int,input().split())
S=input()

AC=[0]*N
cnt=0
for i in range(1,N):
    if S[i-1]=="A" and S[i]=="C":
        cnt+=1
    AC[i]=cnt
        
for _ in range(Q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    print(AC[r]-AC[l])




Measured memory_bytes: 52852
let N = Int(readLine()!)!
var f = Array(repeating: 0, count: 10000)
for x in 1...100 {
    for y in 1...100 {
        for z in 1...100 {
            guard x*x + y*y + z*z + x*y + y*z + z*x <= N else {break}
            f[x*x + y*y + z*z + x*y + y*z + z*x] += 1
        }
    }
}
for n in 1...N {
    print(f[n])
}


Measured memory_bytes: 7848
#include <iostream>
#include <vector>

int main() {
    std::vector<int> a, b;
    int n, tmp = 0;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> tmp;
        a.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
        if ((n + i) % 2 != 0) {
            b.insert(b.begin(), a[i]);
        } else {
            b.push_back(a[i]);
        }
    }
    for (int i = 0; i < n; i++) {
        std::cout << b[i] << " ";
    }
    std::cout << "\n";
}

Measured memory_bytes: 3828
from collections import defaultdict
MOD = int(1e9+7)

N, M = map(int, input().split())
d = defaultdict(int)
m = M
while m != 1:
    for i in range(2, int(m**0.5)+1):
        if m % i == 0:
            d[i] += 1
            m //= i
            break
    else:
        d[m] += 1
        m = 1
ans = 1
for k in d.keys():
    r = d[k]
    n = N + r - 1
    r = min(r, N - 1)
    p = 1
    for i in range(r):
        p *= n - i
        p //= i + 1
    ans *= p
    ans %= MOD
print(ans)

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

int n,m,k,sol=0;
char mat[10][10];
string s="";

void proba()
{
    int cnt=0;
    for (int i=0;i<n;i++){
        if (s[i]=='1') continue;
        for (int j=0;j<m;j++){
            if (s[n+j]=='1') continue;
            if (mat[i][j]=='#') cnt++;
        }
    }
    if (cnt==k) sol++;
    return;
}

void rek()
{
    if (s.size()==n+m){
        proba();
        return;
    }

    s.push_back('0');
    rek();
    s.pop_back();
    s.push_back('1');
    rek();
    s.pop_back();
}

int main()
{
    cin >> n >> m >> k;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> mat[i][j];
        }
    }

    rek();
    cout << sol;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
	public static ArrayList<Integer> list;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		list = new ArrayList<Integer>();
		makeList(1000000);
		while(true) {
			int n  = stdIn.nextInt();
			int p = stdIn.nextInt();
			
			if(n == -1 &&p == -1) break;
			int ans = solv(n,p);
			System.out.println(ans);
			
		}
	}
	
	public static void makeList(int a) {
		boolean[] isPrime = new boolean[a];
		for(int i = 2; i < isPrime.length; i++) {
			isPrime[i] = true;
		}
		for(int i = 2; i < isPrime.length; i++) {
			if(isPrime[i]) {
				list.add(i);
				for(int j = i + i; j < isPrime.length; j += i) {
					isPrime[j] = false;
				}
			}
		}
	}
	
	public static int solv(int n, int p) {
		ArrayList<Integer> listTMP = new ArrayList<Integer>();
		int count = 0;
		for(int i = 0; i < list.size() && count <= p; i++) {
			if(list.get(i) > n) {
				listTMP.add(list.get(i));
				count++;
			}
		}
		PriorityQueue<Integer> listAns = new PriorityQueue<Integer>();
		
		for(int i = 0; i < listTMP.size(); i++) {
			for(int j = i; j < listTMP.size(); j++) {
				listAns.add(listTMP.get(i) + listTMP.get(j));
			}
		}
		for(int i = 0; i < p-1; i++) {
			
			int tmp = listAns.poll();
		}
		return listAns.poll();
		
	}
	
}

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

using namespace std;

int main() {

    string s1, s2;

    cin >> s1 >> s2;

    int size1 = s1.size();
    int size2 = s2.size();
    int d[size1 + 1][size2 + 1];

    for(int i = 0; i <= size1; ++i) {
        d[i][0] = i;
    }

    for(int i = 0; i <= size2; ++i) {
        d[0][i] = i;
    }

    for(int i = 1; i <= size1; ++i) {
        for(int j = 1; j <= size2; ++j) {
            int cost = s1[i - 1] == s2[j - 1] ? 0 : 1;
            d[i][j] = min(min(d[i - 1][j] + 1, d[i][j - 1] + 1), d[i - 1][j - 1] + cost);
        }
    }

    cout << d[size1][size2] << endl;

}

Measured memory_bytes: 5096
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    string s;
    cin >> s;

    bool ok = false;
    int n = s.size();
    if(n%2 == 0){
        for(int i = 0; i < n; i+=2){
        if(s[i] == 'h' && s[i+1] == 'i') ok = true;
        }
    }

    if(ok) cout << "Yes";
    else cout << "No";
}

void solve_B(){
    int A, B, M;
    cin >> A >> B >> M;
    int a[A], b[B];
    int min_A = 1000000, min_B = 1000000;
    REP(i,A){
        cin >> a[i];
        if(min_A >= a[i]) min_A = a[i];
    }
    REP(i,B){
        cin >> b[i];
        if(min_B >= b[i]) min_B = b[i];
    }

    int x[M], y[M], c[M];
    REP(i,M) cin >> x[i] >> y[i] >> c[i];

    int ans = 10000000;
    for(int i = 0; i < M; i++){
        if(ans >= a[x[i]-1] + b[y[i]-1] - c[i]) ans = a[x[i]-1] + b[y[i]-1] - c[i];
    }

    
    if(ans >= min_A + min_B) cout << min_A + min_B;
    else cout << ans;
}

int main(void){
    solve_A();
    
    return 0;
}

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




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

  int n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  if(s[0]=='1'){
    cout << -1 << endl;
    return 0;
  }
  int st=0;
  vector<int> ans;
  int sum=0;
  rep(i,n+1){
    for(int j=m;j>0;j--){
      if(i+j>=n+1) continue;
      else if(s[i+j]=='0'){
	sum+=j;
	ans.pb(j);
	i = i+j-1;
	break;
      }
      else if(j==1){
	cout << -1 << endl;
	return 0;
      }
    }
    //    cout << sum << endl;
  }        
  reverse(ans.begin(),ans.end());
  rep(i,ans.size()){
    cout << ans[i] << " \n"[i==ans.size()-1];
  }
  return 0;
    

}


Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

ll dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	ll w;
	cin >> n >> w;
	rep(i, 100005) dp[i] = 1e18;
	dp[0] = 0;
	repn(i, 1, n + 1){
		ll a;
		int b;
		cin >> a >> b;
		for(int j = 1000 * i - b; j >= 0; j--){
			dp[j + b] = min(dp[j + b], dp[j] + a);
		}
	}
	int ans = 0;
	rep(i, 100001) if(dp[i] <= w) ans = i;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  string s,t,t1;
  cin >> s >> t;
  int a = s.length(),b = t.length();
  t1 = t.substr(0,a);
  if(s == t1 && b==a+1) cout<<"Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 3632