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

template <class T>
inline void read(T &x)
{
	static char ch; 
	while (!isdigit(ch = getchar())); 
	x = ch - '0'; 
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0'; 
}

template <class T>
inline void tense(T &x, const T &y)
{
	if (x > y)
		x = y; 
}

template <class T>
inline void relax(T &x, const T &y)
{
	if (x < y)
		x = y; 
}

typedef std::pair<int, int> pii; 

const int MaxN = 2e5 + 5; 

struct node
{
	int l, r, val; 

	node(){}
	node(int a, int b, int c):
		l(a), r(b), val(c) {}

	inline bool operator < (const node &rhs) const
	{
		if (val != rhs.val)
			return val > rhs.val; 
		if (r != rhs.r)
			return r < rhs.r; 
		return l > rhs.l;  
	}

	inline void operator -= (const node &rhs)
	{
		if (rhs.l <= l && r <= rhs.r)
			return (void)(r = l - 1); 
		if (rhs.l >= l)
			tense(r, rhs.l - 1); 
		if (rhs.r <= r)
			relax(l, rhs.r + 1); 
	}
}; 

int n, a[MaxN]; 
std::vector<node> f[MaxN]; 

int main()
{
	read(n); 
	for (int i = 1; i <= n; ++i)
		read(a[i]); 

	f[0].push_back(node(0, 0, 0)); 
	for (int i = 1; i <= n + 1; ++i)
	{
		std::vector<node> cur; 

		for (node lst : f[i - 1])
		{
			int l = lst.l, v = lst.val; 
			int tmin = std::min(l - 1, a[i] - a[i - 1] + l - 1); 
			int tmax = std::max(l - 1, a[i] - a[i - 1] + l - 1); 
			tense(tmax, a[i]); 

			if (tmin >= 0)
				cur.push_back(node(0, tmin, v + 2)); 
			if (tmin < tmax && tmax >= 0)
				cur.push_back(node(std::max(0, tmin + 1), tmax, v + 1)); 
			if (tmax < a[i])
				cur.push_back(node(tmax + 1, a[i], v)); 
		}

		std::sort(cur.begin(), cur.end()); 
		for (int j = 0; j < (int)cur.size(); ++j)
		{
			for (int k = 0; k < j; ++k)
				cur[k] -= cur[j]; 
		}

		for (int j = 0; j < (int)cur.size(); ++j)
			if (cur[j].l <= cur[j].r)
			{
				if (!f[i].empty() && f[i].rbegin()->val == cur[j].val)
					f[i].rbegin()->r = cur[j].r; 
				else
					f[i].push_back(cur[j]); 
			}
	}

	std::cout << f[n + 1][0].val << '\n'; 

	return 0; 
}


Measured memory_bytes: 18176
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(_;0..readln().chomp().to!int())
    {
        auto a = readln().split().map!(to!int).map!(a=>a*a).array().sort();
        writeln(a[0]+a[1]==a[2]?"YES":"NO");
    }
}

Measured memory_bytes: 1064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0){
            break;
        }
        for(int i=0; i<H; i++){
            if(i==0 || i==H-1){
                for(int Q=0; Q<W; Q++){
                    cout << "#";
                }
                    cout << endl;
                if(i==H-1){
                    cout << endl;
                }
            }
            else if(i>0 && i<H){
                cout << "#";
                for(int U=0; U<W-2; U++){
                    cout << ".";
                }
                cout << "#" << endl;
            }
        }
    }
}



