akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;


class Work implements Comparable<Work> {
	int _a, _b, _idx;
	public Work (int a, int b, int idx) {
		_a = a; _b = b; _idx = idx;
	}

	@Override
	public int compareTo (Work w) {
		int r =  _b-w._b;
		if (r!=0)
			return r;
		r = _a-w._a;
		if (r!=0)
			return r;
		r = _idx-w._idx;
		return r;
	}
}



public class Main {

	public static void main (String[] args) {
		int N;
		Scanner sc = new Scanner (System.in);
		TreeSet<Work> set = new TreeSet<Work> ();
		N = sc.nextInt ();
		for (int i=0; i<N; i++) {
			int a = sc.nextInt(), b = sc.nextInt();
			Work w = new Work (a,b,i);
			set.add (w);
		}

		Iterator<Work> iterator = set.iterator ();
		int time = 0;
		while (iterator.hasNext ()) {
			Work w = iterator.next ();
			time += w._a;
			if (time>w._b) {
				System.out.println ("No");
				return;
			}
		}
		System.out.println ("Yes");
	}
}


Measured memory_bytes: 117408
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    vector<long> d(N);
    long total = 0;
    for(size_t i=0;i<N; i++)
    {
        cin >> d[i];
        total += d[i];
    }
    ll ans = 0;
    for(size_t i=0;i<N; i++)
    {
        ans += (total-d[i]) * d[i];
    }
    cout << ans / 2 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i,f=0;
    cin>>n;
    pair<int,int> p[n];
    for(i=0;i<n;i++)
    cin>>p[i].first>>p[i].second;
    for(i=0;i<n-2;i++){
        if(p[i].first==p[i].second && p[i+1].first==p[i+1].second && p[i+2].first==p[i+2].second){
            f=1;
            break;
        }
    }
    if(f==1)
    cout<<"Yes\n";
    else
    cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
char a[59][59];
int h,w;
void haha(int i,int j)
{
	int sum=0;
	if(a[i-1][j]=='#') sum++;
	if(a[i-1][j-1]=='#') sum++;
	if(a[i-1][j+1]=='#') sum++;
	if(a[i][j+1]=='#') sum++;
	if(a[i][j-1]=='#') sum++;
	if(a[i+1][j]=='#') sum++;
	if(a[i+1][j-1]=='#') sum++;
	if(a[i+1][j+1]=='#') sum++;
	cout<<sum;
}
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>a[i][j];
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(a[i][j]=='.')
			{
				haha(i,j);
			}
			else 
			cout<<a[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll w, a, b, s, t;
  in3(w, a, b);
  s = min(a, b);
  t = max(a, b);
  out(max(0ll, t - s - w));
  memi;
}

Measured memory_bytes: 256
#include<stdio.h>

int Partition(int A[], int p, int r){
  int x = A[r], i = p-1, swap,j;
  
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap=A[i], A[i]=A[j], A[j]=swap;
    }
  }
  swap=A[i+1], A[i+1]=A[r], A[r]=swap;
  
  return i+1;
}

int main(void){
  int n, i, mk;
  
  scanf("%d", &n);
  
  int A[n];
  
  for(i=0;i<n;i++)
    scanf("%d", &A[i]);
  mk = Partition(A, 0, n-1);
  for(i=0;i<mk;i++)
    printf("%d ", A[i]);
  printf("[%d]", A[mk]);
  for(i=mk+1;i<n;i++)
    printf(" %d", A[i]);
  printf("\n");
  
  return 0;
} 



Measured memory_bytes: 2172
#include<stdio.h>
#include <stdlib.h>
#define rep( i, n ) for(((i) = 0); ((i) < (n)); ((i)++))

