akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll L;
    cin >> L;

    ll r = 0;
    vl p(21);  // p[i] : 2のi乗
    p[0] = 1;
    exrep(i, 1, 20) {
        p[i] = 2*p[i-1];
        if(L < p[i]) {
            break;
        }
        r++;
    }

    vector<tuple<ll, ll, ll>> v;
    exrep(i, 1, r) {
        v.emplace_back(i, i+1, 0);
        v.emplace_back(i, i+1, p[i-1]);
    }
    for(ll i = r; i >= 1; i--) {
        if(L - p[i-1] >= p[r]) {
            v.emplace_back(i, r+1, L - p[i-1]);
            L -= p[i-1];
        }
    }

    cout << r+1 << " " << v.size() << "\n";
    for(auto x : v) {
        cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x) << "\n"; 
    }

    re0;
}

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

int main(){
	//int out = 0;
	//array<int,3> a;

	//for(int i = 0; i < 3; i++){
	//	cin >> a[i];
	//}

	//sort(a.begin(),a.end());

	//while(a[1] < a[2]){
	//	a[0]++;
	//	a[1]++;
	//	out++;
	//}

	//while(a[0] < a[2]){
	//	a[0]+=2;
	//	out++;
	//}

	//if(a[0] > a[2]){
	//	out++;
	//}

	//cout << out << endl;

	int a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;

	int x = (a + b + c) % 2 == max({a,b,c}) % 2 ? max({a,b,c}) : max({a,b,c}) + 1;

	cout << (3*x - (a + b + c)) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
/*
* @Author: wxyww
* @Date: 2020-02-16 22:04:08
* @Last Modified time: 2020-02-16 22:07:33
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int N = 200010;
ll read() {
	ll 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*10+c-'0';
		c=getchar();
	}
	return x*f;
}
string s[N];
map<string,int>ma;
int main() {
	int n = read(),mx = 0;
	for(int i = 1;i <= n;++i) {
		cin>>s[i];
		ma[s[i]]++;
		mx = max(mx,ma[s[i]]);
	}

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

	for(int i = 1;i <= n;++i) {
		if(ma[s[i]] == mx) cout<<s[i]<<endl,ma[s[i]] = -1;
	}


	return 0;
}

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

vector<int> to[200005];
vector<int> ans;
void dfs(int x, int p=-1) {
    for (int u : to[x]) {
        if (u == p) continue;
        ans[u] += ans[x];
        dfs(u,x);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) {
        if (i != n-1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23552
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 50 + 3;
int mat[maxn][maxn],n,m,q;
int on[maxn][maxn];
int off[maxn][maxn];
int t[maxn][maxn];
int ptr[maxn][maxn];
vector<int>PPP[maxn][maxn];

char s[maxn][maxn];

struct node
{
    int x,y;
};
node mis[1200];
vector<node> Q;

vector<node> P;

int Flag=0;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int vis[maxn][maxn];
void dfs(int x,int y,int xx,int yy)
{
    if(Flag)return;
    if(x==xx&&y==yy)
    {
        int stary = 0;

        for(int i=1;i<P.size();i++)
            Q.push_back(P[i]);
        Flag=1;
        return;
    }
    for(int i=0;i<4;i++)
    {
        int xxx = x+dx[i];
        int yyy = y+dy[i];
        if(xxx<=0||xxx>n)continue;
        if(yyy<=0||yyy>m)continue;
        if(vis[xxx][yyy])continue;
        if(s[xxx][yyy]=='#')continue;
        node ttt;ttt.x=xxx;ttt.y=yyy;
        P.push_back(ttt);
        vis[xxx][yyy]=1;
        dfs(xxx,yyy,xx,yy);
        P.pop_back();
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&t[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&on[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&off[i][j]);

    for(int i=1;i<=q;i++)
    {
        scanf("%d%d",&mis[i].x,&mis[i].y);
        mis[i].x++;mis[i].y++;
    }
    Q.push_back(mis[1]);
    for(int i=1;i<q;i++)
    {
        memset(vis,0,sizeof(vis));
        Flag=0;
        P.clear();
        vis[mis[i].x][mis[i].y]=1;
        node k;k.x=mis[i].x,k.y=mis[i].y;
        P.push_back(k);
        dfs(mis[i].x,mis[i].y,mis[i+1].x,mis[i+1].y);
    }
    for(int i = 0 ; i < Q.size() ; ++ i)
    {
        node cur = Q[i];
        int x = cur.x , y = cur.y;
        PPP[x][y].push_back(i);
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; ++ i)
        for(int j = 1 ; j <= m ; ++ j)
         if(PPP[i][j].size() != 0)
    {
        ans += on[i][j]; ans += off[i][j];
        for(int z = 0 ; z < PPP[i][j].size() - 1 ; ++ z)
        {
            int dis = PPP[i][j][z+1] - PPP[i][j][z];
            ans += min(dis * t[i][j] , off[i][j] + on[i][j]);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 19592
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,A,B;cin>>N>>A>>B;
  cout <<((B-A-1)&1? "Alice":"Borys") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endll "\n"
#define all(x) x.begin(),x.end()
#define loop(i,a,b) for(int i = a; i < b; i++)
#define speed ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
int main()
{
    speed;
    int n,k;
    cin>>n>>k;
    int v[n];
    loop(i,0,n)cin>>v[i];
    int dp[n];
    loop(i,0,n)dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    
    loop(i,2,n)
    {
        loop(j,1,k+1)
        {
            if(i>=j)dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long Q,H,S,D,N,n;cin>>Q>>H>>S>>D>>n;
    N=n*100;
    if((Q*8<=H*4)&&(Q*8<=S*2)&&(Q*8<=D)){
        cout<<Q*(N/25)<<endl;
        return 0;
    }
    else if((H*4<=Q*8)&&(H*4<=S*2)&&(H*4<=D)){
        cout<<H*(N/50)<<endl;
        return 0;
    }
    else if((S*2<=Q*8)&&(S*2<=H*4)&&(S*2<=D)){
        cout<<S*n<<endl;
        return 0;
    }
    else if((D<=Q*8)&&(D<=H*4)&&(D<=S*2)){
        if(n%2==0){
            cout<<D*(N/200)<<endl;
            return 0;
        }
        else{
            long long ans=0;
            ans+=D*(N/200);
            long long rest=N%200;
            if((Q*8<=H*4)&&(Q*8<=S*2)){
                ans+=(rest/25)*Q;
                cout<<ans<<endl;
                return 0;
            }
            if((H*4<=Q*8)&&(H*4<=S*2)){
                ans+=(rest/50)*H;
                cout<<ans<<endl;
                return  0;
            }
            if((S*2<=Q*8)&&(S*2<=H*4)){
                ans+=(rest/100)*S;
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  for(int i =0; i < 5; i++){
    int tmp; cin >> tmp;
    if(tmp==0){
      cout << i+1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3596
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int cx,cy,cnt;

int main() {
	int N,M;
	while(cin >> N && N) 
	{
		int light[21][21];
		int x,y;
		rep(j,21) {
			rep(i,21){ light[i][j] = false; }
		}
		rep(i,N) {	
			cin >> x >> y;
			light[x][y] = true;
		}
		cin >> M;
		char angle;
		int move;
		cx=10,cy=10,cnt=0;
		rep(i,M) {
			cin >> angle >> move;
			if (angle == 'N') {
				rep(i,move) {
					if (light[cx][cy+i+1]) { 
						cnt++; 
						light[cx][cy+i+1] = false; 
					}
				}
				cy += move;
			}
			else if (angle == 'E') { //東
				rep(i,move) {
					if (light[cx+i+1][cy]) {
						cnt++; 
						light[cx+i+1][cy] = false; 
					}
				}
				cx += move;
			}
			else if (angle == 'S') { //南
				rep(i,move) {
					if (light[cx][cy-i-1]) {
						cnt++;
						light[cx][cy-i-1] = false; 
					}
				}
				cy -= move;
			}
			else if (angle == 'W') { //西
				rep(i,move) {
					if (light[cx-i-1][cy]) {
						cnt++;
						light[cx-i-1][cy] = false; 
					}
				}
				cx -= move;
			}
		}
		if (cnt == N) { cout << "Yes" << endl; }
		else { cout << "No" << endl; }
	}

	return 0;
}

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

int n;
int d[14];
int sum;
ll prod;

// sum???????????§prod?????????
map<ll, ll> dp1[15][140];// [i][sum][prod]
ll f1(){
	dp1[0][0][1] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 140; j++){
			if(dp1[i][j].size() == 0) continue;
			for(auto v : dp1[i][j]){
				ll p = v.first, cnt = v.second;
				for(int k = 0; k < 10; k++){
					ll np = p * (k + 1);
					dp1[i + 1][j + k][np] += cnt;
				}
			}
		}
	}

	ll ret = 0;
	for(int j = 0; j <= sum; j++){
		for(auto v : dp1[n][j]){
			ll p = v.first, cnt = v.second;
			if(j < sum || j == sum && p < prod) ret += cnt;
		}
	}
	return ret;
}

// sum,prod???????????§int?????????
map<ll, ll> dp2[15][2][140];// [i][eq][sum][prod]
ll f2(){
	dp2[0][1][0][1] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 140; k++){
				if(dp2[i][j][k].size() == 0) continue;
				for(auto v : dp2[i][j][k]){
					ll p = v.first, cnt = v.second;
					for(int l = 0; l < 10; l++){
						if(j && d[i] < l) continue;
						int neq = j && (d[i] == l);
						ll np = p * (l + 1);
						dp2[i + 1][neq][k + l][np] += cnt;
					}
				}
			}
		}
	}

	ll ret = 0;
	for(auto v : dp2[n][0][sum]){
		ll p = v.first, cnt = v.second;
		if(p == prod) ret += cnt;
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	cin >> s;
	n = s.size();
	prod = 1;
	for(int i = 0; i < n; i++){
		d[i] = s[i] - '0';
		sum += d[i];
		prod *= d[i] + 1;
	}

	ll ans = 0;
	ans += f1();
	ans += f2();
	cout << ans << endl;
}

Measured memory_bytes: 75796
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	vector<int> b(n);
	for(int i=0; i<n; i++){
		cin >> b[i];
	}
	int size=n;
	int original[n]={};
	for(int i=0; i<n; i++){
		bool ok=0;
		for(int j=size-1; j>=0; j--){
			if(b[j]==j+1){
				original[i] = b[j];
				b.erase(b.begin()+j);
				size--;
				ok = 1;
				break;
			}
		}
		if(!ok){
			cout << "-1" << endl;
			return 0;
		}
	}
	for(int i=n-1; i>=0; i--){
		cout << original[i] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string st;
int bo;
int main()
{
	getline(cin,st);
	for(int i=0;i<=st.size()-1;i++)
	{
		if(st[i]=='C')
		{
			bo=1;
		}
		if(st[i]=='F'&&bo==1)
		{
			bo=2;
		}
	}
	if(bo==2) cout<<"Yes";
	  else cout<<"No";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int main(){
	int d,n;
	cin>>d;
	REP(times,d){
		cin>>n;
		char fld[n][n],a,b;
		REP(i,(n+1)/2){
			if(i%2==0){a='#';b=' ';}
			else{a=' ';b='#';}
			REP(j,(n-i*2)){
				fld[i+j][i]=a;
				fld[i][i+j]=a;
				fld[n-1-i][i+j]=a;
				fld[i+j][n-1-i]=a;
			}
			fld[i+1][n-1-i]=b;
		}
		if(n%4==0)fld[n/2][n/2]=' ';
		REP(i,n){
			REP(j,n)cout<<fld[j][i];
			cout<<endl;
		}
		if(times!=d-1)cout<<endl;
	}
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i :=0; i< n; i++ {
		fmt.Scan(&a[i])
	}
	b := make([]int, n)
  i :=0
	for counter := 1; ; counter++ {
		i = a[i] - 1
		b[i]++

		if b[i] == 2 {
			fmt.Println(-1)
			return
		}
		if i == 1 {
			fmt.Println(counter)
			return
		}
	}
}


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

#define rep(i, n) for(int i = 0; (int)(i) < n; i++)
 
using namespace std;
 
int main() {
  int k, n;
  
  cin >> k >> n;
  vector<int> a(n);
  vector<int> dir(n);
  
  rep(i, n){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  
  rep(i, n - 1){
    dir.at(i) = a.at(i + 1) - a.at(i);
  }
  dir.at(n - 1) = a.at(0) + (k - a.at(n - 1));
  int max = *max_element(dir.begin(), dir.end());
  
  cout << k - max << endl;
    
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] L = new int[M];
        int[] R = new int[M];
        int cnt = 0;
        int Lmax = 0;
        int Rmin = 100000;
        for (int i=0; i<M; i++) {
            L[i] = sc.nextInt();
            if (L[i] > Lmax) Lmax = L[i];
            R[i] = sc.nextInt();
            if (R[i] < Rmin) Rmin = R[i];
        }
        for (int i=Lmax; i<=Rmin; i++) {
            cnt++;
        }
        System.out.println(cnt);
    }
}

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

using namespace std;

int main() {
    int d;
    while (cin >> d) {
        if (d == 0) break;

        int n, m;
        cin >> n >> m;

        vector<int> S;

        for (int i = 0; i < n - 1; i++) {
            int s;
            cin >> s;
            S.push_back(s);
        }

        S.push_back(0);
        S.push_back(d);

        sort(S.begin(), S.end());

        //
        int ans = 0;

        for (int i = 0; i < m; i++) {
            int k;
            cin >> k;
            auto p = lower_bound(S.begin(), S.end(), k);
            if (*p != k) {
                ans += min(k - *(p - 1), *p - k);
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

const int MAX = 2000005;
ll 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;
}

int main(){
    COMinit();
    int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
    ll ans = 0;
    ans = add(ans, COM(r2+c2+2,r2+1)-1);
    ans = add(ans, COM(r1+c1,r1)-1);
    ans = sub(ans, COM(r2+c1+1,r2+1)-1);
    ans = sub(ans, COM(r1+c2+1,r1)-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 47104
import java.util.Scanner;

public class Main {

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

		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();

		String a = String.valueOf(s1.charAt(0));
		String b = String.valueOf(s2.charAt(0));
		String c = String.valueOf(s3.charAt(0));

		String A = a.toUpperCase();
		String B = b.toUpperCase();
		String C = c.toUpperCase();

		System.out.println( A + B + C );
	}
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    long K = sc.nextLong();
    int idx = -1;
    for (int i = 0; i < S.length(); i++) {
      if (S.charAt(i) != '1') {
        idx = i;
        break;
      }
    }
    if (idx < 0) {
      System.out.println(1);
    } else {
      if (K < idx + 1) {
        System.out.println(1);
      } else {
        System.out.println(S.charAt(idx));
      }
    }
  }
}

Measured memory_bytes: 23636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;

class BComparingStrings {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    int a, b;
    in >> a >> b;

    int c = min(a, b);
    int d = max(a, b);
    string s;
    for (int i = 0; i < d; ++i)s += (char) ('0' + c);
    out << s << endl;

  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  BComparingStrings solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

map<ll, int> factorize(ll x) {
    map<ll, int> ret;
    ll t = x;
    for (ll i = 2; i * i <= x; ++i) {
        while (t % i == 0) {
            t /= i;
            ++ret[i];
        }
    }
    if (t > 1) ++ret[t];
    return ret;
}

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

    map<ll, int> m = factorize(n);

    ll ans = 0;
    for (const auto& x : m) {
        int ct = x.se;

        int i = 1;
        while (1) {
            if (ct - i >= 0) {
                ct -= i;
                ++ans;
                ++i;
            } else
                break;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
/*
* @Author: Kabid
* @Date:   2020-04-19 17:59:10
*/

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define in(x)  scanf("%d", &x);
#define ins(x)  scanf("%s", &x);
#define out(x) printf("%d", x);
#define lin puts("");
#define _ putchar(' ');

int main(){
	int c=0,j;
	long long  n,m,s1=0,s2=0,i,s=0;
	scanf("%lli %lli",&n,&m);
	long long k=ceil(pow(10,9))+7;
	for(i=m;i<=n;i++){
		/**for(j=0,c=1;c<=i;j++,c++){
			s1+=j;
			 
		}**/
		//out(s1) lin
		/**for(j=n,c=1;c<=i;j--,c++){
			s2+=j;
			
		}**/
		//out(s2) lin
		s1=((i-1)*(i))/2;
		s2=((n-i)*i+(i*(i+1))/2);
		//printf("s1=%d s2=%d s=%d\n",s1,s2,s);

		s+=(s2-s1+1);
		//printf("s1=%d s2=%d s=%d\n",s1,s2,s);
		s1=0;
		s2=0;
	}
	s++;

	printf("%lli",s%k);
	
	

	

	
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int main() {

	string s;
	cin >> s;
	int maxi = 0;
	int cnt = 0;
	//cout << s << endl;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
		{
			//cout << "a" << endl;
			cnt++;
		}
		else
		{
			//cout << "b" << endl;
			maxi = max(maxi, cnt);
			cnt = 0;
		}
	}

	maxi = max(maxi, cnt);
	cout << maxi << endl;


	return 0;
}

Measured memory_bytes: 256
def ans():
    N = int(input())
    old_t, old_x, old_y = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())

        dt = t - old_t
        dx = x - old_x
        dy = y - old_y
        if abs(dx) + abs(dy) > dt or (abs(dx) + abs(dy)) % 2 != dt % 2:
            print('No')
            return
    
    print('Yes')
    return

