akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int minimum_vote(){
    int vote[10000];
    int index = 0;
    int sum = 0;
    char c = getchar();
    while(1){
        if(c == '['){
            vote[index++] = minimum_vote();
            c = getchar();
        }
        else if(c == ']'){
            qsort(vote, index, sizeof(int), compare_int);
            int i;
            for(i = 0; i < (index + 1) / 2; i++){
                sum += vote[i];
            }
            return sum;
        }
        else{
            int t = c - '0';
            c = getchar();
            while(c >= '0' && c <= '9'){
                t = t * 10 + (c - '0');
                c = getchar();
            }
            vote[index++] = (t + 1) / 2;
        }
    }
}
int main(void){
    int n, i;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        while(getchar() != '[');
        printf("%d\n", minimum_vote());
    }
    return 0;

}

Measured memory_bytes: 708
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    bool flag = false;
    M = 3;
    rep(i,3){
        if(M==N) flag = true;
        M += 2;
    }
    cout<<(flag ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>order(n);
  vector<int>satis(n);
  vector<int>extra(n-1);
  for(int i=0;i<n;i++){
  	cin>>order[i];
  }
  for(int i=0;i<n;i++){
  	cin>>satis[i];
  }
  for(int i=0;i<n-1;i++){
  	cin>>extra[i];
  }
  int sum=satis[0];
  for(int i=1;i<n;i++){
 	if(order[i-1]+1==order[i]){
	  	sum+=satis[i];
	  	sum+=extra[order[i]-2];
	}else{
	  	sum+=satis[i];
	}
  }
  cout<<sum<<endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder.ABC117
{
    public class A
    {
        public static void Solve()
        {

        }    
    }
    public class B
    {
        public static void Solve()
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (a.Max() < a.Sum()-a.Max())
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC117.B.Solve();
        }
    }
}


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

int main(){
  int a, b, ans[1000];
  int count=0;
  char op;

  for(int i=0; i<1000; i++){
    std::cin >> a >> op >> b;
    if( op == '+' ){
      ans[i] = a+b;
    }else if( op == '-' ){
      ans[i] = a-b;
    }else if( op == '*' ){
      ans[i] = a*b;
    }else if( op == '/' ){
      ans[i] = a/b;
    }else{ break; }
    count++;
  }

  for(int i=0; i<count; i++){
    std::cout << ans[i] << std::endl;
  }
  return 0;
}



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

long long a, b, c, d, n;
unsigned long long x, y;
int main() {
	cin >> a >> b >> c >> d >> n;
	if (4 * a < c) c = 4 * a;
	if (2 * b < c) c = 2 * b;
	if (n % 2 == 0) {
		x = n / 2 * d;
		y = n*c;
		if (x <= y)cout << x << endl;
		else cout << y << endl;
	}
	if (n % 2 == 1) {
		x = c + n / 2 * d;
		y = n*c;
		if (x <= y)cout << x << endl;
		else cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, L: "List[int]", R: "List[int]"):
    res = min(R) - max(L) + 1
    if res < 0:
        res = 0
    print(res)
    return


# Generated by 1.1.4 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
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]" 
    R = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    solve(N, M, L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42860
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).
 
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

main :-
  get_number(A),
  get_number(B),
  get_number(N),
  (N >= B - 1 -> (Ans is A*(B-1)//B,writeln(Ans)) ; (Ans is A*N//B, writeln(Ans))).

Measured memory_bytes: 8148
import sys
input = sys.stdin.readline
class UnionFind(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]


    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])


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

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)
def compute_mst_kruskal(N, edges):#N = 頂点数、edges 0-indexed
    edges = sorted(edges, key = lambda x:x[2])
    UF = UnionFind(N)
    cost = 0
    for edge in edges:
        x, y, w = edge
        if not UF.same(x, y):
            UF.unite(x, y)
            cost+=w
    return cost
N = int(input())
ixy = []
for i in range(N):
    x, y = map(int, input().split())
    ixy.append((i, x, y))
xy_x = sorted(ixy, key = lambda x:x[1])
xy_y = sorted(ixy, key = lambda x:x[2])
edges = []
for i in range(N-1):
    i1, x1, y1 = xy_x[i]
    i2, x2, y2 = xy_x[i+1]
    edges.append((i1, i2, x2-x1))
    i1, x1, y1 = xy_y[i]
    i2, x2, y2 = xy_y[i+1]
    edges.append((i1, i2, y2-y1))
