akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cerr<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll MAX=1e16;
const ll MM=1e18;
const ll mod=998244353;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

ll gcd(ll p, ll q){
    while(q != 0) {
        ll r = p % q;
        p = q;
        q = r;
    }
    return p;
}

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}
const ll MaxSize = 3e5;
ll facts[MaxSize], invFacts[MaxSize];

void preproc() {
  facts[0] = 1;
  for (int i = 1; i < MaxSize; i++) {
    facts[i] = ((ll)facts[i - 1] * i) % mod;
  }
  invFacts[MaxSize - 1] = expo(facts[MaxSize - 1], mod - 2,mod);

  for (int i = MaxSize - 2; i >= 0; i--) {
    invFacts[i] = ((ll)invFacts[i + 1] * (i + 1)) % mod;
  }
}

ll combination(ll n, ll k) {
  if(n<k) return 0;
  ll res = facts[n];
  res = ((ll)res * invFacts[k]) % mod;
  return ((ll)res * invFacts[n - k]) % mod;
}

////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////


void solve()
{
    int n;
    cin >> n;
    int dig = n % 10;
    if(dig == 2 || dig == 5  || dig == 7 ||  dig == 9 || dig == 4) {
        cout << "hon" << endl;
    }
    else if(dig == 0 || dig == 1 || dig == 6 || dig == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }
   
} 
int main()
{
  boost;
  int m;
  //cin >> m;
  int t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}



Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			x = in.readLine();
			String[] nm = x.split(" ");
			int n = Integer.parseInt(nm[0]);
			int m = Integer.parseInt(nm[1]);
			
			int[][] md = new int[n + 1][m + 1];
			
			for (int i = 0; i < n; i++) {
				x = in.readLine();
				String[] e = x.split(" ");
				
				for (int j = 0; j < m; j++) {
					if (i == 0) md[n][j] = 0;
					
					md[i][j] = Integer.parseInt(e[j]);
					md[i][m] = md[i][m] + md[i][j];
					md[n][j] = md[n][j] + md[i][j];
				}
			}
			
			md[n][m] = 0;
			for (int i = 0; i < n; i++) {
				md[n][m] = md[n][m] + md[i][m];
			}
			
			for (int i = 0; i < (n + 1); i++) {
				for (int j = 0; j < (m + 1); j++) {
					if (j != 0) System.out.print(" ");
					System.out.print(md[i][j]);
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 31116
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

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

  vector<bool> broken(N + 1);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vector<int> dp(N + 2);
  dp[N] = 1;

  for (int i = N - 1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
  }

  cout << dp[0] << endl;
}

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

using namespace std;

string s;

int main(void)
{
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '1') s[i] = '9';
		else s[i] = '1';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

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

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> a >> b;
	int sa = max(a, b) - min(a, b);
	ans = (1 + sa) * sa / 2;
	cout << ans - b << rt;
	please AC;
}

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

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



int main(){
  
  int n;
  cin >> n;
  if(n%1000 != 0)cout << 1000 -n%1000 << endl;
  else cout << 0 << endl;


  

  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for(auto& i: X) cin >> i;
  auto Y = X;
  sort(begin(Y), end(Y));
  auto l = Y[N/2 - 1], h = Y[N/2];
  for(auto x: X) cout << (x<=l ? h : l) << "\n";
}


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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0,rep,cnt,sad;
char c;
string s;
vector <ll> V;