Measured memory_bytes: 3100
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int d, g, ans;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    cin >> d >> g;
    vector<int> p(d, 0);
    vector<int> c(d, 0);
    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }
    ans = INF;
    for (int mask = 0; mask < (1 << d); ++mask) {
        int s = 0, rest_max = -1, num = 0;
        for (int i = 0; i < d; ++i) {
            if (mask >> i & 1) {
                //全て解いてコンプリートボーナスを得る場合の集計
                s += p[i] * 100 *  (i + 1) + c[i];
                num += p[i];
            } else {
                //全て解かない問題は添字を記録する
                rest_max = i;
            }
        }
        if (s < g) {
            int s1 = 100 * (rest_max + 1);
            //中途半端に解く問題を何題解く必要があるか
            int need = (g - s + s1 - 1) / s1;
            //全て解くかそれ以上に解く必要がある場合は無視
            if (need >= p[rest_max]) {
                continue;
            }
            num += need;
        }
        ans = min(ans, num); 
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



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

int main()
{
	int H, N;
	scanf("%d%d", &H, &N);
	
	int i;
	for(i = 0; i < N; i++)
	{
		int Di;
		scanf("%d", &Di);
		
		H -= Di;
	}
	
	if(H <= 0)
		printf("Yes");
		
	else
		printf("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int binary_square(int x, int n);

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c;
  vector<vector<int>> col(h);
  vector<int> row(w, 0), tmp(w, 0);
  rep(i, h) {
    string s;
    cin >> s;
    c.push_back(s);
  }
  rep(i, h) {
    rep(j, w) {
      if (c[i][j] == '#') {
        col[i].push_back(j);
        row[j]++;
        tmp[j]++;
      }
    }
  }
  int cnt=0;
  // int check = binary_square(2, h+w);
  int check = 1<<(h+w);
  rep(x, check){
      int xnum = x;
      rep(i, h){
          if((xnum>>i)&1){
              int len = col[i].size();
              rep(j, len){
                  tmp[col[i][j]]--;
              }
          }
          // xnum >>= 1;
      }
      int sum = 0;
      rep(i, w){
          if((xnum>>(h+i))&1){
              sum += tmp[i];
          }
          tmp[i] = row[i];
          // xnum >>= 1;
      }
      if(sum==k){
          cnt++;
      }
  }
  cout << cnt << endl;
  return 0;
}

int binary_square(int x, int n) {
  int m = MOD;
  int ans = 1;
  while (n) {
    if(n&1) {
      ans = ans * x % m;
    }
    x = x * x % m;
    n >>= 1;
  }
  return ans % m;
}

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

int main()
{
    int n,j,k=0,w=0,r=0,p=0;scanf("%d",&n);char c[n+1];scanf("%s",c);int v[n];
    for(j=0;j<n;j++)
    {
        if(c[j]=='W')w++;
        else
            r++;
    }p=r;
    for(j=0;j<n;j++)
    {
        if(p==0)
            break;
        if(c[j]=='R')
        {
            v[j]=-1;p--;
        }
        else
        {
            v[j]=p;p--;k++;
        }
    }
    printf("%d\n",k+p);
    return 0;
}


Measured memory_bytes: 2604
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()
N=int(input())
numbers=[input() for i in range(N)]



for n in numbers:
    if a==n:
        a=0
    elif b==n:
        b=0
    elif c==n:
        c=0
    elif d==n:
        d=0
    elif e==n:
        e=0
    elif f==n:
        f=0
    elif g== n:
        g = 0
    elif h == n:
        h = 0
    elif i == n:
        i = 0
    else:
        continue

if a==b==c or d==e==f or g==h==i or a==d==g or b==e==h or c==f==i or a==e==i or c==e==g:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	
	while(true){
		int N, M, Q;
		string ans;
		vector<string> S, B;
		vector<int> unknown;
		vector<vector<int>> light_bulbs;
		
		cin>>N>>M>>Q;
		
		if(!N&&!M&&!Q) break;
		
		S.resize(Q);
		B.resize(Q);
		unknown.resize(N);
		light_bulbs.resize(N, vector<int>(Q+1));
		
		for(int i = 0; i < Q; i++){
			cin>>S[i]>>B[i];
			for(int j = 0; j < N; j++){
				if(S[i][j] == '1'){
					light_bulbs[j][i+1] = !light_bulbs[j][i];
				} else light_bulbs[j][i+1] = light_bulbs[j][i];
			}
		}
		
		for(int i = 0; i < N; i++){
			if(unknown[i]) continue;
			for(int j = i + 1; j < N; j++){
				if(light_bulbs[i] == light_bulbs[j]){
					unknown[i] = true;
					unknown[j] = true;
				}
			}
		}
		// for(int i = 0; i < N; i++) cout<<"NUKNOWN "<<" i = "<<i<<" "<<unknown[i]<<endl;
		// for(int i = 0; i < N; i++) {for(int j = 0; j <= Q; j++) cout<<light_bulbs[i][j]; cout<<endl;}
		for(int i = 0; i < M; i++){
			char ch = '?';
			for(int j = 0; j < N; j++){
				bool same = true;
				for(int k = 0; k < Q; k++){
					if(light_bulbs[j][k+1] && B[k][i] == '0' || !light_bulbs[j][k+1] && B[k][i] == '1'){
						same = false;
						break;
					}
				}
				if(same){
					if(!unknown[j]){
						if(j <= 9) ch = '0' + j;
						else ch = 'A' + j - 10;
					}
					break;
				}
			}
			ans += ch;
		}
		
		cout<<ans<<endl;
		
	}
	
	
	return 0;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int N, M;
  scanf("%d%d", &N, &M);
  int x = 0, sm = 0;
  rep(i, 0, M) {
    scanf("%d", &x);
    sm += x;
  }
  printf("%d\n", max(-1, N - sm));
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  solve();
	return 0;
}



Measured memory_bytes: 3768
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define N 3000
int n;
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

vi prime;
bitset<N> ck;

void seive()
{
    for(int i = 3; 1LL*i*i <= N; i+=2)
        if(ck[i] == 0)
            for(int j = i*i; j<= N; j+= 2*i)
                ck[j] = 1;
    prime.pb(2);
    for(int i = 3; i<= N; i+=2)
        if(!ck[i])
            prime.pb(i);
}




vi fac(N+1);
void fact()
{
    fac[0] = 1;
    for(int i = 1; i<= N; i++)
        fac[i] = 1LL*fac[i-1]*i%mod;
}


ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}


