akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int MOD = (int)1e9 + 7;
int add(int a, int b) {
    int c = a + b;
    if (c >= MOD)c -= MOD;
    else if (c < 0)c += MOD;
    return c;
}
void sadd(int &a, int b) {
    a += b;
    if (a >= MOD)a -= MOD;
    else if (a < 0)a += MOD;
}
int mul(int a, int b) {
    return (int)((long long)a*b%MOD);
}
void smul(int &a, int b) {
    a = (int)((long long)a*b % MOD);
}
int powm(int a, long long k) {
    long long res = 1, b = a;
    while (k) {
        if (k & 1)res = res*b%MOD;
        b = b*b%MOD;
        k >>= 1;
    }
    return (int)res;
}

vector<vector<int>> combinations(int n, int mod) {
    auto res = vector<vector<int>>(n + 1, vector<int>(n + 1));
    rep(i, n + 1) res[i][0] = 1;
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= i; ++j)
        res[i][j] = (res[i - 1][j - 1] + res[i - 1][j]) % mod;
    return res;
}

vector<vi> dp;

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

    int N, M;
    while (cin >> N >> M) {
        MOD = M;
        dp = vector<vi>(N + 1, vi(N + 1));
        dp[0][0] = 1;

        for (int a = 1; a <= N; ++a)for (int b = 0; b <= a; ++b) {
            sadd(dp[a][b], dp[a - 1][b]);
            if (b > 0) {
                sadd(dp[a][b], dp[a - 1][b - 1]);
                sadd(dp[a][b], mul(dp[a - 1][b], b));
            }
        }

        vi A(N + 1);
        rep(a, N + 1) {
            MOD = M - 1;
            int p = powm(2, N - a);
            MOD = M;
            int q = powm(2, p);
            rep(b, a + 1) {
                int r = powm(2, (ll)(N - a)*b);
                int s = mul(q, mul(dp[a][b], r));
                sadd(A[a], s);
            }
        }

        auto C = combinations(N, M);

        int re = 0;
        rep(a, N + 1) {
            int p = mul(C[N][a], A[a]);
            if (a % 2)p = mul(p, -1);
            sadd(re, p);
        }
        cout << re << endl;
    }
}

Measured memory_bytes: 70912
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

enum State { ide, clo, dif };

State Solve(std::string a, std::string b) {
  if (a == b) {
    return ide;
  }

  std::vector<std::string> const_a, const_b, code_a, code_b;
  bool perse_const = false;
  int begin_pos    = 0;

  for (int i = 0; i < a.size(); i++) {
    if (perse_const) {
      if (a[i] == '"') {
        std::string curr_const;
        for (int j = begin_pos; j < i; j++) {
          curr_const += a[j];
        }
        const_a.push_back(curr_const);
        begin_pos   = i + 1;
        perse_const = false;
      }

    } else {
      if (a[i] == '"' || i == a.size() - 1) {
        if (i == a.size() - 1) i++;
        std::string curr_code;
        for (int j = begin_pos; j < i; j++) {
          curr_code += a[j];
        }
        code_a.push_back(curr_code);
        begin_pos   = i + 1;
        perse_const = true;
      }
    }
  }

  begin_pos   = 0;
  perse_const = false;

  for (int i = 0; i < b.size(); i++) {
    if (perse_const) {
      if (b[i] == '"') {
        std::string curr_const;
        for (int j = begin_pos; j < i; j++) {
          curr_const += b[j];
        }
        const_b.push_back(curr_const);
        begin_pos   = i + 1;
        perse_const = false;
      }
    } else {
      if (b[i] == '"' || i == b.size() - 1) {
        if (i == b.size() - 1) i++;
        std::string curr_code;
        for (int j = begin_pos; j < i; j++) {
          curr_code += b[j];
        }
        code_b.push_back(curr_code);
        begin_pos   = i + 1;
        perse_const = true;
      }
    }
  }

  if (const_a.size() != const_b.size()) {
    // cerr << "\033[93m"
    //      << "size is wrong"
    //      << "\033[m" << endl;
    return dif;
  }

  int count = 0;
  for (int i = 0; i < const_a.size(); i++) {
    // cerr << "\033[93m" << const_a[i] << "\t" << const_b[i] << "\033[m" <<
    // endl;
    if (const_a[i] != const_b[i]) {
      count++;
    }
  }
  if (count == 1) {
    for (int i = 0; i < code_a.size(); i++) {
      // cerr << "\033[93m" << code_a[i] << "\t" << code_b[i] << "\033[m" <<
      // endl;
      if (code_a[i] != code_b[i]) {
        return dif;
      }
    }
    return clo;
  } else {
    return dif;
  }
}

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

  while (1) {
    std::string a, b;
    cin >> a;
    if (a == ".") break;
    cin >> b;
    State state = Solve(a, b);
    if (state == ide) {
      cout << "IDENTICAL";
    } else if (state == clo) {
      cout << "CLOSE";
    } else {
      cout << "DIFFERENT";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3136
import java.util.*;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		if(a>12){
			System.out.println(b);
		}
		else if(5<a && a<13){
			System.out.println(b/2);
		}
		else{
			System.out.println('0');
		}
	}
}

