akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from collections import Counter
N, M = map(int, input().split())
X = list(map(int, input().split()))
XX = [x % M for x in X]

cc = Counter(X)
c = Counter(XX)
cnt = c[0] // 2
c[0] -= cnt * 2
if M % 2 == 1:
    to = M // 2 + 1
else:
    to = M // 2
    tmp = c[M//2] // 2
    c[M//2] -= tmp * 2
    cnt += tmp

for i in range(1, to):
    # print(i, M-i, c [i], c[M-i])
    tmp = min(c[i], c[M-i])
    cnt += tmp
    c[i] -= tmp
    c[M-i] -= tmp

# print(c)
# print(cc)
for i in cc:
    # print("i = {}, cc[i] = {}, c[i] = {}".format(i, cc[i], c[i]))
    if cc[i] >= 2:
        # if c[i % M] >= 2:
        tmp = min(c[i % M], cc[i]) // 2
        cnt += tmp
        c[i % M] -= tmp * 2
        # print(cc[i])
        # print(c[i % M],  i, cc[i])
# print(c)
# for i in c:
#     print(i, c[i])

print(cnt)


Measured memory_bytes: 28124
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<string>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = min(a,b);
  int ans1 = min(c,d);
  int cost = ans + ans1;
  cout << cost << endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	int v[25];
	int c[25];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	int sum=0,ans = 0;
	int max = -1000000;
	for (int mask = 0; mask < (1 << n); mask++) {
		for (int i = 0; i < n; i++) {
			if (mask & (1 << i)) {
				sum += v[i];
				ans += c[i];
			}
		
		}
		if (max < sum - ans) {
			max = sum - ans;
		}
		sum = 0;
		ans = 0;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int compare(const void *a, const void *b){
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}

int ab(int x){
	if(x<0)return -x;
	return x;
}

int main(){
	int N;
	scanf("%d",&N);
	int a[N];
	for(int i=0;i<N;i++)scanf("%d",&a[i]);
	qsort(a,N,sizeof(int),compare);
	int min=1000000007;
	int mini=-1;
	for(int i=1;i<N;i++){
		if(min>ab(a[i]-a[0]/2)){
			min=ab(a[i]-a[0]/2);
			mini=i;
		}
	}
	printf("%d %d\n",a[0],a[mini]);
	return 0;
}

Measured memory_bytes: 892
/**
 *      purpose : AtCoder Petrozavodsk Contest 001 B
 *      author  : kyomukyomupurin
 *      created : 2018-10-25 19:02:54
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int64 a[N] = {}; int64 b[N] = {};
    for (int i = 0; i < N; ++i) cin >> a[i];
    for (int i = 0; i < N; ++i) cin >> b[i];

    int64 diff = 0; int64 p = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] < b[i]){
            p += (b[i] - a[i]) / 2;
        }
        else if (a[i] > b[i]) diff += a[i] - b[i];
    }

    if (p >= diff) print("Yes");
    else print("No");
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long n, c, t;
    cin >> n >> c;

    vector<long> w;
    vector<long> v;

    for (int i = 0; i < n; i++) {
        cin >> t;
        w.push_back(t);
        cin >> t;
        v.push_back(t);
    }

    vector<vector<long>> dp(n, vector<long>(c + 1, 0));
    for (int j = 1; j < c + 1; j++) {
        if (w[0] <= j)
            dp[0][j] = v[0];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < c + 1; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i])
                dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
        }
    }
    cout << dp[n - 1][c] << endl;
}


Measured memory_bytes: 79488
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cmath>
#include <sstream>
 
using namespace std;
 
typedef long long Long;

typedef vector<int> VI;
typedef vector<VI> VVI;

VVI adj;
VI SZ, MA, IL;
void dfs(int u, int p, int d, VI &D) {
	D[u] = d;
	for (int v : adj[u]) {
		if (v == p) continue;
		dfs(v, u, d+1, D);
	}
}
struct State {
	vector<int> curr;
	int others;
};

Long getLeaves(VI roots) {
	VI VIS(adj.size() , 0);
	Long shadows = 0;
	while(roots.size()) {
		vector<int> nr;
		for (int u : roots) VIS[u] = 1;
		VI NC;
		for (int u : roots) {
			int nc = 0;
			for (int v : adj[u]) {
				if (!VIS[v]) {
					nr.push_back(v);
					nc++;
				}
			}
			NC.push_back(nc);
		}
		int m = *max_element(NC.begin(), NC.end());
		int sum = 0;
		for (int n : NC) {
			sum += n;
		}
		if (nr.size() == 0) {
			shadows = shadows + roots.size();
		} else {
			shadows = shadows * m + NC.size() * m - sum;
		}
		roots = nr;
	}
	return shadows;
}

int main(int argc, char *argv[]) {
	
	int N;
	cin >> N;
	if (N == 2) {
		cout << 1 << " " << 2 << endl;
		return 0;
	}
	adj = VVI(N);
	SZ = VI(N);
	MA = VI(N);
	for (int i = 0; i < N-1; ++i) {
		int u,v;
		cin >> u >> v;
		u--;v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	VI D0(N);
	dfs(0, -1, 0, D0);
	int p1 = max_element(D0.begin(), D0.end()) - D0.begin();
	VI D1(N);
	dfs(p1, -1, 0, D1);
	int p2 = max_element(D1.begin(), D1.end()) - D1.begin();
	VI D2(N);
	dfs(p2, -1, 0, D2);
	IL = VI(N);
	vector<int> roots;
	int mi = 1000000000;
	for (int i = 0; i < N; ++i) {
		int t = max(D1[i], D2[i]);
		if ( t < mi ) {
			roots.clear();
			roots.push_back(i);
			mi = t;
		} else if(t == mi) {
			roots.push_back(i);
		}
	}
	if (roots.size() == 2) {
		cout << mi << " " << getLeaves(roots) << endl;
	} else {
		Long minLeaves = getLeaves(roots);
		for(int v : adj[roots[0]]) {
			VI tr = roots;
			tr.push_back(v);
			minLeaves = min(minLeaves, getLeaves(tr));
		}
		cout << mi + 1 << " " << minLeaves << endl;
	}
	
	
}

 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}
string toNegativeBase(int n, int negBase)
{
    if (n == 0)
        return "0";
 
    string converted = "";
    while (n != 0)
    {
        int remainder = n % negBase;
        n /= negBase;
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }
        converted = toString(remainder) + converted;
    }
 
    return converted;
}
int main()
{
    int n;
    cin >> n;
    int negBase = -2;
    cout << toNegativeBase(n, negBase);
 
    return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    int mul2 = 0, mul4 = 0, other = 0;

    rep(i, N) {
        int A;
        cin >> A;
        if (A % 4 == 0) {
            mul4++;
        } else if (A % 2 == 0) {
            mul2++;
        } else {
            other++;
        }
    }

    if (mul4 + 1 == other && mul2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << (mul4 >= other ? "Yes" : "No") << endl;
    }
}

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

int main()
{
	int d;
	cin >> d;

	vector<int> c(26+1);
	for (int i=1;i<=26;++i)
	{
		cin >> c[i];
	}

	vector<vector<int>> s(d+1,vector<int>(26+1));
	for (int i=1;i<=d;++i)
	{
		for (int j=1;j<=26;++j)
		{
			cin >> s[i][j];
		}
	}
	vector<int> t(d+1);
#ifdef NEVER_DEFINED
	for (int i=1;i<=d;++i)
	{
		cin >> t[i];
	}
#endif

	vector<int> last(26+1);
	for (int i=1;i<=26;++i)
	{
		last[i]=0;
	}

	// try don_yoku
	for (int i=1;i<=d;++i)
	{
		int64_t largest_score=-10000000000;
		int largest_contest=0;
		for (int j=1;j<=26;++j)
		{
			int64_t sc=s[i][j];
			for (int k=1;k<=26;++k)
			{
				if (j!=k)
				{
					sc-=c[k]*(i-last[k]);
				}
			}
			if (sc>largest_score)
			{
				largest_score=sc;
				largest_contest=j;
			}
		}
		t[i]=largest_contest;
	}


	for (int i=1;i<=d;++i)
	{
		cout << t[i] << endl;
	}
}






Measured memory_bytes: 3688
from collections import deque
N,Q = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
C = [0 for _ in range(N+1)]
for _ in range(Q):
    p,x = map(int,input().split())
    C[p] += x
heap = deque([1])
hist = [0 for _ in range(N+1)]
while heap:
    cur = heap.popleft()
    hist[cur] = 1
    for x in G[cur]:
        if hist[x]==0:
            C[x] += C[cur]
            heap.append(x)
C.pop(0)
print(*C)

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

int main()
{
    int n,ans=0,x;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        {
            cin>>x;
            a[x]=i;
        }
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    return 0;
}



Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define Task "C"

using namespace std;
int n, a[105];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i<=n; ++i) cin >> a[i];
    priority_queue<double, vector<double>, greater<double> > pq;
    for(int i = 1; i<=n; ++i) pq.push(a[i]);
    while (pq.size() > 1){
        auto L = pq.top(); pq.pop();
        auto R = pq.top(); pq.pop();
        pq.push((L+R)/2.0);
    }
    cout << fixed << setprecision(5) << pq.top();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve(int T){
	ll s,tmp,tmp2;
	scanf("%lld",&s);
	if(s<=1e9){
		printf("0 0 0 1 %lld 0",s);
		return;
	}
	if(s==1000000000000000000){
		printf("0 0 1000000000 0 1 1000000000");
		return;
	}
	printf("0 0 %lld 1 %lld %lld",(s/1000000000)+1,(s/1000000000+1)*1000000000-s,1000000000);
}
signed main(){
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++){
    	solve(i);
	}
}


Measured memory_bytes: 3836
#include<iostream>
#include<cmath>
using namespace std;
int main (){
  int rock;
  cin>>rock;
  int values[rock] = {0};
  int dp[rock] = {0};
  for(int i=0;i<rock;++i)
    cin>>values[i];
  dp[1] = dp[0] + abs(values[1] - values[0]);
  for(int i=2;i<rock;++i)
    dp[i] = min(dp[i-1] + abs(values[i] - values[i-1]), dp[i-2] + abs(values[i] - values[i-2]));
  cout<<dp[rock-1];
return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int i,j,n,count=0,number=0;
	scanf("%d",&n);
	for(j=1;j<=n;j++)
	{
		for(i=1,count=0;i<=j;i++)
		{
			if(j%i==0)count++;
		}
		if(count==8&&j%2==1)number++;
	}
	printf("%d\n",number);
	return 0;
} 


Measured memory_bytes: 128
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  int a=0,w=0,t=0,r=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="AC"){
      a++;
    }else if(s=="WA"){
      w++;
    }else if(s=="TLE"){
      t++;
    }else{
      r++;
    }
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<w<<endl;
  cout<<"TLE x "<<t<<endl;
  cout<<"RE x "<<r<<endl;


  return 0;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2*1e5;
const int mod = 1e9+7;

template<class T>
struct BIT {
    vector<T> bit;
    int n;
    BIT(int n): n(n), bit(n+1){}

    void add(int i, T x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }

    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
};

int main() {
    int n;
    ll d, a; 
    cin >> n >> d >> a;
    vector<P> data(n);
    rep(i,n) {
        ll x, h; cin >> x >> h;
        data[i] = P(x,h);
    }
    sort(all(data));
    vll x(n), h(n);
    rep(i,n) {
        x[i] = data[i].first;
        h[i] = data[i].second;
    }
    BIT<ll> bit(n+1);
    ll ct = 0;
    REP(i,n+1) {
        h[i-1] -= bit.sum(i);
        if (h[i-1] <= 0) continue;
        ll n_attack = (h[i-1]+a-1)/a;
        ll damage = n_attack * a;
        ct += n_attack;
        bit.add(i,damage);
        int rx = upper_bound(all(x),x[i-1]+2*d)-x.begin();
        if (rx != n) bit.add(rx+1,-damage);
    }
    cout << ct << endl;
}

Measured memory_bytes: 8064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ x, a ] <- readInts
	print $ which 0 10 $ x < a

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


int main(){
  vector<string> w={"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  string a;
  cin>>a;
  for(int i=0;i<7;i++){
    if(a==w[i]){
      cout<<i+1<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

string str;

int main(){
	cin>>str;
	reverse(str.begin(),str.end());
	cout<<str<<endl;
}

Measured memory_bytes: 1172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=(int)n;i++)
#define mod 998244353
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls rt<<1
#define rs rt<<1|1
#define all(x) x.begin(),x.end()
const int maxn=2e5+10;
const int N=5e4+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qmul(ll p,ll q,ll mo){ll f=0;while(q){if(q&1)f=(f+p)%mo;p=(p+p)%mo;q>>=1;}return f;}
ll qpow(ll p,ll q,ll mo){ll f=1;while(q){if(q&1)f=qmul(f,p,mo)%mo;p=qmul(p,p,mo)%mo;q>>=1;}return f;}
int n,m,k,t,p[2][20][maxn],a[maxn],pos[maxn],xp[maxn];
priority_queue<pair<int,pii>>pq;
int gao(int l,int r)
{
    int x=xp[r-l+1];
    return min(p[l&1][x][l],p[l&1][x][r-(1<<x)+1]);
}
void add(int l,int r)
{
    if(l>r)return;
    int x=gao(l,r);
    pq.push(mp(-x,mp(l,r)));
}
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)
    {
        scanf("%d",&a[i]);
        p[i&1][0][i]=a[i],p[(i&1)^1][0][i]=1e9;
        pos[a[i]]=i;
    }
    rep(i,2,maxn-10)xp[i]=1+xp[i>>1];
    rep(i,1,19)
    {
        for(j=1;j+(1<<i)-1<=n;j++)
        {
            p[0][i][j]=min(p[0][i-1][j],p[0][i-1][j+(1<<i-1)]);
            p[1][i][j]=min(p[1][i-1][j],p[1][i-1][j+(1<<i-1)]);
        }
    }
    add(1,n);
    while(!pq.empty())
    {
        pair<int,pii>p=pq.top();
        pq.pop();
        int ret1=-p.fi;
        int p1=pos[ret1];
        int ret2=gao(p1+1,p.se.se);
        int p2=pos[ret2];
        add(p.se.fi,p1-1);
        add(p1+1,p2-1);
        add(p2+1,p.se.se);
        printf("%d %d ",ret1,ret2);
    }
    return 0;
}


Measured memory_bytes: 34812
H, W = map(int, input().split())
for i in range(H):
  Ss = input().split()
  for j in range(W):
    if Ss[j] == "snuke":
      r = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[j]+str(i+1)
      print(r)
      exit()


Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.Arrays;
public class Main {
 
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for(int i=0; i<n; i++){
            int a[] = new int[3];
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            Arrays.sort(a);
            if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2]){
                System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }
        }
    }
 
}


Measured memory_bytes: 33776
eval"N,M,A,*B,s=#{`tr ' 
' ,`}[d=x=0]*9e5
B.map{|b|e=b
A>b&&b+=M
x+=t=b-A
[0,M].map{|m|s[m-~A]+=1
s[m+b]-=t
s[m-~b]+=t-1}
A=e}
p x-s.map{d+=$.+=_1}.max"
####################################################################################################

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

bool r(string a)
{
	int o=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i] < 'a' || a[i] > 'z'){
			o++;
		}
	}
	if(o > 2) return false;
	else
	{
		if(a[0] == 'A')
		{
			int pos = 0;
			for(int i=2;i<a.size()-1;i++){
				if(a[i] == 'C')
				{
					pos = i;
				}
			}
			if(pos == 0)return false;
			else{
				for(int i=2;i<a.size()-1;i++){
					if(i != pos && (a[i] < 'a' || a[i] > 'z')) return false;
				}
				return true;
			}
		}
		else
		{
			return false;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	if(r(s)) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
MOD=10**9+7
res=0
ans=0
for k in range(K,N+2):
    begin=k*(k-1)//2
    end=N*(N+1)//2 - (N+1-k)*((N+1-k)-1)//2
    res=end-begin+1
    ans= (ans+res) %MOD

print(ans)

Measured memory_bytes: 9140
#include<stdio.h>

int main(){

  int a, b, c;

  scanf("%d %d %d", &a, &b, &c); 

   if(a<b && b<c){
      printf("Yes\n");
   } else if(a>b || b>c || a==b ){
	    printf("No\n");
	    }

return 0;

}



Measured memory_bytes: 2044
#include<stdio.h>

int main()
{
	int n=1,x=1,i,t,N=0;
	
	for(;n!=0||x!=0;){
		N=0;
		scanf("%d %d",&n,&x);
		
		for(i=1;i<n;i++){
			
			for(t=i+1;t<n;t++){
				
				if(x-i-t>=t+1&&x-i-t<=n){
					
					//printf("%d %d\n\n",i,t);
					
					N++;
					
				}
			}
		}
		if(n!=0||x!=0){
			
			printf("%d\n",N);
		}
	}
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
using namespace std;
int x,y,ans;
int m[10][10000];
bool rev[10];

int cnt()
{
	int tmp=0;
	for(int i=0;i<x;i++)
	{
		int xcnt=0;
		for(int j=0;j<y;j++)
		{
			if(rev[j]&&!m[j][i]||!rev[j]&&m[j][i]) xcnt++;
		}
		if(xcnt<y-xcnt) tmp+=y-xcnt;
		else tmp+=xcnt;
	}
	return tmp;
}

void solve(int pos)
{
	if(pos==y)
	{
		ans=max(ans,cnt());
		return;
	}

	rev[pos]=true;
	solve(pos+1);
	rev[pos]=false;
	solve(pos+1);
	return;
}

int main()
{
	while(cin>>y>>x,y)
	{
		for(int i=0;i<y;i++)
		{
			for(int j=0;j<x;j++)
				cin>>m[i][j];
		}

		solve(0);
		cout<<ans<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1252
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
    // assert(freopen("output.txt", "w", stdout));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    srand(time(0));
    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

const int mod = 998244353;

void add(li& x, li y) {
    x += y;
    if (x >= mod)
        x -= mod;
}

const int maxn = 4e5 + 555;

li c[maxn], a[maxn];
vector <li> b;
vector <int> g[maxn];
li ans[maxn], pw2[maxn];
int n;
li res;

void solve1(int x, int i) {
    if (i == n) {
        add(res, 1);
        return;
    }
    if (i >= x) {
        int need = c[i % x] ^ ((i / x) & 1);
        if (a[i] == need)
            solve1(x, i + 1);
        else if (a[i] > need)
            add(res, 1);
        return;
    }
    if (a[i] == 1) {
        int len = (x - i - 1);
        add(res, pw2[len]);
    }
    c[i] = a[i];
    solve1(x, i + 1);
}

li solve1(int x) {
    res = 0;
    solve1(x, 0);

    return res;
}

void solve(bool __attribute__((unused)) read) {
    cin >> n;
    pw2[0] = 1;
    for (int i = 1; i <= n; ++i) {
        pw2[i] = pw2[i - 1] * 2ll % mod;
    }
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        a[i] = (s[i] - '0');
    }
    for (int x = 1; x <= n; ++x) {
        if (n % x == 0 && (n % (2 * x)) != 0) {
            b.push_back(x);
        }
    }
    for (int i = 0; i < (int)b.size(); ++i) {
        g[i].clear();
        for (int j = i + 1; j < (int)b.size(); ++j) {
            if (b[j] % b[i] == 0) {
                g[i].push_back(j);
            }
        }
    }
    memset(ans, 0, sizeof ans);
    li sumans = 0;
    for (int i = 0; i < (int)b.size(); ++i) {
        ans[i] += solve1(b[i]);
        ans[i] = (ans[i] % mod + mod) % mod;
        for (int j : g[i]) {
            ans[j] -= ans[i];
        }
        // cout << b[i] << " " << ans[i] << endl;
        sumans = (sumans + ans[i] * 2ll * b[i]) % mod;
    }
    cout << sumans << endl;

}


Measured memory_bytes: 20628
/*
████████████████████████████████████████████████████████████████
████████████████        ████████████████        ████████████████
████████████              ██████████                ████████████
████████                    ██████                    ██████████
██████                                                  ████████
██████                      ██████                      ████████
████        ██████████    ████████    ██████████          ██████
████      ████        ████████████████          ████      ██████
████        ████  ████    ██    ██████              ██      ████
████          ██████████      ██████        ████████        ████
████            ██████████  ████████    ████████            ████
████              ██    ██  ██    ██    ████████      ████  ████
████              ██████    ██  ████      ██    ██  ██    ██████
████        ████████  ████  ██  ████      ██    ██  ██    ██████
████        ██  ██████        ████        ██    ████    ████████
██████      ██████                  ██    ██    ██    ██████████
██████        ████████████████████████  ██████      ██  ██  ████
████████████      ██            ██████  ██    ██████    ██  ████
██████  ██  ██      ████████████  ██    ██      ██    ██    ████
██████  ██  ██      ████  ██    ██        ██    ██████    ██████
██████  ██  ██      ██  ██  ████            ████████████████████
██████    ██████  ████  ██  ██          ██  ████████    ████████
██████████    ████████      ██          ██      ██    ██████████
██████████    ████    ██████              ██████    ████████████
████████████████  ██  ██  ██                      ██████████████
████████████  ██    ████    ██                  ████████████████
████████████    ██  ████████  ██              ██████    ██    ██
██████████████    ██████████████            ████████          ██
████████████████████████████████████      ██████████          ██
██████████████████████████████████████  ██████████████      ████
████████████████████████████████████████████████████████  ██████
████████████████████████████████████████████████████████████████
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,a,b; cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,(a+b)-n)<<endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 3003;

string a, b;
int n, m;
int dp[N][N];
string res;

void build(int i, int j) {
	if (i == n || j == m)
		return;
	if (dp[i][j] == dp[i + 1][j]) {
		build(i + 1, j);
	} else if (dp[i][j] == dp[i][j + 1]) {
		build(i, j + 1);
	} else {
		res += a[i];
		build(i + 1, j + 1);
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> a >> b;
	n = SZ(a), m = SZ(b);
	for (int i = n - 1; i >= 0; i--) {
		for (int j = m - 1; j >= 0; j--) {
			dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
			if (a[i] == b[j])
				dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
		}
	}
	build(0, 0);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 35456
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //#endif
    vector<int> A(5);
    input(A,5);
    for(int i=0;i<5;i++){
        if(A[i]!=i+1 and A[i]==0){
            cout<<i+1<<'\n';
            break;
        }
    } 
    return 0;
}

Measured memory_bytes: 3640
/*
  _    _ _      _ _      _ _      
 | |__| | | _ _| | | _ _| | | ___
 | '_ \_  _| ' \_  _| ' \_  _(_-< 
 |_.__/ |_||_||_||_||_||_||_|/__/

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define db(x) cout << #x << "=" << x << '\n'
#define rep(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(x) scanf("%s", x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", x)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define F first
#define S second
#define pb push_back
#define ll long long

#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
//#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
//#define polar(r,ang)            ((r)*exp(point(0,ang)))  ==> Already added in c++11
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))


typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef complex<double> point;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int mod = 998244353;
const int N = 3e5 + 7, M = N, OO = 1e9 + 7;
const ll LLOO = 1e18 + 7;

//=======================

vi g[N];
int n,a[N],l[N],r[N],k;
ll dp[N],pref[N];

void solve()
{
    si(n);
    si(k);
    rep(i,0,k)
    {
		si(l[i]);
		si(r[i]);

	}
	
	dp[0] = 1;
	pref[0] = dp[0];
	
	rep(i,1,n)
	{
		dp[i] = 0;
		rep(j,0,k)
		{
			
			if (i-l[j] < 0) continue;
			dp[i] = (dp[i]+pref[i-l[j]])%mod;
			
			if (i-r[j]-1 < 0) continue;
			dp[i] = (dp[i]-pref[i-r[j]-1]+mod)%mod;
			
			
		}
		pref[i] = (pref[i-1]+dp[i])%mod;
	}
	
	pl(dp[n-1]);
}

int main()
{
    // uncomment if file :
    // freopen("in","r",stdin);
    // freopen("out","w",stdout);
    int t = 1;
    // si(t); // uncomment if testcases
    while (t--)
        solve();
    return 0;
}


// btw i use arch


Measured memory_bytes: 13972
class Node:
	def __init__(self, id):
		self.id = id
		self.parent_id = -1
		self.depth = 0
		self.children = None
	def get_type(self):
		if self.parent_id == -1:
			return 'root'
		elif self.children == None or len(self.children) == 0:
			return 'leaf'
		return 'internal node'
	def __str__(self):
		ret = 'node ' + str(self.id) + ': '
		ret += 'parent = ' + str(self.parent_id) + ', '
		ret += 'depth = ' + str(self.depth) + ', '
		ret += self.get_type() + ', '
		ret += '['
		for i in range(len(self.children)):
			ret += str(self.children[i])
			if i != len(self.children) - 1:
				ret += ', '
		ret += ']'
		return ret

n = int(input())
nodes = [Node(i) for i in range(n)]
for i in range(n):
	a = list(map(int, input().split()))
	id = a[0]
	node = nodes[id]
	if node.parent_id != -1:
		node.depth = nodes[node.parent_id].depth + 1

	m = a[1]
	children = []
	for j in range(m):
		child_id = a[j + 2]
		children.append(child_id)
		nodes[child_id].parent_id = id
		nodes[child_id].depth = node.depth + 1
	node.children = children

for i in range(n):
	print(nodes[i])



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

int main() {
    string s;
    cin >> s;
    if(s.size() >= 4){
        if(s.at(0) == 'Y' && s.at(1) == 'A' && s.at(2) == 'K' && s.at(3) == 'I'){
            cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    } else {
        cout << "No" << endl;
    }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
int main()
{
	int n;
	cin >> n;
	set <int> s;
	rep(i, n) {
		int v;
		cin >> v;
		s.insert(v);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long long a[100001];
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        cin>>a[i];
    }
    long long r,l;
    r=l=2;
    for(int i=k-1;i>=0;i--){
        l=(l+a[i]-1)/a[i]*a[i];
        r=r/a[i]*a[i]+a[i]-1;
        if(l>r){
            cout<<"-1"<<endl;
            return 0;
            
        }
    }
   
    cout<<l<<" "<<r<<endl;
    
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  int M; cin >> M;
  ll ans = 0, rest = 0;
  for (int i = 0; i < M; i++){
    ll D, C; cin >> D >> C;
    if (i == 0){
      rest += D; C--;
    }

    ll cnt = 0, now = rest;
    for (int j = 0; j < 9; j++){
      now += D;
      if (now >= 10){
        now -= 9; cnt++;
      }
      cnt++;
    }

    ans += cnt * (C / 9);

    for (int j = 0; j < C % 9; j++){
      ans++;
      rest += D;
      if (rest >= 10){
        rest -= 9; ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    static int count[];
    static boolean flag[];
    static int num ; //order

    static {

        final int n = 1000000;
        count = new int[n];
        flag = new boolean[n];
        num = 0;

        sievePrime(n);
    }
    //是否是素数
    static boolean primeFlag(int n)
    {
        double temp = Math.sqrt(n);
        for(int i=2; i <= temp ; ++i )
        {
            if(n%i == 0)
            {
                return false;
            }
        }
        return true;
    }
    // 素数个数  逐个计数
    static void sievePrime(int n)
    {
        for(int i =2; i<=n; ++i)
        {
            if(primeFlag(i))
            {
                flag[i] = true;
            }
        }
        count[1] = 0;
        for(int j =2 ; j<n; ++j)
        {
            if(flag[j])
            {
                count[j] = count[j-1] + 1;
            }else{
                count[j] = count[j-1];
            }

        }
    }

    public static void main(String[] args)
    {
        Scanner cin = new Scanner(new BufferedInputStream(System.in));
        int a;
        while(cin.hasNext())
        {
            a = cin.nextInt();

            System.out.println(count[a]);
        }
    }


}



Measured memory_bytes: 31432
m,k=map(int,input().split())
if 0<=k<2**m:
    if m==1:
        if k==1:print(-1)
        else:print(*[1,1,0,0])
    else:
        s=[str(i) for i in range(2**m) if i!=k]
        c=""
        for i in s:c+=i+" "
        c+=str(k)+" "
        for i in s[::-1]:c+=i+" "
        print(c+str(k))
else:
    print(-1)

Measured memory_bytes: 17684
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 23;
const ll MOD = 998244353;
const int INF = 1e9+10;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}



int main() {
	setIO();

    char c; cin >> c;
    if ('A' <= c && c <= 'Z') cout << 'A' << "\n";
    else cout << "a\n";

    return 0;
}


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

int main() {
	int w, n, a, b;
	char comma;
	vector<int> amida;
	cin >> w >> n;
	for (int i = 0;i < w;i++) amida.push_back(i + 1);

	for (int i = 0;i < n;i++) {
		cin >> a >> comma >> b;
		swap(amida.at(a - 1), amida.at(b - 1));
	}

	for (int i = 0;i < w;i++) {
		cout << amida.at(i) << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
Astr = input()
Aint = [0]*4
for i in range(4):
  Aint[i] = int(Astr[i])
q = [1,1,1]
ans = 7-Aint[0]

while sum(q) != -3:
  a = [0]*3
  for i in range(3):
    a[i] = Aint[i+1]*q[i]
  if sum(a) == ans:
    print(str(Aint[0])+"{:+}{:+}{:+}".format(a[0],a[1],a[2])+"=7")
    break
  elif q[2] == 1:
    q[2] = -1
  elif q[1] == 1:
    q[1] = -1
    q[2] = 1
  else:
    q[0] = -1
    q[1] = 1
    q[2] = 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
 fastio;
 ll n;
 cin>>n;
 ll res=0;
 for(int i=2;i*i<=n;i++){
  if(n%i==0){
     int k=0;
     while(n%i==0){
      k++;
      n/=i;
     }
     int poe = 1;
     while(k>=poe){
      res++;
      k-=poe;
      poe++;
     }
  }
 }
 if(n>1){
  res++;
 }
 cout << res << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

vector<int> G[100010];
vector<int> d[100010];

void dfs (int k, int l, int m) {
  d[k].push_back(m);
  for (int i=0; i<G[k].size(); i++) {
    if (G[k][i]!=l)
      dfs(G[k][i],k,m+1);
  }
}
    
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n-1; i++) {
    int a,b;
    scanf("%d %d",&a,&b);
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  dfs(0,-1,0);
  dfs(n-1,-1,0);
  int fe=0,su=0;
  for (int i=0; i<n; i++) {
    if (d[i][0]<=d[i][1]) fe++;
    else su++;
  }
  if (fe>su) cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
  return 0;
}


Measured memory_bytes: 17408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main
{
	public static void main( String[] args ) throws IOException
	{
		Reader.init(System.in);
		int n = Reader.nextInt();
		int a = Reader.nextInt();
		int b = Reader.nextInt();
		int at = n*a;
		if ( at < b )
		{
			System.out.println(at);
		}
		else
		{
			System.out.println(b);
		}
	}
}

/** Class for buffered reading int and double values */
class Reader 
{
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) 
    {
        reader = new BufferedReader(new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) 
        {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}

Measured memory_bytes: 21204
// Bismillahir rahmanir rahim
#include <bits/stdc++.h>

using namespace std ;


int main(){

    int n,c=0,p=0;
    cin>>n ;
    int a[n],i;

    //set<int>p;


    for(i=0;i<n;i++){
    cin>>a[i] ;
    if(a[i]%2==0){
        c++;
        if(a[i]%3==0 || a[i]%5==0){
            p++;
        }

    }
   // p.insert(a[i]) ;

    }

    if(c==p){
        printf("APPROVED\n") ;
    }

    else {
        printf("DENIED\n") ;
    }

}



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

int main() {
  string s; cin >> s;
  set<char> k;
  for (int i = 0; i < s.size(); i++) k.insert(s.at(i));
  if (k.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 10000;
  string alp = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 26; i++) {
    int cnt = 0;
    string before = s;
    while (1) {
      string after = "";
      for (int j = 1; j < before.size(); j++) {
        if (before.at(j-1) == alp.at(i)) after += before.at(j-1);
        else if (before.at(j) == alp.at(i)) after += before.at(j);
        else after += before.at(j);
      }
      before = after;
      set<char> l;
      for (int k = 0; k < after.size(); k++) l.insert(after.at(k));
      cnt++;
      if (l.size() == 1) break;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using pii = pair<int, int>; using vi = vector<int>;
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

bool f(string s) {
	rep(i, 0, s.size() - 1)
		if (s[i] != s[i + 1])return false;
	return true;
}

signed main() {
	for (string s; cin >> s&&s != "0";) {
		unordered_map<string, int> m;
		m[s] = 0;
		queue<string> q;
		q.emplace(s);
		while (!q.empty()) {
			string t = q.front(); q.pop();
			rep(i, 0, t.size() - 1) {
				if (t[i] == t[i + 1])continue;
				string tmp = t;
				if (t[i] + t[i + 1] == 'r' + 'g')tmp[i] = tmp[i + 1] = 'b';
				if (t[i] + t[i + 1] == 'g' + 'b')tmp[i] = tmp[i + 1] = 'r';
				if (t[i] + t[i + 1] == 'b' + 'r')tmp[i] = tmp[i + 1] = 'g';

				if (m.find(tmp) == m.end()) {
					q.emplace(tmp);
					m[tmp] = m[t] + 1;
				}
			}
		}

		int ans = INF;
		for (auto itr = m.begin(); itr != m.end(); itr++) {
			if (f(itr->first))ans=min(ans,itr->second);
		}
		if (ans == INF)cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4904
def main():
    N = int(input())
    P = [0] + list(map(int, input().split()))
    L = [0]*(N+1)
    cnt = 0
    mi = 10**10
    for i in range(1,N+1):
        mi = min(mi,P[i])
        if mi == P[i]:
            cnt+=1

    print(cnt)




if __name__ == '__main__':
    main()


Measured memory_bytes: 100024
minDiffFrom753 :: String -> Int
minDiffFrom753 ('7':'5':'3':xs) = 0
minDiffFrom753 target@(x1:x2:x3:xs)
  | null xs   = diff
  | otherwise = min diff $ minDiffFrom753 $ tail target
  where extracted = read [x1,x2,x3]
        diff      = abs $ extracted - 753

main :: IO ()
main = do
  target <- getLine
  print $ minDiffFrom753 target

Measured memory_bytes: 508
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;
#define int long long

signed main(){
    int K=1000000;
    int N;
    cin >> N;
    vector<pair<int, int> > A(N);
    vector<pair<int, int> > B(N);
    for(int i=0;i<N;i++){
        cin >> A[i].second >> A[i].first;
    }
    
    for(int i=0;i<N;i++){
        A.push_back(A[i]);
        A.back().second+=K;
        swap(A.back().first, A.back().second);
    }
    
    
    
    
     N*=2;
     for(int i=0;i<N;i++){
         A.push_back(A[i]);
         A.back().first+=K;
         A.back().second+=K;
     }
    sort(A.begin(),A.end());
    for(int i=0;i<2*N;i++){
        swap(A[i].first, A[i].second);
    }
    const int sz = 22;
    vector<vector<int> > ne(2 * N, vector<int>(sz));
    vector<pair<int,int> > X(3 * K + 1, make_pair(5 * K ,  2 * N));
    int cur = 3 * K;
    for(int i=2 * N - 1;i  >= 0;i--){
        while(A[i].second < cur){
            cur--;
            X[cur] = min(X[cur], X[cur + 1]);
        }
        X[A[i].first] = min(X[A[i].first], make_pair(A[i].second, i));
        ne[i][0] = X[cur].second;
        
    }
    
    for(int j=1;j<sz;j++){
        for(int i=0;i<2*N;i++){
            int t = ne[i][j-1];
            if(t < 2 * N){
                ne[i][j] = ne[t][j-1];
            }else{
                ne[i][j] = 2 * N;
            }
        }
    }
    
    
    // for(int i=0;i<2*N;i++){
    //     cerr << i << " " << A[i].first << " " << A[i].second <<" " << ne[i][0] << endl;
    // }
    
    
    int res = 1000000000;
    
    for(int i=0;i<N/2;i++){
        int cur = i;
        int tmp = 1;
        for(int j=sz-1;j>=0;j--){
            
            if(ne[cur][j] < 2 * N && A[ne[cur][j]].second < A[i].second + K){
                tmp += (1 << j);
                cur = ne[cur][j];
            }
            
        }
        res = min(res, (tmp + 1) / 2);
    }
    
    
    cout << res << endl;
    return 0;
}



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

int main()
{
  long long int a;
  cin>>a;
  long long int ans;
  ans=a+10;
  for(int t=1;t<=sqrt(a);t++)
  {
   if(a%t==0)
   {
     if(ans>t+a/t-2)
      ans=t+a/t-2;
   }
  }

  cout<<ans;
}


Measured memory_bytes: 256
A, B = [int(x) for x in input().split()]

ans = 0
for i in range(A, B + 1):
    xs = []
    x = i
    while x > 0:
        xs.append(x % 10)
        x //= 10
    if xs == list(reversed(xs)):
        ans += 1

print(ans)


Measured memory_bytes: 2940