ll ncr(int n, int r)
{
    ll res = (fac[n] * bigmod(1LL*fac[r] * fac[n-r]%mod, mod - 2))%mod;
    return res;
}



//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    fact();
    int n;
    cin>>n;
    ll ans = 0;
    if(n < 3)
        return cout<<0, 0;
    for(int k = 1;n-3*k >= 0; k++)
        ans = (ans + ncr(n-2*k - 1, k-1))%mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=998244353;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  int n;
  cin >> n;
  bool odd = false;
  rep(i,n){
    ll a;
    cin >> a;
    if(a%2!=0)odd=true;
  }
  if(odd)cout << "first" << endl;
  else cout << "second" << endl;
  return 0;
  
}

Measured memory_bytes: 12160
#include <iostream>
using namespace std;
int n;
int a[100000];
long long ans[100000],sum;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    for(int i=2;i<2*n;i+=2){
        ans[i%n]=ans[(i-2)%n]+2*(a[(i-1)%n]-a[(i-2)%n]);
        sum-=ans[i%n];
    }sum/=n;
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<ans[i]+sum;
    }
    cout<<endl;
    return 0;
}

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


int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

        int n,i,j; cin>>n;
        int h[n];
        for(i=0;i<n;i++) cin>>h[i];

        vector<int> dp(n,INT_MAX);
        dp[0]=0;
        dp[1]=abs(h[0]-h[1]);

        for(i=2;i<n;i++)
        {
            dp[i]=min(dp[i], dp[i-1]+abs(h[i-1]-h[i]));
            dp[i]=min(dp[i], dp[i-2]+abs(h[i-2]-h[i]));
        }

  

        cout<<dp[n-1]<<"\n";

    return 0;
}



Measured memory_bytes: 1792
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a,k; cin>>a>>k;
    vec<pll> m(a);
    for(int q=0; q<a; q++){
        cin>>m[q].F>>m[q].S;
    }
    ll u = 1e5+5;
    vec<ll> dp(u, 1e15);
    dp[0] = 0;
    for(int q=0; q<a; q++){
        ll w = m[q].F, c = m[q].S;
        auto was = dp;
        for(int e=c; e<u; e++){
            dp[e] = min(dp[e], was[e-c]+w);
        }
    }
    ll o = 0;
    for(int q=0; q<u; q++) if(dp[q] <= k) o = q;
    cout<<o;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int mod=1e6+3;