int main(void)
{
    long a,b;
    scanf("%ld %ld\n", &a, &b);

    if((a+b)%2 == 0)
    {
        printf("%ld\n", labs((a+b)/2));
    }
    else
    {
        printf("IMPOSSIBLE");
    }
    
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline

MOD = 10 ** 9 + 7
INF = 2 * 10**18

in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        ret = dict()
        for i in range(self.n):
            r = self.find(i)
            if r in ret:
                ret[r].append(i)
            else:
                ret[r] = [i]
        return ret

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():

    N, M = in_nn()
    uni = UnionFind(N)

    for i in range(M):
        a, b = in_nn()
        a, b = a - 1, b - 1
        uni.union(a, b)

    ans = uni.group_count() - 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int man=1000005;
const int MAXM= 15000005;
ll mod = 1e9+7;
ll fac[man];
ll n,m;
void init()
{
   fac[0]=1;
   for(ll i=1;i<man;i++)
     fac[i]=(fac[i-1]*i)%mod;
}

ll quickpow(ll a,ll b,ll p)
{
    ll ans=1%p;
    while(b)
    {
        if(b&1) ans=ans*a%p;
        a=a*a%p;
        b>>=1;
    }
    return ans;
}
ll inv(ll a,ll  mod)
{
	return quickpow(a,mod-2,mod);
}

ll Cal(ll n,ll m,ll mod)
{
    ll a=fac[n];
	ll b=(fac[m]*fac[n-m])%mod;
	return (a*inv(b,mod))%mod;
}

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>m;
  init();
  auto ss=prime_dection(m);
  ll ans=1;
  for(auto &t: ss)
  {
      ll num = t.second;
      ll tmp=Cal(n+num-1,num,mod);
      ans=(ans*tmp)%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define N 101
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<P> G[N];
int n,m,C;

int dijkstra(){
  vector<vector<int> >D(N,vector<int>(N,INF));
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(0,0)));
  D[0][0] = 0;
  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost = t.first;
    int pos = t.second.first;
    int cnt = t.second.second;
    if(D[pos][cnt]<cost) continue;
    
    for(int i=0;i<G[pos].size();i++){
      int npos = G[pos][i].second;
      int ncost= cost+G[pos][i].first;
      if(D[npos][cnt]>ncost) Q.push(PP(ncost,P(npos,cnt))),D[npos][cnt]=ncost;
      if(cnt+1<N&&D[npos][cnt+1]>cost) Q.push(PP(cost,P(npos,cnt+1))),D[npos][cnt+1]=cost;
    }
  }
  for(int i=0;i<N;i++)if(D[n-1][i]<= C) return i;
}

int main(){
  while(1){
  cin>>n>>m>>C;
  if(!n&&!m&&!C) break;
  for(int i=0;i<N;i++)G[i].clear();
  for(int i=0,a,b,c;i<m;i++)cin>>a>>b>>c,G[a-1].push_back(P(c,b-1));
  cout<<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define ALL(v) (v).begin(),(v).end()
#define REP(i, x, n) for(ll (i)=(x); (i)<(n); (i)++)
#define RREP(i, x, n) for(ll (i)=(n)-1; (i)>=x; (i)--)
#define FOR(i, n) for(ll (i)=0; (i)<(n); (i)++)
#define RFOR(i, n) for(ll (i)=(n)-1; (i)>=0; (i)--)

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

        ll k;
        string s;
        cin >> k >> s;
        if (s.length() <= k) cout << s << endl;
        else cout << s.substr(0, k) + "..." << endl;

        return 0;
}

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

int main() {
  int N, x, y, z, sum;
  sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    z = y - x + 1;
      sum += z;
  }
  cout << sum << endl;
}
      
    

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int check(vector<int> l, vector<int> r) {
    int sum = 0;
    for (int i = 0; i < l.size(); ++i)
        sum += (l[i] - r[i]) * (l[i] - r[i]);

    for (int i = 0; i * i <= sum; ++i)
        if (i * i == sum)
            return 1;
    return 0;
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,d;
    cin >> n >> d;
    vector<vector<int>> a(n, vector<int>(d));
    for (auto& vec : a)
    for (int& x : vec)
        cin >> x;

    int ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            ans += check(a[i], a[j]);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, Q; cin >> N >> Q;
    dsu d(N);
    rep(i, Q) {
        int t, u, v; cin >> t >> u >> v;
        if (t) {
            if (d.same(u, v)) cout << 1 << endl;
            else cout << 0 << endl;
        }
        else {
            d.merge(u, v);
        }
    }
}


Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<map>
#include<cstdlib>
using namespace std;

int main(){
  int n,i,A[111111];

  std::cin >> n;

  for(i=0;i<n;i++){
    std::cin >> A[i];
  }

  sort(A,A+n);

  int ai=A[n-1];
  int aj=A[0];

  for(i=0;i<n-1;i++){
    if(abs(A[i]-ai/2)<=abs(aj-ai/2)) aj=A[i];
  }

  std::cout << ai << " "<<aj;

  return 0;
}


