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

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		String s=sc.next(); //入力された文字列
		
		//YAKIが最初に出現するインデックスが0かどうか確認
		if(s.indexOf("YAKI")==0) System.out.println("Yes");
		else System.out.println("No");
	}
} 

Measured memory_bytes: 23508
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    Rep (i, S.size()-1) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long

int main() {
  int a,b;
  cin >>a>>b;
  
  cout << (a*b%2==1?"Yes":"No");
}



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;

#define MAX_N 202020

typedef long long int64;

const int64 mod = 1e9 + 7;

inline int64 modPow(int64 x, int64 n)
{
  if(n == 0) return 1;
  int64 ret = modPow(x, n/2);
  (ret *= ret) %= mod;
  if(n & 1) (ret *= x) %= mod;
  return ret;
}

inline int64 modInv(int64 a)
{
  return modPow(a, mod - 2);
}

inline int64 modFact(int n)
{
  int64 ret = 1;
  while(n > 1) (ret *= n--) %= mod;
  return ret;
}

inline int64 modComb(int64 n, int64 r)
{
  static int64 fact[MAX_N], invfact[MAX_N];
  if(fact[0] == 0) {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < MAX_N; i++) {
      fact[i] = fact[i-1] * i % mod;
      invfact[i] = modInv(fact[i]);
    }
  }
  if(r < 0 || n < r) return 0;
  return fact[n] * invfact[r] % mod * invfact[n-r] % mod;
}


signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;
  if(N == M) {
    cout << modFact(N)*modFact(M)%mod*2%mod << endl;
    return 0;
  }
  if(abs(N-M) == 1) {
    cout << modFact(N)*modFact(M)%mod << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;


  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#EDPC D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,W = LI()
wv = [LI() for _ in range(n)]
dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    w,v = wv[i]
    for j in range(w):
        dp[i+1][j] = dp[i][j]
    for j in range(W+1):
        if w + j > W:
            break
        dp[i+1][w+j] = max(dp[i][w+j],dp[i][j] + v)
    #print(dp)
print(max(dp[-1]))

Measured memory_bytes: 120668
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
   /* ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        sum+=i;
    }
    cout<<sum;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
int main(void) {
  int a, b;
  int ans=0;
  cin>>a>>b;
  for(int i=a; i<=b; i++) {
    string s=to_string(i);
    if(s[0]==s[4] and s[1]==s[3])
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

S=input()
T=input()
lenS=len(S)

NX=[[-1]*26 for _ in range(len(S))]

for i in range(len(S)*2-1)[::-1]:
    idx = i%lenS
    idx2 = (i+1)%lenS
    for j in range(26):
        if NX[idx2][j] != -1:
            NX[idx][j] = NX[idx2][j] + 1
    NX[idx][ord(S[idx2])%26] = 1

# for lis in NX:
#     print(lis)
# for c in S:
#     print(ord(c)%26, end=" ")
# print("")

res = 0
prev=lenS-1
for c in T:
    v = NX[prev][ord(c)%26]
    if v == -1:
        print(-1)
        exit()
    else:
        res += v
        prev = (prev + v)%lenS

print(res)


Measured memory_bytes: 71772
def main7():
    str = input('');
    buf = str.split();
    num = [];
    for i in range(4):
        num.insert(i,int(buf[i]));
    if num[0] - num[2] <= num[3] and num[2] - num[0] <= num[3]:
        print("Yes");
    elif num[0] - num[1] <= num[3] and num[1] - num[2] <= num[3] and num[0] - num[1] >= 0:
        print("Yes")
    elif num[1] - num[0] <= num[3] and num[2] - num[1] <= num[3] and num[2] - num[1] >= 0:
        print("Yes")
    else:
        print("No")




if __name__ == '__main__':
    main7()

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <queue>

#define INF 1e9
using namespace std;

class DP{
public:
	double cost;
	unsigned char cur, sp, prev;
	
	DP(){}
	DP(double c, int cu, int s, int pr){
		cost = c;cur=cu;sp=s;prev=pr;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};
int n,m,s,go;

char visit[31][31][31];
int g[31][31];
int lim[31][31];

main(){
	int i,j,d,c,x,y;
	while(cin>>n>>m,n){
		priority_queue<DP> dp;
		memset(g, 0, sizeof(g));
		memset(visit, 0, sizeof(visit));
		cin>>s>>go;
		
		for(i=1;i<=m;i++){
			cin>>x>>y>>d>>c;
			g[x][y]=g[y][x]=d;
			lim[x][y]=lim[y][x] = c;
		}
	
		DP T,S;
		dp.push(DP(0,s,0,0));
		while(!dp.empty()){
			S = dp.top();
			dp.pop();
			if(visit[S.cur][S.sp][S.prev]) continue;
			if(S.cur == go && S.sp == 1) break;
			for(i=1;i<=n;i++){
				if(!g[S.cur][i]) continue;
				for(j=S.sp-1;j<=S.sp+1;j++){
					if(lim[S.cur][i] < j || j < 1 || i == S.prev || visit[i][j][S.cur]) continue;
					T.cost = S.cost + g[S.cur][i] / (double)j;
					T.cur = i;
					T.sp = j;
					T.prev = S.cur;
					dp.push(T);
				}
			}
			visit[S.cur][S.sp][S.prev] = 1;
		}
		if(S.cur == go && S.sp == 1) printf("%.4lf\n", S.cost);
		else cout << "unreachable" << endl;
	}
}

Measured memory_bytes: 5092
from heapq import heappush, heappop
V, E, r = map(int, raw_input().split())
g = [[] for i in xrange(V)]
for i in xrange(E):
    s, t, d = map(int, raw_input().split())
    g[s].append((t, d))

INF = 10**10
dist = [INF]*V
que = [(0,r)]
dist[r] = 0
while que:
    c, v = heappop(que)
    if dist[v] < c:
        continue
    for t, cost in g[v]:
        if dist[v] + cost < dist[t]:
            dist[t] = dist[v] + cost
            heappush(que, (dist[t], t))
for i in xrange(V):
    print dist[i] if dist[i]<INF else "INF"

Measured memory_bytes: 87908
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


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

int main() {
	LL x, y; cin >> x >> y;
	bitset<32> i = x, j = x, k = x, z = y;
	i &= z; j |= z; k ^= z;
	cout << i << endl << j << endl << k << endl;
}


Measured memory_bytes: 3164
N = int(input())
result = ""

while N > 26:
    remainder = N % 26
    quotient = N // 26

    if (remainder == 0):
        remainder = 26
        quotient -= 1

    result += chr(remainder + 64)
    N = quotient

result += chr(N + 64)

print(result.lower()[::-1])

Measured memory_bytes: 61652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, n) {
        cin >> q[i];
    }
    vector<bool> flag(n);
    int np = 0;
    int nq = 0;
    rep(i, n) {
        int v = p[i];
        int num = 0;
        int x = 1;
        rep(j, n) {
            if (!flag[j] && (j+1)<v) num++;
            if (j>i) x *= (j-i);
        }
        np += num*x;
        flag[v-1] = true;
    }
    rep(i, n) flag[i] = false;
    rep(i, n) {
        int v = q[i];
        int num = 0;
        int x = 1;
        rep(j, n) {
            if (!flag[j] && (j+1)<v) num++;
            if (j>i) x *= (j-i);
        }
        nq += num*x;
        flag[v-1] = true;
    }
    int ans = abs(np-nq);
    
    
    //cout << np << " " << nq << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k)                \
    for (int i = (n); i >= (k); i--) \
        ;
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template <class T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &elemnt : v)
        is >> elemnt;
    return is;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p)
{
    is >> p.first >> p.second;
    return is;
}
template <class T>
vector<T> make_vector(size_t a) { return vector<T>(a); }
template <class T, class... Ts>
auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...)); }
const int inf = 6e18;
const int mod = 1e9 + 7;

signed main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int ans = 0;
    vector<int> count(21, 0);
    int right = -1;
    for (int i = 0; i < N; i++)
    {
        while (true)
        {
            if (right + 1 == N)
                break;
            bool check = true;
            for (int j = 0; j < 21; j++)
            {
                if ((A[right + 1] & (1 << j)) && count[j] == 1)
                    check = false;
            }
            if (!check)
                break;
            for (int j = 0; j < 21; j++)
            {
                if (A[right + 1] & (1 << j))
                    count[j] = 1;
            }
            ++right;
        }
        ans += right - i + 1;
        for (int j = 0; j < 21; j++)
        {
            if ((A[i] & (1 << j)))
                count[j] = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  set<int> st;
  int n; cin>>n;
  repi(i,0,n){
    int t;
    cin >>t;
    st.insert(t);
  }
  if(st.size()==n){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>

static  int N =1000;

int max(int a,int b){
  if(a>b) return a;
  else return b;
}

int lcs(char x[],char y[]){
  int c[N+1][N+1];
  int m=strlen(x);
  int n=strlen(y);
  int maxl=0,i,j;

  
  for(i=0;i<=m;i++) c[i][0]=0;
  for(j=1;j<=n;j++) c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else{
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main(){
  char s1[1500],s2[1500];
  int n,i;
 scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%s%s",s1,s2);
    printf("%d\n",lcs(s1,s2));
  }
 return 0;
}



Measured memory_bytes: 5716
x = gets.to_i
if x == 1
  puts 1
  exit
end

s = Math.sqrt(x).floor
max = 0

2.upto(s) do |i|
  j = 1
  while x >= i**j
    max = i**j if i**j > max
    j += 1
  end
end
puts max


Measured memory_bytes: 1788
(let ((a (read))
    (b (read))
    (c (read))
    (k (read))
    (ans "No"))
    (loop for i below k do
        (if (>= a b)
            (setq b (* b 2))
            (if (>= b c)
                (setq c (* c 2))
            )
        )
        (if (and (< a b) (< b c))
            (progn
                (setq ans "Yes")
                (return)
            )
        )
    )
    (princ ans)
)

Measured memory_bytes: 23608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    rep(i, m) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    for (int i = 0; i < 10000; i++) {
        string x = to_string(i);
        if (sz(x) != n) continue;
        bool ok = 1;
        rep(i, m) {
            ok &= (x[s[i]] == (char)(c[i] + '0'));
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
comb = Combination(100010)
n,k = inpl()
a = inpl()
a.sort()
res = 0
for i in range(n-k+1):
    cc = comb(n-i-1,k-1)
    res += cc*(-a[i]+a[n-i-1])
    res %= mod
print(res)

Measured memory_bytes: 89800
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;
 
template<int mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x(x%mod) {}
    mint(std::string s) {
        long long z = 0;
        REP(i, s.size()) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& n) {
        return os << n.x;
    }
    bool operator==(const mint a) const {
        return this->x == a.x;
    }
};
 
int main() {
    int n; cin >> n;
    map<int, int> mp;
    mint<MOD> ans = 1;
    mp[-1] = 3;
    REP(i, n) {
        int a; cin >> a;
        if (mp.find(a - 1) == mp.end() || mp[a - 1] <= 0) {
            puts("0");
            return 0;
        }
        ans *= mp[a - 1]--;
        mp[a]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int x, a, b, c;

int main()
{
    cin >> a >> b >> c >> x;
    int ans = 0;
    rep(v1, a + 1) rep(v2, b + 1) rep(v3, c + 1){
        if(500 * v1 + 100 * v2 + 50 * v3 == x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    children = [[] for _ in range(n)]
    parent = [-1]*n
    sibling = [-1]*n
    for _ in range(n):
        ilr = LI()
        id = ilr[0]
        left = ilr[1]
        right = ilr[2]
        children[id] = (left, right)
        if left>=0:
            parent[left] = id
            sibling[left] = right
        if right>=0:
            parent[right] = id
            sibling[right] = left

    depth = [-1]*n
    root = parent.index(-1)
    depth[root] = 0
    que = collections.deque()
    que.append(root)
    while que:
        c = que.popleft()
        for i in children[c]:
            if i!=-1 and depth[i]==-1:
                que.append(i)
                depth[i] = depth[c] + 1

    height = [-1]*n
    def dfs(v):
        children_v = children[v]
        if children_v.count(-1)==2:
            height[v] = 0
        else:
            for i in children_v:
                if i!=-1:
                    height[v] = max(1 + dfs(i), height[v])
        return height[v]
    dfs(root)

    node_type = ['']*n
    for i in range(n):
        if parent[i]==-1:
            node_type[i] = 'root'
        elif children[i].count(-1)==2:
            node_type[i] = 'leaf'
        else:
            node_type[i] = 'internal node'

    for i in range(n):
        print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(i, parent[i], sibling[i], len(children[i])-children[i].count(-1), depth[i], height[i], node_type[i]))

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6024
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n;
vector<string> v1, v2;

void swap(int &a, int &b){
	int tmp = a;
	a = b;
	b = tmp;
}

void BubbleSort(){
	int i=0;
	while(true){
		if(i == n) break;
		for(int j=n-1; j > i; --j){
			if(v1[j][1] < v1[j-1][1])
				swap(v1[j], v1[j-1]);
		}
		++i;
	}
}

void SelectionSort(){
	int num;
	char minv;
	for(int i=0; i < n; ++i){
		minv = 'a';
		for(int j=i+1; j < n; ++j){
			if(v2[j][1] < minv){
				num = j;
				minv = v2[j][1];
			}
		}
		if(v2[i][1] > v2[num][1]) swap(v2[i], v2[num]);
	}
}

void print(vector<string> vec){
	for(int i=0; i<n; ++i){
		cout << vec[i];
		if(i != n-1) cout << " ";
	}
	cout << "\n";
}

int main(){
	cin >> n;
	string vin;
	for(int i=0; i<n; ++i){
		cin >> vin;
		v1.push_back(vin);
		v2.push_back(vin);
	}

	BubbleSort();
	print(v1);
	cout << "Stable" << endl;
	SelectionSort();
	print(v2);

	if(v1 == v2) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}


Measured memory_bytes: 3208
H,W=map(int,input().split())
field=[["#"]*(W+2)]
for i in range(H):
    field.append(["#"])
    field[-1].extend(list(input()))
    field[-1].append("#")
field.append(["#"]*(W+2))
for i in range(1,H+1):
    for j in range(1,W+1):
        cnt=0
        for dy,dx in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            if field[i][j]=="#" and field[i][j]!=field[i+dy][j+dx]:
                cnt+=1
        if cnt==4:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
/**
 *    author:  FromDihPout
 *    created: 2020-06-29
**/

#include <bits/stdc++.h>
using namespace std;


const int INF = 1e5;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> min_cnt(26, INF);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vector<int> curr_cnt(26);
        for (char c : s) {
            curr_cnt[c - 'a']++;
        }
        for (int i = 0; i < 26; i++) {
            min_cnt[i] = min(min_cnt[i], curr_cnt[i]);
        }
    }
    
    string ans = "";
    for (int i = 0; i < 26; i++) {
        if (min_cnt[i] != 0) {
            ans.insert(ans.length(), string(min_cnt[i], i + 'a'));
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
    vector<int> v = {0, 0, 0};
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    int ans = v[2] * 10 + v[1] + v[0];
    cout << ans << endl;
    return 0;
}

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

int main(){
    double W, H, x, y, out;
    int torf;
    
    cin >> W >> H >> x >> y;

    out = W * H / 2;
    if(x == W / 2 && y == H / 2){
        torf = 1;
        printf("%lf %d", out, torf);
    }else{
        torf = 0;
        printf("%lf %d", out, torf);
    }
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
    std::string s, t;
    char sc[26], tc[26];
    bool flag = true;
    std::cin >> s >> t;
    
    for (int i=0; i<26; i++) {
        sc[i] = 'A';
        tc[i] = 'A';
    }

    for (int i=0; i<s.size(); i++) {
        int idx_s = s[i] - 'a';
        int idx_t = t[i] - 'a';
        if (s[i] != t[i]) {
            if ((sc[idx_s] != 'A' && t[i] != sc[idx_s]) || (tc[idx_t] != 'A' && tc[idx_t] != s[i])) {
                flag = false;
            } else if (sc[idx_s] == 'A' && tc[idx_t] == 'A'){
                sc[idx_s] = t[i];
                tc[idx_t] = s[i];
            }
        } else {
            sc[idx_s] = t[i];
            tc[idx_t] = s[i];
        }
    }
    if (flag) std::cout << "Yes" << std::endl;
    else      std::cout << "No"  << std::endl;
    return 0;
}


Measured memory_bytes: 776
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	i := byte('a')
	for {
		if i == 'a' {
			if len(a) == 0 {
				fmt.Println("A")
				return
			}
			i = a[0]
			a = a[1:]
		} else if i == 'b' {
			if len(b) == 0 {
				fmt.Println("B")
				return
			}
			i = b[0]
			b = b[1:]
		} else {
			if len(c) == 0 {
				fmt.Println("C")
				return
			}
			i = c[0]
			c = c[1:]
		}
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void pul(int p);
void kake(int p);
void haita(int p);
void han(int p);


string s,p;
int ansa;
int ansb;
vector<int> ppp;

int main (){
  cin >> s;
  while(s!="."){
    ppp.assign(80,-10);
    ansa=0;
    ansb=0;
    int a,b,c,d;
    cin >> p;
    a=int(p[0])-'0';
    b=int(p[1])-'0';
    c=int(p[2])-'0';
    d=int(p[3])-'0';
    for(int t=0;t<s.size();++t){
      if(s[t]=='['){
        ppp[t]=-1;
      }
      else if(s[t]==']'){
        ppp[t]=-2;
      }
      else if(s[t]=='+'){
        ppp[t]=-3;
      }
      else if(s[t]=='*'){
        ppp[t]=-4;
      }
      else if(s[t]=='^'){
        ppp[t]=-5;
      }
      else{
        switch(s[t]){
          case 'a':
            ppp[t]=a;
            break;
          case 'b':
            ppp[t]=b;
            break;
          case 'c':
            ppp[t]=c;
            break;
          case 'd':
            ppp[t]=d;
            break;
        }
      }
    }
    switch(ppp[0]){
      case 0:
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      case 8:
      case 9:
        break;
      default:
        han(1);
        break;
    }
    ansa=ppp[0];
    for(a=0;a<10;++a){
      for(b=0;b<10;++b){
        for(c=0;c<10;++c){
          for(d=0;d<10;++d){
            ppp.assign(80,-10);
    for(int t=0;t<s.size();++t){
      if(s[t]=='['){
        ppp[t]=-1;
      }
      else if(s[t]==']'){
        ppp[t]=-2;
      }
      else if(s[t]=='+'){
        ppp[t]=-3;
      }
      else if(s[t]=='*'){
        ppp[t]=-4;
      }
      else if(s[t]=='^'){
        ppp[t]=-5;
      }
      else{
        switch(s[t]){
          case 'a':
            ppp[t]=a;
            break;
          case 'b':
            ppp[t]=b;
            break;
          case 'c':
            ppp[t]=c;
            break;
          case 'd':
            ppp[t]=d;
            break;
        }
      }
    }
    switch(ppp[0]){
      case 0:
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      case 8:
      case 9:
        break;
      default:
        han(1);
        break;
    }
    if(ppp[0]==ansa){
      ++ansb;
    }

          }
        }
      }
    }



    printf("%d %d\n",ansa,ansb);
    cin >> s;
  }
  /*for(int t=0;t<q;++t){
    printf("%d\n",qqq[t]);
  }*/
}

void pul(int p){
  if(ppp[p]==-1){
    han(p+1);
  }
  if(ppp[p+1]==-1){
    han(p+2);
  }
  ppp[p-2]=ppp[p]|ppp[p+1];
  ppp.erase(ppp.begin()+p-1,ppp.begin()+p+3);
}

void kake(int p){
  if(ppp[p]==-1){
    han(p+1);
  }
  if(ppp[p+1]==-1){
    han(p+2);
  }
  ppp[p-2]=ppp[p]&ppp[p+1];
  ppp.erase(ppp.begin()+p-1,ppp.begin()+p+3);
}

void haita(int p){
  if(ppp[p]==-1){
    han(p+1);
  }
  if(ppp[p+1]==-1){
    han(p+2);
  }
  ppp[p-2]=ppp[p]^ppp[p+1];
  ppp.erase(ppp.begin()+p-1,ppp.begin()+p+3);
}

void han(int p){
  switch(ppp[p]){
    case -5:
      haita(p+1);
      break;
    case -4:
      kake(p+1);
      break;
    case -3:
      pul(p+1);
      break;
  }
}


Measured memory_bytes: 3264
/**
 * author: Dhakad_123
**/
#include<bits/stdc++.h>
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n , m;
    
    cin >> n >> m;
    
    int nums[m];
    
    for(int i = 0; i < m; i++){
        cin >> nums[i];
    }
    
    int sum = 0;
    
    for(int i = 0; i < m; i++){
        sum += nums[i];
    }
    
    if(n < sum){
        cout<< -1 << "\n";
        exit(0);
    }
    
    else{
        cout << (n-sum) << "\n";
    }
    
  return 0;
}

Measured memory_bytes: 3684
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [Usize1; n],
    }

    let mut i = 1usize;
    let mut v: Vec<Vec<usize>> = vec![(0..n).collect()];
    v.push(a);
    while i < k {
        let p = v.last().unwrap().clone();
        let mut next = vec![0; n];
        for j in 0..n {
            next[j] = p[p[j]];
        }
        v.push(next);
        i *= 2;
    }

    let mut k = k;
    let mut c = 1;
    let mut ans: Vec<usize> = (0..n).collect();
    while k > 0 {
        let p = ans.clone();
        if k & 1 > 0 {
            for i in 0..n {
                ans[i] = v[c][p[i]];
            }
        }
        c += 1;
        k /= 2;
    }

    println!("{}", ans[0] + 1);
}