typedef long long ll;
map<int,int>mp,mmp;
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define pi acos(-1.0)
void read(int &x)
{
	int f=1;x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
struct one
{
	int a,b;
}uu[maxn];
bool cmp(one x,one y)
{
	if(x.b==y.b)return x.a<y.a;
	return x.b<y.b;
}
int main()
{
   int n,i,j;
   read(n);
   for(i=0;i<n;i++)
   {
   	read(uu[i].a);read(uu[i].b);
   }
   sort(uu,uu+n,cmp);
   int tim=0;
   bool ok=1;
   for(i=0;i<n;i++)
   {
   	tim+=uu[i].a;
   	if(tim>uu[i].b)
   	{
   		ok=0;break;
   	}
   }
   if(ok)puts("Yes");
   else puts("No");
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)

const int N=1011111;

int fa[N],d[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int find(int x) {
	if (!fa[x]) return x;
	int f=find(fa[x]);
	d[x]+=d[fa[x]];
	return fa[x]=f;
}

int main(void) {
	int n=read(),m=read();
	for (;m--;) {
		int x=read(),y=read(),k=read();
		int fx=find(x),fy=find(y);
		if (fx==fy) {
			if (d[y]-d[x]!=k) return 0&puts("No");
		} else fa[fy]=fx,d[fy]=d[x]+k-d[y];
	}
	return 0&puts("Yes");
}

Measured memory_bytes: 4608
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;

int main() {
    int x = 0;
    char ch;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        scanf("%c", &ch);
        if (ch == 'R') {
            x++;
            if (x > ans) {
                ans = x;
            }
        } else {
            x = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3228
N=int(input())
E=[[] for _ in [0]*N]
for _ in [0]*(N-1):
    a,b=map(int,input().split())
    E[a-1]+=[b-1]
    E[b-1]+=[a-1]
V=[1]+[0]*(N-2)+[-1]
q=[0,N-1]
while q:
    p=[]
    for i in q:
        for j in E[i]:
            if not V[j]:
                V[j]=V[i]
                p+=[j]
    q=p
print("Fennec" if sum(V)>0 else "Snuke")

Measured memory_bytes: 23432
N,W = map(int,input().split())

v = [0] * N
w = [0] * N
for i in range(N):
    v[i],w[i] = map(int,input().split())

dp = [[0] * (W+1) for _ in range(N)]

for i in range(N):
    for j in range(1, W+1):
        if w[i] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],v[i]+dp[i-1][j-w[i]])
print(dp[i][j])


Measured memory_bytes: 25448
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Convert.ToDouble(Console.ReadLine());
            double area = r * r * Math.PI;
            double length = 2 * Math.PI * r;

            Console.WriteLine(area + " " + length);
        }
    }
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<int> l(k), r(k);
	REP(i, k) cin >> l[i] >> r[i];
	REP(i, k) r[i]++;

	vector<int> dp(n + 1, 0);
	dp[0] = 1;
	dp[1] = -1;
	REP(i, n) {
		if (i > 0)
			dp[i] = (dp[i] + dp[i - 1]) % MOD;
		REP(j, k) {
			if (i + l[j] < n)
				dp[i + l[j]] = (dp[i + l[j]] + dp[i]) % MOD;
			if (i + r[j] < n)
				dp[i + r[j]] = (((dp[i + r[j]] - dp[i]) % MOD) + MOD) % MOD;
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 3928
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 1;
    while(0==0){
      if(ans*2<=N){
        ans*=2;
      }
      else{
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      num=[l[i],l[j],l[k]]
      if len(set(num))!=3:continue
      num.sort()
      if num[2]<num[1]+num[0]:ans+=1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;
int main(void){

    string strInput, input;
    int len,sumNum = 0;
    
    while(cin >> input && input != "0"){
        len = input.length();
        int a[len];
        sumNum = 0;
        
        for(int i=0; i<len; i++){
            strInput = input[i];
            a[i] = stoi(strInput);
            sumNum += a[i];
        }
        cout << sumNum << endl;
    }
    
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
const Int MOD = 998244353;
using ll = __int128_t;
using P = pair<ll, Int>;
map<P, Int> dp;
Int dfs(ll b,Int n){
  if(dp.count(P(b,n))) return dp[P(b,n)];
  Int &res=dp[P(b,n)];
  if(!n) return res=1;
  res=dfs(b>>1,n-1)*((b&1)+1)%MOD;
  res%=MOD;
  for(Int i=1;i*2<=n;i++){
    ll nb=(1LL<<i)-1,tb=b;
    nb&=tb;
    tb>>=i;
    for(Int j=1;i+i*j<=n;j++){      
      nb&=tb;
      tb>>=i;
      res+=dfs(nb,i)*dfs(tb,n-(i+i*j))%MOD;
      res%=MOD;
    }
  }
  res%=MOD;
  return res;
}

signed main(){
  string s;
  cin>>s;
  Int n=s.size();
  ll b=0,k=1;
  for(Int i=0;i<n;i++){
    if(s[i]=='1') b|=k;
    k<<=1;
  }
  cout<<dfs(b,n)<<endl;
  return 0;
}


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

int N, K;
int A[100005];
int cnt = 0;
vector<int> G[100005];

int dfs(int v, int depth = 0) {
        int ret = 1;
        for (auto &u : G[v]) {
                if (u != 1) ret = max(ret, dfs(u, depth + 1) + 1);
        }
        if (depth > 1 && ret == K) {
                cnt++;
                ret = 0;
        }
        return (ret);
}

int main() {
        cin >> N >> K;
        for (int i = 1; i <= N; i++) {
                cin >> A[i];
                G[A[i]].push_back(i);
        }
        if (A[1] != 1) cnt++;
        dfs(1);
        cout << cnt << endl;
        return (0);
}


Measured memory_bytes: 10752
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	string s;
	cin >> s;
	int c = 0;
	for (auto i : s)
		c += i - '0';
	cout << (c % 9 ? "No" : "Yes");
}

Measured memory_bytes: 3492
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        int a, b, division, remainder;
        String f;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder createString = new StringBuilder();
        String line = br.readLine();
        String[] numbers = line.split(" ");
        a = Integer.parseInt(numbers[0]);
        b = Integer.parseInt(numbers[1]);
        division = a / b;
        remainder = a % b;
        f = (String.format("%.5f",((double)a / (double)b)));
        
        createString
            .append(division)
            .append(" ")
            .append(remainder)
            .append(" ")
            .append(f)
            .append("\n");
        System.out.print(createString);
    }
}

Measured memory_bytes: 24768
#include"bits/stdc++.h"
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if (a==b) cout << "Draw" << endl;
  else if (a==1) cout << "Alice" << endl;
  else if (b==1) cout << "Bob" << endl;
  else if (a>b) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

vector<vector<P>> G(100009);
int col[100009];

void dfs(int pos, int befo_pos, int forbidden_edge_num) {
	int cnt = 1;
	for (P v : G[pos]) {
		if (v.first == befo_pos) continue;
		if (cnt == forbidden_edge_num) cnt++;
		col[v.second] = cnt;
		dfs(v.first, pos, cnt);
		cnt++;
	}
}

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

	int N; cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		int a, b; cin >> a >> b;
		G[a].push_back(P(b, i));
		G[b].push_back(P(a, i));
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) ans = max(ans, int(G[i].size()));
	cout << ans << endl;
	dfs(1, 0, 0);
	for (int i = 1; i <= N - 1; i++) cout << col[i] << endl;

	return 0;
}

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