Measured memory_bytes: 640
from bisect import bisect_left,bisect_right
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort()
C.sort()
ans=0
for i in range(N):
    ans+=bisect_left(A,B[i])*(N-bisect_right(C,B[i]))
print(ans)


Measured memory_bytes: 23232
import numpy as np

N = input().split()
n= int(N[0])
m = int(N[1])
way = np.zeros(n)
count = 0
h = input().split()
ans = 0
w =0
r = np.zeros(n)

for j in range(m):
    a = input().split()
    b = int(a[0])
    c = int(a[1])
    if int(h[b-1])>int(h[c-1]):
        r[b-1] += 1
        r[c-1] = -1000000
    elif int(h[c-1])>int(h[b-1]):
        r[c-1] += 1
        r[b-1] = -1000000
    else:
        r[b-1] = -1000000
        r[c-1] = -1000000
print(np.count_nonzero(r>=0))


Measured memory_bytes: 35588
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

int main()
{
    int N;
    cin >> N;
    using integer = long;
    integer num_odd = 0;
    integer num_even = 0;
    for (int i = 0; i < N; ++i)
    {
        integer n;
        cin >> n;
        if (n % 2)
        {
            ++num_odd;
        }
        else
        {
            ++num_even;
        }
    }
    // 偶奇が同じ２つの数を選んで、偶数を１つ加える
    // 奇数同士を貪欲に選ぶ -> 偶数同士を選ぶ
    if (num_odd % 2)
    {
        // 奇数が最後に1つ残る場合、最後に(偶数, 奇数)のペアが残るので絶対にダメ
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

long long solve(long long n, long long a, long long b) {
    return n / (a + b) * a + min(a, n % (a + b));
}

// generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
int main() {
    long long N, A, B;
    scanf("%lld%lld%lld", &N, &A, &B);
    auto ans = solve(N, A, B);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
100なら全探索よっゆ
*/
int main(){
  ll N; cin>>N;
  vector<ll> X(N,0);
  for(ll i=0; i<N; i++) cin>>X[i];
  ll ans=1e8;
  for(ll i=0; i<=100; i++){
    ll tmp=0;
    for(ll j=0; j<N; j++) tmp+=(i-X[j])*(i-X[j]);
    if(ans<tmp) break;
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}

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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = 1e5 + 74, OO = 0x3f3f3f3f, MOD = 998244353;

int f[N], a[N];

long long power(long long b, long long p, long long MOD = 998244353) {
    long long res = 1;
    b %= MOD;
    for (; p; p >>= 1LL) {
        if (p & 1)res = (res * b) % MOD;
        b = (b * b) % MOD;
    }
    return res % MOD;
}

class BCountingOfTrees {
public:
    void solve(istream &cin, ostream &cout) {
        int n;
        cin >> n;
        int mx = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            f[a[i]]++;
            mx = max(mx, a[i]);
        }
        if (f[0] != 1 || a[0] != 0)
            return (void) (cout << 0 << el);
        int ans = 1;
        for (int i = 1; i <= mx; i++) {
            if (!f[i])
                return (void) (cout << 0 << el);
            ans = (ans * power(f[i - 1], f[i])) % MOD;
        }
        cout << ans << el;
        clr(f, 0);
    }
};

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


Measured memory_bytes: 1024
#                         author:  kagemeka 
#                         created: 2019-11-06 21:30:22(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    s = [sys.stdin.readline().rstrip() for _ in range(3)]
    ans = ''.join([s[i][i] for i in range(3)])
    print(ans)

if __name__ == "__main__":
    # execute only if run as a script
    main()


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

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

int main() {
  ll n; cin>>n;
  bool det=false;
  while(det==false) {
    det=is_prime(n);
    n++;
  }
  cout << n-1;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    double sum = 0;
    for(int i=0; i<n; i++){
        sum += double(1)/a.at(i);
    }
    cout << 1/sum;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

inf = float("inf")
dp = [inf for _ in range(N + 1)]
dp[1] = 0
for i in range(1, N + 1):
    for k in range(1, K + 1):
        if i + k <= N:
            if dp[i + k] > dp[i] + abs(h_list[i - 1] - h_list[i - 1 + k]):
                dp[i + k] = dp[i] + abs(h_list[i - 1] - h_list[i - 1 + k])

print(dp[N])

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

int main()
{
  int s;
  cin >> s;
  bool ym = false, my = false;
  if(1 <= (s/100) && (s/100) <= 12) my = true;
  if (1<=(s%100) && (s%100)<=12) ym = true;

  if (my && ym) cout << "AMBIGUOUS" << endl;
  else if (my) cout << "MMYY" << endl;
  else if (ym) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int maxN = 200 * 1000 + 9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

int n;
int c[maxN], memo[maxN], f[maxN];

void read(){
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> c[i];
}

void solv(){
  c[n] = -1;
  memo[n] = 1;

  for(int i = n - 1; i >= 0; i--){
//    for(int j = i; j < n; j++)
//      if(c[i] == c[j] && c[j] != c[j + 1])
//        memo[i] = (memo[i] + memo[j + 1]) % MOD;
    if(c[i] != c[i + 1])
      f[c[i]] = (f[c[i]] + memo[i + 1]) % MOD;

    memo[i] = (memo[i] + f[c[i]]) % MOD;
  }

  cout << memo[0] % MOD << '\n';
  //cout << dp(0) << '\n';
}

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

  #ifdef DEBUG
    freopen("in.txt", "r", stdin);
  #endif

  read();
  solv();

  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
   int ketaSum(int b);
   int main(void){
       int n,a,b,sum=0,c,cnt=0;
       scanf("%d%d%d",&n,&a,&b);
       int i;
       for(i=1;i<=n;i++){
           c=ketaSum(i);
           if(c>=a&&c<=b){
              cnt+=i;
          }
      }
      printf("%d\n",cnt);
      return 0;
  }
  int ketaSum(int b){
    int sum=0;
     while(b>0){
         sum+=b%10;
         b=b/10;
     }
     return sum;
 }

Measured memory_bytes: 128
# エラトステネスの篩を使う！O(nloglogn)
N = int(input())
A = list(map(int,input().split()))

listA = [0] * (10**6+10)
ans = 0
for i in A:
    if listA[i] != 0:
            listA[i] = 2
            continue
    for j in range(i,10**6+10,i):
        listA[j] += 1

for i in A:
    if listA[i] == 1:
        ans += 1

print(ans)


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  ll count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    count -= a.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
    count += b.at(i);
  }
  
  ll adda = 0, addb = 0;
  for (int i = 0; i < n; i++) {
    if (a.at(i) < b.at(i)) {
      if ((b.at(i) - a.at(i)) % 2 == 0) adda += (b.at(i) - a.at(i)) / 2;
      else {
        adda += (b.at(i) - a.at(i) + 1) / 2;
        addb++;
      }
    }
    else if (a.at(i) > b.at(i)) addb += a.at(i) - b.at(i);
  }
  
  if (adda <= count && addb <= count && (count - adda) * 2 == count - addb) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
ll x,k,d;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>x>>k>>d;
	x=abs(x);
	ll t=x/d;
	if(t<=k)
	{
		if((k-t)%2==1)cout<<abs(x-(t+1)*d);
		else cout<<x-t*d;
	}
	else cout<<x-k*d;
	return 0;
}


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

using std::acos;

int main(){
        double const pi1 = acos(-1.0);
        double r;
        double S; // menseki                                                   
        double l; // enshuu                                                    
        cin >> r;

        S = pi1*pow(r,2.0);
        l = 2.0*pi1*r;

        printf("%lf %lf\n", S, l);
        return 0;
}

Measured memory_bytes: 3272
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    no,we,so,ea=0,0,0,0
    for i=s
        if i=='N'
            no+=1
        elseif i=='W'
            we+=1
        elseif i=='S'
            so+=1
        else
            ea+=1
        end
    end
    if ((no>0 && so>0) || no==so==0) && ((we>0 && ea>0) || we==ea==0)
        println("Yes")
    else
        println("No")
    end
end
main()

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int a;
	cin >> a;
	ce(a*a*a);
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;
	ll sum = 0;

	//N = mk + k = (m+1)k
	for (ll k = 1; k*k <= N; k++) {
		if (N%k == 0) {
			ll m = (N-k)/k;
			if (m > k) sum += m;
		}
	}

	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3580
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) - 1 for a in input().split()]
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

def EulerTour(n, X, i0):
    f = lambda k: k * (k + 1) // 2
    USED = [0] * n
    ORG = [0] * n
    TMP = [0] * n
    P = [-1] * n
    ct = -1
    ET1 = [0] * n
    ET2 = [0] * n
    ANS = [f(n)] * n
    IND = [0] * n
    i = i0
    while i >= 0:
        if IND[i] == 0:
            if i: ORG[i] = USED[C[P[i]]]
            ct += 1
            ET1[i] = ct
        
        if IND[i] >= len(X[i]):
            ET2[i] = ct
            USED[C[i]] += 1 + TMP[i]
            if i:
                k = ET2[i] - ET1[i] + 1 - USED[C[P[i]]] + ORG[i]
                ANS[C[P[i]]] -= f(k)
                TMP[P[i]] += k
            i = P[i]
            continue
        
        if P[i] == X[i][IND[i]]:
            IND[i] += 1
            continue
        P[X[i][IND[i]]] = i
        IND[i], i = IND[i] + 1, X[i][IND[i]]
    
    for i in range(n):
        ANS[i] -= f(n - USED[i])
    return ANS

print(*EulerTour(N, X, 0), sep = "\n")

Measured memory_bytes: 84240
#include<stdio.h>
#include<iostream>
using namespace std;

int A,B,K;
int main (){
    cin >> A >> B >> K;
    int cnt = 0;
    for(int i=100; i>=1; i--) {
        if( A % i == 0 && B % i == 0 ) cnt++;
        if( cnt == K ) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;
 
 
void reader(int &a){scanf("%d",&a);}
void reader(double &a){scanf("%lf",&a);}
void reader(char &a){scanf(" %c",&a);}
void reader(char a[]){scanf("%s",a);}
void reader(ll &a){scanf("%lld",&a);}
void reader(ull &a){scanf("%llu",&a);}
// void reader(string& a){cin >> a;};
template<class T,class U> void reader(T& t,U& u){reader(t); reader(u);}
template<class T,class U,class V> void reader(T& t,U& u,V& v){reader(t); reader(u); reader(v);}
 
void writer(int a,char c) {printf("%d",a); putchar(c);}
void writer(ll a,char c) {printf("%lld",a); putchar(c);}
void writer(double a,char c) {printf("%.20lf",a); putchar(c);}
void writer(char a[]) {printf("%s",a);};
void writer(char a[],char c) {printf("%s",a);putchar(c);};
void writer(char a,char c) {putchar(a); putchar(c);};
template<class T>void writerLn(T t){writer(t,'\n');}
template<class T,class U>void writerLn(T t,U u){writer(t,' ');writer(u,'\n');}
template<class T,class U,class V> void writerLn(T t,U u,V v){writer(t,' ');writer(u,' ');writer(v,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
template<class T> void writerVec(vector<T> x){int n=x.size();int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
 
vector<std::string> split(const std::string &str, char sep){std::vector<std::string> v;std::stringstream ss(str);std::string buffer;while(std::getline(ss,buffer,sep)){v.push_back(buffer);}return v;}
 
// #define int ll
bool test = true;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };
ull mod = (int)1e9 + 7;
//..................
int H;
#define MAX (int)1e7
// nはまだ摂取してない
ull dp[10][180][21];
signed main(){
  int i,j,k,l;
  while(1) {
	int N,K,S;
	cin >> N >> K >> S;
	if(N == 0) return 0;
	rep(i,10) rep(j,180) rep(k,21) dp[i][j][k] = 0;
	REP(i,1,N+1) dp[0][i][i] = 1;
	REP(i,1,K) rep(j,S) rep(k,N+1) {
	  REP(l,k+1,N+1) {
		dp[i][j+l][max(k,l)] += dp[i-1][j][k];
	  }
	}
	int sum = 0;
	rep(i,N+1) sum += dp[K-1][S][i];
	cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3384
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n);
  REP(i, 0, n) cin >> a[i];
  int ans = 0;
  int cur = -1;
  int cnt = 0;
  REP(i, 0, n) {
    if (cur != a[i]) {
      ans += cnt / 2;
      cur = a[i];
      cnt = 0;
    }
    cnt++;
  }
  ans += cnt / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long

int a[300][300],vs[300],mx[300];
char s[300][300];
int main()
{
    IO;
    int i, j, m, k, n, t, l=0, mxx,mx1,r,c,x,y;
    cin>>m>>n;
    for(i=1; i<=n; i++){
        cin>>j; l+=j;
    }
    if(l>m) cout<<-1<<endl;
    else cout<<m-l<<endl;
    return 0;

}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> node[100005];
vector<ll> node2[100005];
ll par[100005];
vector<P> ans;
ll cnt[100005]={0};
bool used[100005]={0},used2[100005];
void dfs(ll pos){
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i].first;
    if(!used[to]){
      used[to]=true;
      node2[pos].push_back(to);
      used2[node[pos][i].second]=true;
      dfs(to);
    }
  }
}
ll dfs2(ll pos){
  ll sum=cnt[pos];
  for(int i=0;i<node2[pos].size();i++){
    ll son=node2[pos][i];
    sum+=dfs2(son);
  }
  if(par[pos]==pos) return 0;
  if(sum%2==0){
    ans.push_back(P(par[pos],pos));
    return 1;
  }
  else{
    ans.push_back(P(pos,par[pos]));
    return 0;
  }
}
int main(){
  ll n,m;
  cin>>n>>m;
  vector<P> qr;
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    node[a].push_back(P(b,i));
    node[b].push_back(P(a,i));
    qr.push_back(P(a,b));
  }
  for(int i=0;i<=max(m,n);i++) {
    used[i]=false;
    used2[i]=false;
  }
  used[1]=true;
  if(m%2==1){
    cout<<-1<<endl;
    return 0;
  }
  dfs(1);
  for(int i=0;i<m;i++){
    if(!used2[i]){
      ans.push_back(qr[i]);
      cnt[qr[i].first]++;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<node2[i].size();j++){
      par[node2[i][j]]=i;
    }
  }
  par[1]=1;
  dfs2(1);
  for(int i=0;i<m;i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
}


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

dp = [[0]*3 for i in range(N)]
dp[0] = src[0]
for i in range(1,N):
    for j in range(3):
        for k in range(3):
            if j==k: continue
            dp[i][j] = max(dp[i][j], dp[i-1][k] + src[i][j])
print(max(dp[-1]))

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

const int mod = 1e9+7;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> dp(2001, 0);
    dp[0] = 1;
    for (int i = 3; i <= n; ++i) {
        for (int j = 3; j <= i; ++j) {
            if (dp[i - j]) {
                dp[i] = (dp[i - j] + dp[i]) % mod;
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX_N 102

int a[MAX_N];

void dump(int n)
{
	int i;

	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;

	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}


Measured memory_bytes: 2028
import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

solve :: (Int, Int) -> Int
solve (n, m)
  | 2*n >= m = min n (div m 2)
  | otherwise = n + div (m-2*n) 4

main = do
  [n, m] <- map toInt . words <$> getLine
  print $ solve (n, m)


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

int main() {
	string S, T;
	cin >> S >> T;

	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) {
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
[$A, $B, $C, $K] = ints();
if($K <= $A){
  echo $K;
}elseif($K <= $A+$B){
  echo $A;
}else{
  echo $A * 2 - $K + $B;
}

function str(){return trim(fgets(STDIN));}
function ints($n = false){
  if($n===false){
    return array_map('intval',explode(' ',trim(fgets(STDIN))));
  }else{$ret = [];for($i = 0; $i < $n; $i++)foreach(array_map('intval',explode(' ',trim(fgets(STDIN)))) as $j => $v)$ret[$j][] = $v;return $ret;}
}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 16324
def main():
  input()
  A = list(map(int, input().split()))
  cusum = [0] * len(A)
  cusum[-1] = A[-1]

  if A[0] > 1:
    print(-1)
    return

  for i in range(len(A)-2, -1, -1):
    cusum[i] = cusum[i+1] + A[i]

  pre_node = 1
  ans = 1
  for i in range(1, len(A)):
    node = (pre_node - A[i-1]) * 2

    if node < A[i]:
        print(-1)
        return

    pre_node = min(node, cusum[i])
    ans += pre_node

  print(ans)

if __name__ == '__main__':
  main()
    


Measured memory_bytes: 83384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;


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

  if(a+b>c && a+c>b && b+c>a && a==b && b==c ){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

string s; int k, n;
ll ans = 0;

ll comb(ll N, ll R){
    if(R == 0) return 1;
    if(R == 1) return N;
    if(R == 2) return N*(N-1)/2;
    if(R == 3) return N*(N-1)*(N-2)/6;
    return 0;    
}

ll dfs(int digit, int r_nonzero, bool smaller){
    // digit : 何桁決めたか
    // r_nonzero : 非ゼロをあと何回使うか
    // smaller : n より小さいことが決定しているかどうか
    if(digit == n) {
        if(r_nonzero == 0) return 1;
        else return 0;
    }
    if(r_nonzero == 0){
        return 1;
    }
    if(smaller){
        ll ans = comb(n - digit, r_nonzero) * pow(9, r_nonzero); 
        return ans;        
    }
    int now = s[digit] - '0';
    if(now == 0) return dfs(digit+1, r_nonzero, false);
    ll zero = dfs(digit+1, r_nonzero, true);
    ll between = dfs(digit+1, r_nonzero-1, true) * (now - 1);
    ll same = dfs(digit+1, r_nonzero-1, false);
    return zero + between + same;    
}

void Main() {
    cin >> s >> k;
    n = s.size();
    cout << dfs(0, k, false) << endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int a,b,sum=0,co = 2;
    cin >> a >> b;
    while(co>0){
        if(a>=b){
            sum = sum+a;
            a--;
            co--;
        }else{
            sum = sum+b;
            b--;
            co--;
        }
    }
    
    cout << sum << endl;
    return 0;
}


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

const int MAX = 100005;
int n;
bool visit[MAX][100];

int summ(int x)
{
    int ret = 0;

    while(x > 0)
    {
        ret += x % 10;
        x /= 10;
    }

    return ret;
}

void dfs(int num, int sum)
{
    if(sum >= 99) return;
    if(num >= n) return;
    if(visit[num][sum]) return;

    visit[num][sum] = true;

    for(int i = 0; i < 10; i++){
        dfs ((num * 10 + i) % n, sum + i);
    }
}

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

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        dfs (i, summ(i));
    }

    int ans = summ(n);

    for(int i = 1; i < 99; i++)
    {
        if(visit[0][i]) ans = min (ans, i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 233344
N = gets.to_i
a = gets.split.map(&:to_i)
 
rates = [0,0,0,0, 0,0,0,0]
any = 0
 
a.map{|r|
  if r<3200 then
    rates[r/400] += 1
  else
    any += 1
  end
}
 
col = rates.select{|rc| rc>0}.size
 
puts [col, 1].max.to_s + " " + (col+any).to_s

Measured memory_bytes: 3836
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

int main(){
	string S;
	cin>>S;
	bool YYMM = false, MMYY = false;
	if((S[0]=='0' and S[1]!='0') or (S[1]=='1' and S[2]<='2')){
		MMYY = true;
	}
	if((S[2]=='0' and S[3]!='0') or (S[2]=='1' and S[3]<='2')){
		YYMM = true;
	}
	if(YYMM and MMYY){
		cout<<"AMBIGUOUS"<<endl;
	}else if(YYMM){
		cout<<"YYMM"<<endl;
	}else if(MMYY){
		cout<<"MMYY"<<endl;
	}else{
		cout<<"NA"<<endl;
	}
}


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

int main(){
	int n;
	int pt[200]={},x[200][3],d[101][3]={};
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			int a;
			cin>>x[i][j];
			d[x[i][j]][j]++;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			if(d[x[i][j]][j]==1)pt[i]+=x[i][j];
		}
		cout<<pt[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N,D,X; cin>>N>>D>>X;

  int ans=0;

  rep(i,N){
    int a;cin>>a; int d=D;
    --d; ++ans;
    while(d>=a){
      ++ans;
      d-=a;
    }
  }
  cout<< ans+X<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        for (long i = 1; i < 3500; i++) {
            for (long j = i; j < 3500; j++) {
                long lb = j - 1, ub = 3501;
                while (ub - lb > 1) {
                    long mid = (lb + ub) / 2;
                    if (N * (i * j + j * mid + mid * i) / (i * j * mid) == 4 && N * (i * j + j * mid + mid * i) % (i * j * mid) == 0) {
                        System.out.println(i + " " + j + " " + mid);
                        return;
                    }
                    if (N * (i * j + j * mid + mid * i) / (i * j * mid) < 4) {
                        ub = mid;
                    } else {
                        lb = mid;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 22100
program main
  implicit none
  
  integer :: n,i,j,a(100),t
  
  read(*,*)n
  read(*,*)(a(i),i = 1, n)
  
  do i=1,N-1
     do j=i+1,N
        if(a(i) .gt. a(j))then
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  
  write(*,*)abs(a(1) - a(n))
end program main


Measured memory_bytes: 384
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int inf=1e9,mod=998244353,N=2e5+5;


void solve(){
	int k;
	cin>>k;
	string s="ACL";
	while(k--){
		cout<<s;
	}
}

int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 3568