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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  vector<string> S(3);
  cin >> S[0] >> S[1] >> S[2];
  vector<int> indices = { 1, 0, 0 };
  int turn = 0;
  while (true) {
    int ix = indices[turn];
    if (ix == (int)S[turn].size()) {
      break;
    }
    char ch = S[turn][ix];
    ++indices[turn];
    if (ch == 'a') { turn = 0; }
    else if (ch == 'b') { turn = 1; }
    else if (ch == 'c') { turn = 2; }
  }
  vector<char> players = { 'A', 'B', 'C' };
  printf("%c\n", players[turn]);
  return 0;
}


Measured memory_bytes: 256
while True:
    a, b, c = map(int, input().split())
    if a >= 1 and a <= 10000:
        if b >= 1 and b <= 10000:
            if c >= 1 and c <= 10000:
                break

if a <= b:
    if b <= c:
        print('{0} {1} {2}' .format(a, b, c))
    else :
        if a <= c:
            print('{0} {1} {2}' .format(a, c, b))
        else :
            print('{0} {1} {2}' .format(c, a, b))

else :
    if b >= c:
        print('{0} {1} {2}' .format(c, b, a))
    else :
        if a >= c:
            print('{0} {1} {2}' .format(b, c, a))
        else :
            print('{0} {1} {2}' .format(b, a, c))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,q,b,e,t;
    std::deque<int> deq;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a;
        deq.emplace_back(a);
    }
    cin >> q;
    for (int j=0;j<q;j++) {
        cin >> b >> e >> t;
        for (int k=0;k<(e-b);k++) {
            swap(deq[b+k],deq[t+k]);
        }
    }
    for (int l=0;l<deq.size();l++) {
        if ( l==deq.size()-1 ) {
            cout << deq[l] << endl;
        } else {
            cout << deq[l] << " ";
        }
    }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=3e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int n,m,S,T,cnt=1;
char s[N];int head[N];
struct edge{int t,ne,c;}e[N];
void adde(int a,int b,int c){
	e[++cnt]=(edge){b,head[a],c};head[a]=cnt;
	e[++cnt]=(edge){a,head[b],0};head[b]=cnt;
}
int d[N],w[N],cur[N],pre[N],prek[N],has[N];
int isap(int S,int T,int n){
	int x=S,flag,ans=0,flow=INF;
	while(d[S]<=n){
		flag=0;w[x]=flow;
		for(int k=cur[x];k;k=e[k].ne)if(e[k].c&&d[v]+1==d[x]){
			flag=1;gmin(flow,e[k].c);
			pre[v]=x;prek[v]=cur[x]=k;x=v;
			if(x==T){
				while(x!=S){int t=prek[x];e[t].c-=flow;e[t^1].c+=flow;x=pre[x];}
				ans+=flow;flow=INF;
			}
			break;
		}if(flag)continue;
		int mnd=n;
		run(x)if(e[k].c&&d[v]<mnd)cur[x]=k,mnd=d[v];
		has[d[x]]--;if(!has[d[x]])break;has[d[x]=mnd+1]++;
		if(x!=S){x=pre[x];flow=w[x];}
	}return ans;
} 
int main(){
	read(n,m);S=n+m+1,T=S+1;
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m){
			if(s[j]=='S')adde(S,i,INF),adde(S,j+n,INF);
			if(s[j]=='T')adde(i,T,INF),adde(j+n,T,INF);
			if(s[j]=='o')adde(i,j+n,1),adde(j+n,i,1);
		}
	}
	int ans=isap(S,T,T);
	if(ans>=INF)ans=-1;cout<<ans<<endl;
}

Measured memory_bytes: 16640
using System;
using System.Text;

namespace _078_MagicSquare
{
	class Program
	{
		const int Nothing = 0;

