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

using namespace std;

int main(void) {
  string s;
  cin >> s;

  int sz = s.size(), ans = 0;
  while (s != "") {
    if (s[0] == s[sz - 1]) {
      sz -= 2;
      s = s.substr(1, sz);
    } else if (s[0] == 'x') {
      s = s.substr(1, --sz);
      ans++;
    } else if (s[sz - 1] == 'x') {
      s = s.substr(0, --sz);
      ans++;
    } else {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  
  int choco, ai;
  choco = x;
  rep(i, n) {
    cin >> ai;
    choco += (d-1) / ai + 1;
  }
  cout << choco;
}


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

// なんとなく、置換できる組(xi,yi)をすべて集合にまとめて
// i番目の順列Piとインデックスiがおなじ集合に属しているなら
// 順列中のiとPiは置換できると考えた
// 合ってたけど、証明が書けるようになりたい。
// https://atc001.contest.atcoder.jp/tasks/unionfind_a
struct unionfind{
    vector<int> par, rank;
    unionfind(int s) {
        par.resize(s);
        rank.resize(s, 0);
        for(int i = 0; i < s; ++i) par[i] = i;
    }
    int root(int x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }
    bool same(int x, int y) { return root(x) == root(y); }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
};

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    vector<int> P(N);
    unionfind List(N);
    for(int i = 0; i < N; ++i) {
        int p;
        scanf("%d", &p);
        P[i] = p-1;
    }
    for(int i = 0; i < M; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        List.unite(x-1, y-1);
    }
    int res = 0;
    for(int i = 0; i < N; ++i) {
        if(List.same(i, P[i])) ++res;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"os"
)

const MOD int = 1000000007

func main() {

	var n int

	fmt.Scan(&n)

	m := map[string]int{}
	input := make([]string, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&input[i])
		m[input[i]] += 1
	}

	for key, value := range m {
		if key == "0" {
			if value != 1 {
				fmt.Println("0")
				os.Exit(0)
			}
		} else {
			if value != 2 {
				fmt.Println("0")
				os.Exit(0)
			}
		}
	}

	l := n / 2
	res := 1
	for i := 0; i < l; i++ {
		res = (res * 2) % MOD
	}

	fmt.Println(res)
}


Measured memory_bytes: 11520
import math


def divisor(div, N):
    # 約数
    i = 1
    n = N

    while i <= math.sqrt(n):
        if n % i == 0:
            div.append([i, n // i])
        i += 1


def main():
    N = int(input())
    div = []
    divisor(div, N)
    print(max(int(math.log10(div[-1][0]) + 1),
              int(math.log10(div[-1][1]) + 1)))
    return


main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll t,n,i,x,y,c=0,m;
     ll a[100007];
     cin>>n;
     for(i=0;i<n;i++)
     {
         cin>>a[i];

     }
     ll res[100007];
     res[0]=0;
     res[1]=abs(a[1]-a[0]);
     for(i=2;i<n;i++)
     {
      res[i]=min(res[i-1]+abs(a[i]-a[i-1]),res[i-2]+abs(a[i]-a[i-2]));   
     }
     cout<<res[n-1]<<"\n";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn=5000*5000+233;
long long f[maxn];
void dfs(int w,int c)
{
	if(c<=0) return;
	for(int i=0;i<=5000*5000-w;i++)
	{
		f[i+w]=max(f[i+w],f[i]+c);
	}
}
int main()
{
	int n,ga,gb,sa,sb,ba,bb;
	cin>>n>>ga>>sa>>ba>>gb>>sb>>bb;
	memset(f,0,sizeof(f));
	dfs(ga,gb-ga);dfs(sa,sb-sa);dfs(ba,bb-ba);
	n=n+f[n];
	memset(f,0,sizeof(f));
	dfs(gb,ga-gb);dfs(sb,sa-sb);dfs(bb,ba-bb);
	cout<<n+f[n]<<endl;
	return 0;
}


Measured memory_bytes: 195712
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        int low = in.nextInt(), high = in.nextInt(), x = in.nextInt();
        int cnt=0;

        for(int i = low; i <= high; i++){
            if(x % i == 0)cnt++;
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 26348
nk = input('')
n = int(nk.split(' ')[0])
k = int(nk.split(' ')[1])

sunukes = [0]*n
for i in range(k):
    d = int(input(''))
    a = input('').split(' ')
    for j in a:
        no = int(j)-1
        sunukes[no] = 1

cnt=0
for s in sunukes:
    if s == 0:
        cnt+=1
print(cnt)



Measured memory_bytes: 9160
import itertools

if __name__ == '__main__':
    # P and Q are both rearrangements of (1, 2, ..., N)).
    # N! possible permutations of size N
    # among them, let P and Q be the a-th and the b-th
    n = int(input())
    p = input().split(' ')
    q = input().split(' ')

    for i in range(0, len(q)):
        p[i] = int(p[i])
        q[i] = int(q[i])

    realnums = p.copy()

    realnums.sort()

    perm = list(itertools.permutations(realnums))

    it = 0

    qplace = 0
    pplace = 0

    for i in perm:
        if list(i) == q:
            qplace = it
        if list(i) == p:
            pplace = it
        it += 1
    print(abs(qplace - pplace))

Measured memory_bytes: 8052
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
k=min(m//2,n)
m-=2*k;n-=k
count+=k
# print(n,m,k)
count+=m//4
print(count)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int n,a[100];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 1; i <= n; i++) {
		if (i == 1)cout << a[n - i];
		else cout << " " << a[n - i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3052
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;

int main(){
    char a;
    int c[26];
    
    int i;
    
    for (i=0;i<26;i++){
        c[i]=0;
    }
    
    
    while ( scanf("%c", &a) != EOF ){
        
            if (a==0x41 || a==0x61){
                c[0]=c[0]+1;
            }else if (a==0x42 || a==0x62){
                c[1]=c[1]+1;
            }else if (a==0x43 || a==0x63){
                c[2]=c[2]+1;
            }else if (a==0x44 || a==0x64){
                c[3]=c[3]+1;
            }else if (a==0x45 || a==0x65){
                c[4]=c[4]+1;
            }else if (a==0x46 || a==0x66){
                c[5]=c[5]+1;
            }else if (a==0x47 || a==0x67){
                c[6]=c[6]+1;    
            }else if (a==0x48 || a==0x68){
                c[7]=c[7]+1;
            }else if (a==0x49 || a==0x69){
                c[8]=c[8]+1;
            }else if (a==0x4a || a==0x6a){
                c[9]=c[9]+1;
            }else if (a==0x4b || a==0x6b){
                c[10]=c[10]+1;
            }else if (a==0x4c || a==0x6c){
                c[11]=c[11]+1;
            }else if (a==0x4d || a==0x6d){
                c[12]=c[12]+1;
            }else if (a==0x4e || a==0x6e){
                c[13]=c[13]+1;
            }else if (a==0x4f || a==0x6f){
                c[14]=c[14]+1;
            }else if (a==0x50 || a==0x70){
                c[15]=c[15]+1;
            }else if (a==0x51 || a==0x71){
                c[16]=c[16]+1;
            }else if (a==0x52 || a==0x72){
                c[17]=c[17]+1;
            }else if (a==0x53 || a==0x73){
                c[18]=c[18]+1;
            }else if (a==0x54 || a==0x74){
                c[19]=c[19]+1;
            }else if (a==0x55 || a==0x75){
                c[20]=c[20]+1;
            }else if (a==0x56 || a==0x76){
                c[21]=c[21]+1;
            }else if (a==0x57 || a==0x77){
                c[22]=c[22]+1;
            }else if (a==0x58 || a==0x78){
                c[23]=c[23]+1;
            }else if (a==0x59 || a==0x79){
                c[24]=c[24]+1;
            }else if (a==0x5a || a==0x7a){
                c[25]=c[25]+1;
            }else{
                
            }
        
    }
    
    for (i=0;i<26;i++){
        printf("%c : ", 97+i);
        cout << c[i] << endl;
    }
    return 0;
}

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

using namespace std;

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

template<typename T> void pv(T a, T b) { for (T i = a; i < b; i++) cout << *i << ' '; cout << endl; }
template<typename T, typename U> void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void chmax(T &x, U y) { if (x < y) x = y; }

int N;
int in[200010], xs[200010];

int main() {
  scanf("%d", &N);
  REP(i,N) {
    scanf("%d", &in[i]);
    xs[i] = in[i];
  }

  sort(xs, xs + N);

  int a = xs[N / 2 - 1], b = xs[N / 2];
  REP(i,N) {
    if (in[i] <= a) {
      cout << b;
    } else if (b <= in[i]) {
      cout << a;
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3712
#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() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll sum = 0;
  ll cur = a[0];
  for(int i=1;i<n;i++) {
    if(cur <= a[i]) {
      cur = a[i];
    } else {
      sum += cur - a[i];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[100005];
signed main() {
    int N;
    cin >> N;
    vector<int>a(N);
    int X = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(i == 0) {
            X = a[i];
        }
        else {
            X = X ^ a[i];
        }
    }
    for(int i = 0; i < N; i++) {
        if(i != 0) {
            cout << " ";
        }
        int ans = X ^ a[i];
        cout << ans;
    }
    cout << endl;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;
ll gcd(ll a, ll b){
    if(b == 0)return a;
    return gcd(b,a%b);
}

ll lcm(ll c, ll d){
    ll g = gcd(c,d);
    ll l = c/g*d;//最小公倍数
    return l;
}
int main() {
  int n;
  ll m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i], a[i] /= 2;

  set<int> st;
  auto calc = [&](ll x){
    int cnt = 0;
    while (x % 2 == 0) {
      x /= 2;
      cnt++;
    }
    st.insert(cnt);
    return (int)st.size() == 1;
  };
  int ok = 1;
  for (int i = 0; i < n; i++) {
    ok &= calc(a[i]);
  }
  if (!ok) {
    cout << 0 << endl;
    return 0;
  }
  ll lc = 1;
  for (int i = 0; i < n; i++) {
    lc = lcm(lc, a[i]);
    if (lc > m) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << (m / lc + 1) / 2 << endl;
  return 0;
} 

Measured memory_bytes: 4052
import sys
from collections import defaultdict
from bisect import bisect_right as bi_r

def sieve_of_eratosthenes(n=10 ** 6):
  if n == 1: return set()
  sieve = set(range(2, n + 1))
  for p in sieve_of_eratosthenes(int(n ** 0.5)):
    sieve -= set(range(p * 2, n + 1, p))
  return sieve

prime_numbers = sieve_of_eratosthenes()
soted_prime_numbers = sorted(prime_numbers)

def is_prime(n): return n in prime_numbers

def prime_factorize(n):
  res = defaultdict(int)
  if n < 2: return res
  for p in soted_prime_numbers[:bi_r(soted_prime_numbers, int(n ** 0.5))]:
    while n % p == 0:
      res[p] += 1
      n //= p
    if n == 1:
      return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = defaultdict(int)
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items():
      res[p] += c
  return res

MOD = 10 ** 9 + 7

n = int(sys.stdin.readline().rstrip())

def main():
    res = 1
    for c in prime_factorize_factorial(n).values():
        res *= c + 1; res %= MOD
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 131548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<double> p(n);
    rep(i, n) cin >> p[i];
    vector<double> dp(n + 1, 0);
    dp[0] = 1;
    rep(i, n) {
        rreps(j, 1, n + 1) {
            dp[j] = dp[j] * (1 - p[i]) + dp[j - 1] * p[i];
        }
        dp[0] = dp[0] * (1 - p[i]);
    }
    double ans = 0;
    reps(i, (n + 1) / 2, n + 1) {
        ans += dp[i];
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
class point2d {
public:
	double x, y;
	point2d() : x(0), y(0) {};
	point2d(double x_, double y_) : x(x_), y(y_) {};
	bool operator==(const point2d& p) { return x == p.x && y == p.y; }
	bool operator!=(const point2d& p) { return x != p.x || y != p.y; }
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d& operator*=(const double v) { x *= v; y *= v; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	point2d operator*(const double v) const { return point2d(*this) *= v; }
	double norm() const { return x * x + y * y; }
	double abs() const { return std::sqrt(x * x + y * y); }
	double dot(const point2d& p) const { return x * p.x + y * p.y; }
	double cross(const point2d& p) const { return x * p.y - y * p.x; }
	int ccw(const point2d& p1, const point2d& p2) {
		// RETURNS: P0 -> P1 -> P2 IS COLLINEAR --> ((P0, P1, P2) IS CENTER --> (2, -2, 0)), COUNTER-CLOCKWISE --> 1, CLOCKWISE --> -1
		point2d pr1 = p1 - point2d(*this);
		point2d pr2 = p2 - point2d(*this);
		if (pr1.cross(pr2) != 0) return pr1.cross(pr2) > 0 ? 1 : -1;
		if (pr1.dot(pr2) < 0) return 2;
		return pr1.norm() < pr2.norm() ? -2 : 0;
	}
};
double area(point2d p1, point2d p2, point2d p3) {
	return (p1.cross(p2) + p2.cross(p3) + p3.cross(p1)) * 0.5;
}
int main() {
	int R, N;
	point2d P;
	cin >> R >> P.x >> P.y >> N;
	vector<point2d> V(N + 1);
	V[0] = point2d(0, R);
	vector<int> p(N);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
		sum += p[i];
		V[i + 1] = point2d(sin(sum * 0.02 * acos(-1.0)), cos(sum * 0.02 * acos(-1.0))) * R;
	}
	for (int i = 0; i < N; ++i) {
		if (i) cout << ' ';
		double da = area(point2d(), P, V[i]);
		double db = area(point2d(), P, V[i + 1]);
		double dc = R * R * acos(-1.0) * p[i] / 100;
		cout << (int)((dc - da + db) / dc * 100);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		String a=sc.next();
		for(int i=0;i<s.length();i++) {
			System.out.print(s.charAt(i));
			System.out.print(a.charAt(i));
		}
		System.out.println();

	}

}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	char c;
	cin >> c;

	char bo[] = {'a', 'e', 'i', 'o', 'u'};

	for(int i=0; i<5; i++){
		if(bo[i] == c){
			puts("vowel");
			return 0;
		}
	}
	puts("consonant");
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;


    int main(){
      int n,m;
      cin>>n>>m;
      priority_queue<ll>pq;
      rep(i,n){
          int a;
          cin>>a;
          pq.push(a);
      }
      rep(i,m){
          ll v = pq.top();
          pq.pop();
          v /= 2;
          pq.push(v);
      }
      ll res = 0;
      while(!pq.empty()){
          res += pq.top();
          pq.pop();
      }
      cout<<res<<endl;
    }


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
  int p;
  cin >> p;
  int days, leftover;
  cin >> days >> leftover;
  int numchoco = 0;
  for (int i=0; i<p; i++){
    int ate;
    cin >> ate;
    int mult = 0;
    while (true){
      if (ate*mult+1 <= days){
        numchoco += 1;

      }else{
        break;
      }
      mult++;
    }
  }
  cout << numchoco+leftover;
}

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

using namespace std;
using ll = long long;
using ii = pair < int , int >;
using vi3 = pair < int , ii >;
using vi = vector < int >;
using vii = vector < ii >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;

main(){
    scanf("%d" , &n);
    if(n == 3 || n == 5 || n == 7)printf("YES\n");
    else printf("NO\n");
    return 0;
}





Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int A, B;
    cin >> A >> B;

    cout << max(max(A + B, A - B), A * B) << "\n";
    return 0;
}

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


int main() {
    int n; cin >> n;
    int cnt = 0, ans = -1;
    for(int i=0; i<n; i++) {
        int x, y; cin >> x >> y;
        if(x == y) cnt++;
        else {
            ans = max(cnt, ans);
            cnt = 0;
        }
    }
    cout << ((ans >= 3 || cnt >= 3) ? "Yes" : "No") << endl;
}

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

using namespace std;

#define MAX 10000
#define NIL -1

struct Node { int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if(u == NIL ){
        return;
    }
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if( T[u].left != NIL){
        h1 = setHeight(T[u].left) + 1;
    }
    if( T[u].right != NIL){
        h2 = setHeight(T[u].right) + 1;
    }
    return H[u] = ( h1 > h2 ? h1 : h2);
}

int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    if( T[T[u].parent].left != u && T[T[u].parent].left != NIL){
        return T[T[u].parent].left;
    }
    if( T[T[u].parent].right != u && T[T[u].parent].right != NIL){
        return T[T[u].parent].right;
    }
    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if( T[u].left != NIL) deg++;
    if( T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if(T[u].parent == NIL){
        printf("root\n");
    }else if (T[u].left == NIL && T[u].right == NIL)
    {
        printf("leaf\n");
    }else
    {
        printf("internal node\n");
    }
}

int main(){
    int v, l, r, root = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for (int i = 0; i < n; i++)
    {
        cin >> v;
        cin >> l;
        cin >> r;
        T[v].left = l;
        T[v].right = r;
        if( l != NIL ) T[l].parent = v;
        if( r != NIL ) T[r].parent = v;
    }
    
    for( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;
    
    setDepth(root, 0);
    setHeight(root);

    for(int i = 0; i < n; i++) print(i);

    return 0;
}


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

int main() {
	int n; 
	cin>>n;
	vector <int> V(n);
	vector <int> Vsorted(n);
	for (auto itr = V.begin(), end=V.end(); itr != end; itr++ ) {
		cin>>*itr;
	}
	for ( int i=0; i < n; i++ ) Vsorted[i] = V[i];
	sort(Vsorted.begin(),Vsorted.end());

	int preMedian_for = Vsorted[n/2-1];
	int preMedian_back = Vsorted[n/2];
	
	for ( int i=0; i<n; i++) {
		if(V[i]<preMedian_back) cout << preMedian_back<< "\n";
		else if ( V[i] > preMedian_for) cout << preMedian_for << "\n";
		else if ( V[i] == preMedian_back) cout << preMedian_for<< "\n";
		else if ( V[i] == preMedian_for) cout << preMedian_for<< "\n";
	}

	return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>

#define MAX_N 2000001
#define MAX_K 10001

void countingSort(int,int*);

int main(){
  int n,i;
  static int A[MAX_N];
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  countingSort(n,A);
  return 0;
}

void countingSort(int n,int *A){
  int i,C[MAX_K] = {0};
  static int B[MAX_N];
  for(i = 0 ; i < n ; i++){ C[A[i]]++; }
  for(i = 1 ; i < MAX_K ; i++){ C[i] += C[i-1]; }
  for(i = n-1 ; i >= 0 ; i--){
    B[C[A[i]]] = A[i]; C[A[i]]--;
  }
  for(i = 0 ; i < n ; i++){
    printf("%d%c",B[i+1],i != n-1 ? ' ' : '\n');
  }
}

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

int main(){
  int n,m; cin>>n>>m;
  int sum=0;
  vector<int> a(n);
  for(int i=0; i<n; ++i){cin>>a[i]; sum+=a[i];}

  if(sum%(4*m)==0)sum/=(4*m);
  else sum=(sum+4*m)/(4*m);

  int ch=0;
  for(int i=0; i<n; ++i)if(a[i]>=sum)++ch;

  if(ch>=m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import math

n = int(input())

a = list(map(float, input().split()))
b = list(map(float, input().split()))

d1 = [0 for i in range(n)]
d2 = [0 for i in range(n)]
d3 = [0 for i in range(n)]

for i in range(n):
    d1[i] = abs(a[i] - b[i])
    d2[i] = abs(a[i] - b[i])**2
    d3[i] = abs(a[i] - b[i])**3

print(sum(d1))
print(math.sqrt(sum(d2)))
print(sum(d3)**(1/3))
print(max(d1))


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

int main() {
  vector<char> alp(26);
  alp={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
       'q','r','s','t','u','v','w','x','y','z'};
  char s;cin>>s;
  rep(i,25) {
    if (s==alp[i]) cout<<alp[i+1];
  }
  return 0;
}

Measured memory_bytes: 256
// 一度でも下の段に降りたら二度と戻れない -> つまりそういうこと
package main
import "fmt"
func main(){
	var N int
	fmt.Scan(&N)
	A1, A2 := make([]int, N), make([]int, N)
	for i:=0; i<N;i++{
		fmt.Scan(&A1[i])
	}
	for i:=0; i<N; i++{
		fmt.Scan(&A2[i])
	}
	Ruiseki1, Ruiseki2 := make([]int, N), make([]int ,N)
	Ruiseki1[0] = A1[0]
	Ruiseki2[N-1] = A2[N-1]
	for i:=1; i<N; i++{
		Ruiseki1[i] = A1[i]+Ruiseki1[i-1]
		Ruiseki2[N-i-1] = A2[N-i-1] + Ruiseki2[N-i]
	}
	ans := 0
	for i:=0; i<N; i++{
		ans = max(ans, Ruiseki1[i]+Ruiseki2[i])
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a<b{
		return a
	}
	return b
}

func max(a, b int) int {
	if a<b{
		return b
	}
	return a
}

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

void Main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b + 2 - 1) / 2 << endl;
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long A,B,N;
    cin >> A >> B >> N;
    long long X = 0;
    if(B > N) {
        X += N;
    }
    else if(B <= N) {
        X += B-1;
    }
    cout << ((A*X)/B)-(A*(X/B)) << endl;
}


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

using namespace std;

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

    cin >> a >> b >> c >> d;

    long long ans;

    long long n,m,x,y;

    n = a*c;
    m = a*d;
    x = b*c;
    y = b*d;

    ans = max(n,m);
    ans = max(ans,x);
    ans = max(ans,y);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
vector<ll> A;
ll solve(int l, int r, int cl, int cr) {
	if (r - l == 1) return 0;
	ll ret = LLONG_MAX;
	for (int m = l + 1; m < r; ++m) {
		ret = min(ret, solve(l, m, cl, cl + cr) + solve(m, r, cl + cr, cr) + A[m] * (cl + cr));
	}
	return ret;
}
int main() {
	int n;
	scanf("%d", &n);
	A.resize(n);
	for (int i = 0; i < n; ++i) scanf("%lld", &A[i]);
	ll ans = solve(0, n - 1, 1, 1) + A[0] + A[n - 1];
	printf("%lld\n", ans);
}


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

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    
    int ans(0);
    for(int i=0;i<n;i++){
        int a;  cin >> a;
        for(int j=0;j<d;j++){
            if(j*a+1<=d){
                ans++;
            }
        }
    }
    ans += x;
    
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> judge(N);
  for(int i = 0; i < N; i++) cin >> judge.at(i);
  int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
  for(int i = 0; i < N; i++) {
    if(judge.at(i) == "AC") c0++;
    if(judge.at(i) == "WA") c1++;
    if(judge.at(i) == "TLE") c2++;
    if(judge.at(i) == "RE") c3++;
  }
  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;
}

Measured memory_bytes: 6348
#include<iostream>
#include<string>
using namespace std;
int main(){
  char s;
  int n,a,b;
  cin >> n >> a >> b;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=='a'){
      if(a>0) a--;
      else if(b>0) b--;
      else{
	cout << "No" << endl;
	continue;
      }
      cout << "Yes" << endl;
    }
    else if(s=='b'){
      if(b>0){
	b--;
	cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }
 return 0;
}


Measured memory_bytes: 640
from bisect import bisect_right

N, A, B = map(int, input().split())
v = [int(i) for i in input().split()]
v.sort(reverse=True)

def comb(n, r) :
    if n == 0 or r == 0 :
        return 0
    ret = 1
    for i in range(1, n+1) :
        ret *= i
    for i in range(1, r+1) :
        ret //= i
    for i in range(1, n-r+1) :
        ret //= i
    return ret

print(sum(v[:A])/A)

if v[A-1] != v[0] :
    ret = 0
    a = v.count(v[A-1])
    r = v[:A].count(v[A-1])
    print(comb(a, r))

else :
    a = v.count(v[A-1])
    ret = 0
    for i in range(A, min(B, a) + 1) :
        ret += comb(a, i)
    print(ret)

Measured memory_bytes: 38896
alpha = [chr(i) for i in range(65, 65+26)]
a_change = []
n = int(input())
s = input()
for i in range(len(s)):
    moji = s[i]
    ind_moji = alpha.index(moji)
    a_change.append(alpha[(ind_moji+n) % 26])
print("".join(a_change))


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

function main()
  R, G, B, N = readline() |> split |> parseArray

  c = 0
  for i in 0:div(N, R),j in 0:div(N - R * i, G)
    (N - R * i - G * j) % B != 0 && continue
    c += 1
  end
  println(c)
end

main()

Measured memory_bytes: 111620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, vis[100005], a, b, c;
bool flag;
vector<ll> adj[100005];

void dfs (ll cur) {
	for(auto nxt : adj[cur]) {
		if(!vis[nxt]) {vis[nxt] = 3-vis[cur]; dfs(nxt);}
		else if(vis[nxt] == vis[cur]) flag = true;
	}
}

int main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=m;i++) {
		ll A, B;
		scanf("%lld%lld",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	for(int i=1;i<=n;i++) {
		if(vis[i]) continue;
		if(adj[i].size() == 0) c++;
		else {
			flag = false; vis[i] = 1;
			dfs(i);
			flag ? b++ : a++;
		}
	}
	printf("%lld\n",a*a*2+a*b*2+b*b+(n*n-(n-c)*(n-c)));
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

void solve(){
	ll n,x,m;
	cin>>n>>x>>m;
	ll LOG=log2(n)+1;
	vector<vector<ll>>dp(LOG+1,vector<ll>(m,-1)),sum(LOG+1,vector<ll>(m+1));
	for(ll i=0;i<m;++i){
		dp[0][i]=(i*i)%m;
		sum[0][i]=i;
	}
	rep(i,LOG){
		rep(j,m){
			if(dp[i][j]==-1){
				dp[i+1][j]=dp[i][j];
				continue;
			}
			dp[i+1][j]=dp[i][dp[i][j]];
			sum[i+1][j]=sum[i][j]+sum[i][dp[i][j]];
		}
	}
	ll ans=0;
	int cur=x;
	for(int i=LOG;i>=0;--i){
		if(n&(1LL<<i)){
			ans+=sum[i][cur];
			cur=dp[i][cur];
		}
	}
	cout<<ans;
}


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


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

#define INF 1E18



int main(){
    string s,t;
    cin>>s>>t;

    bool flag  = true;
    rep(i,s.length()){
        if(s[i] != t[i]){
            flag = false;
            break;
        }  
    }

    if(flag) cout<< "Yes" << endl;
    else cout<< "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)

char G[8][8];
bool V[8][8];

void activate(int x, int y){
  G[y][x] = '0';
  V[y][x] = true;
  static const int dx[4] = {1, 0, -1, 0};
  static const int dy[4] = {0, -1, 0, 1};
  int nx, ny;

  rep(d, 3) rep(r, 4){
    nx = x + dx[r]*(d+1);
    ny = y + dy[r]*(d+1);
    if ( nx < 0 || nx >= 8 ) continue;
    if ( ny < 0 || ny >= 8 ) continue;
    if ( !V[ny][nx] && G[ny][nx] == '1' ) activate(nx, ny);
  }
}
main(){

  int n; cin >> n;
  int sx, sy;
  rep(tcase, n){
    rep(y, 8) rep(x, 8) cin >> G[y][x];
    rep(y, 8) rep(x, 8) V[y][x] = false;
    cin >> sx >> sy; 
    sx--; sy--;
    if ( G[sy][sx] == '1' ) activate(sx, sy);
    cout << "Data " << tcase+1 << ":" << endl;
    rep(y, 8){
      rep(x, 8) cout << G[y][x];
      cout << endl;
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s;
    cin >> s;
    if(s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k;
	cin >> n >> m;
	vector<string> s(n);
	vector<bool> ux(n, false), uy(m, false);
	for (i = 0; i < n; i++) {
		cin >> s[i];
		for (j = 0; j < m; j++) {
			if (s[i][j] == '#') ux[i] = true, uy[j] = true;
		}
	}

	for (i = 0; i < n; i++) {
		if (!ux[i]) continue;
		for (j = 0; j < m; j++) {
			if (uy[j]) cout << s[i][j];
		}
		cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,k,z,x,c;
int main()
{
   cin>>n>>k;
   for(int i=1;i<=n;i++){
    cin>>x;
    z+=x;
    if(z<=k)c++;
   }
   cout<<c+1<<endl;
}


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

using namespace std;

//typedef
//------------------------------------------
template<class T> using V = vector<T>;
using VI = V<int>;
using VVI = V<VI>;
using VS = V<string>;
using LL = long long;
using ULL = unsigned long long;
using VLL = V<LL>;
using VVLL = V<VLL>;
template<class T, class U> using P = pair<T, U>;
using PII = P<int, int>;
using PLL = P<LL, LL>;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

template<class T> inline T updmax(T &a, T b){return a = max(a,b);}
template<class T> inline T updmin(T &a, T b){return a = min(a,b);}

const int MOD = 1000000007;


int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
def read_ints():
    return [int(c) for c in input().split()]


def dsum(i):
    return sum(int(c) for c in str(i))


def main():
    n = int(input())

    ans = 9999999
    for a in range(1, n):
        b = n - a
        ans = min(ans, dsum(a) + dsum(b))

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 44776
N, X, Y = map(int, input().split())

#直線グラフの作成
g = [[]  for i in range(N)]
for i in range(N):
    u = i
    v = i + 1
    if v < N:
        g[u].append(v)
        g[v].append(u)

#辺を一つたす
g[X - 1].append(Y - 1)
g[Y - 1].append(X - 1)

from collections import deque
#dis = iとjの最短距離（表N＊Nの表）
dis = [[float('Inf')] * N for _ in range(N)]
#count = 最短距離の頂点組み合わせ数
count = [0] * (N - 1)

def bfs(i):#頂点iについてのbfs
    d = [False] * N #行ってないとこはFalse,いったとこはTrue
    que = deque()
    #for j in g[i]:
    que.append(i)#最初にi(最初の頂点)を追加
    d[i] = True#いったとこはTrue
    dis[i][i] = 0#自分は距離0
    #pre = i
    while que:
        p = que.popleft()

        for k in g[p]:#グラフの中にある間は
            if d[k]:#kがいったことあったらスルー
                continue
            else:
                d[k] = True#kがいったことなかったら、遷移先（k）にプラス１する
                que.append(k)
                dis[i][k] = dis[i][p] + 1
                #dis[k][i] = dis[i][p] + 1
                count[dis[i][k] - 1] += 1#indexは-１になる。
                #count[dis[k][i] - 1] += 1
        #pre = p

for i in range(N):#すべての頂点を起点にしてBFS
    bfs(i)

for i in range(N - 1):
    print(count[i] // 2)#（i,j）についてはi起点とj起点で二回加えているので、半分にする

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

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

    long long a[n+1];
    long long b[n+1];
    for(long long i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = 0;
    }

    
    long long count = 0;

    for(long long i = n; i >= 1; i--){
        long long j = i;
        long long sum = 0;
        while(j <= n){
            sum = sum + b[j];
            j = j + i;
        }
        
        if((sum+a[i])%2 == 1){
            b[i] = 1;
            count++;
        }
    
    }

    printf("%lld\n", count);

    if(count >= 1){
        for(long long i = n; i >= 1; i--){
            if(b[i] == 1){
                printf("%lld ", i);
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
       cin>>arr[i];
    ll ans=0;
    for(ll i=0;i<n-1;i++)
    {
        if(arr[i]>arr[i+1])
        {
            ans+=abs(arr[i]-arr[i+1]);
            arr[i+1]=arr[i];
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5152
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

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 long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

vector<bool> isprime;

void eratos(ll n) {
	isprime.resize(n + 1);
	for (ll i = 0; i <= n; i++) {
		isprime[i] = true;
	}
	isprime[0] = false;
	isprime[1] = false;
	for (ll i = 2; i * i <= n; i++) {
		if (isprime[i]) {
			ll j = i + i;
			while (j <= n) {
				isprime[j] = false;
				j = j + i;
			}
		}
	}
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	eratos(10000000);
	vector<ll> pr;
	for (ll i = 1; i <= 10000000; i++) {
		if (isprime[i]) pr.push_back(i);
	}
	while (1) {
		ll n; scanf("%lld", &n);
		if (n == 0) break;
		ll res = upper_bound(pr.begin(), pr.end(), n * 2) - upper_bound(pr.begin(), pr.end(), n);
		printf("%lld\n", res);
	}
	return 0;
}


Measured memory_bytes: 12176
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

X = I()

count = 1
eps = 10**(-6)
now = [0,1]
while True:
    count += 1
    now[0] -= math.sin(math.radians((count-1)*X))
    now[1] += math.cos(math.radians((count-1)*X))
    if abs(now[0]) < eps and abs(now[1]) < eps:
        print(count)
        exit()

Measured memory_bytes: 66044
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 400 + 20 , mod = 1e9 + 7 ;
int n , c , a[N] , b[N] ;
int pw[N][N] , pp[N][N] , C[N][N] ;
int dp[N][N] ;

inline int sum (int a , int b) {
	int res = a + b ;
	if (res >= mod) res -= mod ;
	return res ;
}

inline void pre () {
	for (int i = 0 ; i < N ; i ++) {
		C[i][0] = C[i][i] = 1 ;
		for (int j = 1 ; j < i ; j ++)
			C[i][j] = sum(C[i - 1][j] , C[i - 1][j - 1]) ;
	}

	for (int i = 0 ; i < N ; i ++) {
		for (int j = 1 ; j < N ; j ++) {
			if (!i) pw[i][j] = 1 ;
			else pw[i][j] = 1ll * pw[i - 1][j] * j % mod ;

			pp[i][j] = sum(pp[i][j - 1] , pw[i][j]) ;
		}
	}
}

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

	pre() ;

	cin >> n >> c ;
	for (int i = 0 ; i < n ; i ++) cin >> a[i] ;
	for (int i = 0 ; i < n ; i ++) cin >> b[i] ;

	dp[0][0] = 1 ;
	for (int i = 0 ; i < n ; i ++) {
		for (int s1 = 0 ; s1 <= c ; s1 ++) {
			for (int s2 = s1 ; s2 <= c ; s2 ++) {
				dp[i + 1][s2] = sum(dp[i + 1][s2] , 1ll * dp[i][s1] * sum(pp[s2 - s1][b[i]] , mod - pp[s2 - s1][a[i] - 1]) % mod) ;
			}
		}
	}

	cout << dp[n][c] << '\n' ;
}


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

struct StNumCnt
{
  StNumCnt() :
    m_nNum(0), m_nCnt(0)
  { }

  int m_nNum;
  int m_nCnt;
};

void fnInput(vector<int>& rvnNum)
{
  int nSize;
  cin >> nSize;
  rvnNum.resize(nSize);

  for (int& rnElm : rvnNum)
    cin >> rnElm;
}

int fnTogether(const vector<int>& cnrvnNum)
{
  map<int, int> mpNumCnt;
  for (int nNum : cnrvnNum)
  {
    mpNumCnt[nNum]++;
    mpNumCnt[nNum - 1]++;
    mpNumCnt[nNum + 1]++;
  }

  int nMaxCnt = 0;
  for (pair<const int, int> PNumCnt : mpNumCnt)
    nMaxCnt = max(PNumCnt.second, nMaxCnt);

  return nMaxCnt;
}

int main()
{
  vector<int> vnNum;

  fnInput(vnNum);
  cout << fnTogether(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vector<vi> a(n, vi(n));
	rep(i, n) rep(j, n) if(i != j) cin >> a[i][j];
	
	vector<vector<ll>> dp(n, vector<ll>(n, 1e18));
	vector<vector<ll>> ls(n + 1, vector<ll>(n));
	vector<vector<ll>> rs(n + 1, vector<ll>(n));
	
	rep(i, n) rep(j, n) rs[j + 1][i] = rs[j][i] + a[i][j];
	rep(i, n) rep(j, n) ls[j + 1][i] = ls[j][i] + a[j][i];
	
	ll ans = 1e18;
	dp[0][0] = 0;
	rep(j, n) rep(i, j + 1){
		vector<ll> sum(n + 1);
		for(int k = n - 1; k > j; k--) sum[k] = sum[k + 1] + rs[j][k] - rs[i][k];
		ll tmp = 0;
		for(int k = j + 1; k < n; k++){
			dp[j][k] = min(dp[j][k], dp[i][j] + tmp + sum[k]);
			tmp += ls[k][k] - ls[j][k];
		}		
		ans = min(ans, dp[i][j] + tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7296
use std::io::stdin;

fn read_int() -> i32 {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().parse().unwrap()
}

fn main () {
    let rating = read_int();
    let ans = if rating < 1200 { "ABC" } else if rating < 2800 { "ARC" } else { "AGC" };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define INT_MAX INF
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
int main() {
	int A,B,C;
	cin>>A>>B>>C;
	cout<<A+B+C-max({A,B,C})<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')cout<<"Yes";
	else cout<<"No";
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll V[20], C[20];
    cin >> N;
    rep(i,0,N) cin >> V[i];
    rep(i,0,N) cin >> C[i];
    ll ans = 0;
    rep(bit,0,(1LL<<N)){
        ll tt = 0;
        rep(i,0,N){
            if((bit>>i) & 1) tt += V[i] - C[i];
        }
        ans = max(ans, tt);
    }
    print(ans);

}

Measured memory_bytes: 256