ans()

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

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;

    //i = 2
    while(n % 2 == 0) {
        ret[2]++;
        n /= 2;
    }

    for(int64_t i = 3; i * i <= n; i += 2) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main(){
    int64_t n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl; 
        return 0;
    }
    map<int64_t, int> a = prime_factor(n);
    int max_count = 0;
    int k,power;
    int flag = 1; //Nが素数かどうか

    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        
        flag = 0;
        k = 1;
        power = itr->second;
        while(power - k > k){
            power -= k;
            k++;
            max_count++;
        }
        max_count++;
    }

    if(flag == 1) max_count++;
    cout << max_count << endl;

    return 0;
}

/*
24
1
64
1000000007
997764507000
*/

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
struct threeElements{
int _1st,_2nd,_3rd;
};
vector<vector<int>>adj(100);
ll n;
ll a[2000009];
bool check(string s,string t)
{
    int n1=s.length(),n2=t.length(),j=0;
    for(int i=0;i<n1;i++)
    {
        if(s[i]==t[j])
            j++;
        if(j==n2)
            return 1;
    }
    return 0;
}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:52
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
    {
        cout<<adj[i].size()<<endl;
    }

}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[14];
signed main() {
	int n,ans=0,anss;
	cin >> n;
	rep(i, n) cin >> a[i];
		sort(a, a + n);
  rep(i,n){
		ans += a[i];
		anss=a[n - 1] / 2;
	}
	cout << ans-anss << 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 N = sc.nextInt();
		int max = 0, sum = 0;
		for (int i = 0; i < N; i++) {
			int c = sc.nextInt();
			max = Math.max(max, c);
			sum += c;
		}
		System.out.println(sum - max / 2);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#define int long long
using namespace std;
signed main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i%2==0) {
			b += a / 2;
			a /= 2;
		}
		else {
			a += b / 2;
			b/= 2;
		}
	}
	cout << a <<" "<< b << endl;
}