		static void Main ( string[] args )
		{
			StringBuilder[] output = new StringBuilder[15 + 1];

			//pre-processing
			for (int i = 3; i < output.Length; i += 2)
			{
				int[,] square = new int[i, i];

				int x = i / 2;
				int y = i / 2;
				int value = 1;

				y++;
				square[y, x] = value;
				value++;


				int limit = i * i;

				while (value <= limit)
				{
					bool isPadding = false;

					while (true)
					{
						if (isPadding)
						{
							x -= 1;
							y += 1;
							isPadding = false;
						}
						else
						{
							x += 1;
							y += 1;
						}

						if (i <= x)
						{
							x = 0;
						}
						if (i <= y)
						{
							y = 0;
						}
						if (x < 0)
						{
							x = i - 1;
						}

						if (square[y, x] == Nothing)
						{
							square[y, x] = value;
							value++;
							break;
						}
						else
						{
							isPadding = true;
						}
					}
				}

				//memory
				output[i] = new StringBuilder (4 * i * i);

				for (int row = 0; row < i; row++)
				{
					for (int col = 0; col < i; col++)
					{
						//?????°??? 4???
						output[i].AppendFormat ("{0,4}", square[row, col]);
					}
					output[i].AppendLine ();
				}
			}

			//input and output
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int index = int.Parse (inputStr);
				Console.Write (output[index]);
			}
		}
	}
}

Measured memory_bytes: 9104
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
    double x1, y1, x2, y2;
    
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)));
    
    return 0;
}



Measured memory_bytes: 3280
#include <vector>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <iostream>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1 ; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define FILL(a,b) memset(a , b , sizeof(a))
#define SZ(a) (int)a.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAX = 100007;

int gcd(int a, int b)
{
	if (!b) return a;
	return gcd(b , a % b);
}