typedef long long ll;

ll n, a[100000];
ll dp[100002];
ll INF = 0xfffffffffffffff;

int main() {
    cin >> n;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        dp[i] = INF;
    }
    dp[n] = dp[n + 1] = INF;
    dp[0] = -1;
    for(ll i = 0; i < n; i++) {
        ll k = lower_bound(dp, dp + n + 2, a[i]) - dp;
        dp[k] = a[i];
    }
    ll ans = 0;
    while(dp[ans + 1] != INF) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4664
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int l[110];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) cin >> l[i];
    sort(l, l+n);

    int cnt = 0;
    for (int i=0;i<n;i++) {
        for (int j=i+1;j<n;j++) {
            for (int k=j+1;k<n;k++) {
                if (l[i]==l[j]||l[j]==l[k]) continue;
                if (l[i]+l[j]>l[k]) cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int> h(n);
    for(int& x:h)
    {
        cin>>x;
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));

            }
        }
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
n,k = gets.chomp.split(' ').map(&:to_i)
ans = [n-k+1,0].max.to_f/n
i = 1
if n >= k
  range = k
else
  range = n+1
end

while i < range
  count = 0
  while true
    if i*(2**count) >= k
      break
    end
    count += 1
  end
  ans += 1.0/((2**count)*n)
  i += 1
end
puts ans

Measured memory_bytes: 14264
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  priority_queue< int, vector< int >, greater< int > > queL;
  priority_queue< int > queR;
  int N;
  cin >> N;
  vec< int > a(3 * N);
  vec< int > sumL(N + 1);
  vec< int > sumR(N + 1);
  REP(i, 3 * N) { cin >> a[i]; }
  int ans = 0;
  REP(i, N) {
    ans += a[i];
    queL.push(a[i]);
  }
  sumL[0] = ans;
  ans = 0;
  REP(i, N) {
    ans += a[i + 2 * N];
    queR.push(a[i + 2 * N]);
  }
  sumR[0] = ans;

  REP(i, N) {
    int v0 = a[N + i];
    queL.push(v0);
    int v1 = queL.top();
    queL.pop();
    sumL[i + 1] = sumL[i] + v0 - v1;
  }
  REP(i, N) {
    int v0 = a[2 * N - 1 - i];
    queR.push(v0);
    int v1 = queR.top();
    queR.pop();
    sumR[i + 1] = sumR[i] + v0 - v1;
  }
  ans = sumL[0] - sumR[N];
  REPS(i, N) { chmax(ans, sumL[i] - sumR[N - i]); }
  print(ans);
}

Measured memory_bytes: 6516
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	sp := strings.Split(s, "")
	answers := make([]string, 0, 0)
	for _, v := range sp {
		if v == "0" || v == "1" {
			answers = append(answers, v)
		} else {
			if len(answers) > 0 {
				answers = answers[:len(answers)-1]
			}
		}
	}
	fmt.Print(strings.Join(answers, ""))
}


Measured memory_bytes: 1840
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;

const int maxn = 200000+22;

