akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n; cin >> n; cin.ignore();
    string s, t; cin >> s >> t;
    int com = 0;
    repq(i,1,n) {
        string a1 = s.substr(n-i);
        string a2 = t.substr(0,i);
        if(a1 == a2) com = max(com, i);
    }
    cout << 2 * n - com << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

struct Str {
	string s;
	char c;

	void input() {
		cin >> s;
		reverse(all(s));
		c = s.back();
		s.pop_back();
	}

	size_t size() {
		return s.size();
	}

};

bool asc(Str &a, Str &b) {
	if (a.s == b.s) return a.c < b.c;
	return a.s < b.s;
}

int main(void){
	ll n;
	cin >> n;
	vector<Str> s(n);
	rep(i, n) s[i].input();
	sort(all(s), asc);
	// rep(i, n) cout << s[i].s << "+" << s[i].c << endl;

	ll ans = 0;
	rep(i, n) {
		REP(j, i + 1, n) {
			if (s[i].size() > s[j].size()) break;
			if (s[i].size() == s[j].size()) continue;
			ll l = s[i].size();
			if (s[i].s == s[j].s.substr(0, l)) {
				if (s[j].s.find(s[i].c, l) != string::npos || s[i].c == s[j].c) ans++;
			} else
				break;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 11028
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n, h;
	cin >> n >> h;
	int kmx = -1;
	priority_queue<int> Tho;
	Tho.push(-1);
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		kmx = max(kmx, a);
		Tho.push(b);
	}
	int dm = 0, cnt = 0;
	while(dm < h){
		int d = Tho.top();
		Tho.pop();
		if(kmx < d) dm += d, cnt++;
		else {
			int s = (h - dm) / kmx;
			if(((h - dm) % kmx) > 0) s++;
			dm += kmx * s; cnt += s;
//			cout << s << endl;
		}
	}
	cout << cnt << endl;
	return 0;
}	

Measured memory_bytes: 892
n,x = map(int,input().split())
l = list(map(int,input().split()))
count = 1
x1 = 0
for i in range(n):
  if x1 + l[i] <= x:
    count += 1
    x1 += l[i]
  else:
    print(count)
    exit()
print(count)  


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll H,W,N;
  cin>>H>>W>>N;
  ll ans=0;
  if(H>W){
    ll i=1;
    while(H*i<N){
      i++;
    }
    ans=i;
  }
  else{
    ll i=1;
    while(W*i<N){
      i++;
    }
    ans=i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3568
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	var W, H int
	if scanner.Scan() {
		str := scanner.Text()
		cols := strings.Split(str, " ")
		H, _ = strconv.Atoi(cols[0])
		W, _ = strconv.Atoi(cols[1])

	}
	var ans int

	if H == 1 || W == 1 {
		ans = 1
	} else {
		p := H * W
		if p%2 == 1 {
			ans = p/2 + 1
		} else {
			ans = p / 2
		}
	}

	fmt.Fprintln(wtr, ans)
	_ = wtr.Flush()
}


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

int main(){
    int H, N;
    cin >> H >> N;
    int A[N];
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += A[i];
    }
    if(sum>=H) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    string S; cin >> S;
    int cnt=0;
    int N=S.size();
    for(int i=0;i<N/2;i++){
        if(S[i] != S[N-i-1]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())


ans = 0

# N = pb + r

for b in range(k+1,n+1):
    p = n//b
    r = n%b
    ans += p * max(0,b-k) + max(0, r-k+1)


if k==0:
    ans -= n

print(ans)

Measured memory_bytes: 3060
n, k, s = map(int, input().split())
ans = [0 for i in range(n)]
inf = 10**9
if s == inf:
    inf = 1
for i in range(n):
    if i < k:
        ans[i] = s
    else:
        ans[i] = inf
for i in range(n):
    print("{} ".format(ans[i]),end = "")


Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N,M;

void input() {
  cin >>N >>M;
}

int main() {
  input();
  int n = N / 2 * 2;
  if (N%2 == 1){
    rep(i, M){
      cout <<N/2-i <<" " <<N/2+1+i <<endl;
    }
  }else{
    rep(i, M){
      int a = N/2-i-1;
      if (2*i < N/2-1) cout <<a <<" " <<a+2*i+1 <<endl;
      else cout <<a <<" " <<N/2+1+i <<endl;
    }
  }
}

/*

Ax/B <= [Ax/B] < Ax/B + 1

Ax/B <= A*[x/B] < A(x/B-1)

2 4 6
8 10 12
*/


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

int
main(void)
{
        char S[5];

        scanf("%s", S);

        char a[3] = { S[0], S[1] };
        char b[3] = { S[2], S[3] };

        int A = atoi(a);
        int B = atoi(b);

        if ((0 < A && A <= 12) && (0 < B && B <= 12)) {
                printf("AMBIGUOUS");
        } else if (0 < A && A <= 12) {
                printf("MMYY");
        } else if (0 < B && B <= 12) {
                printf("YYMM");
        } else {
                printf("NA");
        }

        return 0;
}


Measured memory_bytes: 128
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n,k;cin>>n>>k;
  int ans = 0;
  while(n){
    n/=k;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  char set[] =  {'a', 'i', 'u', 'e', 'o'};
  char a;
  cin >> a;
  for(int i = 0; i < 5; i++){
    if(set[i] == a){
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
	int a, b;
	cin >> a >> b;
	int count = 0;
	for (int i = a; i <= b;i++) {
		int s = i % 10, t = i / 10000 % 10;
		int u = i / 10 % 10, v = i / 1000 % 10;
		if (s==t&&u==v)count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MAX_N=2e5;
const ll INF=1e18;
int N;
int N2;
ll D;
typedef pair<ll,int> P;
ll orgA[MAX_N];
P A[MAX_N];
P seg[2][MAX_N<<2];
P query(int typ,int l,int r,int k,int a,int b){
	if (r<=a || b<=l){
		return P(INF,-1);
	}
	if (l<=a && b<=r){
		return seg[typ][k];
	}
	P lseg=query(typ,l,r,k*2+1,a,(a+b)/2),rseg=query(typ,l,r,k*2+2,(a+b)/2,b);
	return min(lseg,rseg);
}
void change(int typ,int inx,ll val){
	seg[typ][N2-1+inx]=P(val,inx);
	inx+=N2-1;
	while(1){
		if (inx==0){
			return;
		}
		inx=(inx-1)/2;
		seg[typ][inx]=min(seg[typ][inx*2+1],seg[typ][inx*2+2]);
	}
}
struct edge{
	int s,t;
	ll cst;
	edge(int s=-1,int t=-1,ll c=INF):s(s),t(t),cst(c){}
	bool operator < (const edge &e)const{
		return cst<e.cst;
	}
};
vector<edge> G;
ll calcst(int x,int y){
	return orgA[x]+orgA[y]+abs(x-y)*D;
}
int ufpar[MAX_N];
int uffnd(int v){
	if (ufpar[v]==v){
		return v;
	}
	return ufpar[v]=uffnd(ufpar[v]);
}
bool iscon(int s,int t){
	s=uffnd(s);
	t=uffnd(t);
	return s==t;
}
void ufunite(int s,int t){
	s=uffnd(s);
	t=uffnd(t);
	ufpar[s]=t;
}
int main(){
	cin>>N>>D;
	REP(i,N){
		ll a;
		cin>>a;
		orgA[i]=a;
		A[i]=P(a,i);
	}
	N2=1;
	while(N2<N) N2<<=1;
	REP(i,2){
		REP(j,N2*2-1){
			seg[i][j]=P(INF,-1);
		}
	}
	sort(A,A+N);
	REP(i,N){
		P l,r;
		l=r=P(INF,-1);
		edge el,er;
		el=er=edge(-1,-1,INF);
		if (A[i].second>0){
			l=query(0,0,A[i].second,0,0,N2);
		}
		if (A[i].second<N-1){
			r=query(1,A[i].second+1,N,0,0,N2);
		}
		if (l.second!=-1){
			G.push_back(edge(A[i].second,l.second,calcst(A[i].second,l.second)));
			el=edge(A[i].second,l.second,calcst(A[i].second,l.second));
		}
		if (r.second!=-1){
			G.push_back(edge(A[i].second,r.second,calcst(A[i].second,r.second)));
			er=edge(A[i].second,r.second,calcst(A[i].second,r.second));
		}
		change(0,A[i].second,A[i].first-A[i].second*D);
		change(1,A[i].second,A[i].first+A[i].second*D);
	}
	sort(G.begin(),G.end());
	ll ans=0;
	REP(i,N){
		ufpar[i]=i;
	}
	for(auto e:G){
		if (!iscon(e.s,e.t)){
			ufunite(e.s,e.t);
			ans+=e.cst;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, arr[110];
	
	cin >> n;
	for(int i = 1; i < n; i++){
		cin >> arr[i];
	}
	
	arr[0] = arr[n] = 1e6;
	ll ans = 0;
	
	for(int i = 0; i < n; i++){
		ans += min(arr[i], arr[i + 1]);
	}
	
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
char RB[305];int len,N;char dec(char T) {if (T>='a' && T<='c') return '2'; else if (T>='d' && T<='f') return '3'; else if (T>='g' && T<='i') return '4'; else if (T>='j' && T<='l') return '5'; else if (T>='m' && T<='o') return '6'; else if (T>='p' && T<='s') return '7'; else if (T>='t' && T<='v') return '8'; else return '9';}
struct air{char T[55],Code[55];}A[102];bool operator <(air a, air b) {int l=strlen(a.T),r=strlen(b.T);if (l>r) l=r;for (r=0;r<l;r++) if (a.Code[r]!=b.Code[r]) return a.Code[r]<b.Code[r];return strlen(a.T)<strlen(b.T);}
int BS(char val) {int l=0,r=N-1,a=N+1;while (l<=r) {int c=(l+r)>>1;if (A[c].Code[0]>=val) a=c,r=c-1; else l=c+1; } return a;}
vector<int>ans;void dfs(int pos) {int i,j,here,f;if (pos==len) {for (i=0,j=ans.size();i<j;i++) {if (i) printf(" ");printf("%s",A[ans[i]].T);} puts(".");}
	for (here=BS(RB[pos]);here<N && A[here].Code[0]==RB[pos];here++) {for (i=0,j=strlen(A[here].Code),f=pos;f<len && i<j;f++,i++) if (A[here].Code[i]!=RB[f]) break;if (i==j) {ans.push_back(here);dfs(f);ans.pop_back();}}}
int main() {int i,j;while (1) {scanf("%d",&N);if (!N) return 0;ans.clear();for (i=0;i<N;i++) {scanf("%s",&A[i].T);for (j=strlen(A[i].T),A[i].Code[j--]=0;j>=0;j--) A[i].Code[j]=dec(A[i].T[j]);}sort(A,A+N);scanf("%s",&RB);len=strlen(RB);dfs(0);puts("--");}}

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

int main() {
	int a,b;
	cin >> a >> b;

	if(a+b==15)
		cout << "+" << endl;
	else if(a*b==15)
		cout << "*" << endl;
	else
		cout << "x" << endl;
	return 0;
}

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

int gcd(int a, int b) {
    if (a < b) {
        swap(a, b);
    }
    if (a%b == 0) {
        return b;
    }
    return gcd(b, a%b);
}

int gcd3(int a, int b, int c) {
    return gcd(gcd(a, b), c);
}

int main() {
    int K; cin >> K;
    int ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                ans += gcd3(a, b, c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    ll n;
    cin >> n;
    if(n%2)
        cout << 0 << endl;
    else{
        n /= 2;
        ll ans = 0;
        ll f = 5;
        while(n / f > 0){
            ans += n / f;
            f *= 5;
        }
        cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);     
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		for(int i = a;i < a + k;i++) {
			if(i <= b) System.out.println(i);
		}
		for(int i = b - k + 1;i <= b;i++) {
			if(i >= a + k && i >= a) System.out.println(i);
		}
        sc.close();
	}

}

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

int main(){
    ll x; cin >> x;
    ll ans = (x / 11) * 2;
    x -= (ans/2) * 11;
    if(0 < x)ans++;
    if(6 < x)ans++;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);
  vector<P>b(N);
  rep(i,N){
    cin>>b[i].first;
    b[i].second=i+1-b[i].first;
  }
  vl a(N);
  
  bool NG=false;
  
  int count=N-1;
  
  for(int i=0;i<N;i++){
    for(int j=N-1;j>=0;j--){
      if(b[j].second==0){
        a[count]=b[j].first; count--;
        for(int k=j;k<N;k++)
          b[k].second--;
        break;
      }
      if(j==0)
        NG=true;
    }
  }
  
  //a.reverse(all(a));
  
  if(NG)
    cout<<-1;
  else{
    rep(i,N)
    cout<<a[i]<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
  
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
const int INF = 1e7;
int N,M,C,S,G;
int d[20][100][100];
int cost[100][100];
int p[20],q[20][50],r[20][50];
int rec(int c,int ds){
	int res=0;
	for(int i=1;i<p[c];i++){
		if(ds<=q[c][i]){
			res+=(ds-q[c][i-1])*r[c][i-1];
			return res;
		}else{
			res+=(q[c][i]-q[c][i-1])*r[c][i-1];
		}
	}
	res+=(ds-q[c][p[c]-1])*r[c][p[c]-1];
	return res;
}
int main(){
	while(1){
		cin>>N>>M>>C>>S>>G;
		if(N+M+C+S+G==0)break;
		S--;G--;
		REP(i,N)REP(j,N)REP(k,C){
			if(i==j)d[k][i][j]=0;
			else d[k][i][j]=INF;
		}
		REP(i,N)REP(j,N)cost[i][j]=INF;
		REP(i,M){
			int x,y,z,c;
			cin>>x>>y>>z>>c;x--;y--;c--;
			d[c][x][y]=min(d[c][x][y],z);
			d[c][y][x]=d[c][x][y];
		}
		REP(i,C)cin>>p[i];
		REP(i,C){
			q[i][0]=0;
			REP(j,p[i]-1)cin>>q[i][j+1];
			REP(j,p[i])cin>>r[i][j];
		}
		REP(c,C)REP(k,N)REP(i,N)REP(j,N)
			d[c][i][j]=min(d[c][i][j],d[c][i][k]+d[c][k][j]);
		
		REP(c,C){
			REP(i,N)REP(j,N){
				cost[i][j]=min(cost[i][j],rec(c,d[c][i][j]));
			}
		}

		/*REP(i,N){
			REP(j,N)cout<<cost[i][j]<<" ";cout<<endl;
		}*/

		REP(k,N)REP(i,N)REP(j,N)
			cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
		
		if(cost[S][G]==INF)cout<<-1<<endl;
		else cout<<cost[S][G]<<endl;
	}
}



Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main(){
    string s,t;
    cin>>s>>t;
    rep(i,t.size()) cout<<s[i]<<t[i];
    if(s.size()-t.size()==1) cout<<s[s.size()-1];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import bisect as bi
N = int(input())
li6 = [6 ** i for i in range(7)]
li9 = [9 ** j for j in range(6)]

def s69(n):
  if n < 6:
    return n
  else:
    s6 = li6[bi.bisect(li6, n)-1]
    s9 = li9[bi.bisect(li9, n)-1]
    return min(n // s6 + s69(n % s6), 1 + s69(n-s9))
print (s69(N))

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, X, Y, Z;
    cin >> N >> X >> Y >> Z;

    constexpr ll MOD = (ll)1e9 + 7;
    const ll MAX = 1LL << (X + Y + Z - 1);

    //XYZを含む⇔符号化するとX + Y + Z - 1個目, Y + Z - 1個目, Z - 1個目のビットが立っている
    const ll NG_BITS = (1LL << (X + Y + Z - 1)) | (1LL << (Y + Z - 1)) | (1LL << (Z - 1));

    //dp[i][j] := i番目まで見て,直前の数列を符号化したものがjであるときのXYZとなっていない数
    vector<vector<ll>> dp(N + 1, vector<ll>(MAX, 0));
    dp[0][0] = 1;

    for (ll i = 0; i < N; i++) {
        for (ll j = 1; j <= 10; j++) {
            for (ll k = 0; k < MAX; k++) {
                //k:前回までのbit列
                //遷移:kをjだけ左にシフトして、そこに先頭だけ1を立てたものを入れる
                ll t = (k << j) | (1LL << (j - 1));

                //XYZとなっているかの判定
                if ((NG_BITS & t) != NG_BITS) {
                    //上の方は関係ないのでマスクする
                    t &= (MAX - 1);

                    dp[i + 1][t] += dp[i][k];
                    dp[i + 1][t] %= MOD;
                }
            }
        }
    }

    //全ての数からXYZとならない数を引く
    ll ans = 1;
    for (ll i = 0; i < N; i++) {
        ans *= 10;
        ans %= MOD;
    }

    for (ll i = 0; i < MAX; i++) {
        ans += MOD - dp[N][i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21888
#include <iostream>
#include <string>
#define D 6
using namespace std;

class dice {
    int f[D];
public:
    dice(int n[]) {
        for (int i = 0; i < D; i++)
            f[i] = n[i];
    }

    void roll(int a, int b, int c, int d) {
        int t = f[d];
        f[d] = f[c];
        f[c] = f[b];
        f[b] = f[a];
        f[a] = t;
    }

    void rollX() {
        roll(0, 2, 5, 3);
    }
    void rollY() {
        roll(0, 1, 5, 4);
    }
    void rollZ() {
        roll(1, 2, 4, 3);
    }

    void move(char ch) {
        switch (ch) {
            case 'N': for (int i = 0; i < 3; i++) rollY(); break;
            case 'E': rollX(); break;
            case 'S': rollY(); break;
            case 'W': for (int i = 0; i < 3; i++) rollX(); break;
        }
    }

    void show(int n) {
        cout << f[n] << endl;
    }
};

int main()
{
    int num[D];
    string order;

    for (int i = 0; i < D; i++)
        cin >> num[i];
    dice ob(num);

    cin >> order;
    for (int i = 0; i < order.size(); i++)
        ob.move(order[i]);

    ob.show(0);
}


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

int main() {
	int L, R;
	cin >> L >> R;
	if (R - L + 1 >= 2019) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 2018;
	for (int i = L; i < R; i++) {
		for (int j = L + 1; j <= R; j++) ans = min(ans, (i % 2019) * (j % 2019) % 2019);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
s = str(input())

if (s[0] == s[1]) and (s[2] == s[3]) and (s[1] == s[2]):
  print('No')
elif (s[0] == s[1]) and (s[2] == s[3]):
  print('Yes')
elif (s[0] == s[2]) and (s[1] == s[3]):
  print('Yes')
elif (s[0] == s[3]) and (s[2] == s[1]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e3+20 , M = 230;
int n,m,b[M][N],L[M][N],R[M][N],st[N],top;
ll sum[N][N],a[N],ans;
inline void input(void)
{
    scanf("%d%d",&n,&m);
    for (int i=2;i<=n;i++)
        scanf("%lld",&a[i]) , a[i] += a[i-1];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            scanf("%d",&b[j][i]);
}
inline void solve(void)
{
    for (int i=1;i<=m;i++)
    {
        for (int j=1;j<=n;j++)
        {
            while ( top && b[i][j] >= b[i][st[top]] )
                R[i][st[top]] = j-1 , top--;
            st[++top] = j;
        }
        while ( top ) R[i][st[top]] = n , top--;
        for (int j=n;j>=1;j--)
        {
            while ( top && b[i][j] >= b[i][st[top]] )
                L[i][st[top]] = j+1 , top--;
            st[++top] = j;
        }
        while ( top ) L[i][st[top]] = 1 , top--;
        for (int j=1;j<=n;j++)
        {
            sum[L[i][j]][j] += b[i][j];
            sum[L[i][j]][R[i][j]+1] -= b[i][j];
            sum[j+1][j] -= b[i][j];
            sum[j+1][R[i][j]+1] += b[i][j];
        }
    }
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    for (int i=1;i<=n;i++)
        for (int j=i;j<=n;j++)
            ans = max( ans , sum[i][j] - a[j] + a[i] );
}
int main(void)
{
    input();
    solve();
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 210048
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(){
   int n;
   cin >> n;
   int ki = n/2;
   if(n%2==1) ki++;

   cout <<fixed <<(double)ki/n<< endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct P {
  vector<int> v;
  P(vector<int> &v) : v(v) {}
  P rotate1() {
    P r = *this;
    REP(i,3) swap(r.v[i],r.v[(i+1)%4]);
    REP(i,3) swap(r.v[4+i],r.v[4+(i+1)%4]);
    return r;
  }
  P rotate2() {
    vector<int> w = this->v;
    swap(w[0],w[4]);swap(w[4],w[5]);swap(w[5],w[1]);
    swap(w[2],w[3]);swap(w[3],w[7]);swap(w[7],w[6]);
    return P(w);
  }
  P rotate3() {
    vector<int> w = this->v;
    swap(w[0],w[3]);swap(w[3],w[7]);swap(w[7],w[4]);
    swap(w[1],w[2]);swap(w[2],w[6]);swap(w[6],w[5]);
    return P(w);
  }
  int regular() {
    P r = *this;
    vector<int> mi=r.v;
    for (int i=0; i<6; ++i,r=(i&1?r.rotate2():r.rotate3()))
      for (int j=0;j<4; ++j,r=r.rotate1())
        mi = min(mi,r.v);
    int res = 0;
    int a = 1;
    REP(i,8) res += a*mi[i], a *= 8;
    return res;
  }
};
int main() {
  string s;
  while(cin>>s) {
    map<string, int> mp;
    int num = 0;
    vector<int> v;
    mp[s] = num++;
    v.push_back(mp[s]);
    REP(i,7) {
      cin >> s;
      if (mp.count(s) == 0) mp[s] = num++;
      v.push_back(mp[s]);
    }
    sort(ALL(v));
    set<int> se;
    do {
      se.insert(P(v).regular());
    } while(next_permutation(ALL(v)));
    
    cout << se.size() << endl;
  }
}

Measured memory_bytes: 960
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int a[5], k;

int main(){
  REP(i, 5) cin >> a[i];
  cin >> k;
  sort(a, a + 5);
  if(a[4] - a[0] <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;

  return 0;
}


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

int main()
{
	int N, K;
	string S;
	cin >> N >> S >> K;

	for (int i = 0; i < N; i++) {
		if (S[K - 1] != S[i]) {
			S[i] = '*';
		}
	}


	cout << S << endl;	
}

Measured memory_bytes: 256
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IS(): return str(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve(N,A):
    ans = 1
    if 0 in A:
        print(0)
        return
    
    for i in A:
        ans *= i
        if ans > pow(10,18):
            print(-1)
            return
    print(ans)

def main():
    N = II()
    A = LI()
    solve(N,A)

#main
if __name__ == '__main__':
    main()

Measured memory_bytes: 23380
K=int(input())

if K<=12:
    print(K)
    exit()

from collections import deque

d=deque(["2","3","4","5","6","7","8","9","10","11","12"])
num=[1,2,3,4,5,6,7,8,9,10,11,12]

while True:
    s=d.popleft()
    x=int(s[-1])
    if x==0:
        for i in ["0","1"]:
            temp=s+i
            d.append(temp)
            num.append(int(temp))

    elif x==9:
        for i in ["8","9"]:
            temp=s+i
            d.append(temp)
            num.append(int(temp))
    else:
        for j in [-1,0,1]:
            temp=s+str(x+j)
            d.append(temp)
            num.append(int(temp))
    if len(num)>=K:
        print(num[K-1])
        exit()


Measured memory_bytes: 11940
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 1; i <= n; i++) {
            int x = i;
            if((x % 3) == 0) {
                System.out.print(" " + i);
            } else {
                while(x != 0) {
                    if((x % 10) == 3) {
                        System.out.print(" " + i);
                        x = 0;
                    }
                    x = x / 10;
                }
            }
        }
        System.out.println();
    }
}

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

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

fn main() {
    let s: String = read();

    let v: Vec<usize> = s.chars().rev().map(|c| ((c as u8) - b'0') as usize).collect();

    let n = s.len() - 1;

    let mut sum = 0;
    for bit in 0..(1 << n) {
        let mut ten = 1;
        sum += v[0];
        for i in 0..n {
            if bit & (1 << i) != 0{
                ten = 1;
            } else {
                ten *= 10;
            }
            sum += v[i+1] * ten;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
#include <bitset>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

void count(vector<int> v,vector<int>& ans){
    sort1(v);
    int n=v.size();
  int k=1;
  int i=1;
  bool bl=true;
    while(true){
    while(bl){
        if(v[i-1]==v[i]){
        k++;    
      }else{
          bl=false;
      }
      i++;
      }
      ans.push_back(k);
      if(i>=(n-1))break;
      k=1;
      bl=true;
    }
    }




int main() {
  int a,b;
  cin >> a >>b;
  cout << a*b;
    }


    

Measured memory_bytes: 3628
main = do
    n  <- readLn
    as <- map read . words <$> getLine
    bs <- map read . words <$> getLine
    print $ maximum [ sum $ zipWith3 z as bs [1 .. n] | z <- map zipper [1 .. n] ]

zipper k a b i | i < k     = a
               | i > k     = b
               | otherwise = a + b


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

long long a, b, res = 0;

int main() {
  cin >> a >> b;
  for(int i = 0; i <= 1000000; ++i)
    if((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      cout << i << endl;
      return 0;
    }
  cout << -1 << endl;
  return 0;
}

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

cnt = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
int h, w, n, m, k, s, t, q, sum, last, cnt, ans, a[1000000],dp0[1<<20], dp1[1 << 20];
string str, ss;
bool f;
char c;
int di[4][2] = { {1,0},{-1,0} ,{0,1},{0,-1} };
struct Edge { LL to,cost; };
vector<Edge>vec[10000];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
unsigned int popcnt(unsigned long long x)
{
	x = (x & 0x5555555555555555ULL) + ((x >> 1) & 0x5555555555555555ULL);
	x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
	x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL);
	return (x * 0x0101010101010101ULL) >> 56;
}
int main() {
	cin >> n >> m;
	cin >> str;
	rep(i, 1 << n) {
		dp0[((1 << n) - 1) ^ i] = str[i]-'0';
		dp1[i] = str[i] - '0';
	}
	rep(i,n)
		rep(s, 1LL << n) {
		if ((s & (1 << i)) == 0) {
			dp0[s] += dp0[s | (1 << i)];
			dp1[s] += dp1[s | (1 << i)];
		}
	}
	rep(i, m) {
		int ma0 = 0, ma1 = 0, ma2 = 0;
		int cnt[3] = {};
		ans = 0;
		cin >> ss;
		rep(j, n)
			if (ss[n-1-j] == '0')
				ma0 += 1 << j,cnt[0]++;
			else if (ss[n-1-j] == '1')
				ma1 += 1 << j,cnt[1]++;
			else ma2 += 1 << j,cnt[2]++;

			if (cnt[0] <= n / 3) {
				Mfor(k, ma0 + 1) {
					k &= ma0;
					if (popcnt(k) % 2)ans -= dp1[k|ma1];
					else ans += dp1[k|ma1];
				}
			}
			else if (cnt[1] <= n / 3) {
				Mfor(k, ma1 + 1) {
					k &= ma1;
					if (popcnt(k) % 2)ans -= dp0[k|ma0];
					else ans += dp0[k | ma0];
				}
			}
			else {
				Mfor(k, ma2 + 1) {
					k &= ma2;
					ans += str[ma1 + k] - '0';
				}
			}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll x;
  cin >> x;
  ll tmp=100;
  ll i=0;
  while(x>tmp) {
    tmp*=1.01;
    i++;
  }
  cout << i << endl;
}

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

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	vector<lli> num(5, 0);
	rep(i, 0, N) {
		string tmp; cin >> tmp;
		if (tmp[0] == 'M')num[0]++;
		else if (tmp[0] == 'A')num[1]++;
		else if (tmp[0] == 'R')num[2]++;
		else if (tmp[0] == 'C')num[3]++;
		else if (tmp[0] == 'H')num[4]++;
	}

	lli ans = 0;
	rep(i, 0, 3) {
		rep(j, i + 1, 4) {
			rep(k, j + 1, 5) {
				ans += (num[i] * num[j] * num[k]);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int arr[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  double per = 0;
  per = ((double)arr[0] + arr[1]) / 2.0;
  for (int i = 2; i < n; ++i) {
    per = (per + 1.0*arr[i]) / 2.0;
  }
  cout << per;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a,x,b,y,sum=0,sum1=0;
	scanf("%d %d %d %d %d",&n,&a,&x,&b,&y);
	if(n%a==0){
		sum+=(n/a)*x;
	}
	else{
		sum+=((n/a)+1)*x;
	}
	if(n%b==0){
		sum1+=(n/b)*y;
	}
	else{
		sum1+=((n/b)+1)*y;
	
	}
	if(sum>sum1){
		printf("%d\n",sum1);
	}
	else{
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2100
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        int last = a.Last();
        double lasthalf = (double)last / 2;
        a = a.Take(a.Length - 1).ToArray();
        double limdef = int.MaxValue;
        int limval = 0;
        foreach (var item in a)
        {
            if (Abs(lasthalf - item) < limdef)
            {
                limdef = Abs(lasthalf - item);
                limval = item;
            }
        }
        Console.WriteLine($"{last} {limval}");
    }
}


Measured memory_bytes: 25184
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double T = sc.nextDouble();
    double X = sc.nextDouble();
    System.out.println(T/X);
  }
}





































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

int main(){
    char op[100];
    stack<int> s;
    long long ans = 0;

    int work;
    while(cin >> op){
        if(op[0] == '+'){
            work = s.top(); s.pop(); work += s.top(); s.pop();
            s.push(work);
        }else if(op[0] == '-'){
            work = -s.top(); s.pop(); work += s.top(); s.pop();
            s.push(work);
        }else if(op[0] == '*'){
            work = s.top(); s.pop(); work *= s.top(); s.pop();
            s.push(work);
        }else if(op[0] == 'a'){
            break;    
        }else{
            s.push(atoi(op));
        }
    }

    cout << s.top() << endl;
}


Measured memory_bytes: 3112
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

vector<vector<int> > G;

vector<bool> used;

int rec(int pos)
{
    used[pos] = true; int ret = 1;
    
    for(int i = 0; i < G[pos].size(); i++)
    {
        if(!used[G[pos][i]])
        {
            ret = max(ret, rec(G[pos][i]) + 1);
        }
    }
    
    used[pos] = false;
    
    return ret;
}

int main()
{
    int N, A, B;
    
    while(true)
    {
        scanf("%d", &N);
        
        if(N == 0) { break; }

        G = vector<vector<int> >(100, vector<int>());
        
        used = vector<bool>(100);
    
        for(int i = 0; i < N; i++)
        {
            scanf("%d", &A); A--;
            scanf("%d", &B); B--;
        
            G[A].push_back(B);
            G[B].push_back(A);
        }
    
        int ret = 0;
    
        for(int i = 0; i < 100; i++)
        {
            if(G[i].size())
            {
                ret = max(ret, rec(i));
            }
        }
        
        printf("%d\n", ret);
    }
    
    return 0;
}

Measured memory_bytes: 3152
#include <iostream>

using namespace std;

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

typedef long long ll;

int n, k;
int w[100001];

bool check(int p){
  ll sum=0;
  int idx = 0;

  rep(i, k){
    sum = 0;
    while(w[idx] + sum <= p){
      sum+=w[idx];
      idx++;
      if(idx == n) return true;
    }
  }
  return false;
}

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

  rep(i, n) cin >> w[i];
  
  // binary search
  ll left = 0, right = 100000 * 10000;
  while(right - left > 1){
    ll mid = (left + right) / 2;
    if(check(mid)) right = mid;
    else left = mid;
  }
  
  cout << right << endl;
}


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

using namespace std;

int main()
{
    string S, ans = "AC";
    int count = 0;

    cin >> S;

    if (S[0] != 'A') ans = "WA";
    for (int i = 1; i < S.size(); i++) {
        if (isupper(S[i])) {
            if (i == 1 || i == S.size()-1 || S[i] != 'C') {
                ans = "WA";
            }
            count++;
        }
    }
    if (count != 1) ans = "WA";
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	long long int total=-1e18, a, b, c, d;
	cin >> a >> b >> c >> d;
	if(total < a*c)
	{
		total = a*c;
	}
	if(total < a*d) 
	{
		total = a*d;
	}
	if(total < b*c)
	{
		total = b*c;
	}
	if(total <b*d)
	{
		total = b*d;
	}
	cout << total;
}



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

int main(){
  string s;
  int c = 0;
  cin >> s;
  if(s[0]=='1')++c;
  if(s[1]=='1')++c;
  if(s[2]=='1')++c;
  
  cout << c;
  
}

Measured memory_bytes: 256