Measured memory_bytes: 21204
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    cur=0
    isum=[]
    for i in range(1,41):
        cur+=i
        isum.append(cur)
    def prime_factorize(n):
        a = dict()
        while n % 2 == 0:
            a[2]=a.get(2,0)+1
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a[f]=a.get(f,0)+1
                n //= f
            else:
                f += 2
        if n != 1:
            a[n]=a.get(n,0)+1
        return a
    a=prime_factorize(N)
    primes=a.keys()

    
    #primes=list(primes)

    #primes=divs&primes
    #divisors = []
    ans=0

    for p in primes:
        imax=1
        imax=a[p]
        for j,ind in enumerate(isum):
            if imax<ind:
                #print(p,ind)
                ans+=j
                break

    print(ans)
    # divisors.sort()
    return 0



if __name__ == "__main__":
    main()

Measured memory_bytes: 68236
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
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 MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string>ss;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; j <= k && i + j <= s.size(); j++) {
			ss.insert(s.substr(i, j));
		}
	}
	int cnt = 0;
	for (auto i : ss) {
		cnt++;
		if (cnt == k) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>

using namespace std;
int N;
int a[100005], b[100005], c[100005];

int main() {
    //ifstream cin("vacation.in");
    int i;
    cin >> N;
    for (i = 1; i <= N; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i] = a[i] + max(b[i - 1], c[i - 1]);
        b[i] = b[i] + max(a[i - 1], c[i - 1]);
        c[i] = c[i] + max(a[i - 1], b[i - 1]);
    }
    cout<<max(a[N],max(b[N],c[N]));

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

int main() {
    int n;
    cin >> n;
    int ok = 1;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2) continue;
        if (x % 3 == 0 || x % 5 == 0) {
            ;
        } else {
            ok = 0;
        }
    }
    puts(ok ? "APPROVED" : "DENIED");
    return 0;
}


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

using namespace std;
typedef long long ll;

const int N = 1e5+100;
ll ans[N];
int mod=1e9+7;
ll qpow(int x,int y)
{
    ll ans=1;
    if(x==0) return 0;
    else {
        while(y){
            if(y&1) ans=(ans*x)%mod;
            x=(1ll*x*x)%mod;
            y>>=1;
        }
    }
    return ans;
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=k;i>=1;i--){
        ans[i]=qpow(k/i,n)%mod;
        //cout<<ans[i]<<endl;
        for(int j=i*2;j<=k;j+=i){
            ans[i]=((ans[i]-ans[j])%mod+mod)%mod;
        }
    }
    ll sum=0;
    for(int i=1;i<=k;i++)
        sum=(sum+ans[i]*i)%mod;
    cout<<sum<<endl;
}


Measured memory_bytes: 4488
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;
 
using namespace std;

template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return halfpower*halfpower;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (halfpower*halfpower)*a;
      }
  }
};


int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;