ans = compute_mst_kruskal(N, edges)
print(ans)

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int sum = 0;
  if(A >= K){
   sum += K;
  }else{
    sum += A;
    K -= A;
    if(B < K){
      K -= B;
      sum -= K;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int H, W;
 char a[200][200];

 cin >> H >> W;

 H = H + 2;
 W = W + 2;

 for(int h = 1; h < H-1; h++){
     for(int w = 1; w < W-1; w++){
         cin >> a[h][w];
     }
 }

 for(int w = 0; w < W; w++){
     a[0][w] = '#';
 }
for(int w = 0; w < W; w++){
     a[H-1][w] = '#';
 }
for(int h = 0; h < H; h++){
     a[h][0] = '#';
 }
for(int h = 0; h < H; h++){
     a[h][W-1] = '#';
 }    

 for(int h = 0; h < H; h++){
     for(int w = 0; w < W; w++){
         cout << a[h][w];
     }
     cout << endl;
 } 

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=1e9+7;
#define N 400000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    ll int a[N];
    rep(i,3*n){
        scanf("%d",&a[i]);
    }
    ll int b[N],c[N];
    pqg q;
    int i=0;
    ll int sum=0;
    while(i<n){
        q.push(a[i]);
        sum+=a[i];
        i++;
    }
    b[i]=sum;
    while(i<=2*n){
        ll int t=q.top();
        q.pop();
        sum+=(max(a[i],t)-t);
        q.push(max(a[i],t));
        i++;
        b[i]=sum;
    }
    i=3*n-1;
    pq p;
    sum=0;
    while(i>=2*n){
        p.push(a[i]);
        sum+=a[i];
        i--;
    }
    c[i+1]=sum;
    while(i>=n){
        ll int t=p.top();
        p.pop();
        sum+=(min(a[i],t)-t);
        p.push(min(a[i],t));
        i--;
        c[i+1]=sum;
    }
    ll int ans=-1e15;
    rep2(i,n,2*n){
        ans=max(ans,b[i]-c[i]);
    }
    cout<<ans;
    return 0;

}

Measured memory_bytes: 10360
#include<stdio.h>
#include<stdint.h>

//0からnまでのXOR
uint64_t XOR(uint64_t n){
	if(n==-1) return 0;
	else if(n%4==1){
		return 1;
	}
	else if(n%4==3){
		return 0;
	}
	else if(n%4==2){
		return 1^n;
	}
	else{
		return n;
	}
}
	
int main(void){
	uint64_t A,B;
	scanf("%llu %llu",&A,&B);
	
	printf("%llu",XOR(A-1)^XOR(B));
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;


 int main(){
     int N,K;cin>>N>>K;
     string S;cin>>S;

     vector<int> Nums;
     int now = 1;
     int cnt = 0;
     REP(i,N){
         if(S[i]-'0'== now) cnt++;
         else{
             Nums.push_back(cnt);
             now = 1 -now;
             cnt =1;
         }
     }
     if(cnt!=0) Nums.push_back(cnt);
     //1-0-1という形
     if(Nums.size()%2==0) Nums.push_back(0);

     int Add = 2 * K + 1;
     vector<int> sum(Nums.size()+1);
     REP(i,Nums.size()){
         sum[i+1] = sum[i] + Nums[i];
     }
     int ans = 0;
     for (int i = 0; i < Nums.size(); i+=2)
     {
        int left = i;
        int right = min(i+Add,(int)Nums.size());
        int tmp = sum[right] - sum[left];
        ans = max(tmp,ans);
     }
     cout<<ans<<endl;
     
 }

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

typedef long long ll;

vector<int> a[100010];
int x;

int dfs(int now){
  vector<int> v;
  int i;
  for(int i=0;i<a[now].size();i++){
    v.push_back(dfs(a[now][i]));
  }
    sort(v.begin(),v.end());
    int tmp=0;
    for(int i=1;i<=v.size();i++){
      tmp=max(tmp,i+v[v.size()-i]);
    }
  return tmp;
}
int main(){
  int N;
  cin>>N;
  N--;
  for(int i=0;i<N;i++){
    cin>>x;
    //0Index かち　負け
    a[x-1].push_back(i+1);
  }
  cout<<dfs(0)<<endl;

}


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

sys.setrecursionlimit(10000)


N, K = (int(i) for i in input().split())
H = []
for i in range(N):
    H.append(int(input()))

H.sort()
res = 100000000000000
for i in range(N-K+1):
    res = min(res, H[i+K-1] - H[i])

print(res)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 7;
const ll mod = 1e9+7;

ll fac[maxn], ifac[maxn];
ll inv[maxn]; // https://cp-algorithms.com/algebra/module-inverse.html

void gen() {
    fac[0] = ifac[0] = inv[0] = 1LL;
    fac[1] = ifac[1] = inv[1] = 1LL;
    for (ll i = 2; i < maxn; i++) {
        fac[i] = fac[i-1] * i;
        fac[i] %= mod;
        inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
        ifac[i] = ifac[i-1] * inv[i];
        ifac[i] %= mod;
    }
    assert(fac[3] == 6LL);
}

ll nCk(ll nn, ll kk) {
    ll ans = fac[nn] * ifac[kk];
    ans %= mod;
    ans *= ifac[nn-kk];
    ans %= mod;
    return ans;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    ll tot; cin >> tot;

    if (tot < 3) out(0);

    gen();

    ll ans = 0LL;

    ll mostdigs = tot/3LL;
    for (int i = 1; i <= mostdigs; i++) {
        ll diff = tot - 3LL*i;
        ans += nCk(diff+i-1,diff);
        ans %= mod;
    }

    out(ans);
    
    return 0;
}


Measured memory_bytes: 27028
N=int(input())
c=input()

count=0;
lp=0
rp=N-1
swap=0
for i in range(N):
    while c[lp]!='W' and lp<rp:
        lp+=1
    while c[rp]!='R' and lp<rp:
        rp-=1
    if lp<rp:
        swap+=1
        lp+=1
        rp-=1
    else:
        break
print(swap)


Measured memory_bytes: 9436
A, B = [int(i) for i in input().split()];

A -= 1;
B -= 1;

def list_2d(H, W, v) :
    return [[v for i in range(W)] for j in range(H)];

ans = list_2d(50, 100, '#') + list_2d(50, 100, '.');

for i in range(1, 50, 2) :
    for j in range(1, 100, 2) :
        if (A) :
            ans[i][j] = '.';
            A -= 1;

for i in range(51, 100, 2) :
    for j in range(1, 100, 2) :
        if (B) :
            ans[i][j] = '#';
            B -= 1;

print(100, 100);
for i in ans :
    for j in i :
        print(j, end = '');
    print();


Measured memory_bytes: 4468
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }
inline int mul(int x, int y) { return (1LL*x*y)%MOD; }

int N;
int fact[201];
int A[200], C[200];
int T[5][801][201];
int nCr[201][201];
int R[201];
int num[5];

void solve(int type) {
  if (num[type] == 0) return;
  auto &dp = T[type];
  rep(i, 801) rep(j, 201) dp[i][j] = 0;
  num[type]--;
  dp[0][0] = 1;
  for (int x=1; x<=4; x++) rep(_, num[x]) {
    for (int j=800-x; j>=0; j--) {
      for (int k=199; k>=0; k--) {
        add(dp[j+x][k+1], dp[j][k]);
      }
    }
  }
  num[type]++;
}
int f() {
  for (int i=1; i<=4; i++) solve(i);
  int sum = 0;
  rep(i, N) {
    int p = A[i];
    rep(s, 801) {
      rep(k, N) {
        if (T[C[i]][s][k] == 0) continue;
        add(sum, mul(mul(mul(fact[k], T[C[i]][s][k]), p), R[N-1-k]));
      }
      p = (10LL*p)%MOD;
    }
  }
  return sum;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  sort(A, A+N, greater<int>());

  fact[0] = 1;
  for (int i=1; i<=200; i++) fact[i] = (1LL*i*fact[i-1]) % MOD;
  nCr[0][0] = 1;
  for (int i=1; i<=200; i++) {
    nCr[i][0] = 1;
    for (int j=1; j<=200; j++) nCr[i][j] = (nCr[i-1][j-1] + nCr[i-1][j]) % MOD;
  }
  rep(i, N+1) {
    rep(j, i+1) add(R[i], mul(nCr[i][j], fact[j]));
  }

  bool has_zero = false;
  rep(i, N) {
    int x = A[i];
    if (x == 0) {
      C[i] = 1;
      has_zero = true;
    }
    while (x) C[i]++, x/=10;
    num[C[i]]++;
  }
  int sum = f();
  if (has_zero) {
    N--;
    num[1]--;
    add(sum, (MOD-f())%MOD);
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 5868
import scala.io.{StdIn => in}

object Main extends App {
  val tar = "ACGT".toCharArray

  val s = in.readLine
  val ans = {
    var res = 0
    for {
      i <- 0 until s.size
      j <- i+1 to s.size
    } {
      val ss = s.substring(i,j)
      if(ss.forall(ch => tar.exists(_ == ch))) {
        var n = ss.size
        debug(ss)

        if(n > res) res = n
      }
    }
    res
  }
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString == "class Main$") return
    println(any.mkString(" "))
  }
}

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

int main(){
  long n,p;
  cin >> n >> p;
  if(n == 1){
    cout << p << endl;
    return 0;
  } else if(n >= 40){
    cout << 1 << endl;
    return 0;
  }
  int cnt = 0;
  int ans = 1;
  for(int i = 2; i <= p && i <= 1000000  ; i++){
//	  cout << "A" << i << endl;
	  while((p % i) == 0){
		  p/=i;
		  cnt++;
//		  cout << "b p;" << p << "cnt" << cnt << endl;
	  }
	  while(cnt >= n){
		  ans *= i;
		  cnt -= n;
	  }
         cnt = 0;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX=100000;
int s[MAX],t[MAX],c[MAX];
int sum[2*MAX+1],tt[2*MAX+1];
int N,C,max_sum;

void solve(){
    for(int i=1;i<=C;i++){
        for(int j=0;j<2*MAX+1;j++)tt[j]=0;
        for(int j=0;j<N;j++){
            if(c[j]==i){
                tt[s[j]*2-1]++;
                tt[t[j]*2]--;
            }
        }
        for(int j=1;j<=MAX*2;j++){
            tt[j]+=tt[j-1];
        }    
        for(int j=0;j<=MAX*2;j++){
            if(tt[j]>0)sum[j]++;
        }    
    }

    for(int i=0;i<MAX*2;i++){
        if(max_sum<sum[i])max_sum=sum[i];
    }
}
int main(){
    cin>>N>>C;
    for(int i=0;i<N;i++)
        cin>>s[i]>>t[i]>>c[i];
    solve();
    cout<<max_sum<<"\n";
    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}

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

    ll A, B; cin >> A >> B;
    ll C = __gcd(A, B);

    ll X = C;
    set<ll> s = {1LL};
    rep(i, 2, sqrt(C) + 2){
        bool ok = false;
        while(X % i == 0LL){
            X /= i;
            ok = true;
        }
        if(ok){
            s.insert(i);
        }
    }
    s.insert(X);

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, A: "List[int]", B: "List[int]"):
    data = list(sorted(zip(B, A)))
    curr = 0
    for i in range(N):
        b, a = data[i]
        curr += a
        if curr > b:
            no()
            return
    yes()
    return


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
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

vector<ll> div(ll x) {
  vector<ll> res;
  res.push_back(x);
  for (ll i = 2; i * i <= x; i++)
    if (x % i == 0) {
      res.push_back(i);
      if (i * i != x)
        res.push_back(x / i);
    }
  return res; 
}

int main() {
  ll n; 
  cin >> n;
  if (n == 2) {
    cout << 1 << '\n';
    return 0;
  }
  ll ans = div(n - 1).size();
  vector<ll> a = div(n);
  for (int i = 0; i < a.size(); i++) {
    ll t = n; 
    while (t % a[i] == 0)
      t /= a[i];
    if (t % a[i] == 1)
      ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char ci[cm];
char *cn = ci + cm;
inline char getcha() {
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	return *cn++;
}

inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

inline void putint(int X) {
	if (X == 0) putchar('0');
	int keta = 0;
	char C[10];
	while (X) {
		C[keta] = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(C[i]);
	putchar('\n');
}

int oya;
int D[100001];
int P[100001];
vector<int> V[100001];
int sagasu(int A) {
	if (*(D + A)) return *(D + A);
	if (A == oya) return 1;
	int ret = 0;
	for (int i : *(V + A)) {
		int kari = sagasu(i) + 1;
		if (ret < kari) {
			ret = kari;
			*(P + A) = i;
		}
	}
	*(D + A) = ret;
	return ret;
}

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


	int N, M;
	N = getint();
	M = getint();
	bool kodomo[100001] = {};
	rep(i, N + M - 1) {
		int a, b;
		a = getint();
		b = getint();
		V[b].pb(a);
		kodomo[b] = true;
	}

	rep1(i, N) {
		if (!kodomo[i]) {
			oya = i;
			break;
		}
	}

	rep1(i, N) {
		sagasu(i);
		putint(P[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 11264
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B){
    if((A%2) && (B%2))
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int x,a,b;
  cin>>x>>a>>b;
  cout<<(x-a)%b<<endl;      
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const ll mod = 1000000007;

ll bm(ll b, ll p, ll m) {
	ll r = 1;
	for(; p; p >>= 1, b = b * b % m) if (p & 1) r = r * b % m;
	return r;
}

ll inv(ll x) { return bm(x, mod - 2, mod); }

ll fact[200005], factinv[200005];

ll ncr(ll n, ll r) {
	return fact[n] * factinv[r] % mod * factinv[n - r] % mod;
}

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

	fact[0] = 1;
	rep(i, 1, 200005) fact[i] = fact[i - 1] * i % mod;
	rep(i, 0, 200005) factinv[i] = inv(fact[i]);

	ll h, w, a, b; read(h, w, a, b);
	ll ans = 0;

	rep(i, 0, h - a) {
		ll dx = w - 1 - b, dy = h - 1 - i;
		ans += ncr(b - 1 + i, i) * ncr(dx + dy, dx) % mod;
	}

	die(ans % mod);
}



Measured memory_bytes: 3328
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){

	int n;cin>>n;
	int res=0;
	for(int i=2;i*i<=n;i++){
		int save=i;
		while(n%save==0){
			n/=save;
		save*=i;
		res++;
		}
		if(n%i==0){
			while(n%i==0) n/=i;
			// while(n%i==0) n/=i;
		}
	}
	if(n>1) res++;
	cout<<res;


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


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=0LL;i<=k;i++){
    	ans+=(com(k,i)*modpow(i,n)*modpow(-1,k-i))%mod;
    	ans%=mod;
    }
    cout <<(ans+mod)%mod<<endl;
    return 0;
}



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


int main() {
  ll N;
  cin>>N;
  ll sM=-100000000000,sm=100000000000,dM=-1000000000000,dm=100000000000;
  rep(i,N){
    ll x,y;
    cin>>x>>y;
    sM=max(sM,x+y);
    sm=min(sm,x+y);
    dM=max(dM,x-y);
    dm=min(dm,x-y);
  }
  cout<<max(sM-sm,dM-dm);
}



Measured memory_bytes: 3484
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

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

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

int main()
{
	int h, w;
	while (cin >> h >> w && h != 0 && w != 0)
	{
		int t = (h * h) + (w * w);
		int min_t = MAX;
		int min_h = MAX;
		int min_w = 0;
		for (int ww = 1; ww<= 150; ww++)
		{
			for (int hh = 1; hh  < ww; hh++)
			{
				int a = (hh * hh) + (ww * ww);

				if (a > t && min_t > a)
				{
					min_t = a;
					min_h = hh;
					min_w = ww;
				}
				else if (a == t && hh > h && hh < min_h)
				{
					min_t = a;
					min_h = hh;
					min_w = ww;
				}
				else if (a > t && a == min_t && hh < min_h)
				{
					min_t = a;
					min_h = hh;
					min_w = ww;
				}
			}
		}
		cout << min_h << " " << min_w << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#長方形のタテ、ヨコの長さを受け取り、
#面積と周を計算して返すプログラム

splittedStr = input().split() #3 4

#リスト内包表記
#tate,yoko = [int(str) for str in splittedStr]
#高階関数を用いて
[tate,yoko] = list( map(lambda x:int(x),splittedStr) )


#面積を計算
square = tate*yoko
#周の長さを計算
circumference = tate+yoko+tate+yoko
#出力
print("{} {}".format(square,circumference))


Measured memory_bytes: 5592
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int count = 0;
			int I, J, K;

			if(n == 0 && x == 0) {
				break;
			}

			for(int i = 1; i <= Math.min(x-3, n); i++) {
				for(int j = 1; j <= Math.min(x-3, n); j++) {
					int k = x - i - j;

					if( (i != j && i != k && j!= k)
						&& (k >= 1 && k <= n)
							) {
						count++;
					}
				}
			}

			System.out.println(count/6);
		}
	}
}



Measured memory_bytes: 26668
#include<cstdio>
using namespace std;
void func(int,int);
int a,b;
int x,y;
int cnt;
int kouzi[17][17];

int main(void)
{
	int i,j,n;
	scanf("%d %d",&a,&b);
	while(a!=0 && a!=0){
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++){
				kouzi[i][j]=0;
			}
		}
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			kouzi[y][x]=1;
		}
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
		
		scanf("%d %d",&a,&b);
		
	}
	return 0;
}
void func(int y,int x)
{
	if(a==x && b==y){
		cnt++;
	}
	else{
		if(kouzi[y][x+1]==0 && x+1<=a){
			func(y,x+1);
		}
		if(kouzi[y+1][x]==0 && y+1<=b){
			func(y+1,x);
		}
	}
}
	

Measured memory_bytes: 1028
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	b := make([]string, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&b[i])
	}

	for ai := 0; ai <= n-m; ai++ {
		for aj := 0; aj <= n-m; aj++ {
			ok := true
			for bi := 0; bi < m; bi++ {
				for bj := 0; bj < m; bj++ {
					if a[ai+bi][aj+bj] != b[bi][bj] {
						ok = false
						break
					}
				}
				if !ok {
					break
				}
			}
			if ok {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


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

int main() {
    int N;
    cin >> N;
    int L[200];
    for(int i=0; i<N; i++)
        cin >> L[i];
    sort(L, L+N);
    int Max = L[N-1];
    int Sum;
    for(int i=0; i<N-1; i++)
        Sum += L[i];
    if(Sum > Max)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#include <fstream>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int main() {
	int i, j, k;
	int N, M, K;
	const ll AAA2 = AAA * 2;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N);
	ll sum = 0;
	ll a2sum = 0;
	rep(i, 0, N) {
		cin >> A[i];
		sum += A[i];
		B[i] = A[i] * A[i] % AAA2;
		a2sum += B[i];
	}
	sum %= AAA2;
	a2sum %= AAA2;
	ll sum2 = sum * sum % AAA2;

	ll ans = (sum2 - a2sum + AAA2) % AAA2 / 2;
	cout << ans;
	return 0;

}


Measured memory_bytes: 6408
n,y = [int(e) for e in input().split()]
for i in range(0,n+1):
    for j in range(0,n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(str(i)+" " +str(j) + " " + str(n-i-j))
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 ll MRINF = 5000000000000000;


int main() {

  ll c1, c2;
  cin >> c1 >> c2;
  ll ans = 0;

  for(ll i=c1; i<=c2; i++){
    string n = to_string(i);

    // string n1 = to_string(i / 1000);
    // string n2 = to_string(i - (i/100)*100);
    // cout << n1 << " " << n2 << endl;
    

    if(n[0]==n[4] && n[1]==n[3]){
      ans++;
    }

  }

  cout << ans << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int n;
map<string, int> mp;

int main(){
  cin >> n;
  int M = 0;
  rep(i, n){
    string s;
    cin >> s;
    mp[s]++;
    M = max(M, mp[s]);
  }
  
  auto begin = mp.begin(), end = mp.end();
  for(auto iter = begin; iter != end; iter++){
    if(iter->second == M){
      cout << iter->first << endl;
    }
    //cerr << iter->second << endl;
  }
  
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  map<char, int> counter;
  for(int i=0;i<s.size();i++) {
    counter[s[i]]++;
  }
  vector<char> alphabet(26);
  iota(alphabet.begin(), alphabet.end(), 'a');

  char ans = 'a';
  bool ansExists = false;
  for(int i=0;i<alphabet.size();i++) {
    if(counter[alphabet[i]] == 0) {
      ans = alphabet[i];
      ansExists = true;
      break;
    }
  }

  if(!ansExists) {
    cout << "None" << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 512
#include <stdio.h>
 
int main () {
int i,j;
char n[100000] = {0};
int  x[1001] = {0};
 
i = 0;
j = 0;
 
 
while(1) {
scanf("%c",&n[i]);
if(n[i] == '0' && n[i-1] == '\n'|| n[0] == '0') {break;}
 
if(n[i] >= '1' && '9' >= n[i] && n[i] != '\n') {
x[j] += n[i]-48;
}
  if(n[i] == '\n') {
j = j + 1;
}
 
i= i+1;
 
}
 
for(i=0; i < j;i++) {
printf("%d",x[i]);
printf("\n"); 
 
} 
 
return 0;
 
}


Measured memory_bytes: 2824
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<s64, int>;

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

    s64 n;
    cin >> n;
    vector<P> a(n);
    rep (i, n)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end(), greater<P>());
    s64 dp[n + 1][n + 1];
    rep (i, n + 1) rep (j, n + 1) dp[i][j] = 0;

    s64 ans = 0;
    rep (l, n)
    {
        for (int r = 0; l + r <= n; ++r)
        {
            if (l + r == n)
            {
                ans = MAX(ans, dp[l][r]);
                break;
            }
            else
            {
                int pos = a[l + r].second;
                s64 A = a[l + r].first;
                dp[l + 1][r] = MAX(dp[l + 1][r], dp[l][r] + A * (pos - l));
                dp[l][r + 1] = MAX(dp[l][r + 1], dp[l][r] + A * (n - 1 - r - pos));
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 34956
fun main(args: Array<String>) {
    var N = nextInt()
    var buf = StringBuilder()
    while (N != 0) {
        if (N % 2 != 0) {
            N -= 1
            buf.append("1")
        }
        else buf.append("0")
        N /= -2
    }
    val ans = if (buf.length == 0) "0" else buf.reversed()
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 33860
import java.util.*;
import java.io.*;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int M1 = sc.nextInt();
		int D1 = sc.nextInt();
		int M2 = sc.nextInt();
		int D2 = sc.nextInt();
		if (M1 != M2) {
			System.out.println("1");
		} else {
			System.out.println("0");
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ.Volume0
{
    class Program0008
    {
        static void Main(string[] args)
        {
            string input;
            Queue<int> results = new Queue<int>();

            while ((input = Console.ReadLine()) != null)
            {
                int sum = int.Parse(input);

                results.Enqueue(Calculate(sum, 1));
            }

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }

        static int Calculate(int sum, int depth)
        {
            int result = 0;

            for (int i = 0; i <= 9; i++)
            {
                if (depth < 4 && sum - i > 0)
                {
                    result += Calculate(sum - i, depth + 1);
                }
                else if (sum - i == 0)
                {
                    result++;
                    break;
                }
            }

            return result;
        }
    }
}

Measured memory_bytes: 5900
#include<stdio.h>
int main(void){

int a,b,c,i,S=0;
scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++){

if( c%i == 0 ){
S++;
}
}

printf("%d\n",S);

return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main()
{
  short m, f, r;

  fscanf(stdin, "%hd %hd %hd", &m, &f, &r);

  for (;m != -1 || f != -1 || r != -1;) {
    if (m == -1 || f == -1) {
      puts("F");
    } else if (m + f >= 80) {
      puts("A");
    } else if (m + f >= 65) {
      puts("B");
    } else if (m + f >= 50 || (m + f >= 30 && r >= 50)) {
      puts("C");
    } else if (m + f >= 30) {
      puts("D");
    } else {
      puts("F");
    }
    fscanf(stdin, "%hd %hd %hd", &m, &f, &r);
  }

  return 0;
}

Measured memory_bytes: 588
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int flag=0;
  int ans;
  for(ans=0;ans<=1500;ans++){
    if(((ans*8)/100)==a && (((ans*10)/100)==b)){
      	flag=1;
      break;
    }
  }
  if(flag)cout<<ans<<endl;
  else cout<<-1<<endl;
  return 0;}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i, j, n;
  
  scanf("%d", &n);
  
  for (i=1; i<=9; i++) {
     for (j=1; j<=9; j++) {
       if (i*j == n) {
         printf("Yes\n");
         return 0;
       }
     }
  }
  
  printf("No\n");
    
  return 0;
  }

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

AC_and_penalty = {i:[False, 0] for i in range(1, N+1)}

for p, s in PS:
  _AC_and_penalty = AC_and_penalty[int(p)]
  if _AC_and_penalty[0]:
    continue
  else:
    if s == "AC":
      _AC_and_penalty[0] = True
    else:
      _AC_and_penalty[1] += 1
    
num_AC = 0
penalty = 0
for cond, p in AC_and_penalty.values():
  if cond:
    num_AC += 1
    penalty += p
    
print("{} {}".format(num_AC, penalty))
    

Measured memory_bytes: 52412
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=5e6+500;
int n,m,k;

int gti(void)
{
    char c=getchar();
    int ret=0,st=1;
    for (;!isdigit(c);c=getchar()) if (c=='-') st=-1;
    for (;isdigit(c);c=getchar()) ret=ret*10+c-'0';
    return ret*st;
}

bool atedge(int x,int y)
{
    return x==0||x==n||y==0||y==m;
}

int val[2][2][2];
struct P
{
    int x,y,v;
    bool operator<(const P &b)const
    {
        if (val[bool(x)][bool(y)][x>y]!=val[bool(b.x)][bool(b.y)][b.x>b.y])
            return val[bool(x)][bool(y)][x>y]<val[bool(b.x)][bool(b.y)][b.x>b.y];
        if (!y) return x>b.x;
        if (y==m) return x<b.x;
        if (!x) return y<b.y;
        if (x==n) return y>b.y;
        return true;
    }
}p[N<<1];

int cnt,stk[N<<1],top=0;
bool vis[N<<1];
bool getans(void)
{
    sort(p+1,p+1+cnt);
    for (int i=1;i<=cnt;i++)
    {
        if (vis[p[i].v])
        {
            if (stk[top]!=p[i].v)
                return false;
            --top;
        }
        else stk[++top]=p[i].v,vis[p[i].v]=true;
    }
    return true;
}

int main(void)
{
    n=gti(),m=gti(),k=gti();
    val[0][1][0]=1,val[1][1][0]=2,val[1][1][1]=3,val[1][0][1]=4;
    for (int i=1;i<=k;i++)
    {
        int x1=gti(),y1=gti(),x2=gti(),y2=gti();
        if (atedge(x1,y1)&&atedge(x2,y2))
            p[++cnt]=(P){x1,y1,i},p[++cnt]=(P){x2,y2,i};
    }
    if (getans()) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 6400
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<int,int> m,sum,dt;
int main(){
	ios::sync_with_stdio(false);
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k<<endl;
	}else if(a+b>=k){
		cout<<a<<endl;
	}else if(a+b+c>=k){
		cout<<a-(k-a-b)<<endl;
	}else{
		cout<<a-c<<endl;
	}
}

Measured memory_bytes: 3604
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt
  d = readline() |> split |> parseArray

  ans=sum(d[i]*d[j] for i in 1:n-1 for j in i+1:n)
  println(ans)
end

main()


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

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

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

    ll t[n];
    rep(i, n){
        cin >> t[i];
    }

    rep(i, n-1){
        t[i+1] = lcm(t[i], t[i+1]);
    }

    cout << t[n-1] << endl;
    return 0;
}


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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    int n;
    cin >> n;
    unordered_map<string,int> m;
    int count=0;
    while(n--)
    {
        string s;
        cin >> s;
        if(m.find(s)==m.end())
        {
            count++;
            m[s]=1;
        }
    }
    cout << count << endl;
    
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

void burn(int, int);

char data[8][8];

int main(){
	int n;
	int a,b;
	
	
	cin >> n;
	
	for(int k=1; k<=n; k++){
		
		for(int i=0; i<8; i++){
			for(int j=0; j<8; j++) cin >> data[i][j];
		}
		
		cin >> a >> b;
		
		burn(b-1,a-1);
		cout<< "Data "<<k<<":"<<endl;
		for(int i=0; i<8; i++){
			for(int j=0; j<8; j++) cout << data[i][j];
			cout << endl;
		}
	}
}

void burn(int x, int y){
	data[x][y]='0';
	//cout << "t";
	//cout << "x=" << x << " y=" << y << endl;
	for(int i=1;i<=3;i++){
		if(data[x+i][y]=='1' && 0 <= x+i && x+i < 8) burn(x+i,y);
		if(data[x-i][y]=='1' && 0 <= x-i && x-i < 8) burn(x-i,y);
		if(data[x][y+i]=='1' && 0 <= y+i && y+i < 8) burn(x,y+i);
		if(data[x][y-i]=='1' && 0 <= y-i && y-i < 8) burn(x,y-i);
	}
}

Measured memory_bytes: 1164