int a[maxn];
int b[maxn];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(a+1,a+1+n);
	int ans1=a[n/2];
	int ans2=a[n/2+1];
	for(int i=1;i<=n;i++){
		if(b[i]<=ans1){
			printf("%d\n",ans2);
		}else{
			printf("%d\n",ans1);
		}
	}

	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

struct point {
    ll next;
    ll score;
};

ll get_cluster_result(vector<point>& points, vector<bool>& done, ll istart, ll K) {
    ll loop_score = 0;
    vector<ll> cluster;
    point p = points[istart];
    while (true) {
        cluster.push_back(p.next);
        done[p.next] = true;
        loop_score += points[p.next].score;
        if (p.next == istart) {
            break;
        }
        p = points[p.next];
    }

    ll size = cluster.size();
    ll cresult = 0;
    ll RK;
    if (loop_score > 0) {
        if (K >= 2 * size) {
            ll shu = K / size - 1;
            cresult += shu * loop_score;
            RK = K - shu * size;
        } else {
            RK = K;
        }
    } else {
        RK = size;
    }
    ll max_move = -INF;
    for (ll p0 : cluster) {
        ll move_score = 0;
        point pp = points[p0];
        for (ll j = 0; j < RK; j++) {
            move_score += points[pp.next].score;
            pp = points[pp.next];
            max_move = max(move_score, max_move);
        }
    }
    cresult += max_move;
    return cresult;
}
int main() {
    ll N, K;
    cin >> N >> K;
    vector<point> points(N + 1);
    for (ll i = 1; i <= N; i++) {
        cin >> points[i].next;
    }
    for (ll i = 1; i <= N; i++) {
        cin >> points[i].score;
    }
    vector<bool> done(N + 1);
    for (ll i = 0; i <= N; i++) {
        done[i] = false;
    }

    ll gresult = -INF;
    for (ll i = 1; i <= N; i++) {
        if (done[i]) {
            continue;
        }
        gresult = max(gresult, get_cluster_result(points, done, i, K));
    }
    print(gresult);
}