//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readint(k);
        vector<int> events(n+1, 0);
        forr(i,0,n)  {
            readint(kk); events[max(0,i-kk)]++;  events[min(i+kk+1,n)]--;
        }
        k--;

        while (k>0) {
            vector<int> ev_new(n+1, 0);
            int val = 0;
            bool all_val_n = true;
            forr(i,0,n) {
                val += events[i];
                all_val_n = all_val_n && (val == n);
                ev_new[max(0, i-val)]++;
                ev_new[min(i+val+1, n)]--;
            }
            events = move(ev_new);
            if (all_val_n) {  break; }
            k--; if (k==0) {break;}
        }

        int val = 0;
        forr(i,0,n) {
            val += events[i];
            cout << val << " ";
        }
        cout << endl;

    }

//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 5144
n,c,k = map(int,input().split())
t = [int(input()) for _ in range(n)]
t.sort()
ans = 0
i = 0
while i<n:
    time = t[i]
    for j in range(0,c+1):
        if j>c or not t[i+j]-time<=k:
            ans += 1
            i += j
            break
        if (i+j)==(n-1):
            ans += 1
            i += j+1
            break
        if j==c:
            ans += 1
            i += j
print(ans)

Measured memory_bytes: 7384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <memory.h>

using namespace std;

const int maxn = 1e+5 + 10;

int par[maxn];

int find_par(int k) {
	if (par[k] == k)
		return k;
	else
		return par[k] = find_par(par[k]);
}

void join(int p, int q) {
	int x = find_par(p);
	int y = find_par(q);
	par[x] = y;
}

int N, M;
int nums[maxn], a, b;
vector<int> idx[maxn], nu[maxn];