int main()
{
	//freopen("in.txt" , "r" , stdin);

	int n , k;
	cin >> n >> k;
	int mx = 0;
	int g = 0;
	FOR(i,0,n)
	{
		int x;
		cin >> x;
		mx = max(mx , x);
		g = gcd(g , x);
	}

	if (k <= mx && k % g == 0)
	{
		cout << "POSSIBLE" << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;
  
  string s;
  cin >> s;
  
  ll ta = 0, tb = 0;
  for (int i = 0; i < n; i++){
    if (s[i] == 'c'){
      cout << "No" << endl;
    }
    else if (s[i] == 'a'){
      if (ta + tb < a + b){
        cout << "Yes" << endl;
        ta++;
      }
      else {
        cout << "No" << endl;
      }
    }
    else {
      if (ta + tb < a + b && tb < b){
        cout << "Yes" << endl;
        tb++;
      }
      else {
        cout << "No" << endl;
      }
    }
  }

  

  return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD;

using namespace std;

char str[10][1005];
int s[12][12][1005];
int ne[12][12][1005];

void solve()
{
    int h, w, K;
    scanf("%d%d%d", &h, &w, &K);
    int i, j, k;
    for (i = 0; i < h; i++) {
        scanf("%s", str[i]);
        for (j = 0; j < w; j++) {
            s[i][i + 1][j + 1] = s[i][i + 1][j] + (str[i][j] == '1' ? 1 : 0);
        }
    }

    for (k = 0; k <= w; k++) {
        for (i = 0; i <= h; i++) {
            for (j = i + 2; j <= h; j++) {
                s[i][j][k] = s[i][j - 1][k] + s[j - 1][j][k];
            }
        }
    }

    for (i = 0; i <= h; i++) {
        for (j = i + 1; j <= h; j++) {
            for (k = 0; k < w; k++) {
                int off = lower_bound(&s[i][j][k], &s[i][j][w + 1], s[i][j][k] + K + 1) - &s[i][j][0];
                off--;
                ne[i][j][k] = off;
            }
        }
    }
    
    int ans = INF;
    for (k = 0; k < (1 << (h - 1)); k++) {
        int cnt0 = 0;
        for (i = 1; i < h; i++) {
            if (k & (1 << (i - 1))) {
                cnt0++;
            }
        }

        int cnt = 0;
        int stt = 0;
        while (stt < w) {
            int min = INF;
            int prev = 0;
            for (i = 1; i <= h; i++) {
                if (i==h || (k & (1 << (i - 1)))) {
                    int off = ne[prev][i][stt];
                    min = MIN(min, off);
                    prev = i;
                }
            }
            cnt++;
            if (min <= stt) {
                cnt = INF;
                break;
            }
            stt = min;
        }
        //printf("%d ", cnt+cnt0-1);
        ans = MIN(ans, cnt + cnt0 - 1);
    }
    printf("%d\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 640
from sys import stdin

def solve(N, xys):
    diff = []
    diff_count = []
    idx = 0
    for i in range(N-1):
        for j in range(i+1,N):
            tmp_a = [xys[i][0] - xys[j][0], xys[i][1] - xys[j][1]]
            tmp_b = [xys[j][0] - xys[i][0], xys[j][1] - xys[i][1]]
            if tmp_a in diff:
                diff_count[diff.index(tmp_a)] += 1
            elif tmp_b in diff:
                diff_count[diff.index(tmp_b)] += 1
            else:
                diff.append(tmp_a)
                diff_count.append(1)
                idx += 1
    if diff == []:
        diff_count.append(0)
    return N - max(diff_count)

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    xys = []
    for i in range(N):
        xys.append([int(x) for x in stdin.readline().rstrip().split()])
    print(solve(N, xys))


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

int main(int argc, char const *argv[])
{
    long N, K;
    cin >> N >> K;
    int keta = 0;
    while (true)
    {
        if (N < K)
        {
            keta++;
            break;
        }
        else
        {
            N /= K;
            keta++;
        }
    }
    cout << keta << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  string N;
  cin>>N;
  if (N[0] == N[2])
    puts("Yes");
  else
    puts("No");
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define LL long long
LL dp[MAXN],a[MAXN],T,tmp=1000000000000000LL;
int n,m,t;
int main()
{
	scanf("%d%d%lld",&n,&m,&T);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		while(T<=2*(a[i]-a[t+1]))
			tmp=min(tmp,dp[t]-2*a[t+1]),t++;
		dp[i]=min(tmp+2*a[i],dp[t]+T);
	}
	printf("%lld\n",dp[n]+m);
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

int main()
{
  int N, M;

  cin >> N >> M;

  int ans[50];
  memset(ans, 0, sizeof(ans));

  for (int i = 0; i < M; i++) {
    int f, t; cin >> f >> t; f--; t--;
    ans[f]++; ans[t]++;
  }

  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)
Y = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

x_sum = 0

N.times do |n|
  x = X[n]

  x_sum = (x_sum + n * x - (N - n - 1) * x) % MOD
end

y_sum = 0

M.times do |m|
  y = Y[m]

  y_sum = (y_sum + m * y - (M - m - 1) * y) % MOD
end

puts (x_sum * y_sum) % MOD


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

int main(){
	int n,a,b,c,x;
	while(cin >> n >> a >> b >> c >> x && n){
		int key[100];
		for(int i = 0 ; i < n ; i++) cin >> key[i];
		int t = 0 , T = 0;
		if(x == key[0]) t++;
		while(t < n && ++T <= 10000){
			x = (a * x + b) % c;
			if(x==key[t]){t++;}
		}
		if(T == 10001) cout << -1 << endl;
		else cout << T << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int s[5]= {0};
int main()
{
int z[5];
    int n=0;
    int m;
    int i,j=0,k;
    int t=0;
    for(i=0; i<5; i++)
    {
        scanf("%d",&s[i]);
    }
    for(i=0; i<5; i++)
    {
        if(s[i]%10!=0)
       z[i]=10-s[i]%10;
       else
        z[i]=0;
    }
    t=z[0];
    for(i=1;i<5;i++)
        if(t<z[i])
    {
        t=z[i];
        n=i;
    }

    for(i=0;i<5;i++)
   {
       if(i!=n)
        {
            j=j+z[i]+s[i];
        }
        else
            j=j+s[i];
   }
    printf("%d",j);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  for (int C = 1; C <= N;C+=2){
    int sum = 0;
    for (int X = 1; X <= C;++X){
      if (C%X==0){
        sum++;
      }
    }
    if (sum == 8 ){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    ll ans = 0;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                ans += gcd(gcd(i, j), k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

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

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

typedef long long ll;

using namespace std;


class sieve
{
public:
  int p=0;
  vector<bool> furui;
  vector<int> ni;
  sieve(int n)
  {
    furui.resize(n,1);
    ni.resize(n,0);
    for(int i=2;i<n;i++)
    {
      if(furui[i])
      {
        for(int j=i*2;j<n;j+=i)furui[j]=0;
      }
    }
    repi(i,3,n)
    {
      if(i&1 && isprime(i) && isprime(i/2+1))ni[i]=1;
    }
    rep(i,n-1)
    {
      ni[i+1]+=ni[i];
    }
  }
  bool isprime(int m)
  {
    return furui[m];
  }
  int cnt(int l,int r)
  {
    return ni[r]-ni[l-1];
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  sieve s(1e5+1);
  int q;
  cin>>q;
  rep(i,q)
  {
    int l,r;
    cin>>l>>r;
    cout<<s.cnt(l,r)<<"\n";
  }
  cout<<flush;

  return 0;

}


Measured memory_bytes: 1024
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,x=IL()
L=IL()
ans=1
d=0
for i in range(n):
    d+=L[i]
    if d<=x:
        ans+=1
    else:
        
        break
print(ans)

Measured memory_bytes: 38492
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char ch[210000];
int A[30];
int main(){
	scanf("%s",ch+1); int n=strlen(ch+1); long long ans=1;
	for (int i=1;i<=n;i++){
		ans+=i-1-A[ch[i]-'a']; A[ch[i]-'a']++;
	}
	cout<<ans<<endl;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  char a[h][w];
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  rep(i,w+2){
    cout << '#';
  }
  cout << endl;
  rep(i,h){
    rep(j,w+2){
      if(j == 0 || j == w+1){
        cout << '#';
      }
      else{
        cout << a[i][j-1];
      }
    }
    cout << endl;
  }
  rep(i,w+2){
    cout << '#';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
h = [int(i) for i in input().split()]
hs = sorted(h)
hs.reverse()
c = 0
for i in range(len(hs)-1):
  nh = []
  a = 0
  for j in range(N-1):
    if not h[j]==h[j+1]:
      nh.append(h[j])
    if h[j]==hs[i]:
      h[j] = hs[i+1]
  nh.append(h[N-1])
  if h[N-1]==hs[i]:
    h[N-1] = hs[i+1]
  c += (hs[i]-hs[i+1])*nh.count(hs[i])
c += hs[-1]
print(c)

Measured memory_bytes: 3188
#include "iostream"
#include "vector"
#include "iomanip"

std::vector<std::vector<int>> root_pair(std::vector<std::pair<int, int>> r, int n) {
	std::vector<std::vector<int>> ans(n);
	for (int i = 0; i < r.size(); ++i)
		ans[r[i].first].push_back(r[i].second);
	return ans;
}

long double exp_root(int n, int max, int m, std::vector<long double> *ans, bool change, std::vector<std::vector<int>> v) {
	std::vector<long double> ans_tmp(*ans);
	for (int i = max; i >= 1; --i) {
		if (v[i].size() == 0) {
			ans_tmp[i] = -1;
			continue;
		}

		long double exp = 0;
		for (int j = 0; (unsigned)j < v[i].size(); ++j)
			if (ans_tmp[v[i][j]] == -1) {
				ans_tmp[i] = -1;
				break;
			}
			else exp += ans_tmp[v[i][j]];

		if (ans_tmp[i] != -1) ans_tmp[i] = exp / v[i].size() + 1;
	}

	if (change)
		*ans = ans_tmp;

	return ans_tmp[1];
}

long double erase_root(int n, int m, int erase_f, int erase_s, std::vector<long double> ans, std::vector<std::vector<int>> v) {
	std::vector<std::vector<int>> v_tmp(v);
	v_tmp[erase_f].erase(v_tmp[erase_f].begin() + erase_s);
	return exp_root(n, erase_f, m - 1, &ans, 0, v_tmp);
}

int main() {
	int n, m;
	std::cin >> n;
	std::cin >> m;

	std::vector<std::pair<int, int>> r(m);
	for (int i = 0; i < m; ++i) {
		std::cin >> r[i].first;
		std::cin >> r[i].second;
	}

	std::vector<std::vector<int>> v = root_pair(r, n);

	std::vector<long double> ans(n + 1, 0);
	long double min = exp_root(n, n - 1, m, &ans, 1, v);

	long double tmp;
	for (int i = 1; i < n; i++)
		if (v[i].size() > 1) {
			long double tmp_max = ans[v[i][0]];
			int tmp_max_num = 0;
			for (int j = 1; j < v[i].size(); ++j)
				if (ans[v[i][j]] > tmp_max) {
					tmp_max = ans[v[i][j]];
					tmp_max_num = j;
				}
			if ((tmp = erase_root(n, m, i, tmp_max_num,  ans, v)) != -1 && tmp < min)
				min = tmp;
		}

	std::cout << std::setprecision(10) << std::fixed << min << std::endl;
}

Measured memory_bytes: 4868
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#define MAX_N 100
#define MAX_T 200
#define INF (1LL<<31)
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;
 
int main(){
  int a;
  string str;
  cin>>str;
  a=str.length();
  for(int i=0; i<a;i+=2){
    cout<<str[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
l = list(map(int, input().split(' ')))
H = l[0]
W = l[1]

s = []
for i in range(H):
    a = str(input())
    s.append(a)

for i in range(W+2):
    print('#', end="")

print('')
for j in s:
    print('#', end="")
    print(j, end="")
    print('#', end="")
    print('')

for i in range(W+2):
    print('#', end="")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }

void solve()
{
    ll n;
    cin >> n;
    map<ll, ll> mp;
    rep(i, n) {    ll x; cin >> x; mp[x]++;
    }
    ll ans  =0;
    itr(it, mp)
    {
        if(it->ft > it->sd) ans += it->sd;
        else if(it->ft <= it->sd) ans += (it->sd - it->ft);
    }
    cout << ans;
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string c;
  cin >> c;
  int r = 0, w = 0;
  rep(i, n) if(c[i] == 'R') r++;
  int ans = max(r, w);
  rep(i, n) {
    if(c[i] == 'R') r--;
    else w++;
    int tmp = max(r, w);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <fstream>

using namespace std;

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

ll analize(string s){
  bool isOk=true;
  for(int i=1;i<(int)s.size()-1;i++){
    if(!(s[i]>='0'&&s[i]<='9')){
      isOk=false;
    }
  }
  if(isOk){
    return atoi(s.substr(1,(int)s.size()-2).c_str())/2+1;
  }
  int cnt=0;
  vector<ll> v;
  int a,b;
  stack<int> stk;
  for(int i=1;i<(int)s.size()-1;i++){
    if(s[i]=='['){
      stk.push(i);
      cnt++;
      //a=i;
    }
    else if(s[i]==']'){
      a=stk.top();
      stk.pop();
      cnt--;
      b=i;
    }
    if(cnt==0){
      v.push_back(analize(s.substr(a,b-a+1)));
    }
  }
  sort(v.begin(),v.end());
  ll sum=0;
  for(int i=0;i<=(int)v.size()/2;i++){
    sum+=v[i];
  }
  return sum;
}

int main(){

  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    cout<<analize(s)<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1332
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	int x;
	for (int i = 1; i < 10001; ++i) {
		cin >> x;
		if (!x)break;
		cout << "Case " << i << ": " <<x<< endl;
	}
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  ll a,b,c,x,y;
  cin >>a>>b>>c>>x>>y;
  ll ans = 0;
  if(a+b>=2*c){
    ans += min(x,y)*2*c;
    ll k=min(x,y);
    x -= k;  y-=k;
    ans += (x>y ? x*min(2*c, a) : y*min(2*c, b));
  }else{
    ans += x*a+y*b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k, m;
  cin >> n;
  int cnt = 1;
  cin >> m;
  for(int i = 0; i < n-1; ++i)
  {
    cin >> k;
  	if( m <= k)
    {
      cnt++;
      m = k;
    } 
  }
  cout << cnt ;
}

Measured memory_bytes: 256
from collections import Counter

blue_cards = [input() for _ in range(int(input()))]
red_cards = Counter([input() for _ in range(int(input()))])

sources = set(blue_cards)
blue_cards = Counter(blue_cards)

result = 0
for x in sources:
  tmp = blue_cards[x]
  
  if x in red_cards:
    tmp -= red_cards[x]
  
  result = max(result, tmp)
  
print(result)

Measured memory_bytes: 9444
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a1 = new int[n];
    for(int i = 0; i < n; i++){
      a1[i] = sc.nextInt();
    }
    Arrays.sort(a1);//綺麗にする
    int a = 0;
    int b = 0;
    int flag = 0;
    for(int i = a1.length-1; i >= 0; i--){
      if(flag == 0){
        a = a + a1[i];
        flag = 1;
      }else{
        b = b + a1[i];
        flag = 0;
      }
    }
    System.out.println(a-b);

  }
}


Measured memory_bytes: 21844
List=[]
num = 0

H, N = map(int, input().split())
L = input().split()

for i in range(N):
    a = int(L[i])
    List.append(a)

for i in range(len(List)):
    num = num + List[i]

if H <= num:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14016
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int main() {
  int N;
  cin >> N;
  set<char> st;
  rep(i, 0, N) {
    char c;
    cin >> c;
    st.insert(c);
  }
  if (st.size() == 3) {
    cout << "Three";
  } else {
    cout << "Four";
  }
}


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

int main(){
  int cnt=0,n,i,j,num;

  scanf("%d",&n);

  //素数が含まれる数をカウントするプログラム
  for(i=0;i<n;i++){
    scanf("%d",&num);
    if(num==2){
      cnt++;
      continue;
    }
    if(num<2 || num%2==0) continue;
    j=3;
    while(j<=sqrt(num)){
      if(num%j==0){
        cnt--;
        break;
      }
        j=j+2;
      }
    cnt++;
  }
  printf("%d\n",cnt);

  return 0;
}


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

template<class T>
bool eq_3(T t1,T t2,T t3){
    return t1==t2 && t2==t3;
}

char solve(string f){
    for(int i=0;i<9;i+=3){
        if(eq_3(f[i],f[i+1],f[i+2]) && f[i]!='s'){
            return f[i];
        }
    }

    for(int i=0;i<3;i++){
        if(eq_3(f[i],f[i+3],f[i+6]) && f[i]!='s'){
            return f[i];
        }
    }

    if(eq_3(f[0],f[4],f[8]) && f[0]!='s'){
        return f[0];
    }

    if(eq_3(f[2],f[4],f[6]) && f[2]!='s'){
        return f[2];
    }

    return 'd';
}

int main(){
    string f;

    while(getline(cin,f)){
        cout<<solve(f)<<endl;
    }

    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  int i,ans=0;
  char S[200],T[200];
  scanf("%s%s",S,T);

  printf("%s%s\n",T,S);
	return 0;
}


Measured memory_bytes: 128
import kotlin.math.ceil
import kotlin.math.floor

fun main() {
    val nk = nextIntList()
    val ans = solve(nk)
    println(ans)



}

/**
777...の倍数　→　111...の7倍
 */
fun solve(k: List<Int>): Int {
    val a = ceil(k[0].toDouble() / k[1].toDouble()).toInt()
    return a * k[2]
}


fun mod(k: Int): Int {
    tailrec fun innerFunc(modSum: Int, plainMod: Int, count: Int): Int {
        return if (modSum == 0) {
            count
        } else {
            val newPlainMod = plainMod * 10

            val newModSum = if (modSum + newPlainMod < k) {
                modSum + newPlainMod
            } else {
                (modSum + newPlainMod) % k
            }
            innerFunc(newModSum, newPlainMod, count + 1)
        }
    }
    return innerFunc((1 % k), (1 % k), 1)
}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextLongList(): List<Long> {
    return readLine()!!.split(" ").map { it.toLong() }
}

fun nextString(): String {
    return readLine()!!
}

Measured memory_bytes: 36436
#include<iostream>
#include<queue>
#include<vector>

#define COL 5
#define ROW 4

using namespace std;

struct patience{
	int cards[COL][ROW];
	int got_pairs;
	void Compact(){
		for(int i = 0; i < COL; ++i){
			for(int j = 0; j < ROW; ++j){
				if( cards[i][j] == -1 ){
					if( j < ROW - 1 ){
						swap(cards[i][j],cards[i][j+1]);
					}else{
						if( i < COL - 1 ){
							swap(cards[i][j],cards[i+1][0]);
						}
					}
				}
			}
		}
	}
	int Penalty(){
		int ret = 0;
		for(int i = 0; i < COL; ++i){
			for(int j = 0; j < ROW; ++j){
				if( cards[i][j] != -1 )
					++ret;
			}
		}
		return ret;
	}
	void Print()
	{
		for(int i = 0; i < COL; ++i){
			for(int j = 0; j < ROW; ++j){
				printf("%d ", cards[i][j] );
			}
			printf("\n");
		}
	}
};

void solve_dfs( patience p, int &got ){
	int ans = 0;
	const int di[] = {-1,-1,-1, 0,0, 1,1,1};
	const int dj[] = {-1, 0, 1,-1,1,-1,0,1};

	patience t = p;

	t = p;
	for(int i = 0; i < COL; ++i){
		for(int j = 0; j < ROW; ++j){
			for(int k = 0; k < 8; ++k){
				int ti = i+di[k];
				int tj = j+dj[k];
				if( 0<=ti && ti<COL && 0<=tj && tj<ROW ){
					t = p;
					if( t.cards[i][j] == t.cards[ti][tj] && t.cards[ti][tj] != -1 ){
						t.cards[i][j] = -1;
						t.cards[ti][tj] = -1;
						t.Compact();
						t.Compact();
						++t.got_pairs;
						got = max( got, t.got_pairs );
						solve_dfs( t, got );
					}
				}
			}
		}
	}
}

int solve(patience &p){
	int ret = 0;
	const int di[] = {-1,-1,-1,0,0,1,1,1};
	const int dj[] = {-1,0,1,-1,1,-1,0,1};
	queue< patience > qp;

	qp.push( p );
	while( !qp.empty() ){
		patience t = qp.front();
		qp.pop();

		if( ret == 10 ){
			return 10;
		}
		ret = max( ret, t.got_pairs );
		
		if( t.got_pairs <= 3 ){
			for(int i = 0; i < COL; ++i){
				for(int j = 0; j < ROW; ++j){
					for(int k = 0; k < sizeof(di)/sizeof(*di); ++k){
						if( 0<=i+di[k]&&i+di[k]<COL&&0<=j+dj[k]&&j+dj[k]<ROW ){
							if( t.cards[i][j] == t.cards[i+di[k]][j+dj[k]] && t.cards[i+di[k]][j+dj[k]] != -1 ){
								patience tt = t;
								tt.cards[i][j] = -1;
								tt.cards[i+di[k]][j+dj[k]] = -1;
								tt.Compact();
								tt.Compact();
								++tt.got_pairs;

								qp.push( tt );
							}
						}
					}
				}
			}
		}else{
			int got = 0;
			
			solve_dfs( t, got );
			ret = max( ret, got );
		}
	}
	return ret;
}

int invest;

int main(){
	int n;
	scanf("%d", &n);
	for(int tc = 0; tc < n; ++tc){
		int ans = 0;
		patience p;

		for(int i = 0; i < COL; ++i){
			for(int j = 0; j < ROW; ++j){
				scanf("%d", &p.cards[i][j]);
			}
		}

		p.got_pairs = 0;
		ans = solve( p );

		printf("%d\n", COL*ROW - 2*ans);
	}
	return 0;
}

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

const int N = 100005;
typedef long long LL;

int n, head[N], nxt[N], size[N];
LL D[N];
std::pair<LL, int> d[N];

void no() {std::cout << "-1\n", std::exit(0);}

void link(int x, int y) {nxt[y] = head[x], head[x] = y;}
int find(LL x) {
	auto it = std::lower_bound(d + 1, d + n + 1, std::make_pair(x, 0));
	if (it->first != x) no();
	return it->second;
}
int dfs0(int x) {
	for (int i = head[x]; i; i = nxt[i])
		D[x] += dfs0(i) + size[i];
	return D[x];
}
void dfs1(int x) {
	for (int i = head[x]; i; i = nxt[i])
		D[i] = D[x] + (n - 2 * size[i]), dfs1(i);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i)
		std::cin >> d[i].first, d[i].second = i, size[i] = 1;
	std::sort(d + 1, d + n + 1);
	for (int i = n; i > 1; --i) {
		int p = d[i].second, f = find(d[i].first - (n - 2 * size[p]));
		size[f] += size[p], link(f, p);
	}
	dfs0(d[1].second), dfs1(d[1].second);
	for (int i = 1; i <= n; ++i)
		if (D[d[i].second] != d[i].first) no();
	for (int i = 1; i <= n; ++i)
		for (int j = head[i]; j; j = nxt[j]) std::cout << i << ' ' << j << '\n';
	return 0;
}

Measured memory_bytes: 6528
import numpy as np
N,M = map(int,input().split())
ab = [np.array(list(map(int,input().split()))) for i in range(N)]
cd = [np.array(list(map(int,input().split()))) for i in range(M)]
ans = []
for i in range(N):
    tmp = []
    for j in range(M):
        tmp.append(sum(list(map(abs,list(ab[i] - cd[j])))))
    ans.append(tmp.index(min(tmp)))
for i in ans:
    print(i+1)

Measured memory_bytes: 12520
// 頻度管理 bool
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    vector<bool> flag(1e9, false);
    int ans = 0;
    rep(i, n) {
        ll a; cin >> a;
        if(flag[a]) flag[a] = false, ans--;
        else flag[a] = true, ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 122368
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc107/tasks/arc101_a
# C - Candles
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
cnt = [0] * (N + 1)

cnt[1] = 1

for i in range(2, N + 1):
    t = i
    for d in range(2, int(sqrt(i)) + 1):
        while (t % d == 0):
            cnt[d] += 1
            t = t // d

    if (t > 1):
        cnt[t] += 1

ans = 1

#print(cnt)

for d in range(2, N + 1):
    if cnt[d]:
        ans *= (cnt[d] + 1)
        ans %= MOD

print(ans)


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n, -1) {};
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        --A, --B;
        uf.unite(A, B);
    }
    int res = 0;
    for (int i = 0; i < N; ++i) res = max(res, uf.size(i));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    string s,t; cin >> s >> t;
    vector<char> v1,v2;
    for(int i = 0;i < s.length();i++){
        v1.push_back(s[i]);
    }
    
    string ans1;
    for(int i = 0;i < s.length();i++){
        ans1 += v1[i];
    }
    
    for(int i = 0;i < t.length();i++){
        v2.push_back(t[i]);
    }
    
    string ans2;
    for(int i = 0;i < t.length();i++){
        ans2 += v2[i];
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end(),greater<char>());
    v1 < v2 ? cout << "Yes" : cout << "No";
}


Measured memory_bytes: 3652
#import <iostream>
#import <string>
using namespace std;
int main(){
	int temp=0,X;
	string S,T;
	cin>>S>>T;
	int s,t;
	s=S.size();
	t=T.size();
	string check(s,'a');
	for(int i=0;i<s;i++){
		for(int j=0;j<s;j++){
			X=i+j;
			if(X>=s)X-=s;
			check[j]=S[X];
			if(check[j]!=T[j]){
				j=0;
				break;
			}
			if(j==s-1){
				temp=1;
				break;
			}
		}
		if(temp==1)break;
	}
	if(temp==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int count = 0;

    for (int i = 0; i <= A; i++){
        for (int j = 0; j <= B; j++){
            for (int k = 0; k <= C; k++){
                if (500 * i + 100 * j + 50 * k == X)
                count++;
            }  
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int A,B,C,D;
int main() {
	cin>>A>>B>>C>>D;

	if(A+B==C+D)cout<<"Balanced"<<endl;
	if(A+B>C+D)cout<<"Left"<<endl;
	if(A+B<C+D)cout<<"Right"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(void)
{
    int A[100][100];
    int b[100];
    int c,i,j,n,m;
      
    scanf("%d %d",&n,&m);
      
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
      
    for(i=0;i<n;i++){
        c=0;
        for(j=0;j<m;j++){
            c+=A[i][j]*b[j];
        }
        printf("%d\n",c);
    }
      
    return 0;
}


Measured memory_bytes: 2140
import java.util.*;
 
public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		if(a%2==0)
		{System.out.println(a);}
		else
		{System.out.println(a*2);}
	
	}
}

Measured memory_bytes: 21972
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 415
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}



int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
const int inf = 2e9, mod = 1e9 + 7,N=1e5+5;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n;i>n-r;i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
*/
int main()
{
    bizarre
  long long n,k,x;
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>x;
  cout << ((n-1)/(k-1))+((n-1)%(k-1)!=0?1:0);
    return 0;
}


Measured memory_bytes: 256
while line = gets
  data = line.chomp.split(//).map(&:to_i)
  while data.size != 1
    next_data = []
    for i in 0..data.size-2
      next_data << (data[i] + data[i+1]).to_s[-1].to_i
    end
    data = next_data
  end
  puts data[0]
end

Measured memory_bytes: 6096
# AOJ 0033 Ball
# Python3 2018.6.16 bal4u

n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	b = c = 0
	yes = True
	for j in range(10):
		if a[j] > b: b = a[j]
		elif a[j] > c: c = a[j]
		else: yes = False
	print('YES' if yes else 'NO')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;
using Int = long long;

int main() {
  int n;cin>>n;
  int bit = 0;
  rep(i,n) {
    char color; cin>>color;
    if (color=='P') bit |= 1;
    if (color=='W') bit |= 2;
    if (color=='G') bit |= 4;
    if (color=='Y') bit |= 8;
  }
  string ans = bit == 15 ? "Four" : "Three";
  cout << ans << endl;
}


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 result = 0;
		if (a == 1) {
			if (b == 2) {
				result = 3;
			} else {
				result = 2;
			}
		} else if (a == 2) {
			if (b == 1) {
				result = 3;
			} else {
				result = 1;
			}
		} else {
			if (b == 1) {
				result = 2;
			} else {
				result = 1;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 22740