Measured memory_bytes: 103148
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int count_prime(int n){
    int p = 0;
    vector<int> prime(n+1, true);
    prime[0] = prime[1] = false; 
    for(int i = 2; i <= n; i++)
        if(prime[i]) {
            p++;
            for (int j = i*2; j <= n; j += i) prime[j] = false;
        }

    return p;
}

int main(void)
{
    int n;
    while(cin >> n)
        pr(count_prime(n));
}


Measured memory_bytes: 7104
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
#define MAX_N 300000
vector<int> X[MAX_N], Y[MAX_N]; map<pair<int, int>, int>M;
int n, m, q, a[MAX_N], b[MAX_N], c[MAX_N], e[MAX_N], dist[MAX_N], color[MAX_N];
int main() {
	cin >> n >> m >> q;
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i]; if (a[i] > b[i])swap(a[i], b[i]);
		X[a[i]].push_back(b[i]); X[b[i]].push_back(a[i]);
	}
	queue<int>Q; Q.push(1);
	for (int i = 0; i < MAX_N; i++)dist[i] = 1 << 30; dist[1] = 0;
	while (!Q.empty()) {
		int aa = Q.front(); Q.pop();
		for (int i = 0; i < X[aa].size(); i++) {
			int to = X[aa][i]; if (dist[to] <= dist[aa] + 1)continue;
			Q.push(to); dist[to] = dist[aa] + 1;
		}
	}
	for (int i = 0; i < q; i++) { cin >> c[i]; }
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] != dist[b[i]]) {
			if (dist[a[i]] < dist[b[i]]) { Y[a[i]].push_back(b[i]); e[b[i]]++; }
			if (dist[b[i]] < dist[a[i]]) { Y[b[i]].push_back(a[i]); e[a[i]]++; }
		}
	}
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		int P1 = a[c[i]], P2 = b[c[i]];
		if (dist[P1] != dist[P2]) {
			int G = 0, H = 0;
			if (dist[P1] < dist[P2]) { G = P2; H = P1; }
			if (dist[P2] < dist[P1]) { G = P1; H = P2; }
			if (M[make_pair(H, G)] != 1) {
				M[make_pair(H, G)] = 1; color[G]++;
				if (color[G] == e[G]) { cnt++; Q.push(G); }

				while (!Q.empty()) {
					int A = Q.front(); Q.pop();
					for (int j = 0; j < Y[A].size(); j++) {
						if (M[make_pair(A, Y[A][j])] == 1)continue;
						color[Y[A][j]]++;
						M[make_pair(A, Y[A][j])] = 1;
						if (color[Y[A][j]] == e[Y[A][j]]) {
							cnt++; Q.push(Y[A][j]);
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 38436
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] t = new int[N];

		int sum = 0;
		t[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			t[i] = sc.nextInt();

			if(t[i-1] + T < t[i]) {
				sum += T;
			}else {
				sum += t[i] - t[i-1];
			}
		}

		sum += T;
		System.out.println(sum);
	}
}


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



int main(){
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    map<char,int> m,now;

    for(char x : s[0]){
        m[x]++;
    }

    rep2(i,n){
        for(char x: s[i]){
            now[x]++;
        }
        for(char c='a';c<='z';c++){
            m[c]=min(m[c],now[c]);
        }
        for(char c='a';c<='z';c++){
            now[c]=0;
        }
        
    }
    for(auto p: m){
        auto key = p.first;
        auto value = p.second;
        rep(i,value){
            cout << key;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

const int MAX_NUM = 2000000;

void CountingSort(int * A, int * B, int n) {
    int C[MAX_NUM + 1] = {};

    for (int i = 0; i < n; i++) {
        C[A[i]]++;
    }

    for (int i = 1; i <= MAX_NUM; i++) {
        C[i] = C[i] + C[i - 1];
    }

    for (int i = n - 1; i >= 0; i--) {
        B[C[A[i]] - 1] = A[i];
        C[A[i]]--;
    }
}


int main() {
    int n;
    std::cin >> n;
    int A[n], B[n];

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

    CountingSort(A, B, n);

    for (int i = 0; i < n - 1; i++) {
        std::cout << B[i] << " ";
    }
    std::cout << B[n - 1] << std::endl;
}



Measured memory_bytes: 26496
inf = float('inf')

SMALLER = 0
TBD = 1

n, k = map(int, input().split())
a = tuple(map(int, input().split()))
b = [0] * 50  # 10^12 < 2^40

for x in a:
    for j in range(40):
        if (x >> j) & 1 == 1:
            b[j] += 1  # xの下からj桁目にbitが立っている個数

dp = [[-inf] * 2 for _ in range(50 + 1)]
dp[50][TBD] = 0

for j in reversed(range(50)):
    if (k >> j) & 1 == 1:
        # bitを立ててよい
        dp[j][TBD] = dp[j + 1][TBD] + ((n - b[j]) << j)
        dp[j][SMALLER] = max(
            dp[j + 1][TBD] + (b[j] << j),
            dp[j + 1][SMALLER] + (max(n - b[j], b[j]) << j)
        )
    else:
        # bitを立てられない
        dp[j][TBD] = dp[j + 1][TBD] + (b[j] << j)
        dp[j][SMALLER] = dp[j + 1][SMALLER] + (max(n - b[j], b[j]) << j)

print(max(dp[0]))


Measured memory_bytes: 71768
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>
#include <string.h>
#define ll long long
#define pb push_back
using namespace std;

int main()
{
int a;
cin>>a;
if (a<=999)
cout<<"ABC";
else
cout<<"ABD"; 
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

pair<int, int> dish[3010];
int dp[3010][3010];

int main() {
	int N, T;
	cin >> N >> T;
	for(int i=0; i<N; ++i){
		int A, B;
		cin >> A >> B;
		dish[i]=make_pair(A, B);
	}
	sort(dish, dish+N);
	int ans=dish[0].second;
	for(int i=0; i+1<N; ++i){
		for(int j=1; j<T; ++j){
			dp[i+1][j]=max(dp[i+1][j-1], dp[i][j]);
			if(dish[i].first<=j){
				dp[i+1][j]=max(dp[i+1][j], dp[i][j-dish[i].first]+dish[i].second);
			}
		}
		ans=max(ans, dp[i+1][T-1]+dish[i+1].second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int n;
cin>>n;
string s[n];
	int AC=0,WA=0,TLE=0,RE=0;
FOR(i,n)
{
	cin>>s[i];

	if(s[i]=="AC")
	{
		AC++;
	}
		else if (s[i]=="WA")
	{
		WA++;
	}
	   else if(s[i]=="TLE")
	{
		TLE++;
	}
		else
	{
		RE++;
	}

}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
return  0;
}






Measured memory_bytes: 6752
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL = std::numeric_limits<long long>::max();

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

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////

//int cntnb(const int n) {
//    int ans = 1;
//    vector<int> x(n + 1);
//    int num = n; 
//
//    for (int i = 2; i <= n; i++) {
//        while (num%i == 0) { 
//            x[i]++;
//            num /= i;
//        }
//    }
//
//    for (int i = 2; i <= n; i++)
//    {
//        ans *= x.at(i) + 1;
//    }
//    return ans;
//}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({ a, ex });
    }
    if (N != 1) res.push_back({ N, 1 });
    return res;
}

ll cntnb(long long N) {
    const auto &pf = prime_factorize(N);
    long long res = 1;
    for (auto p : pf) res *= p.second + 1;
    return res;
}

void Main() {
    long long N; cin >> N;
    long long cnt = 0;
    for (long long i = 1; i < N; ++i) {
        cnt += cntnb(N - i);
    }
    cout << cnt << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    double tmp;
    cin >> tmp;

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main()
{
    int a[100];
    int count;

    scanf("%d", &a[0]);
    scanf("%d", &a[1]);
    scanf("%d", &a[2]);

    for(int i=0; i < a[0]; i++)
    {
        scanf("%d", &a[i+3]);
    }

    count = 0;

    for(int i=0; i < a[0]; i++)    //人数分行う
    {
        for(int j=0; a[1] >= (j*(a[i+3]) + 1); ++j) //D日間 
        {
                count = count + 1;
        }
    }

    printf("%d\n", (a[2] + count));

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#define INF 2000000
#define t first
#define x second
using namespace std;
typedef pair <double,int> P;
double b,v,e,f;
int r;

double mk(int x) {
  if(x >= r) return 1.0/(v-e*(x-r));
  return  1.0/(v-f*(r-x));
}

int main() {
  while(1) {
    int n,a[110]={};
    cin >> n;
    if(n==0) break;
    for(int i=1;i<=n;i++) cin >> a[i];
    cin >> b;
    cin >> r >> v >> e >> f;
    P dp[10100]={};
    for(int i=1;i<=a[n];i++) dp[i] = make_pair(INF,0);

    for(int i=0;i<n;i++) {
      int tx;
      double tt;
      //No Change
      tx=dp[a[i]].x,  tt=dp[a[i]].t;
      for(int j=a[i]+1;j<=a[n];j++){
	double k = mk(tx);
	tt += k , tx++;
	dp[j] = min(dp[j],make_pair(tt,tx));
      }

      //Change
      tx= 0, tt=dp[a[i]].t+b;
      for(int j=a[i]+1;j<=a[n];j++){
	double k = mk(tx);
	tt +=k; tx++;
	dp[j] = min(dp[j],make_pair(tt,tx));
      }
      
    }
    printf("%.4f\n",dp[a[n]].t);
  }
  return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long t = sc.nextInt();
		long min=Long.MAX_VALUE;
		long profit=0;
		int count=1;
		for(int i = 0; i<n; i++){
			long a = sc.nextLong();
			if(i!=0 && a-min>=profit){
				if(profit==a-min){
					count++;
				}else{
					count=1;
				}
				profit=a-min;
			}
			if(min>a){
				min=a;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 48496
#include <bits/stdc++.h>
#define ll long long
#define Whitebeard ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
    Whitebeard;
ll a,b;
cin>>a>>b;
if(500*a>=b){cout<<"Yes";}
else{cout<<"No";}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main() {
    ll a, b, pa, pb;
    cin >> a >> b;
    a--;
    pa = 64 -__builtin_clzll(a);
    pb = 64 -__builtin_clzll(b);

    map<ll, ll> mp, mp2;
    for (ll i = pa; i >= 0; i--) {
        ll t = (1LL << (i + 1));
        mp[i] = ((a + 1) / t) * (t / 2) + max(0LL, ((a + 1) % t) - (t / 2));
    }

    for (ll i = pb; i >= 0; i--) {
        ll t = (1LL << (i + 1));
        mp2[i] = ((b + 1) / t) * (t / 2) + max(0LL, ((b + 1) % t) - (t / 2));
    }

    ll ans = 0LL;
    for (int i = pb; i >= 0; i--) {
        if ((mp2[i] - ((a < 0) ? 0 : mp[i])) % 2 == 1)ans += (1LL << i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <map>
using namespace std;
 
#define int long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repd(i, a) for (int i = (a)-1; i >= 0; i--)
#define reps(i, a, j) for (int i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define mp make_pair
#define eb emplace_back
#define FastOpen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pii pair < int , int >
//int power(int x,int p){if(p==0)return 1;if(p==1)return x;if(p%2)return x*power(x,p-1);int y=power(x,p/2);return y*y;}
/*
*/

const int inf = 1e9 +7;
void solve() {
    int n; cin >> n;
    int resa,resb,resc;
    rep(i,n) {
        int a,b,c; cin >> a >> b >> c;
        if (i == 0) {
            resa = a;
            resb = b;
            resc = c;
        }else {
            a = max(resb,resc) + a;
            b = max(resc,resa) + b;
            c = max(resa,resb) + c;
            resa = a;
            resb = b;
            resc = c;
        }
    }
    cout << max({resa,resb,resc}) << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    FastOpen
    int t; t=1;
    while (t--) solve();
}





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

int main() {
    int H, W; cin >> H >> W;
    int count = 0;
    for (int i = 0; i < H; ++i) {
        string S; cin >> S;
        for (auto c : S) if (c == '#') ++count;
    }
    if (count == H + W - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

int main(){
	int N,M; cin>>N>>M;
	string T(N,'-');
	rep(i,M){
		int s,c; cin>>s>>c; s--, c+='0';
		if(T[s] !='-' && T[s] != c){ puts("-1"); return 0; }
		if(N!=1 && s==0 && c=='0'){ puts("-1"); return 0; }
		T[s] = c;
	}

	int ans = INT_MAX;
	rep(i,999){
		string A = to_string(i);
		if(A.size() != N) continue;
		bool exist = true;
		rep(j,N) if(T[j]!='-' && T[j]!=A[j]){ exist = false; break; }
		if(exist) ans = min(ans, i);
	}
	cout<< ans <<endl;

}

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

int n,a;
int tms[3];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if ((a&3)==0) tms[2]++;
		else if ((a&1)==0) tms[1]++;
		else tms[0]++;
	}
	
	if (tms[0]>tms[2]+1)
	{
		printf("No\n");
		return 0;
	}
	else if (tms[0]==tms[2]+1 && tms[1]>0)
	{
		printf("No\n");
		return 0;
	}
	else
	{
		printf("Yes\n");
		return 0;
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    std::vector<int> P(N);
    for(auto &p : P){
        std::cin >> p;
    }
    std::vector<int> Q = P;
    std::sort(Q.begin(),Q.end());
    int distance=0;
    for(int i=0; i<N; ++i){
        if(P[i]!=Q[i]){ ++distance; }
    }
    if(distance <= 2){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    int ret = 0;
    if (A == B)
        ret++;
    if (A == C)
        ret++;
    if (B == C)
        ret++;
    if(ret==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256