Measured memory_bytes: 256
n=int(input())
b=list(map(int,input().split()))
a=[]
while True:
    for i in range(len(b),0,-1):
        if b[i-1]==i:
            del(b[i-1])
            a+=[i]
            break
    else:
        print(-1)
        exit()
    if len(b)==0:
        break
for i in range(1,n+1):
    print(a[n-i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define all(x) x.begin(), x.end()
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int n, k;
    cin >> n >> k;
    Int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    vector<string> v(k);
    for (Int i = 0; i < k; i++) {
        string add = "";
        for (Int j = 0; i + j * k < t.size(); j++) {
            add += t[i + j * k];
        }
        v[i] = add;
    }
    Int res = 0;
    for (Int i = 0; i < k; i++) {
       // dump(v[i]);
        vector<pair<char, Int>> rl;
        rl.emplace_back(v[i][0], 1);
        for (Int j = 1; j < v[i].size(); j++) {
            if (v[i][j] == rl.back().fi) {
                rl[rl.size() - 1].se++;
            }
            else {
                rl.emplace_back(v[i][j], 1);
            }
        }
        for (Int j = 0; j < rl.size(); j++) {
            if (rl[j].fi == 'r') {
                res += p * ((rl[j].se + 1) / 2);
            }
            else if (rl[j].fi == 's') {
                res += r * ((rl[j].se + 1) / 2);
            }
            else {
                res += s * ((rl[j].se + 1) / 2);
            }
            //dump(rl[j].se);
        }
    }
    dump(res);
    return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int>> C(10,vector<int>(10));
  for(int i=0;i<=9;i++){
    for(int j=0;j<=9;j++){
      cin >> C[i][j];
    }
  }
  vector<int> cost(10);
  cost[1]=0;
  for(int i=0;i<=9;i++){
    if(i==1){
      continue;
    }
    cost[i]=C[i][1];
  }
  bool flag=true;
  while(flag){
    flag=false;
    for(int i=0;i<=9;i++){
      if(i==1){
        continue;
      }
      for(int j=0;j<=9;j++){
        if(j==1){
          continue;
        }
        if(C[i][j]+cost[j]<cost[i]){
          cost[i]=C[i][j]+cost[j];
          flag=true;
        }
      }
    }
  }
  ll ans=0;
  for(int i=0;i<H*W;i++){
    int A;
    cin >> A;
    if(A==-1 || A==1){
      continue;
    }
    ans+=cost[A];
  }
  cout << ans << endl;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::string S;

  std::cin >> N >> S;

  std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  int a = 'A';
  for(char c : S) {
    std::cout << alphabet[(c - a + N) % 26];
  }
  std::cout << "" << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int m = n;
	int k = 0;
	while (m > 0)
	{
		k += m % 10;
		m /= 10;
	}
	if (n % k == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

std::map<ll, int > prime_factor(ll n) {
  std::map<ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

  std::map<ll, int> factors = prime_factor(N);

  ll ans = 0;
  for(auto prime : factors) {
    ll p = prime.first;
    int cnt = prime.second;

    int e = 1;
    while(cnt >= e) {
      ++ans;
      cnt -= e;
      ++e;
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
int main(){
    int h,w;cin>>h>>w;
    string s;
    fol(i,h){
        cin>>s;
        cout << s << endl<<s <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char s[1000];
  int n,i;
  scanf("%s",s);
  scanf("%d",&n);  
  if(n==1){
    printf("%s",s);
    return 0;
  }
  
  while(s[i]){
    if((i+1)%n==1){
      printf("%c",s[i]);
    }
    i++;
  }
  
  printf("\n");
  
  return 0;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555555555555555555555555555555545555555555555555555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 1e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 3e5 + 5;

vector<int> g[N];
int dp[N], vis[N];

void dfs(int u) {
    vis[u] = 1;
    for(int v : g[u]) {
        if(!vis[v]) dfs(v);
        smax(dp[u], dp[v] + 1);
    }
}

int solve() {
    int n, m; Int(n, m);
    for(int i = 1; i <= m; i++) {
        int u, v; Int(u, v);
        g[u].push_back(v);
    }
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) dfs(i);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        smax(ans, dp[i]);
    }
    printf("%d\n", ans);
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




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

int main()
{
    int ans=1,n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        if(i==0)
            ans*=k;
        else
            ans*=(k-1);
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3516
#include <iostream>
#include <vector>
using namespace std;
void print_t(vector<int> A)
{
    std::size_t size = A.size(); //std::size_t 十分に大きい符号なし整数型
    if (size > 0)
    {
        cout << A.at(0);
        for (std::size_t i = 1; i < size; i++)
        {
            cout << ' ' << A.at(i);
        }
    }
    cout << endl;
}
int main()
{
    typedef vector<int> row; //ここでrowを空にコンストラクタすべき？それともここは型？なのでコンストラクタはいらない？→ここは型
    int n;
    cin >> n;
    vector<row> A(n); //n個にコンストラクタ
    // vector<vector<int>> A; //A[t][x] A.at(t).at(x)
    int q;
    cin >> q;
    while (q)
    {
        int query;
        int t;
        cin >> query;
        cin >> t;
        row &r = A.at(t); //rがA.at(t)の参照(別名)になる。
        if (query == 0)
        {
            int x;
            cin >> x;
            //A[t][末尾] = x;
            r.push_back(x);
        }
        else if (query == 1)
        {
            //A[t]を出力
            print_t(r);
        }
        else if (query == 2)
        {
            //A[t]を空にする
            r.clear();
        }
        q--;
    }
}
//離れた場所で宣言しない


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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

int costs[100][100];
int times[100][100];

void Warshall_Floyd(int N, int (&cost)[100][100])
{
    rep(k, N) rep(i, N) rep(j, N)
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
}

int main()
{
    int N, M;
    while (cin >> M >> N && N)
    {
        rep(i, 100) rep(j, 100) costs[i][j] = iINF;
        rep(i, 100) rep(j, 100) times[i][j] = iINF;

        rep(i, M)
        {
            int a, b, c, t;
            cin >> a >> b >> c >> t;
            a--;
            b--;

            costs[a][b] = min(costs[a][b], c);
            costs[b][a] = min(costs[b][a], c);

            times[a][b] = min(times[a][b], t);
            times[b][a] = min(times[b][a], t);
        }

        Warshall_Floyd(N, costs);
        Warshall_Floyd(N, times);

        int K;
        cin >> K;

        int p, q, r;

        rep(i, K)
        {
            cin >> p >> q >> r;
            p--;
            q--;

            cout << (r == 1 ? times[p][q] : costs[p][q]) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3176
using System;
using System.Linq;

namespace aoj_ALDS1_2_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			int numberCount = int.Parse(Console.ReadLine());
			int[] numberArray = Console.ReadLine().Split(' ').Select(d => int.Parse(d)).ToArray();

			int tradeCount = 0;
			bool isSorted = true;
			while (isSorted) 
			{
				isSorted = false;
			    for (int i = numberCount - 1; i > 0; i--)
				{
                    if (numberArray[i - 1] > numberArray[i])
					{
						int temp = numberArray[i - 1];
						numberArray[i - 1] = numberArray[i];
						numberArray[i] = temp;

						tradeCount++;
						isSorted = true;
					}
				}
			}

			Console.WriteLine(String.Join(" ", numberArray));
			Console.WriteLine(tradeCount);
        }
    }
}



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

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

  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; ++i) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());

  string name = S[0];
  int cnt = 1;
  for(int i = 0; i < N; ++i) {
    if(name != S[i]) {
      name = S[i];
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 9480
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<int> B(N-1); REP(i, N-1) cin >> B[i];

  ll ans = B[0]+B[N-2];
  for (int i = 1; i < N-1; ++i) {
    ans += min(B[i-1], B[i]);
  }
  cout << ans << endl;
}

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

int n, T, a, b, Min = INF;

int main()
{
	scanf("%d%d", &n, &T);
	for (int i=1; i<=n; i++)
	{
		scanf("%d%d", &a, &b);
		if (b<=T) Min=min(Min, a);
	}
	if (Min == INF) puts("TLE"); else printf("%d\n", Min);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int N;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int a[] = new int[N];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			ans += sc.nextInt() - 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25712
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (S, T) = Scanner.Scan<string, string>();
            var (A, B) = Scanner.Scan<int, int>();
            var U = Scanner.Scan<string>();
            if (U == S) A--;
            else B--;
            Console.WriteLine($"{A} {B}");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28336
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define inf LLONG_MAX
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6];
ll power(ll x,ll n){
    if(x==0) return 0;
    if(n==0) return 1;
    /*while(n){
        if(n%2) x=(((x*x)%M)*x)%M; 
        else x=(x*x)%M;
        n/=2;
    }*/
    if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=M6;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll n,m,ar[M6];
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,test,flag,t,t2,ans; string s;
    //cin>>test;
    test=1;
    while(test--){
    	cin>>s;
    	for(j=0;j<8;j++){
    		k=s[0]-48;
    		i=j;
    		if(i%2) k+=s[1]-48;
    		else k-=s[1]-48;
    		i/=2;
    		if(i%2) k+=s[2]-48;
    		else k-=s[2]-48;
    		i/=2;
    		if(i%2) k+=s[3]-48;
    		else k-=s[3]-48;
    		if(k==7){
    			i=j;
    			cout<<s[0];
    			for(t=1;t<4;t++){
    				if(i%2) cout<<"+";
    				else cout<<"-";
    				i/=2;
    				cout<<s[t];
    			}
    			cout<<"=7";
    			break;
    		}
    	}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int main(){
	int flag = 1;
	int N;
	cin >> N;
	cout << N / 2 + N % 2;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,N,ans=1;
  if(scanf("%d",&N)<1) return 1;
  int H[N];
  for(i=0;i<N;i++){
    if(scanf("%d",&H[i])<1) return 1;
  }
  int M=H[0];
  for(i=1;i<N;i++){
    if(H[i]>=M){
      M=H[i];
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
MOD=998244353

fact = [0] * 220000
invfact = [0] * 220000

fact[0] = 1
for i in range(1, 220000):
    fact[i] = fact[i-1] * i % MOD

invfact[220000 - 1] = pow(fact[220000 - 1], MOD-2, MOD)

for i in range(220000 - 2, -1, -1):
    invfact[i] = invfact[i+1] * (i+1) % MOD

def nCk(n, k):
    if k < 0 or n < k:return 0
    return fact[n] * invfact[k] * invfact[n-k] % MOD

n,m,k=map(int,input().split())
ans=0
for i in range(0, k+1):
    ans += m * (pow(m-1, n-i-1, MOD) %MOD)* (nCk(n-1, i) % MOD)
    ans%=MOD
print(ans % MOD)

Measured memory_bytes: 26152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n,d;cin>>n>>d;
    d=2*d+1;
    cout<<n/d+bool(n%d);
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    n = int(input())
    vn = list(map(int, input().split()))
    even = count(vn, n, True)
    odd = count(vn, n, False)
    e1k, e1v, e2k, e2v = largest(even)
    o1k, o1v, o2k, o2v = largest(odd)
    res = solve(e1k, e1v, e2k, e2v, o1k, o1v, o2k, o2v, n)
    print(res)

def solve(e1k, e1v, e2k, e2v, o1k, o1v, o2k, o2v, n):
    if e1k != o1k:
        return n - e1v - o1v
    return min(n - e1v - o2v, n - e2v - o1v)

def count(vn, n, is_even):
    di = {}
    st = 0 if is_even else 1
    for i in range(st, n, 2):
        v = vn[i]
        if v in di:
            di[v] += 1
        else:
            di[v] = 1
    return di

def largest(di):
    li_tu = []
    for k in di:
        tu = (k, di[k])
        li_tu.append(tu)
    li_tu = sorted(li_tu, reverse=True, key=lambda x: x[1])
    assert len(li_tu) >= 1
    lg_key = li_tu[0][0]
    lg_val = li_tu[0][1]
    if len(li_tu) == 1:
        sc_key = 0
        sc_val = 0
    else:
        sc_key = li_tu[1][0]
        sc_val = li_tu[1][1]
    return lg_key, lg_val, sc_key, sc_val

main()


Measured memory_bytes: 19424
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100000 + 10;
char dat[SIZE];
bool zz[SIZE];
int n, k;
int main() {
	scanf("%d%d", &n, &k);
	scanf("%s", dat);
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 2; j++) {
			zz[0] = i; zz[1] = j;
			for (int k = 1; k < n - 1; k++)
				zz[k + 1] = zz[k - 1] ^ zz[k] ^ (dat[k] == 'x');
			if ((dat[n - 1] == 'x') == (zz[n - 2] ^ zz[n - 1] ^ zz[0]) && 
				(dat[0] == 'x') == (zz[n - 1] ^ zz[0] ^ zz[1])) {
				for (int k = 0; k < n; k++)
					printf("%c", zz[k] ? 'W' : 'S');
				printf("\n");
				return 0;
			}
		}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
import math

N, K = map(int, input().split())

probability_list = []

for i in range(N):
    if i+1 > K:
        probability_list.append(float(1))
    else:
        probability_list.append(1/2**(math.ceil(math.log2(K/(i+1)))))

print(sum(probability_list)/N)


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007;

int n,val[_];

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	sort(val+1,val+n+1,greater<int>());

	int now=1;
	while(now<n && now+1<=val[now+1])now++;
	if((val[now]-now)%2==0)
	{
		int cnt=0;
		while(now+cnt<n && now-1<val[now+cnt+1])cnt++;
		if(cnt%2==0){puts("Second");return 0;}
	}
	puts("First");
	
	return 0;
}


Measured memory_bytes: 640