akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		List<Integer> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	}
	public static int findKthDivisor(List<Integer> manyDivisor, List<Integer> fewDivisor, int k) {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	}
}


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

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

  int ans = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j * j <= n - i; j++) {
      if ((n - i) % j == 0) {
        ans++;
        if (j * j != n - i) ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;

}
/*
*/


Measured memory_bytes: 3668
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
struct uzi{
  int x,y;
  bool operator < (const uzi & t)const{
    return x<t.x;
  }
}p[N];
int n,b[N];
#define mid (l+r>>1)
#define ls o<<1
#define rs o<<1|1
void build(LL *t,int o,int l,int r){
  t[o]=-2e9;
  if(l==r){
    return ;
  }
  build(t,ls,l,mid);
  build(t,rs,mid+1,r);
}
void up(LL *t,int o,int l,int r,int x,LL y){
  if(l==r){
    t[o]=max(t[o],y);
    return ;
  }
  if(x<=mid)up(t,ls,l,mid,x,y);
  else up(t,rs,mid+1,r,x,y);
  t[o]=max(t[ls],t[rs]);
}
LL get(LL *t,int o,int l,int r,int x,int y){
  if(l>=x&&r<=y){
    return t[o];
  }
  LL mx=0;
  if(x<=mid)mx=max(mx,get(t,ls,l,mid,x,y));
  if(y>mid)mx=max(mx,get(t,rs,mid+1,r,x,y));
  return mx;
}
LL L[N<<2],R[N<<2];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++)cin>>p[i].x>>p[i].y,b[i]=p[i].y;
  sort(b+1,b+1+n);
  int len=unique(b+1,b+1+n)-b-1;
  build(L,1,1,len);
  build(R,1,1,len);
  for(int i=1;i<=n;i++)p[i].y=lower_bound(b+1,b+1+len,p[i].y)-b;
  sort(p+1,p+1+n);
  LL ans=0;
  for(int i=1;i<=n;i++){
    ans=max(ans,get(L,1,1,len,p[i].y,len)+p[i].x-b[p[i].y]);
    ans=max(ans,get(R,1,1,len,1,len)+b[p[i].y]+p[i].x);
    up(L,1,1,len,p[i].y,-p[i].x+b[p[i].y]);
    up(R,1,1,len,p[i].y,-p[i].x-b[p[i].y]);
   // cout<<i<<' '<<ans<<'\n';
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 14164
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n, k;
int a[100];
vector<pair<int, int>> vv;
vector<int> ans;
int lst[100];

int getnx(int x, int c) {
	for (int i = 0; i < n; ++i)
		lst[i] = ans.size();
	for (int i = x; i < ans.size(); ++i)
		lst[ans[i]] = min(lst[ans[i]], i);
	int mx = x;
	for (int i = 0; i < n; ++i)
		if (i != c)
			mx = max(mx, lst[i]);
	return mx;
}
int go[100];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i], vv.emplace_back(a[i], i);
	sort(ALL(vv));
	reverse(ALL(vv));
	vector<int> av;
	int mx = (k + 1) / 2;
	ans.resize(n + (n - 1) * k, -1);
	for (int i = n - 1; i >= 0; --i) {
		int nd = k + 1;
		int hv = vv[i].first;
		int x = nd - hv;
		if (x > 0) {
			if (x > mx) {
				cout << -1 << "\n";
				return 0;
			}
			go[vv[i].second] = x;
		}
	}
	int lst = -1;
	for (int i = n - 1; i < ans.size() - 1; i += n - 1) {
		int mx = -1;
		for (int j = 0; j < n; ++j)
			if (j != lst && (mx == -1 || go[j] > go[mx]))
				mx = j;
		if (mx == -1 || go[mx] == 0) {
			lst = -1;
			continue;
		}
		ans[i] = mx;
		--go[mx];
		lst = mx;
	}
	for (int i = 0; i < ans.size() - 1; i += n - 1) {
		set<int> ss;
		for (int j = 0; j < n; ++j)
			ss.insert(j);
		vector<int> av;
		for (int j = i; j <= i + (n - 1); ++j) {
			if (ans[j] == -1)
				av.push_back(j);
			else
				ss.erase(ans[j]);
		}
		for (int j: av) {
			int x = *ss.begin();
			ans[j] = x;
			ss.erase(x);
		}
	}
	for (int i = 0; i < n; ++i) {
		if (go[i] != 0) {
			cout << -1 << "\n";
			return 0;
		}
	}

	int now = getnx(0, -1);
	for (int i = 0; i < k && now < ans.size(); ++i)
		now = getnx(now + 1, ans[now]);
	if (now == ans.size())
		cout << -1 << "\n";
	else {
		/*cout << 1 << "\n";
		return 0;*/
		cout << ans.size() << "\n";
		for (int i: ans)
			cout << i + 1 << " ";
		cout << "\n";
	}
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    for (auto &&i : a)
    {
        cin >> i;
    }

    ll score = 1;

    for (int i = k; i < n; i++)
    {
        if (a[i] > a[i - k])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 4008
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>

using namespace std;

string S1,S2,S3;

int main(){

 cin>>S1>>S2>>S3;

 int t=1,i=0,j=0,k=0;

 while(1){

  if(t==1&&S1[i]=='a') {t=1; i++;}
  else if(t==1&&S1[i]=='b') {t=2; i++;}
  else if(t==1&&S1[i]=='c') {t=3; i++;}
  if(t==1&&i==S1.size()){
  cout<<'A'<<endl; break;
  }

  if(t==2&&S2[j]=='a') {t=1; j++;}
  else if(t==2&&S2[j]=='b') {t=2; j++;}
  else if(t==2&&S2[j]=='c') {t=3; j++;}
  if(t==2&&j==S2.size()){
  cout<<'B'<<endl; break;
  }

  if(t==3&&S3[k]=='a') {t=1; k++;}
  else if(t==3&&S3[k]=='b') {t=2; k++;}
  else if(t==3&&S3[k]=='c') {t=3; k++;}
  if(t==3&&k==S3.size()){
  cout<<'C'<<endl; break;
  }

 }

 return 0;

}

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


int main(){
    int N, K;
    cin >> N >> K;
    int l[N-1];
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }

    sort(l, l + N, greater<int>());

    int result = 0;

    for (int i = 0; i < K; i++) {
        result += l[i];
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
friends = [set() for _ in range(N)]
for __ in range(M):
    a, b = map(int, input().split())
    if b-1 not in friends[a-1]:
        friends[a-1] |= {b-1}
    if a-1 not in friends[b-1]:
        friends[b-1] |= {a-1}
check = [0 for _ in range(N)]
ans = 0
for i in range(N):
    if check[i]:
        continue
    count = 1
    next = [i]
    check[i] = 1
    while next:
        fri = next.pop()
        for F in friends[fri]:
            if check[F]:
                continue
            count += 1
            check[F] = 1
            next.append(F)
    ans = max(ans, count)
print(ans)

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

int main() {

    int N;
    cin >> N;

    vector<pair<int, int>> vp;
    int a;
    rep(i, N) {
        cin >> a;
        vp.push_back(make_pair(a, i+1));
    }
    sort(vp.begin(), vp.end());

    rep(i, N) {
        cout << vp[i].second << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/dp/tasks/dp_b

int main() {
  int N, K; cin >> N >> K;
  int h[N+5]; REP(i, N) cin >> h[i+1];

  ll dp[N+5]; REP(i, N+5) dp[i] = INF;

  for (int i = 1; i < N+1; i++) {
    if (i==1) dp[i] = 0;
    else {
      for (int j = max(0,i-K); j < i; j++) {
	chmin(dp[i], dp[j] + abs(h[j]-h[i]));
      }
    }
  }

  cout << dp[N] << "\n";


  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<string> vec1(n);
    vector<int> vec2(n);

    rep(i,n){
        cin >> vec1[i] >>  vec2[i]; 
    }
    string str;
    cin >> str;

    bool flag = false;

    int cnt = 0;
    rep(i,n){
        if(flag){
            cnt += vec2[i];
        }
        if(str == vec1[i]) flag = true;
    }

    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int num;
    int step;
    string text;
    string left_str;
    string right_str;
    
    while (cin >> text)
    {
        if (text == "-")
        {
            break;
        }
        
        cin >> num;
        for (int i = 0; i < num; i++)
        {
            cin >> step;
            left_str = text.substr(0, step);
            right_str = text.substr(step);
            text = "";
            text = right_str + left_str;
        }
        
        cout << text << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3200
/*
Author :: Shourov Chowdhury
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define D(x) cout << #x " is " << x << endl
#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

using namespace std;

typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

const int INF = 2000000009;
const int MX = 100005;
const double EPS = 1e-9;
const int MOD = 1000000007;

/**********************Code starts here*********************************/


int main()
{
	int n=II(),a=II(),b=II();
	if ( (b-a-1)%2==1) printf("Alice\n");
	else printf("Borys\n");

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<assert.h>
#define INF 0x3f3f3f3f//3f3f3f3f
#define ll long long
#define ull unsigned long long
#define lowbit(a) ((a)&(-(a)))
using namespace std;
int n, m;
struct edge{
    int v, next;
}e[200005];
int head[100005], du[100005], cnt;
int tp[100005], tc, vis[100005], fa[100005];
void add(int u,int v){
    e[cnt].v = v, e[cnt].next = head[u], head[u] = cnt ++;
}
void init(){
    memset(head,-1,sizeof head); cnt = 0;
    memset(du, 0, sizeof du);
    memset(vis, 0, sizeof du);
    memset(fa, 0, sizeof du);
    tc = 0;
}
int main() {
    while(~scanf("%d%d",&n,&m)){
        init();
        for(int i = 1;i<n+m;i++){
            int u,v;
            scanf("%d %d",&u,&v);
            add(u, v);
            du[v] ++;
        }
        queue<int> que;
        for(int i = 1;i<=n;i++){
            if(du[i] == 0){
                tp[i] = ++tc;
                vis[i] = 1;
                que.push(i); break;
            }
        }
        while(que.size()){
            int d = que.front(); que.pop();
            for(int i = head[d]; ~i; i = e[i].next){
                if(!vis[e[i].v]){
                    du[e[i].v] --;
                    if(du[e[i].v] == 0){
                        que.push(e[i].v);
                        vis[e[i].v] = 1;
                        tp[e[i].v] = ++tc;
                    }
                }
            }
        }
        tp[0] = 0;
        for(int i = 1;i<=n;i++){
            for(int j = head[i]; ~j; j = e[j].next){
                if(tp[i] > tp[fa[e[j].v]])
                    fa[e[j].v] = i;
            }
        }
        for(int i = 1;i<=n;i++){
            printf("%d\n", fa[i]);
        }
    }
    return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> leftE(n);
    vector<int> rightW(n);
    leftE[0]=0;
    rightW[n-1]=0;
    for(int i=0;i<n-1;i++){
        if(s[i]=='E')leftE[i+1]=leftE[i]+1;
        else leftE[i+1]=leftE[i];
    }
    for(int i=n-1;i>0;i--){
        if(s[i]=='W')rightW[i-1]=rightW[i]+1;
        else rightW[i-1]=rightW[i];
    }
    
    int max = 0;
    for(int i=0;i<n;i++){
        int temp = leftE[i] + rightW[i];
        if(max<temp){
            max = temp;
        }
    }
    cout << n-max-1 << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define pb push_back
#define PI acos(-1)
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 500010
using namespace std;

int main()
{
    RUN_FAST;
    int n;
    string s;
    cin >> n;
    int arr[4]={0};
    while (n--) {
        cin >> s;
        if (s=="AC") arr[0]++;
        else if (s=="WA") arr[1]++;
        else if (s=="TLE") arr[2]++;
        else arr[3]++;
    }
    cout << "AC x  " << arr[0] << endl;
    cout << "WA x  " << arr[1] << endl;
    cout << "TLE x  " << arr[2] << endl;
    cout << "RE x  " << arr[3] << endl;
    return 0;

}


Measured memory_bytes: 3644
N = int(input())
from collections import deque

def func(S):
  q = deque([S])
  while q:
    x = q.popleft()
    if len(x) == N:
      print(x)
    else:
      for char_no in range(ord('a'), max([ ord(i) for i in x ])+2):
        y = x + chr(char_no)
        q.append(y)


start = 'a'
func(start)

Measured memory_bytes: 11876
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1_000_000_007L
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun solve() {
}


fun main(args: Array<String>) {
    val X = readIntArray()
    val N = X.size

    for (i in 0 until N) {
        if (X[i] == 0) {
            println(i+1)
            return
        }
    }
}


Measured memory_bytes: 36448
import sys 
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))

#box = [0]*(N+1)

for i in range(N,0,-1):
    k=2
    temp=a[i-1]
    #print(123,i,ball)
    while i*k<=N:
        if a[i*k-1]==1:
            temp = (temp+1)%2
        k+=1
    a[i-1] = temp
#print(box)
M=0
b=[]
for i in range(1,N+1):
    if a[i-1]==1:
        M+=1
        b.append(i)

print(M)
[print(x) for x in b]

Measured memory_bytes: 68216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=9&&b<=9)cout<<a*b<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int N; cin >> N;
    int s[110]; rep(i, N) cin >> s[i];
    int dp[110][10010];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    rep(i, N) {
        rep(j, 10010) {
            dp[i + 1][j] += dp[i][j];
            if(j - s[i] >= 0) dp[i + 1][j] += dp[i][j - s[i]];
        }
    }
    int ans = 0;
    rep(j, 10010) {
        if(j % 10 != 0 && dp[N][j] > 0) {
            ans = j;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

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

    int A[2][N];

    for (int i = 0; i <= 1; i++){
        for (int j = 0; j <= N-1; j++){
            cin >> A[i][j];
        }
    }

    int maxCandy = 0;

    for (int j = 0; j <= N-1; j++){
        int numCandy = 0;
        for (int k = 0; k <= j; k++){
            numCandy += A[0][k];
        }
        for (int k = j; k <= N-1; k++){
            numCandy += A[1][k];
        }
        maxCandy = max(maxCandy, numCandy);
    }

    cout << maxCandy << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int mod = 1000000007;

int fact[200005];

int multiply(int a, int b){
	return int((1LL * a * b) % mod);
}

int pw(int x, int y){
	int r = 1;
	while (1) {
		if (y & 1) r = multiply(r, x);
		if (y >>= 1) x = multiply(x, x);
		else break;
	}
	return r;
}

int inv(int x){
	return pw(x, mod - 2);
}

int C(int a, int b){                                   // Calculates (a + b)! / (a! * b!)
	return multiply(fact[a + b], multiply(inv(fact[a]), inv(fact[b])));          // Number of ways of choosing a or b objects out of a + b objects
}

int main(){
	fact[0] = 1;
	for(int i = 1; i < 200005; ++i){
		fact[i] = multiply(fact[i - 1], i);
	}
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int res = 0;
	for(int i = b + 1; i <= w; ++i){
		res = (res + multiply(C(h - a - 1, i - 1), C(a - 1, w - i))) % mod;
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

//方向をずらすベクトル
vi dh = {1,0,-1,0},dw = {0,1,0,-1};
int H,W;

void rec(vector<pii> &bp, vector<vector<bool>> &seen, int &ans, int &cnt){
  ans++;//呼び出された回数を計数

  vector<pii> nbp;
  for(auto p: bp){
    int h = p.first, w = p.second;
    for (int dir = 0; dir < 4; dir++) {
      int nh = h + dh[dir];
      int nw = w + dw[dir];
      if(nh == -1 || nh == H || nw == -1 || nw == W) continue;
      if(seen[nh][nw]) continue;
      seen[nh][nw] = true; cnt++;
      nbp.push_back(make_pair(nh, nw));
    }
  }
  //各bpの更新が終わったら#の数をチェック
  if (cnt == H*W) return;//全部#なら終了
  else rec(nbp, seen, ans, cnt);//そうでなければnbpに対して再探査
}

int main(){
  cin >> H >> W;
  vector<pii> bp;// black_position:(h,w)を値に持つ配列
  int cnt = 0;// #の数を計数

  vector<vector<bool>> seen(H,vector<bool>(W,false));
  rep(h, H) rep(w, W){
    char a; cin >> a;
    if(a == '#') {bp.push_back(make_pair(h,w)); cnt++; seen[h][w] = true;}
  }
  int ans = 0;
  if (cnt == H*W) {
    std::cout << ans << '\n';
    return 0;
  }
  rec(bp, seen, ans, cnt);
  std::cout << ans << '\n';
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	FIO();
	string s; cin >> s;
	if (s[s.length() - 1] != 's')
	{
		cout << s << 's';
	}
	else if (s[s.length() - 1] == 's')
	{
		cout << s << "es";
	}
	return 0;
}

Measured memory_bytes: 3664
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,k; 
    cin>>n>>k;
    vi a(n+1);
    for (int i=1;i<=n;i++){
        cin>>a[i];
    } a[0]=a[1];
    int ans=k;
    for (int i=1;i<=n;i++){
        ans += min(a[i]-a[i-1],k);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<ll, ll> pf = prime_factor(n);
	cout << n << ":";
	for(auto p : pf){
		rep(i,p.second) cout << " " << p.first;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3236
#include<stdio.h>

int main(){
int a,b,c;

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

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

if (a > b) printf("No\n");
if(a == b) printf("No\n");
return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define SORT(v) sort(v.begin(),v.end(),greater<lli>())

vector<lli> a,b,c;

typedef struct{
	lli sum;
	lli x,y,z;
}element;

bool operator<(const element &a1,const element &b1){
	if(a1.sum != b1.sum)return a1.sum < b1.sum;
	else if(a1.x != b1.x)return a1.x < b1.x;
	else if(a1.y != b1.y)return a1.y < b1.y;
	else return a1.z < b1.z;
}

element rtn(lli sx,lli sy,lli sz){
	element e;
	e.sum = a[sx]+b[sy]+c[sz];
	e.x = sx;
	e.y = sy;
	e.z = sz;

	return e;
}

signed main(){

	lli x,y,z,k;
	cin>>x>>y>>z>>k;

	a.resize(x);
	b.resize(y);
	c.resize(z);

	REP(i,0,x)cin>>a[i];
	REP(i,0,y)cin>>b[i];
	REP(i,0,z)cin>>c[i];

	SORT(a);
	SORT(b);
	SORT(c);

	priority_queue<element> q;
	element e = rtn(0,0,0);

	q.push(e);
	set<element> s;
	lli cnt=0;

	while(q.size()){
		if(cnt>=k)break;
		element now = q.top();
		cout<<now.sum<<endl;
		q.pop();

		lli dx[3]={1,0,0};
		lli dy[3]={0,1,0};
		lli dz[3]={0,0,1};
		REP(i,0,3){
			lli nextX = now.x+dx[i];
			lli nextY = now.y+dy[i];
			lli nextZ = now.z+dz[i];
			if(nextX>=x || nextY >= y|| nextZ>=z)continue;
			element next = rtn(nextX,nextY,nextZ);

			if(s.find(next)!=s.end())continue;
			q.push(next);
			s.insert(next);
		}
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 1152
while True:
    cnt = 0
    n,x = map(int,input().split())
    if n == x == 0:
        break
        exit()
    for i in range(101):
        for j in range(101):
            if j>=i:
               for k in range(101):
                    if k>=j:
                        if i!=j!=k and i+j+k==x and i!=0 and j!=0 and k!=0 and n>=k>j>i:
                            cnt += 1
    print(cnt)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<int, int>;

struct data {
  int num, lx, ly;
};

bool asc(data l, data r) {
  return l.lx * l.ly < r.lx * r.ly;
}

int n, w, d;
vector<p> cut;
vector<data> lst;

void solve();

int main() {
  while(1) {
    cin >> n >> w >> d;
    if(n + w + d == 0) break;
    lst.push_back({-1, w, d});
    for(int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      cut.push_back({--a, b});
    }
    solve();
    sort(lst.begin(), lst.end(), asc);
    for(int i = 0; i < lst.size(); ++i) {
      if(i != 0) cout << " ";
      cout << lst[i].lx * lst[i].ly;
    }
    cout << endl;
    lst.erase(lst.begin(), lst.end());
    cut.erase(cut.begin(), cut.end());
  }
  return 0;
}

void solve() {
  for(int t = 0; t < n; ++t) {
    data now = lst[cut[t].fi], next1, next2;
    lst.erase(lst.begin() + cut[t].fi);
    next1 = next2 = now;
    next1.num = next2.num = t;
    cut[t].se %= (now.lx + now.ly);
    if(cut[t].se > now.lx) {
      cut[t].se -= now.lx;
      next1.ly = min(cut[t].se, now.ly - cut[t].se);
      next2.ly -= next1.ly;
    }
    else {
      next1.lx = min(cut[t].se, now.lx - cut[t].se);
      next2.lx -= next1.lx;
    }
    lst.push_back(next1);
    lst.push_back(next2);
  }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  cout<<fixed<<setprecision(10);
  vector<int> A(5);
  int num=10;
  int order=0;
  for(int i=0; i<5; ++i){
    cin >> A[i];
    if(num > A[i]%10 && A[i]%10 != 0){
    order = i;
    num = min(num, A[i]%10);
    } 
  }
  num=0;
  for(int i=0; i<5; ++i){
    if(i!=order) num += ((A[i]+9)/10)*10;
    else num += A[i];
  }
  cout << num << endl;
}


Measured memory_bytes: 256
N=int(input())
res=[]
for i in range(N):
  a,b=map(int,input().split())
  res.append((a+b,a,b))
  
res = sorted(res,reverse=True)

ans=0
for i in range(N):
  if i % 2== 0:
    ans += res[i][1]
  else:
    ans -= res[i][2]
    
print(ans)

Measured memory_bytes: 26808
#!/usr/bin/env python3
import sys
import numpy as np

bases = [26 ** i for i in range(15)]
cum_sum = np.cumsum(bases)


def int2alpha(i):
    assert i > 0
    return chr(i + 96)


def to_26_base(num):
    res = []
    for i in reversed(range(14)):
        b = bases[i]
        # print(num, b, cum_sum[i])
        if cum_sum[i] <= num < cum_sum[i + 1]:
            if i == 0:
                q = num // b
            else:
                q = (num - cum_sum[i-1]) // b
            num -= q * b
            res.append(q)
    return "".join(int2alpha(x) for x in res)


def solve(N: int):
    print(to_26_base(N))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27092
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x ;
        n = n / 2;
        x = x * x;
    }
    return result;
}
int main() {
    fio
    int l,r,x;
    cin>>l>>r>>x;
    int ans=0;
//    for(int i=l;i<=r;i++){
//        if(i%x==0){
//            ans=i;
//            break;
//        }
//    }
    int c=0;
    for(int i=l;i<=r;i++){
        if(i%x==0)
            c++;
    }
    cout<<c<<endl;


   return 0;
}


Measured memory_bytes: 3648
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

delta_v = V - W
if delta_v <= 0:
    print('NO')
elif (abs(A - B) + delta_v - 1) // delta_v > T:
    print('NO')
else:
    print('YES')



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


int main(){
	int a, b;
	cin >> a >> b;
	cout << (a+b >= 10 ? "error" : to_string(a+b)) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var d int
	fmt.Scan(&d)

	if d == 22 {
		fmt.Println("Christmas Eve Eve Eve")
	} else if d == 23 {
		fmt.Println("Christmas Eve Eve")
	} else if d == 24 {
		fmt.Println("Christmas Eve")
	} else if d == 25 {
		fmt.Println("Christmas")
	}
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
	
def main():
	H, W = map(int, input().split())
	chk = "." * W
	A = []
	for _ in range(H):
		tmp = input()
		if tmp != chk:
			A.append(list(tmp))
		else:
			H -= 1
			
	del_list = []
	for i in range(W):
		del_ok = True
		for j in range(H):
			if "." != A[j][i]:
				del_ok = False
				break
		if del_ok == True:
			del_list.append(i)
			
	ans = []
	line = ""
	for i in range(H):
		line = ""
		for j in range(W):
			if j in del_list:
				continue
			line += A[i][j]
		print(line)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,m,i,c,k=1;
		boolean f[];
		while(true){
			n=sc.nextInt();
			m=sc.nextInt();
			if(n==0 && m==0) break;
			f=new boolean[n+1];
			Arrays.fill(f,true);
			c=0;k=0;
			for(i=0;;){
				if(c==n-1) break;

				//System.out.println(i+" "+k+" "+(c+1));

				if(k==m*(c+1) && f[i]){
					f[i]=false;
					//System.out.println(i);
					c++;
					k++;
				}
				else if(f[i]){
					k++;
				}
				i++;
				if(i>=n+1) i=1;
			}
			for(i=1;i<=n;i++){
				if(f[i])
					System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <queue>
#define INF 1001001001
//幅優先探索にはvectorとqueueを使う
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
vector<int> to[n];
vector<int> pre(n,-1);
vector<int> dis(n,INF);

for(int i=0;i<m;i++)
{
int a,b;
cin>>a>>b;a--;b--;
to[a].push_back(b);
to[b].push_back(a);

}
queue<int>q;
q.push(0);
while(!q.empty())
{
int v=q.front();q.pop();
for(int u:to[v])
    {
    if(dis[u]!=INF)continue;
    dis[u]=dis[v]+1;
    pre[u]=v;
    q.push(u);
    }
}
cout <<"Yes"<<endl;
for(int i=0;i<n;i++)
{
if(i==0)continue;
int ans =pre[i];
ans++;
cout <<ans<<endl;

}


}

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

int main()
{
	int i,j,n;
    long long ans=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
      cin>>a[i];
    for(i=0;i<n;i++)
    {
      for(j=i+1;j<n;j++)
      {
        long long temp=a[i]*a[j];
        ans+=temp;
      }
    }
    cout<<ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int X;
	cin >> X;
	cout << X*360/__gcd(X, (int)360)/X << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main()
{
int a,b,c,x,count=0;

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

    for(x=a;x<=b;x++){
      if(c%x==0)
      count++;
    }
      printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dp[3030];
typedef pair<int, int> P;

int main() {
  int N, T; cin >> N >> T;
  vector<P> vec(N);
  for(int i = 0; i < N; i++) cin >> vec[i].first >> vec[i].second;
  sort(vec.begin(), vec.end());

  int ans = 0;
  for(int i = 0; i < N; i++) {
    int w, v; w = vec[i].first; v = vec[i].second;
    for(int j = T-1; j >= 0; j--) {
      if(j+w >= T) ans = max(ans, dp[j]+v);
      else dp[j+w] = max(dp[j+w], dp[j]+v);
    }
  }

  for(int i = 0; i < T; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import fractions
from functools import reduce

def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    modtmp = 0
    for i,aa in enumerate(a):
        j = 0

        while aa % 2 == 0:
            aa //= 2
            j+=1
        if i == 0:
            modtmp = j
        else:
            if modtmp != j:
                print(0)
                return

    for i,aa in enumerate(a):
        a[i] = aa//2
    tmp = lcm(*a)
    # print(tmp)
    cnt =0
    # print(a)

    up = m//tmp
    if up % 2 == 0:
        up = up//2
    else:
        up = up//2 + 1

    nowtmp = tmp
    cnt = 0
    ans = 0
    a.sort()
    # print(nowtmp)
    # print(up)
    before = 0
    before_aa = 0
    print(up)
    return
    

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
if __name__=='__main__':
    main()


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

int main () {
    string S;
    cin >> S;
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		Map<String, Integer> map = new HashMap<String, Integer>();
		for (int i=0; i<S.length(); i++) {
			String s = String.valueOf(S.charAt(i));
			if (!map.containsKey(s)) {
				map.put(s, i);
				continue;
			}
			int v = map.put(s, i);
			int charLen = i-v+1;
			if (2<=charLen/2) continue;
			System.out.printf("%d %d\n", v+1, i+1);
			sc.close();
			return;
		}
		System.out.println("-1 -1");
		sc.close();
	}

}


Measured memory_bytes: 19316
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<time.h>
#include<chrono>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
    ll n,a[1010][1010],ans=-1;
    bool b[1010]={};
    vll v[1010];
    cin>>n;
    rep(i,n)rep(j,n-1){
        cin>>a[i][j];
        v[i+1].pb(a[i][j]);
    }
    rep(i,n*(n-1)/2+1){
        end = chrono::system_clock::now();
        double time = (double)(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);
        if(time>=1950){
            cout<<(n-1)*n/2<<endl;
            return 0;
        } 
        bool flag=false;
        rep2(j,1,n+1) b[j]=0;
        rep2(j,1,n+1){
            if(!v[j].empty()){
                flag=true;
                break;
            }
        }
        if(!flag){
            ans=i;
            break;
        }
        rep2(j,1,n+1){
            if(b[j]||v[j].empty()) continue;
            ll u=v[j][0];
            if(b[u]) continue;
            if(v[u].empty()){
                cout<<-1<<endl;
                return 0;
            }
            if(v[u][0]!=j) continue;
            b[j]=1;b[u]=1;
            v[j].erase(v[j].begin());
            v[u].erase(v[u].begin());
        }
        rep2(j,1,n+1){
            if(b[j]) flag=false;
        }
        if(flag){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16256
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if N == 1:
    print(0)

else:
    F = factorization(N)
    ans = 0
    for i in range(len(F)):
        k, num = F[i]
        j = 1
        while num >= j:
            ans += 1
            num -= j
            j += 1

    print(ans)

Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  ll N;
  scanf("%lld", &N);

  FOR(i,1,3500){
    FOR(j,1,3500){
      ll x = 4*i*j - N*i - N*j;
      ll y = N*i*j;

      if(x==0) continue;

      if(y%x==0 && y/x>0){
        cout << i << " " << j << " " << y/x << endl;
        return 0;
      }
    }
  }
  

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 3005
using namespace std;

int main() {
  int i, n, a, max=0;
  cin >> n;
  for(i=0;i<n;i++) {
    cin >> a;
    max += (a-1);
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
/////////


void solve(){
  ini(A , B);
  vector<string> g(100 , string(100 , '.'));

  rep(i , 50) rep(j , 100) g[i][j] = '#' , g[i + 50][j] = '.';

  int a = 1 , b = 1;
  rep(i , 25)  {
    rep(j , 50){
      if(a == A) break;
      g[i * 2][j * 2] = '.';
      a++;
    }
    if(a == A) break;
  }

  rep(i , 25)  {
    rep(j , 50){
      if(b == B) break;
      g[51 + i * 2][j * 2] = '#';
      b++;
    }
    if(b == B) break;
  }

   out(100 , 100);
  each(x , g) out(x);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(ll N, ll K, vector<ll> p) {
  sort(p.begin(), p.end());
  ll ans(0);
  REP(i, K)
    ans += p[i];
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  ll K;
  cin >> K;
  vector<ll> p(N);
  REP(i, N) {
    cin >> p[i];
  }

  solve(N, K, move(p));

  return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc108_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = (int)Floor(n/2.0);
            var b = (int)Ceiling(n/2.0);

            WriteLine(a*b);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c,count=3;
  cin>>a>>b>>c;
  if(a==b)
    count--;
  if(a==c)
    count--;
  if(b==c)
    count--;
  if(a==b && b==c && c==a)
    count=1;
  cout<<count;
  return 0;
}

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

long long a,b,c,ans,tmp1,tmp2,tmp3;
long long d,e,f;

int main()
{
	scanf("%lld %lld %lld",&a,&b,&c);
	d=a;e=b;f=c;
	while(1)
	{
		if(a%2==1||b%2==1||c%2==1)
		{
			printf("%lld\n",ans);
			return 0;
		}
		tmp1=a/2;
		tmp2=b/2;
		tmp3=c/2;
		a=tmp2+tmp3;
		b=tmp1+tmp3;
		c=tmp1+tmp2;
		if(a==d&&b==e&&c==f)
		{
			puts("-1");
			return 0;
		}
		ans++;
	}
} 

Measured memory_bytes: 256
N,K,Q=map(int,input().split())
P=[K for _ in range(N)]
for i in range(Q):
  P[int(input())-1]+=1
P=[j-Q for j in P]
for k in range(N):
  if P[k]>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9816