ll gcd(ll a, ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

int main()
{
    cin >> k;
    for (int a=1;a<=k;a++){
        for (int b=1;b<=k;b++){
            for (int c=1;c<=k;c++){
                sol+=gcd(gcd(a,b),c);
            }
        }
    }
    cout << sol;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

vector<ll> num;

struct Nbase {
    int n;
    int sz = 1;
    long long max = 1e18;

    Nbase(int k = 2){
        n = k;
        while(max != 0){
            max /= n;
            sz++;
        }
        num.resize(sz);
    };

    //繰り返し二乗法
    ll EX(ll x,ll n){
        if(n == 0) return 1;
        else if(n%2 == 1) return EX(x,n-1)*x;
        else return EX(x*x,n/2);
    }

    vector<int> to_n(ll num){
        vector<int> ret(sz);
        for(int i = sz-1; i >= 0; i--){
            long long subtraction = EX(n,i);
            if(subtraction <= num){
                for(int j = 1; j <= n; j++){
                    if(num < j*subtraction){
                        ret[i] = j-1;
                        num -= ret[i]*subtraction;
                    } 
                }
            } else ret[i] = 0;
        }
        return ret;
    }

    long long re_n(vector<int>& vec){
        long long ret = 0;
        vec.resize(sz);
        for(int i = 0; i < sz; i++){
            ret += vec[i]*EX(n,i);
        }
        return ret;
    }

    void supress(const vector<int>& lim,vector<int>& at){
        bool upper = true;
        for(int i = sz; i >= 0; i--){
            if(upper && lim[i] > 0) upper = false;
            if(lim[i] > at[i]) break;
            else if(upper || lim[i] < at[i]) at[i] = lim[i];
        }
    }
};

int main(){
    Nbase base = 2;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        vector<int> sam = base.to_n(a[i]);
        for(int j = 0; j < base.sz; j++){
            if(sam[j] == 1) num[j]++;
        }
    }
    vector<int> x(base.sz);
    for(int i = 0; i < base.sz; i++){
        if(num[i] <= n/2) x[i] = 1;
        else x[i] = 0;
    }
    
    vector<int> kd = base.to_n(k);
    base.supress(kd,x);
    /*bool flag = true;
    for(int i = base.sz; i >= 0; i--){
        if(flag && kd[i] == 1) flag = false;
        if(kd[i] == 1 && x[i] == 0) break;
        else if(kd[i] == 0 || flag) x[i] = 0;
    }*/
    ll X = base.re_n(x);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += X^a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	ll asum=0,bsum=0;
	vl a(n),b(n);
	rep(i,0,n)cin>>a[i],asum+=a[i];
	rep(i,0,n)cin>>b[i],bsum+=b[i];
	if(asum<bsum){
		cout<<-1<<endl;
		return 0;
	}
	vl s(0),t(0);
	ll ans=0;
	// sは必要な方
	ll cnt=0;
	// tは余ってる方
	rep(i,0,n){
		if(b[i]>a[i]){
			cnt+=b[i]-a[i];
			ans++;
		}
		else if(b[i]!=a[i]){
			t.push_back(a[i]-b[i]);
		}
	}
	sort(all(t));
	ll j=t.size();
	if(cnt>0){
		for(int i=t.size()-1;i>=0;--i){
			ans++;
			if(cnt<=t[i])break;
			else cnt-=t[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5340
import scala.io.StdIn

object Main extends App {
  val mainStr = StdIn.readLine()
  val subStr = StdIn.readLine()

  val ans = subStr.length -
    (for(i <- 0 until mainStr.length - (subStr.length -1))yield{
      (for(j <- 0 until subStr.length if mainStr(i+j) == subStr(j))yield 1)
        .sum
    }).max

  println(ans)
}








Measured memory_bytes: 56420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k,q;
  cin >> n >> k >> q;
  int n_max = 100000;
  int a;
  int score[n_max];
  REP(i,n_max)score[i] = -q+k;
  REP(i,q){
    cin >> a;
    score[a-1]++;
  }
  REP(i,n){
    if (score[i]>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main() {
	
    int  m,cnt=0,i,k,t,flag1=0,flag2=0;
    int c[18],b[18],d[18];
    scanf("%d",&m);
    for(i=0;i<m;i++){
    	scanf("%d",&b[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d",&c[i]);
	}

    int a[10] = {1,2,3,4,5,6,7,8,9,10};
    do {
    	flag1=1;flag2=1;
    	cnt++;
      for( i = 0; i < m; ++i) 
      {
      	d[i]=a[i];	
	  }
	 for(i=0;i<m;i++){
	 	if(d[i]!=b[i]){
	 		flag1=0;
		 }
		 if(d[i]!=c[i]){
		 	flag2=0;
		 }
	 }
	 if(flag1)k=cnt;
	 if(flag2)t=cnt;
    } while (next_permutation(a, a+m));
    printf("%d ",abs(k-t));  
  
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.Maybe

readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine

readInt :: B.ByteString -> Int
readInt = fst . fromJust . B.readInt

main = do
  s <- getLine
  print (st_ring s)

st_ring = length . foldr remove ""

remove 'S' ('T':acc) = acc
remove c acc = c : acc

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  int x, y, s, i, j, k, l, a, b, extreambonbar;
  cin >> x >> y >> s;
  while (x != 0) {
    l = 0;
    for (i = 1; i < s / 2 + 1; i++) {
      a = i * (100 + x) / 100;
      b = (s - a) * 100 / (100 + x);
      while ((b + 1) * (100 + x) / 100 + a <= s)
        b++;
      extreambonbar = i * (100 + y) / 100 + b * (100 + y) / 100;
      if (b * (100 + x) / 100 + a == s && extreambonbar > l) {
        l = extreambonbar;
      }
    }
    cout << l << endl;
    cin >> x >> y >> s;
  }
  return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////

int main() {
	ll a[3];
	for (int i = 0; i < 3; ++i)cin >> a[i];
	for (int i = 0; i < 3; ++i) {
		if (a[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = 1e20;
	for (int i = 0; i < 3; ++i) {
		for (int j = i + 1; j < 3; ++j) {
			ans = min(ans, a[i] * a[j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from functools import reduce

def gcd(*numbers):
    from fractions import gcd
    return reduce(gcd, numbers)

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

n = int(input())
t = [int(input()) for _ in range(n)]
print(lcm(*t))


Measured memory_bytes: 5364
N = int(input())
series = 0
for _ in range(N):
  a,b = map(int,input().split())
  if a == b:
    if series == 2:
      print('Yes')
      exit()
    elif series == 1:
      series += 1
    else:
      series = 1
  else:
    series = 0
print('No')

Measured memory_bytes: 9172
#include <stdio.h>
#include <math.h>

#define I 1
#define V 5
#define X 10
#define L 50
#define C 100
#define D 500
#define M 1000

char Roma[7]={'I', 'V', 'X', 'L', 'C', 'D' ,'M'};

int main(){
	char a[101];
	int i,j=4,k;
	int n;
	while(scanf("%s",a)!=EOF){
		i=0;
		n=0;
		
		for(i=0;a[i]!='\0';i++){
			for(j=0;j<7;j++){
				if(Roma[j]==a[i]){
					n+=((int)pow(10.0,(double)((int)(j/2)))*((j%2)?5:1));
					break;
				}
			}
			for(k=0;k<7;k++){
				if(Roma[k]==a[i+1]){
					if(k>j&&a[i]!='\0'){
						n-=((int)pow(10,j/2)*((j%2)?5:1))*2;
					}
					break;
				}
			}
		}
		printf("%d\n",n);
	}
	return 0;
}

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

using namespace std;

int main()
{
 	int n;
  cin>>n;
  string a="";
  string b="";
  for(int i=0; i<n/2; i++)
  {
   	char c;
    cin>>c;
    a+=c;
  }
  for(int i=n/2; i<n; i++)
  {
   	char c;
    cin>>c;
    b+=c;
  }
  if(a==b)
  {
    cout<<"Yes"<<endl;
    return 0;
  }
  else
  {
    cout<<"No"<<endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
from math import factorial
mod = 10 ** 9 + 7

def P(n, r):
  if r > n:
    return 1
  elif r == 0:
    return 1
  else:
    return(factorial(n) // factorial(n-r))
N, K = map(int, input().split())
D = dd(list)
for i in range(N-1):
  a, b = map(int, input().split())
  D[a-1].append(b-1)
  D[b-1].append(a-1)

Q = [0]
vstd = set()
ans = K
while Q:
  a = Q.pop()
  vstd.add(a)

  if a == 0:
    num = K-1
  else:
    num = K-2
  for b in D[a]:
#    print (a, D[a], b, vstd, Q, ans, end="->")
    if b not in vstd:
      if num <= 0 : ans = 0
      ans = (ans * num) % mod
#      print ("*", num, end="=")
      num -= 1
      Q.append(b)
#    print (ans)      

print (ans % mod)

Measured memory_bytes: 38612
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
		int result;

		if(p<=q) {
			result = p;
			if(r<=q){
				result += r;
			}else {
				result += q;
			}
		}else {
			result = q;
			if(r<=p) {
				result += r;
			}else {
				result += p;
			}
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 21588
#include <iostream>
#include<vector>
#include <cmath>
 
using namespace std;
 
int main() 
{
   
   int n;
   long long int result=1;
   cin>>n;
   long long int input;
   long long int wrong=pow(10,18);
   bool isBad = false;
   for (int i = 0; i < n; i++)
   {
       cin>>input;

      if (input == 0) {
          cout << 0;
          return 0;
      }

      if (log10(input) + log10(result) > 18) {
          isBad = true;
      }


       result=result*input;
   }


   if (result > wrong || isBad == true)
   {
   cout<<-1;
   }
   else
    {
    	cout<<result;
    }
}

Measured memory_bytes: 3536
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

const int B = mod;

int N;
string S;

bool ok[5005][5005];

signed main()
{
	cin >> N >> S;

	int mx = 0;

	range(i, 0, N - 1) {
		range(j, i + 1, N) {
			if (S[i] != S[j]) continue;

			if (ok[i][j]) continue;

			for (int len = 1; i + len <= j; ++len) {
				if (S[i + len - 1] != S[j + len - 1]) break;
				ok[i + len - 1][j + len - 1] = true;
				chmax(mx, len);
			}
		}
	}

	cout << mx << endl;
}



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

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	
	int arr[N + 5];
	
	int i;
	for(i = 0; i < N; i++)
		scanf("%d", &arr[i]);
		
	sort(arr, arr + N);
	
	long long Sum = 0;
	for(i = 0; i < N - K; i++)
		Sum += arr[i];
		
	printf("%lld", Sum);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

int main() {
    string s; cin >> s;
    int n = (int) s.size();
    
    int ans = 0;
    int mine = 0;
    for (int i = 0; i < n; i++) {
        int l = i+1;
        if (s[i] == 'p') {
            mine++;
        } else {
            if (mine < (l/2)) {
                mine++;
                ans++;
            }
        }
        if (mine > (l/2)) {
            mine--;
            ans--;
        }
    }
    cout << ans << '\n';
}






























Measured memory_bytes: 512
#include <cstdio>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n<=111)
    printf("111\n");
    else if(n<=222)
    printf("222\n");
    else if(n<=333)
    printf("333\n");
    else if(n<=444)
    printf("444\n");
    else if(n<=555)
    printf("555\n");
    else if(n<=666)
    printf("666\n");
    else if(n<=777)
    printf("777\n");
    else if(n<=888)
    printf("888\n");
    else if(n<=999)
    printf("999\n");
}


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

int main() {
    int a, b, ans = -1;
    cin >> a >> b;
    for (int i = 1; i < 1001; i++) {
        int xA = i * 0.08;
        int xB = i * 0.1;
        if ((int) xA == a && (int) xB == b)  {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define DIVCEIL(a, b) ((a+b-1)/b)
using namespace std;

void solve(long long N, std::vector<long long> T, std::vector<long long> A){
    long long fac=1;
    for(int i=1; i<N; i++){
        fac = max(DIVCEIL(A[i-1]*fac, A[i]), DIVCEIL(T[i-1]*fac, T[i]));
    }
    cout << (T[N-1]+A[N-1])*fac << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> T(N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&T[i]);
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(T), std::move(A));
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 501
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,n,K;
    //double start=clock();
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&a==c)puts("Yes");
    else puts("No");
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template <class T> void swap(T& a, T& b) { T t = std::move(a); a = std::move(b); b = std::move(t); }

int main(void)
{
    ll n, i, a[100001], N, R, min=INF;
    double half;

    cin >> n;

    for(i=1; i<=n; i++){
        cin >> a[i];
    }

    sort(a+1, a+n+1);

    N = a[n];
    half = (double)(N)/2;

    for(i=1; i<=n-1; i++){
        if(fabs((double)a[i]-half) < min){
            min = fabs((double)a[i]-half);
            R = a[i];
        }
    }

    cout << N << " " << R << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


bool isPrime(ll n) {
  if(n == 1)return false;
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

// TODO: write
int main() {
  int n;cin>>n;
  while(true){
    if(isPrime(n)){
      print(n);
      break;
    }
    n++;
  }
  return 0; 
}


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

int n;


#define MAX 150002
vector<int> v[MAX];

long double dp[MAX];
long double sum[MAX];

int pa[MAX];

int deg[MAX];

inline void dfs(int b, int pr = -1){
	pa[b] = pr;
	if (v[b].size() == 1 && pr != -1)return;
	long double p = 1.0 / (long double)(v[b].size()-(pr!=-1));
	deg[b] = v[b].size() - (pr != -1);
	for (int i = 0; i < v[b].size(); i++){
		if (pr == v[b][i])continue;
		dfs(v[b][i], b);
		dp[b] += p*(1.0+dp[v[b][i]]);
		if (v[b].size() - 1){
			long double pp = 1.0 / (long double)(v[b].size() - 1);
			sum[b] += pp*(1.0 + dp[v[b][i]]);
		}
	}
}
map<int, long double> mp[MAX];
inline long double rdfs(int b, int pr = -1){
	if (pa[b] == pr){
		return dp[b];
	}
	if (mp[b].count(pr)){
		return mp[b][pr];
	}
	if (pr == -1){
		long double p = 1.0 / (long double)(v[b].size());
		mp[b][-1] = 0;
		for (int i = 0; i < v[b].size(); i++){
			mp[b][-1] += p*(1.0 + rdfs(v[b][i], b));
		}
		return mp[b][-1];
	}
	if (v[b].size() == 1){
		mp[b][pr] = 0;
		return 0;
	}
	long double nex = sum[b];
	long double p = 1.0 / (long double)(v[b].size() - 1);
	nex -= p*(1.0+dp[pr]);
	if (b != 0){
		if (v[b].size() > 1){
			nex += p*(1.0 + rdfs(pa[b], b));
		}
	}
	mp[b][pr] = nex;
	return nex;
}
int main(){
	cin >> n;
	for (int i = 1; i < n; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0);
	for (int i = 0; i < n; i++){
		double ans=rdfs(i);
		printf("%.16f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 52224
#include	<iostream>

using namespace std;

void
Main();

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

void
Main() {

	int	N;
	cin >> N;

	long long	A[ N ];
	for ( auto i = 0; i < N; i++ ) cin >> A[ i ];

	long long	v = 0;
	long long 	w = 0;
	int		j = 0;

	for ( auto i = 0; i < N; i++ ) {
		while ( j < N && ( w ^ A[ j ] ) == ( w + A[ j ] ) ) {
			w += A[ j ];
			j++;
		}
		v += j - i;
		w -= A[ i ];
	}

	cout << v << endl;
}

Measured memory_bytes: 1792
K, A, B = map(int, input().split())

if B - A >= 2:
    if K >= A:
        ans = ((K - A + 1) // 2) * (B - A) + A + ((K - A - 1) % 2)
    else:
        ans = 1 + K
else:
    ans = 1 + K

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>
int main ()
{
    int n, p=0;
    scanf ("%d", &n);
    int v[n], c[n];
    for (int i=0;i<n;i++) scanf ("%d", &v[i]);
    for (int j=0;j<n;j++) {
        scanf ("%d", &c[j]);
        if (c[j]<=v[j]) p=p+v[j]-c[j];
    }
    if (p>0) printf ("%d", p);
    else printf ("0");
    return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    string S;
    cin >> S;
    bool n = 0, w = 0, s = 0, e = 0;
    int N = S.size(), x = 0, y = 0;
    for(int i = 0; i < N; i++) {
        char c = S[i];
        if(c == 'N') n = 1;
        else if(c == 'S') s = 1;
        else if(c == 'E') e = 1;
        else if(c == 'W') w = 1;
    }
    bool ans = !((n ^ s) || (e ^ w));
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, k; cin >> n >> k;
  	vector<int> p(n);
  	for (int &i : p) {
      	cin >> i;
    }
  	sort(p.begin(), p.end());
  	cout << accumulate(p.begin(), p.begin() + k, 0) << endl;
    return 0;
}


Measured memory_bytes: 3612
while true
    arr = gets.chomp.split('.')
    break if arr[0][0] == '-'

    result = nil
        if arr[0].to_i >= 2 ** 8
        result = "NA"
    else
        arr << "0" if arr.length == 1
        r = Rational(arr[1], 10 ** (arr[1].length))
        b = ["0", "0", "0", "0"]
        c = Rational(1, 2)
        4.times{|i|
            if r >= c
                b[i] = "1"
                r -= c
            end
            c /= 2
        }
        if r == 0
            result = sprintf("%08b.", arr[0].to_i) + b.join
        else
            result = "NA"
        end
    end
    puts result
end


Measured memory_bytes: 6952
N = int(input())
ans = 'Yes'
a = set()
pre = ''
for i in range(N):
    word = input()
    if not word in a and (pre == word[0] or pre == '') and ans == 'Yes':
        ans = 'Yes'
        a.add(word)
        pre = word[-1]
    else:
        ans = 'No'
print(ans)


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n,k;
int a[110];
bool b[110000];

main(){
  cin>>n>>k;
  rep(i,n){
    cin>>a[i];
  }

  FOR(i,1,k+1){
    rep(j,n){
      if(i-a[j]<0) b[i]=false;
      else if(!b[i-a[j]]){
        b[i]=true;
        break;
      }
    }
  }

  cout<<(b[k]?"First":"Second")<<endl;

}


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

int main() {
	string c[3];
	for (int i = 0;i < 3;++ i) cin >> c[i];
	for (int i = 0;i < 3;++ i) cout << c[i][i];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけですね
*/

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <type_traits>
#include <vector>

// lib/pow2.hpp
#ifndef POW2_HPP
#define POW2_HPP

/*
usage:

tools::pow2(5) => 32
*/


namespace tools {
  template <typename T, typename std::enable_if<std::is_unsigned<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(1) << x;
  }

  template <typename T, typename std::enable_if<std::is_signed<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(static_cast<typename std::make_unsigned<T>::type>(1) << static_cast<typename std::make_unsigned<T>::type>(x));
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::array<i64, 3> N;
  tools::read(N);
  i64 K;
  std::cin >> K;

  std::sort(N.begin(), N.end());
  std::cout << N[0] + N[1] + N[2] * tools::pow2(K) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

ll dp[2020][2020]; // dp[i][j] := checked S[0]~S[i], T[0]~T[j]

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> S(N),T(M);
    REP(i,N) cin >> S[i];
    REP(i,M) cin >> T[i];

   
    REP(i,N+1) dp[i][0] = 1;
    REP(i,M+1) dp[0][i] = 1;
    for(int i=1;i<=N;++i){
        for(int j=1;j<=M;++j){
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            if(S[i-1]!=T[j-1]) dp[i][j] -= dp[i-1][j-1];
            dp[i][j] %= MOD;
        }
    }
    if(dp[N][M] < 0) dp[N][M] += MOD;
    cout << dp[N][M] << endl;
    return 0;
}

Measured memory_bytes: 31872
#include <algorithm>
#include <iostream>
#include <sstream>
#include <stack>
#include <vector>

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

  int id = 0;
  int ids[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) { ids[i][j] = ids[j][i] = id++; }
  }

  int M = N * (N - 1) / 2;
  int indegrees[M];
  std::vector<std::vector<int> > s2t(M);
  for (int i = 0; i < M; i++) { indegrees[i] = 0; }

  for (int i = 0; i < N; i++) {
    int s, j;
    std::cin >> j;
    j--;
    s = ids[i][j];

    for (int _ = 0; _ < N - 2; _++) {
      std::cin >> j;
      j--;
      int t = ids[i][j];
      s2t[s].push_back(t);
      indegrees[t]++;
      s = t;
    }
  }

  std::vector<int> topolo_order;
  std::stack<int> st1, st2;
  for (int i = 0; i < M; i++)
    if (indegrees[i] == 0) st1.push(i);

  int cnt = 0;
  auto sta = &st1;
  auto stb = &st2;
  do {
    while (sta->size() > 0) {
      int i = sta->top();
      sta->pop();
      topolo_order.push_back(i);
      // std::cout << i << ", ";
      while (s2t[i].size() > 0) {
        int j = s2t[i].back();
        s2t[i].pop_back();
        indegrees[j]--;
        if (indegrees[j] == 0) stb->push(j);
      }
    }
    auto tmp = sta;
    sta = stb;
    stb = tmp;
    cnt++;
    // std::cout << " : " << cnt << std::endl;
  } while (sta->size() > 0);

  if (topolo_order.size() != M) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << cnt << std::endl;
  }
}


Measured memory_bytes: 35576
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    ll H,N;
    cin >> H >> N;
    int sum = 0,tmp;
    for(int i = 0; i < N;i++){
        cin >> tmp;
        sum += tmp;
    }

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

    return 0;
}

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

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  int sum = 0;
  sum = A1 + A2 + A3;
  if (sum > 21) {
    cout << "bust";
  }
  else {
    cout << "win";
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	ll N;

	int count = 1;
	int res = 0;

	cin >> N ;

	fi(N) {
		int temp = 0;
		cin >> temp;
		if (temp==count) {
			count++;
		}
		else {
			res++;
		}
	}

	if (count == 1) {
		ce(-1)
	}
	else {
		ce(res)
	}

}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;

	int A[100001] = {}, C[100001] = {};
	int SA[100001], SC[100001];
	SA[0] = 0;
	SC[0] = 0;

	int a = -1;
	rep(i, N) {
		if (S[i] == 'A') {
			a = i;
		}
		else if (S[i] == 'C') {
			if (a != -1) {
				A[a + 1] = 1;
				C[i + 1] = 1;
				a = -1;
			}
		}
		else a = -1;
		SC[i + 1] = SC[i] + C[i + 1];
	}
	rep(i, N) SA[i + 1] = SA[i] + A[i + 1];

	rep(i, Q) {
		int l, r;
		cin >> l >> r;
		int a = SA[r] - SA[l - 1];
		int c = SC[r] - SC[l - 1];

		if (SA[l - 1] == SC[l - 1]) co(c);
		else co(c - 1);
	}

	Would you please return 0;
}

Measured memory_bytes: 2640
n, m=gets.split.map &:to_i
a=(1..n).map{gets.chomp.bytes.map{|e|e%2}}

q=[]
a.each_with_index do |v, i|
    v.each_with_index do |c, j|
        q << i*m+j if a[i][j]==1
    end
end

res=0
while t=q.shift
    res=a[r=t/m][c=t%m]-1
    if r>0 && a[nr=r-1][nc=c]==0
        a[nr][nc]=a[r][c]+1
        q << nr*m+nc
    end
    if r<n-1 && a[nr=r+1][nc=c]==0
        a[nr][nc]=a[r][c]+1
        q << nr*m+nc
    end
    if c>0 && a[nr=r][nc=c-1]==0
        a[nr][nc]=a[r][c]+1
        q << nr*m+nc
    end
    if c<m-1 && a[nr=r][nc=c+1]==0
        a[nr][nc]=a[r][c]+1
        q << nr*m+nc
    end
end

p res


Measured memory_bytes: 27256
#include<stdio.h>
main(){
  int s=0,H=0,M=0;
  scanf("%d",&s);
  while(s>3599){
    s=s-3600;
    H++;
  }
  while(s>59){
    s=s-60;
    M++;
  }
  printf("%d:%d:%d\n",H,M,s);
  return 0;
}


Measured memory_bytes: 2048
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static decimal result;
    static int N;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        // delegate int CFunc();//下関数に使うデリゲータ。コイツと同じ引数と戻り値で関数作って、下の評価式の部分に関数名を入れる。
        //PriorityQueue pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
        Read1();
        result=N*N*N;

        Console.WriteLine(result.ToString());
    }


    static void Read1()
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2(int kosuu)
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < kosuu; i++) { s.Add(int.Parse(tmp[i])); }
    }

}

Measured memory_bytes: 13140
n = int(input())
h = [int(i) for i in input().split()]
r = i = 0
while max(h) != 0:
    if h[i] == 0:
        i += 1
    else:
        r += 1
        while i < n and h[i] > 0:
            h[i] -= 1
            i += 1
        i = 0
print(r)

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

int main(){
  int N;
  int R;
  int count;
  cin >> N >> R;
  if (N > 9){
    cout << R << endl;
  }
  else{
    count = R + 100 * (10 - N);
    cout << count << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (set.contains(x)) {
				set.remove(x);
			} else {
				set.add(x);
			}
		}
		System.out.println(set.size());
	}
}


Measured memory_bytes: 62888
#include<cstdio>
#include<cstring>
#include<bitset>
#include<algorithm>
using namespace std;

const int N=5000+5;

int n,k;

bitset<N>bit;
int A[N];

void Read(){
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
}

bool Check(int x){
	if(A[x]>=k) return true;
    bit.reset();
    bit.set(0);
    for(int i=0;i<n;i++){
        if(i==x) continue;
        bit|=(bit<<A[i]);
    }
    for(int i=k-A[x];i<k;i++){
        if(bit.test(i)) return true;
    }
    return false;
}

void Solve(){
    sort(A,A+n);
    int res=-1;
    int l=0,r=n-1,mid;
    while(l<=r){
		mid=(l+r)>>1;
		if(Check(mid)){
            r=mid-1;
		}
		else{
            res=mid;
            l=mid+1;
		}
    }
    printf("%d\n",res+1);
}

int main(){
	while(~scanf("%d%d",&n,&k)){
		Read();
		Solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int n, k;
    while (cin >> n >> k, n) {
        vector<string> a(n);
        rep(i, n) cin >> a[i];

        set<string> st;
        rep(s, 1 << n) {
            if (__builtin_popcount(s) != k) continue;

            vector<string> b;
            rep(i, n) {
                if ((s >> i) & 1) {
                    b.emplace_back(a[i]);
                }
            }

            sort(all(b));
            do {
                string t = "";
                rep(i, b.size()) {
                    t += b[i];
                }
                if (st.count(t) == 0) {
                    st.insert(t);
                }
            } while (next_permutation(all(b)));
        }

        cout << st.size() << endl;
    }

}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
char s[20];
signed main()
{
	scanf("%s",s+1);
	int cnt=0;
	for (int i=1;i<=strlen(s+1);i++) if (s[i]=='x') cnt++;
	if (cnt>=8) cout<<"NO";else cout<<"YES";
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 256