Measured memory_bytes: 3788
#include <cstdio>
#include <algorithm>
using namespace std;
int n,i,p,s,a[100004];
long long r;
int main()
{
    scanf ("%d", &n);
    for (i=1;i<=n;i++)
        scanf ("%d", &a[i]);
    sort (a+1,a+n+1);
    p=0;
    s=0;
    for (i=n;i>=1;i--)
    {
        if (a[i]==a[i-1])
        {
            if (p==0)
                p=a[i];
            else
            {
                s=a[i];
                break;
            }
            i--;
        }
    }
    r=(1LL)*p*s;
    printf ("%lld\n", r);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    string n;
    cin >> n;
    ll sum = 0;
    for (char c : n)
        sum += (c - '0');
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3692
/*
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll factor(ll x) {
	ll ret = 1;
	ll tmp = 0;
	for (ll p = 2;;p++) {
		if (x == 1) {
			ret *= tmp + 1;
			break;
		}
		if (x % p == 0) {
			tmp += 1;
			x /= p;
			p--;
			continue;
		}
		ret *= tmp + 1;
		tmp = 0;
	}
	return ret;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start

	ll N;
	cin >> N;
	ll ans = 0;

	for (ll i = 1; i <= N; i++) {
		ll ret = factor(i);
		ll tmp = ret;
		ans += i * tmp;
	}

	cout << ans << endl;



EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}


*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	


	int S, W;
	cin >> S >> W;

	if (S <= W) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // exponential

        // divide as much as you can
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // push the result
        res.push_back({a, ex});
    }

    // last num (if the lasting n is prime number and not 1)
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main() {

    ll n,ans = 0,tmp; cin >> n;

    for(int i = 1; n-i >= 1; i ++){
        ll m = n-i;
        if(m == 1){
            ans ++;
            continue;
        }
        tmp = 1;

        vector<pair<long long, long long> >v = prime_factorize(m);

        rep(j,v.size()) tmp *= (v[j].second+1);

        ans += tmp;
    }

    cout << ans;



}


Measured memory_bytes: 3628
def selectionSort(A, N):
    count = 0
    for i in range(0, N):
        minj = i
        flag = 0
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
                flag = 1
        if flag == 1:
            count += 1
        v = A[i]
        A[i] = A[minj]
        A[minj] = v

    return A, count

N = input()

line = raw_input()
line = line.strip().split()
line = map(lambda x: int(x), line)
a = selectionSort(line, N)

print(' '.join(map(lambda x: str(x), a[0])))
print(a[1])


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

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int main() {
  string s;
  cin >> s;
  cout << stringcount(s, '+') - stringcount(s, '-') << endl;
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
PY = [tuple(map(int,input().split())) for i in range(M)]

#こういう書き方ができると暗記する
ypi = sorted((y,p,i) for i,(p,y) in enumerate(PY))
 
from collections import defaultdict
d = defaultdict(lambda: 0)

#list初期化
ans = [None] * M

for y,p,i in ypi:
    d[p] += 1

    #lenがMのansのlistに添字ではなくて、意図的に、iでインデックス指定で入れる。
    #こうすることで、わざわざ探す処理なく、順番も入れ替えることなく処理が可能
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)
print(*ans, sep='\n')

Measured memory_bytes: 44012
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline);
line[0] = line[0].split(' ').map(Number);
H = line[0][0];
W = line[0][1];
field = line.slice(1, 1+H);
line[1+H] = line[1+H].split(' ').map(Number);
R = line[1+H][0];
C = line[1+H][1];
pat = line.slice(1+H+1, 1+H+1+R);

if (H < R || W < C) process.exit();

hash = {};
cnt = 0;
function register(str) {
  if (!hash.hasOwnProperty(str)) {
    hash[str] = cnt;
    return cnt++;
  }
  return hash[str];
}

matrix = field.map(function (str) {
  var res, i;
  res = [];
  for (i = 0; i <= W-C; i++) res.push(register(str.slice(i, i+C)));
  return res;
});
pat = pat.map(register);

for (i = 0; i <= H-R; i++) {
  for (j = 0; j <= W-C; j++) {
    flag = true;
    for (k = 0; k < R; k++) {
      if (matrix[i+k][j] !== pat[k]) {
        flag = false;
        break;
      }
    }
    if (flag) console.log(i, j);
  }
}

Measured memory_bytes: 212952
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = s.charAt(0);
        switch(c){
            case 'a':
            case 'e':
            case 'i':
            case 'o':
            case 'u':

            System.out.println("vowel");
            break;
            default:
            System.out.println("consonant");
            break;
        }
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>

using namespace std;
typedef long long ll;

ll mod(ll A, ll B) {
  ll a = A;
  ll b = B;
  if(B > A) {
    a = B;
    b = A;
  }
  {
    if(a % b == 0) {
      return b;
    }
    else {
      return mod(b, a % b);
    }
  }
}

ll dp[100000] = {0};

ll sosu(ll num) {
  ll max = sqrt(num);
  if(num == 1) return 1;
  if(num == 2) return 1;
  if(num == 3) return 1;
  for(ll i = 4; i <= max; i++) {
    if(num % i == 0) return -1; 
  }
  return 1;
}

ll sosu_(ll num) {
  if(dp[num] != 0) {
    return dp[num]; 
  }
  ll n = sosu(num);
  dp[num] = n;
  return n;
}  

int main() {
  ll A, B;
  cin >> A >> B;
  
  ll m = mod(A, B);
  ll d = m;
  
  if(d <= 1) {
    cout << d; return 0;
  }
  
  ll cnt = 1;
  for(ll i = 2; i <= sqrt(d); i++) {
    if(m % i == 0) {
      cnt++;
      while(m%i==0) m = m / i;
    }
  }
  if(m != 1) cnt++;
  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;
int n;

string parse(int &i) {
  string t;
  while (i < n) {
    if (s[i] == '[') {
      i++;
      string tmp = parse(i);
      reverse(tmp.begin(), tmp.end());
      t += tmp;
    } else  {
      if (s[i] == ']') break;
      t += s[i];
    }
    i++;
  }
  return t;
}


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> s, s != ".") {
    n = s.size();
    int l = 0, r = 0;
    string t;
    while (l < n) {
      while (l < n && (s[l] != '+' && s[l] != '-')) {
        t += (s[l] == '?' ? 'A' : s[l]);
        l++, r++;
      }
      int tmp = 0;
      while (r < n && (s[r] == '+' || s[r] == '-')) {
        if (s[r] == '+') tmp++;
        else tmp--;
        r++;
      }
      if (r < n) {
        if (s[r] == '?') {
          t += 'A';
        } else {
          tmp += (s[r]-'A');
          tmp %= 26;
          while (tmp < 0) tmp += 26;
          t += char(tmp+'A');
        }
      }
      l = ++r;
    }
    s = t;
    n = s.size();
    int i = 0;
    cout << parse(i) << endl;
  }  

  return 0;
}


Measured memory_bytes: 3204
n, m, c = input().split()
N = int(n)
M = int(m)
C = int(c)

array = list(map(int, input().strip().split(' ')))

A = []
for i in range(N):
    A.append(list(map(int, input().strip().split(' '))))

count = 0
for i in range(N):
    calc = 0
    for j in range(M):
        calc += A[i][j] * array[j]
    if 0 < calc + C:
        count += 1
print(count)


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  ll ans = 0;
  if( vec[0] > x ) {
    ans += ( vec[0] - x );
    vec[0] = x;
  }
  REP(i,1,n) {
    if( vec[i] + vec[i-1] > x ) {
      ll cost = ( (vec[i]+vec[i-1]) - x );
      ans += cost;
      vec[i] -= cost;
      assert( vec[i] >= 0 );
    }
  }
  cout << ans << endl;
  compute();
  return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: Chars
    }
    let l = n.len();
    let ans = match n[l - 1] {
        '2' => "hon",
        '4' => "hon",
        '5' => "hon",
        '7' => "hon",
        '9' => "hon",
        '3' => "bon",
        _ => "pon",
    };
    println!("{}", ans);
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e7 + 6;

ll rec[MAX];

void seive() {
    
    for(int i =1 ; i < MAX ; i++ ) rec[i] = 1;
    
    for(int i = 2 ; i < MAX ; i++ ) {
        if(rec[i] != 1) continue;
        for(int j = i ; j < MAX ; j += i ) {
            
            int tmp = j;
            int cnt = 0;
            
            while(tmp % i == 0) cnt++, tmp /= i;
            
            rec[j] *= 1LL*(cnt+1);
        }
    }
    
//    for(int i =1 ; i < 10 ; i++) cout<<rec[i]<<" ";
//    cout<<'\n';
}
int main()
{
    fastRead;
    seive();
    
    for(int i =1 ; i < MAX ; i++ ) {
        rec[i] = rec[i-1] + i *(rec[i]);
    }
    int n;
    cin>>n;
    cout<<rec[n]<<'\n';
    return 0;
}

Measured memory_bytes: 81740
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int>a(3*N);
    for (int i = 0; i < 3*N; i++) {
        cin>>a[i];
    }

    ll psum=0, ssum=0;
    priority_queue<int , vector<int>, greater<int>> pre;
    priority_queue<int> suf;

    for (int i = 0; i < N; i++) {
        psum+=a[i];
        ssum+=a[3*N-1-i];
        pre.push(a[i]);
        suf.push(a[3*N-1-i]);
    }

    vector<ll> pret(N+1), sret(N+1);
    pret[0]=psum, sret[N]=ssum;

    for (int i = N; i < 2*N; i++) {
        //前半部分
        int pt = a[i];
        pre.push(pt);
        psum+=pt;
        psum-=pre.top();
        pre.pop();
        pret[i-N+1]=psum;
    }
    
    for (int i = 2*N-1; i >= N; i--) {
        //後半部分
        int rt = a[i];
        suf.push(rt);
        ssum+=rt;
        ssum-=suf.top();
        suf.pop();
        sret[i-N]=ssum;
    }
    
    ll res = (ll)-1e15;
    for (int i = 0; i <= N; i++) {
        res=max(res, pret[i]-sret[i]);
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
	//作るときはParentの値を全て-1にする
	//こうするとすべてバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}
	//AとBをくっつける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついているからくっつけない
			return false;
		}
		//大きい方(A)に小さいほう(B)をくっつけたい
		//大小が逆だったらひっくり返しちゃう
		if (size(A) < size(B)) swap(A, B);
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
	//AとBが同じグループにいるか
	bool same(int A, int B) { return root(A) == root(B); }
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	vector<P> p(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		p[m - i - 1] = make_pair(a, b);
	}
	UnionFind Uni(n);
	vector<ll> ans(m);
	ll sum = n * (n - 1) / 2;
	ans[0] = sum;
	rep(i, m - 1) {
		int a, b;
		tie(a, b) = p[i];
		if (!Uni.same(a, b)) {
			ll res = Uni.size(a);
			res *= Uni.size(b);
			sum -= res;
			Uni.connect(a, b);
		}
		ans[i + 1] = sum;
	}
	rep(i, m) cout << ans[m - i - 1] << endl;
	return 0;
}


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

using namespace std;
typedef long long int lld;
lld arr[1000000][3];
lld DP[1000000][3];
lld compute(int day, int act){
	if(DP[day][act]!=-1)return DP[day][act];
	for(int j=0;j<3;j++){
		if(j!=act)DP[day][act]=max(DP[day][act],compute(day-1,j)+arr[day-1][act]);
	}
	return DP[day][act];
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)cin>>arr[i][j];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)DP[i+1][j]=-1;
	}
	for(int j=0;j<3;j++)DP[0][j]=0;
	cout<<max(compute(n,0),max(compute(n,1),compute(n,2)))<<endl;
	return 0;
}

Measured memory_bytes: 14720