int count(int i) {
	sort(idx[i].begin(), idx[i].end());
	sort(nu[i].begin(), nu[i].end());
	auto it1 = idx[i].begin();
	auto it2 = nu[i].begin();
	int cnt = 0;
	while (it1 != idx[i].end() && it2 != nu[i].end()) {
		if (*it1 == *it2) {
			cnt++;
			it1++;
			it2++;
		}
		else if (*it1 > *it2) 
			it2++;
		else 
			it1++;
	}
	return cnt;
}

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

	for (int i = 1; i <= N; i++) {
		cin >> nums[i];
		par[i] = i;
	}
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		join(a, b);
	}

	for (int i = 1; i <= N; i++) {
		int k = find_par(i);
		idx[k].push_back(i);
		nu[k].push_back(nums[i]);
	}

	int res = 0;
	for (int i = 1; i <= N; i++) {
		res += count(i);
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 12032
##################################################################

if __name__ == "__main__":
    Input = [input() for i in range(2)]
    # = list(map(int,Input[0].split()))
    S = str(Input[0])
    K = int(Input[1])

    n = len(S)
    ren = 1
    bef = S[0]
    cont = []
    if n == 1:
        cont = [1]
    for s in range(1,n):
        if bef == S[s]:
            ren += 1
            bef = S[s]
            if s == n-1:
                cont.append(ren)                
        else:
            cont.append(ren)
            ren = 1
            bef = S[s]

    ans = (sum([c//2 for c in cont]))*K
    if n ==1:
        ans += K//2
    elif S[0] == S[-1]:
        if len(cont)>1 and cont[0]%2==1 and cont[-1]%2==1:
            ans += K-1
        elif len(cont) ==1:
            ans = (n*K)//2
    print(ans)


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

int x[55], y[55];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    auto M = 1e9;
    for(int i = 0; i < n; i++) {
        for(int j = i; j < n; j++) {
            auto u = (x[i] + x[j]) / 2., v = (y[i] + y[j]) / 2.;
            auto m = 0.;
            for(int l = 0; l < n; l++)
                m = max(m, (x[l] - u) * (x[l] - u) + (y[l] - v) * (y[l] - v));
            M = min(M, m);
            for(int k = j; k < n; k++) {
                double a = (x[i] - x[j]) * (x[i] - x[j]) +
                           (y[i] - y[j]) * (y[i] - y[j]);
                double b = (x[k] - x[j]) * (x[k] - x[j]) +
                           (y[k] - y[j]) * (y[k] - y[j]);
                double c = (x[i] - x[k]) * (x[i] - x[k]) +
                           (y[i] - y[k]) * (y[i] - y[k]);
                auto A = b + c - a, B = a + c - b, C = a + b - c;
                auto d = a * A + b * B + c * C;
                if(d == 0)
                    continue;
                auto u = a * A * x[k] + b * B * x[i] + c * C * x[j];
                u /= d;
                auto v = a * A * y[k] + b * B * y[i] + c * C * y[j];
                v /= d;
                auto m = 0.;
                for(int l = 0; l < n; l++)
                    m = max(m,
                            (x[l] - u) * (x[l] - u) + (y[l] - v) * (y[l] - v));
                M = min(M, m);
            }
        }
    }
    cout.precision(18);
    cout << sqrt(M) << endl;
    return 0;
}


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

int main(void){
  const ll DIG_MAX = 41;
  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> A(N);
  vector<ll> c(41, 0);
  vector<vector<ll>> dp(DIG_MAX, vector<ll>(2, -1));
  for(auto& _a: A) cin >> _a;

  for(ll i = 0; i < (ll)c.size(); i++){
    for(ll j = 0; j < (ll)A.size(); j++){
      if(A[j] & (ll)((ll)1 << (ll)i)){
        c[i]++;
      }
    }
  }

  dp[DIG_MAX-1][1] = 0;
  for(ll i = DIG_MAX-2; i >= 0; i--){
    ll coeff = 1LL << i;
    if(dp[i+1][0] != -1){
      dp[i][0] = max(dp[i][0], dp[i+1][0] + coeff * max(c[i], N-c[i]));
    }

    if(dp[i+1][1] != 1){
      if(K & (1LL << i)){
        dp[i][0] = max(dp[i][0], dp[i+1][1] + coeff * c[i]);          // put 0
        dp[i][1] = max(dp[i][1], dp[i+1][1] + coeff * (N - c[i]));    // put 1
      }else{
        dp[i][1] = max(dp[i][1], dp[i+1][1] + coeff * c[i]);
      }
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=3e3+51,MOD=1e9+7;
ll x,y,res;
ll dp[MAXN][MAXN][2];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
int main()
{
	x=read(),y=read(),dp[0][0][1]=1;
	for(register int i=1;i<=x;i++)
	{
		dp[0][i][0]=1;
	}
	for(register int i=1;i<=y+1;i++)
	{
		for(register int j=0;j<=x;j++)
		{
			if(j>=1)
			{
				dp[i][j-1][1]=(dp[i][j-1][1]+dp[i-1][j][1])%MOD;
				dp[i][j-1][j==1]=(dp[i][j-1][j==1]+dp[i-1][j][0])%MOD;
			}
			if(j<x)
			{
				dp[i][j+1][1]=(dp[i][j+1][1]+dp[i-1][j][1])%MOD;
				dp[i][j+1][0]=(dp[i][j+1][0]+dp[i-1][j][0])%MOD;
			}
			if(j>=1)
			{
				dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][1])%MOD;
				dp[i][j][j==1]=(dp[i][j][j==1]+dp[i-1][j][0])%MOD;
			}
			if(j<x)
			{
				dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][1])%MOD;
				dp[i][j][0]=(dp[i][j][0]+dp[i-1][j][0])%MOD;
			}
		}
	}
	for(register int i=0;i<=x;i++)
	{
		res=(res+dp[y][i][1])%MOD;
	}
	printf("%d\n",res);
}


Measured memory_bytes: 71936
import * as fs from "fs";
const n = parseInt(fs.readFileSync("/dev/stdin", "utf8"));
const counter = Array(n+1).fill(1);
for (let i = 2; i <= n; i++) {
    const base = i;
    let current = i;
    while (current <= n) {
        counter[current] += 1;
        current += base;
        //console.log(counter);
    }
}
let sum = 0;
for (let i = 1; i <= n; i++) {
    sum += i * counter[i];
}
console.log(sum);

Measured memory_bytes: 110832
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int X[100005];
int Y[100005];
int N,A,B,C,m,n,o,i,j,k;
int main ()
{
	cin>>N;
	for(i=1;i<=N;i++)
	{
		cin>>m;
		X[i]=m;
		if(i==1)
		continue;
		if(X[i]==X[i-1]+1)
		{
			Y[X[i - 1]]=1;
		}
	}
	for(j=1;j<=N;j++)
	{
		cin>>n;
		A+=n;
	}
	for(k=1;k<=N-1;k++)
	{
		cin>>o;
		if(Y[k])
		{
			B+=o;
		}
	}
	cout<<A+B;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
        int a,b,k;
        cin>>k>>a>>b;
        for(int i=a;i<=b;i++){
          if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
          }
        }
        cout<<"NG"<<endl;
        return 0;

 




}


        


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 998244353;

ll modpow(ll n, ll p){
    if(p == 0) return 1;
    if(p % 2 == 1) return n * modpow(n, p-1) % MOD;
    ll t = modpow(n, p/2);
    return t*t % MOD;
}

constexpr int COMB_MAX = 210000;
ll fac[COMB_MAX], finv[COMB_MAX], inv[COMB_MAX];

void initComb(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COMB_MAX; i ++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    Cin(int, n, m, k);
    initComb();
    
    ll ans = 0;
    For(i, k+1){
        ll tmp = m * modpow(m-1, n-i-1) % MOD * comb(n-i-1 + i, i) % MOD;
        // Cout(tmp);
        ans = (ans + tmp) % MOD;
    }
    Cout(ans);
}



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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

bool pairCompare(const pii& Fir, const pii& Sec)
{
    return Fir.first < Sec.first; // 1番目について昇順
}

int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    vector<pll> X;
    rep(i,N){
        ll x, h;
        cin >> x >> h;
        X.push_back(make_pair(x,h));
    }  
    sort(X.begin(), X.end(), pairCompare);
    queue<pll> que;
    ll damage = 0;
    ll ans = 0;
    rep(i,N){
        while(!que.empty()){
            if(X[i].first > que.front().first + 2*D){
                damage -= que.front().second * A;
                que.pop();
            } else {
                break;
            }
        }
        if(X[i].second - damage <= 0) continue;
        ll add = (X[i].second - damage - 1) / A + 1;
        ans += add;
        que.push(make_pair(X[i].first, add));
        damage += add * A;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        boolean[] hh = new boolean[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(h[a - 1] <= h[b - 1]) {
                hh[a -1] = true;
            }
            if(h[a - 1] >= h[b - 1]) {
                hh[b -1] = true;
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if(!hh[i]) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 59540
from collections import Counter
n = int(input())
A = sorted(map(int, input().split()))
M = A[-1]
c = Counter(A)
s = set()
ans = 0
for a in A:
    if a in s:
        continue
    if c[a] == 1:
        ans += 1
    i = 1
    while a * i <= M:
        s.add(a * i)
        i += 1
print(ans)


Measured memory_bytes: 103304
#include<iostream>
#include<algorithm>
#include<string>

int const MAXN = 1e5;
int N, K, R, S, P;
std::string T, RSP = "rsp";
int iRSP[256];
int sRSP[3];

// greedy
int calc(int n) {
  int c = (iRSP[T[n]]+2)%3;
  int res = sRSP[c];
  while(n+K < N) {
    n += K;
    int newc = (iRSP[T[n]]+2)%3;
    if(c != newc) res += sRSP[c = newc];
     else c = -1;
  }
  return res;
}

int main() {
  std::cin >> N >> K >> R >> S >> P >> T;
  sRSP[0] = R; sRSP[1] = S; sRSP[2] = P;
  iRSP['r'] = 0; iRSP['s'] = 1; iRSP['p'] = 2;
  int ans = 0;
  for(int i = 0; i < K; ++i) ans += calc(i);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
def main():
    n = int(input())
    a = list(map(lambda x: int(x)-1, list(input())))
    b = [i % 2 for i in a]

    def all_a(x):
        ans = 0
        for j, i in enumerate(x):
            ans ^= (n-1 | j == n-1)*i
        return ans

    all_b = all_a(b)
    if all_b == 1:
        print(1)
        return
    if 1 in a:
        print(0)
        return
    b = [i//2 for i in a]
    print(all_a(b)*2)


main()

Measured memory_bytes: 30640
s = gets.chomp
q = gets.chomp.to_i
qs = q.times.map { gets.chomp.split(' ') }

rev = false
pref = []
suff = []

qs.each do |t, f, c|
    if t == '1'
        rev = !rev
        next
    end

    if f == '1'
        (!rev ? pref : suff) << c
    else
        (rev ? pref : suff) << c
    end
end

if !rev
    puts pref.reverse.join + s + suff.join
else
    puts (pref.reverse.join + s + suff.join).reverse
end


Measured memory_bytes: 56828
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
	char a;
	scanf("%c",&a);
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'){
		printf("vowel\n");
	}else{
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  long long h, w;
  cin >> h >> w;
  if (h == 1LL || w == 1LL) {
    cout << 1 << endl;
  } else if (h % 2LL && w % 2LL) {
    cout << h * w / 2LL + 1LL << endl;
  } else {
    cout << h * w / 2LL << endl;
  }
}

Measured memory_bytes: 256
import kotlin.*


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val a = sc.nextInt()
        val b = sc.nextInt()

        val ans = if(a < b){
            Array(b){a}.joinToString("")
        }
        else{
            Array(a){b}.joinToString("")
        }
        println(ans)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 36256
#include<stdio.h>
int main()
{
    int A,B,sum=0;
    while(scanf("%d%d",&A,&B)!=EOF){
    sum=(A+B)/2;
    if(A+B==sum*2)
        printf("%d\n",sum);
    else
        printf("IMPOSSIBLE\n");
    }
    return 0;

}


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

struct thing
{
  int w;
  int v;
};

int main()
{
  int W,N,v_sum=0,w_sum=0;
  // vector<int.int,double>w,v;
  // vector<double>e;
  cin>>N>>W;
  thing *t=new thing[N+1];
  for(int i=1;i<=N;i++)
      cin>>t[i].v>>t[i].w;
  int **V=new int*[N+1];
  for(int i=0;i<N+1;i++)
    V[i]=new int[W+1];
  for(int i=0;i<=N;i++)
    {
      for(int c=0;c<W+1;c++)
	{
	  if(i<=0||c<=0)
	    V[i][c]=0;
	  else if(c<t[i].w)
	    V[i][c]=V[i-1][c];
	  else
	    V[i][c]=(t[i].v+V[i-1][c-t[i].w])>V[i-1][c]?t[i].v+V[i-1][c-t[i].w]:V[i-1][c];
	}
    }
  cout<<V[N][W]<<endl;
}

Measured memory_bytes: 7044
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,d,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d %d", &n, &d);

	ans = n / (2*d+1);
	if (n % (2*d+1) !=0 ) ans++;
	printf("%d\n",ans);


	return 0;
}


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

int main() 
{ 
	lli n;
	cin >> n;
	int x = 360, i = 1;
	while(1)
	{
		if(x*i%n==0)
		{
			cout << x*i/n;
			break;
		}
		i++;
	}
}

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

#define int long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define mp make_pair

int a[200001];
int used[1000001];
map<int,int> m;

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

	int n;
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>a[i];
		used[a[i]]=1;
		m[a[i]]++;
	}
	int res=0;
	for (int i=0; i<n; i++){
		int x=a[i];
		bool ok=true;
		for (int j=1; j*j<=x; j++){
			if (x%j==0){
				if (used[j]){
					if (j==x && m[x]==1) continue;
					ok=false;
					break;
				}
				if (x/j!=j){
					if (x/j==x && m[x]==1) continue;
					if (used[x/j]){
						ok=false;
						break;
					}
				}
			}
		}
		if (ok) res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 24244
import sys


N = int(input())


k = 0

while k*(k+1) <= 2 * N:

    if k * (k+1) == 2 * N:

        lis = [ [] for i in range(k+1) ]
        now = 1

        for i in range(k):

            for j in range(k-i):

                lis[i].append(now)
                lis[i+1+j].append(now)
                now += 1
        print ("Yes")
        print (k+1)
        for i in range(k+1):
            print (k," ".join(map(str,lis[i])))
        sys.exit()

    k += 1

print ("No")

Measured memory_bytes: 9168
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>
 
using namespace std;

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

    string num="";
    for(int i=0;i<n;i++) num += 'x';

    int s;
    char c;
    for(int i=0;i<m;i++){
        cin >> s >> c;

        if(num[s-1] != 'x' && num[s-1] != c){
            cout << -1 << endl;
            return 0;
        }
        if(n != 1 && s == 1 && c == '0'){
            cout << -1 << endl;
            return 0;
        }

        num[s-1] = c;
    }

    if(n ==  1){
        if(num == "x") cout << 0 << endl;
        else cout << num << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(num[i] == 'x'){
            if(i == 0) num[i] = '1';
            else num[i] = '0';
        }
    }

    cout << num << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        int answer;
        if (A <= 5) {
            answer = 0;
        }
        else if (A <= 12) {
            answer = B / 2;
        }
        else {
            answer = B;
        }

        System.out.println(answer);
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n, k;
    cin >> n >> k;
    vll a(n);
    REP(i, n){
        cin >> a[i];
    }
    ll res = 0;

    ll lo = 1;
    ll hi = *max_element(a.begin(), a.end());
    if (k == 0) {
        cout << hi << "\n";
        return;
    }
    res = hi;
    while (lo <= hi) {
        ll mid = lo + (hi - lo) / 2;
        ll cuts = 0;
        REP(i, n) {
            if (a[i] <= mid)
                continue;
            cuts += a[i] / mid;
        }
        if (cuts > k) {
            lo = mid + 1;
        } else {
            res = mid;
            hi = mid - 1;
        }
    }

    // cout << fixed << setprecision(6);
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    //cin.rdbuf()->in_avail()
    return 0;
}


Measured memory_bytes: 4776
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;

vector <int> v[MAXN];
vector <int> v2[MAXN];

bool bt(int x, int idx)
{
	return (x >> idx)%2;
}

bool check(int x)
{
	for (int i = 0; i < n; ++i)
	{
		bool h = true;

		for (int j = 0; j < v[i].size(); ++j)
			h &= (bt(x,v[i][j]) == v2[i][j]);

		if(h != bt(x,i))
			return false;
	}

	return true;
}

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

	for (int i = 0; i < n; ++i)
	{
		int t;
		cin >> t;
		v[i].resize(t);
		v2[i].resize(t);
		for (int j = 0; j < t; ++j)
		{
			cin >> v[i][j] >> v2[i][j];
			v[i][j]--;
		}
	}

	int ans = 0;
	for (int i = (1<<n) - 1; i >= 0; --i)
		if(check(i))
		{
			int ct = __builtin_popcount(i);
			ans = max(ans, ct);
		}

	cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  int n = s.size();
  if(n<4){
    cout<<"No"<<endl;
    return 0;
  }
  string t = "";
  REP(i,4){
    t += s[i];
  }
  if(t == "YAKI"){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


char s[1005];
int main(){
    int n,i,j,k,K,T,m;
    scanf("%s",s);
    int a=0,b=0,c=0,d=0;
    for(i=0;s[i];i++){
        if(s[i]=='N')a=1;
        else if(s[i]=='S')b=1;
        else if(s[i]=='W')c=1;
        else d=1;
    }
    if((a^b)||(c^d))puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

Graph G;
int dp[100010];

int rec(int v){
    if(dp[v]!=-1)return dp[v];
    int res = 0;
    for(int nv:G[v]){
        chmax(res,rec(nv)+1);
    }
    return dp[v]=res;
}

int main(){
    int n,m;
    cin >> n >> m;
    G.resize(n);
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
    }

    rep(i,n){
        dp[i]=-1;
    }
    int ans = 0;
    rep(i,n){
        chmax(ans,rec(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <stdio.h>
#include <math.h>

int sosu(int);

int main(){
  int n,i,c=0;
  int A[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=0;i<n;i++){
    c+=sosu(A[i]);
  }
  printf("%d\n",c);
  return 0;
}

int sosu(int x){
  if(x<=1)return 0;
  else if(x==2)return 1;
  else if(x%2==0)return 0;
  double sq=pow(x,0.5);
  int i;
  for(i=3;i<=sq;i+=2){
    if(x%i==0){
      return 0;
    }
  }
  return 1;
}



Measured memory_bytes: 2044
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32,
        m: u32,
    }
    for i in 0..n+1 {
        for j in 0..n-i+1 {
            let k: u32 = n - i - j;
            if (i*10000 + j*5000 + k*1000) == m {
                println!("{} {} {}", i, j, k);
                return;
            }
        }
    }
    println!("-1 -1 -1")
}


Measured memory_bytes: 4352
import math
def div(n):
    q=[]
    num=[]
    new=1
    while(new):
        orin=n
        for i in range(2,int(math.sqrt(n))):
            if n%i==0:
                q.append(i)
                num.append(0)
                curp = len(num)-1
                new=1
            while(n%i==0):
                n=n//i
                num[curp]+=1
        if orin==n:
            if n!=1:
                q.append(n)
                num.append(1)
            break
    return q,num

def check(num):
    i=1
    count=0
    while(num>=i):
        num-=i
        count+=1
        i+=1
    return count

n=int(input())
q,num=div(n)
if n==1:
    print(0)
else:
    total=0
    for i in range(len(num)):
        total+=check(num[i])
    print(total)


Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b ,c ,x ,y ;
  cin >> a >> b >> c >> x >> y ;
  int ans = 1<<30;
  for( int i = 0 ; i <= max(2*x, 2*y) ; i += 2){
    int X = 0;
    int Y = 0;
    if( x - i/2 > 0){
      X = x - i/2;
    }
    if( y - i/2 > 0 ){
      Y = y -i/2;
    }
    if( ans > a*X + b*Y + c*i){
      ans = a*X + b*Y + c*i;
    }
  }
  cout << ans << endl ;
}

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

using namespace std;

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	int x = a.length();
	int y = b.length();
	if(a[x-1] == b[0] && b[y-1] == c[0]){
        cout << "YES";
	}else{
        cout << "NO";
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
using namespace std;

int main()
{
  int a,b,C;
  cin>>a>>b>>C;
  double rad=C*acos(-1)/180;
  double s=a*b*sin(rad)/2;
  printf("%.8f\n",s);
  double c=sqrt(a*a+b*b-2*a*b*cos(rad));
  printf("%.8f\n",a+b+c);
  double h=s*2/a;
  printf("%.8f\n",h);
  return 0;
}      



Measured memory_bytes: 3400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        for (int i = s.length - t.length; i >= 0; i--) {
            if (s[i] != t[0] && s[i] != '?') {
                continue;
            }

            for (int j = 0; j < t.length; j++) {
                if (s[i + j] != t[j] && s[i + j] != '?') {
                    break;
                }

                if (j == t.length - 1) {
                    String prefix = String.valueOf(s).substring(0, i);
                    String sufix = String.valueOf(s).substring(i + t.length);
                    System.out.println((prefix + String.valueOf(t) + sufix).replace('?', 'a'));
                    return;
                }
            }
        }

        System.out.println("UNRESTORABLE");
    }
}

Measured memory_bytes: 21844
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [r, g, b] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const rgb = Number(`${r}${g}${b}`)

console.log(rgb % 4 === 0 ? 'YES' : 'NO')


Measured memory_bytes: 7372
#include <iostream>
#include <math.h>
using namespace std;

int main(void){
    // Your code here!
    int x, y;
    
    cin >> x >> y;
    
    while(x != 0 && y != 0){
        if(x > y){
            x = x % y;
        }else{
            y = y % x;
        }
    }
    
    if(x == 0){
        cout << y << endl;
    }else{
        cout << x << endl;    
    }
    

}



Measured memory_bytes: 3116
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int x,n,Min;
    cin >> x >> n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    sort(p, p + n);
    int i;
    Min=abs(x-p[0]);
    for(i=1; Min>abs(x-p[i])&&i<n; i++){
        Min = abs(x - p[i]);
    }
    i--;
    for (int j = 1; true; j++){
        if(p[i]-j!=p[i-j]){
            cout << p[i] - j << endl;
            return 0;
        }
        else if(p[i]+j!=p[i+j]){
            cout << p[i] + j << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636