akhauriyash/Code-Regression huggingface dataset:
/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int s=0, w=1;

	char ch=getchar();

	while(ch<'0' || ch>'9')
	{
		if(ch='-')
		{
			w=-w;
		}

		ch=getchar();
	}

	while(ch>='0' && ch<='9')
	{
		s=(((s*10ll))+(ch-'0'));

		ch=getchar();
	}

	return s;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	
	cin>>s;
	
	if(s[2]==s[3])
	{
		if(s[4]==s[5])
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#import<cstdio>
#import<deque>
#import<algorithm>
using namespace std;main(){int n,i;deque<int> h;for(;~scanf("%d",&n);)h.push_back(n);sort(h.begin(),h.end());for(i=9;i>6;i--)printf("%d\n",h[i]);}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <math.h> 
using namespace std;
int main(){
  string s, t, u;
  cin  >> s >> t >> u;
  s[0] = s[0] - 0x20;
  t[0] = t[0] - 0x20;
  u[0] = u[0] - 0x20;

  cout << s[0] << t[0] << u[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define re0 return 0
#define pb push_back
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    sort(rall(a));

    ll A = 0, B = 0;
    rep(i, n) {
        if(i%2 == 0) {
            A += a[i];
        }
        else {
            B += a[i];
        }
    }

    out(A-B);
    re0;
}

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

int n,a[12],cnt;

void go(int idx, bool flag)
{
    if(idx == n) {
        if(flag) ++cnt;
        return;
    }
    go(idx+1, flag | ((a[idx]-1 & 1) == 0));
    go(idx+1, flag | ((a[idx] & 1) == 0));
    go(idx+1, flag | ((a[idx]+1 & 1) == 0));
}

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d",&a[i]);
    go(0, 0);
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,M;
int H[1666];
int W[1666];

ll h[2000000];
ll w[2000000];

int main() {
  while( cin >> N >> M && (N || M) ){
    for(int i=0;i<N;i++){
      int hi;
      cin >> hi;
      H[i+1] = H[i] + hi;
    }
    for(int i=0;i<M;i++){
      int wi;
      cin >> wi;
      W[i+1] = W[i] + wi;
    }

    memset(h,0,sizeof(h));
    memset(w,0,sizeof(w));

    for(int i=0;i<N;i++){
      for(int j=0;j<N-i;j++){
	int nd = i+j;
	h[H[nd+1]-H[j]]++;
      }
    }
    for(int i=0;i<M;i++){
      for(int j=0;j<M-i;j++){
	int nd = i+j;
	w[W[nd+1]-W[j]]++;
      }
    }
    ll res = 0;
    for(int i=0;i<=2000000;i++){
      res += h[i]*w[i];
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 32428
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;

int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,ans,mn,mx,sum=0;
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    cin>>n;

    ll arr[n];

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

    for(int i=0;i<n-1;i++)
    {
        if(arr[i]>arr[i+1])
        {
            sum+= arr[i]-arr[i+1];
            arr[i+1]=arr[i];
        }
    }

    cout<<sum<<endl;


}




Measured memory_bytes: 5176
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, k;
string s;

int main() {
    cin >> k;
    V<Pii> p(k);
    REP(i, k) {
        int y, x;
        cin >> y >> x;
        p[i] = {x, y};
    }

    Vi v(8);
    REP(i, 8) v[i] = i;
    do {
        bool f = true;
        REP(i, k) {
            f &= v[p[i].first] == p[i].second;
        }
        if (!f) continue;

        REP(i, 8) {
            int x = i + v[i], y = v[i] - i;
            REP2(j, i+1, 8) {
                f &= !(x == j + v[j] || y == v[j] - j);
            }
            if (!f) break;
        }
        if (!f) continue;

        REP(i, 8) {
            REP(j, 8) {
                if (v[j] == i) std::cout << "Q";
                else std::cout << ".";
            }
            std::cout << '\n';
        }
    } while(next_permutation(ALL(v)));

    return 0;
}



Measured memory_bytes: 3164
// https://atcoder.jp/contests/dp/tasks/dp_c
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; ++i)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define MOD 1000000007

using namespace std;

int solve(int n, int* a, int* b, int* c) {
    int dpa[n];
    int dpb[n];
    int dpc[n];
    rep(i, 0, n) { dpa[i] = INF; }
    rep(i, 0, n) { dpb[i] = INF; }
    rep(i, 0, n) { dpc[i] = INF; }
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];

    rep(i, 1, n) {
        dpa[i] = max(dpb[i - 1], dpc[i - 1]) + a[i];
        dpb[i] = max(dpa[i - 1], dpc[i - 1]) + b[i];
        dpc[i] = max(dpa[i - 1], dpb[i - 1]) + c[i];
    }

    return max(dpa[n - 1], max(dpb[n - 1], dpc[n - 1]));
}

int main() {
    int n, ai, bi, ci;

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    int a[n], b[n], c[n];

    rep(i, 0, n) {
        cin >> ai >> bi >> ci;
        a[i] = ai;
        b[i] = bi;
        c[i] = ci;
    }

    int ans = solve(n, a, b, c);
    cout << ans << endl;
}


Measured memory_bytes: 5936
#!/usr/bin/env python3
#ディスカバリーチャンネルコードコンテスト2020 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
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()))

h,w,k = LI()
maze = [list(input()) for _ in range(h)]
ans = [[None]*w for _ in range(h)]
tmp = 1
for i in range(h):
    for j in range(w):
        if maze[i][j] == '#':
            ans[i][j] = tmp
            for k in range(j+1,w):
                if ans[i][k] == None and maze[i][k] == '.':
                    ans[i][k] = tmp
                else:
                    break
            for k in range(0,j)[::-1]:
                if ans[i][k] == None and maze[i][k] == '.':
                    ans[i][k] = tmp
                else:
                    break
            tmp += 1
for i in range(h):
    for j in range(w):
        if ans[i][j] == None:
            for k in range(i+1,h):
                if ans[k][j] != None:
                    ans[i][j] = ans[k][j]
                    break
            else:
                for k in range(0,i)[::-1]:
                    if ans[k][j] != None:
                        ans[i][j] = ans[k][j]
                        break 
for i in ans:
    print(' '.join(list(map(str,i))))

Measured memory_bytes: 50156
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
L = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
D = defaultdict(int)

for i in A:
  if D[L[i]] < i:
    D[L[i]] = i

INF = float("inf")
dp = [-INF]*(N+1)
dp[0] = 0

for i in range(1, N+1):
  for j in D.keys():
    if i-j >= 0:
      dp[i] = max(dp[i], dp[i-j] + 1)
    else:
      dp[i] = max(dp[i], -INF)

ans = ""
temp = N

#なるべく大きい数字から使う
for i, x in sorted(D.items(), key=lambda x: x[1], reverse=True):
  while temp - i >= 0 and dp[temp-i] == dp[temp] - 1:
    ans += str(x)
    temp -= i

print(ans)

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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	int X; cin>>X;
	if(X>=30) cout<<"Yes"; else cout<<"No";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3660
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

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

const ll MAX = 200001;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 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;
    }
}

// 二項係数計算
long long COM(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;
}

using P = pair<int, ll>;
struct node {
    vector<int> link;
    int mattanp;
};

vector<node> nod;
unordered_map<ull, P> mem;

P f(int ind, int parent) {
    ull skey;
    if (parent != -1) {
        skey = ind;
        skey <<= 32;
        skey |= parent;
        if (mem.find(skey) != mem.end()) return mem[skey];
    }
    vector<P> ps;
    for (int i : nod[ind].link) if (i != parent) ps.push_back(f(i, ind));
    int cc = 0;
    ll ret = 1;
    for (int i = 0; i < ps.size(); ++i)cc += ps[i].first;
    int cur = cc;
    for (int i = 0; i < ps.size(); ++i) {
        ret *= COM(cur, ps[i].first);
        cur -= ps[i].first;
        ret %= MOD;
        ret *= ps[i].second;
        ret %= MOD;
    }
    P r = P(cc + 1, ret);
    if(parent != -1) mem.insert(pair<ull, P>(skey, r));
    return r;
}

int main() {
    COMinit();
    int n;
    cin >> n;
    nod.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        nod[a - 1].link.push_back(b-1);
        nod[b - 1].link.push_back(a- 1);
    }
    vector<ll> res(n);
    unordered_map<int, vector<int>> mp;
    rep(i, n) {
        if (nod[i].link.size() == 1) {
            nod[i].mattanp = nod[i].link[0];
            mp[nod[i].mattanp].push_back(i);
        }
        else nod[i].mattanp = -1;
    }
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ll val = f(itr->second[0], -1).second;
        for (int i = 0; i < itr->second.size(); ++i) res[itr->second[i]] = val;
    }
    rep(i, n) if (nod[i].mattanp == -1) res[i] = f(i, -1).second;
    rep(i, n) cout << res[i] << endl;
    return 0;
}



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

using namespace std;
#define ll long long

const int N = 55, M = 18;
int n, k, s, t, a[N], f[1<<M];
ll ans, g[N], C[N][N];
int main() {
	scanf("%d%d%d%d", &n, &k, &s, &t);
	for(int i=0; i<n; ++i){
		scanf("%d", a+i);
		if((a[i]&s)!=s || (a[i]&t)!=a[i]) --i, --n;
		else a[i]^=s;
	}
	C[0][0]=1;
	for(int i=1; i<=n; ++i) for(int j=0; j<=i; ++j) C[i][j]=C[i-1][j]+(j?C[i-1][j-1]:0);
	for(int i=1; i<=n; ++i) for(int j=1; j<=k; ++j) g[i]+=C[i][j];
	for(int i=s^=t;; i=(i-1)&s){
		ll sum=0;
		for(int j=0; j<n; ++j) ++f[a[j]&i];
		for(int j=0; j<n; ++j) sum+=g[f[a[j]&i]], f[a[j]&i]=0;
		ans+=(__builtin_popcount(i)&1?-1:1)*sum;
		if(!i) break;
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

main(){
	int n;
	cin >> n;
	int s=0;
	int a=100000;
	while (s<n){
		s++;
		a=a+a*0.05;
		a=((a+999)/1000)*1000;
	}
	printf("%d\n",a);
}





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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < N; i++){
        map<char,int> m1,m2;
        for (char k = 'a'; k <= 'z'; k++){
            m1.insert(make_pair(k, 0));
            m2.insert(make_pair(k, 0));
        }
        for (int k = 0; k < i; k++){
            m1[s[k]]++;
        }
        for (int k = i; k < N; k++){
            m2[s[k]]++;
        }
        int cnt = 0;
        for (char k = 'a'; k <= 'z'; k++){
            if (m1[k] >= 1 && m2[k] >= 1){
                cnt++;
            }
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
import numpy as np
H, W, D=list(map(int,input().split(" ")))
#print(in1)
#arr=np.zeros((in1[0],in1[1]))
d={}
for i in range(H):
    #arr[i]=input().split(" ")
    for n,k in enumerate(input().split(" ")):
        d[int(k)]=[i,n]
#print(arr)
Q=int(input())
out=[]

cost={}

for i in range(1,D+1):
    now = i + D
    cost[i]=0
    #cost[i]=abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
    while now <= H * W:
        cost[now] = cost[now - D] + abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
        now += D


out=[]
for k in range(Q):
    start,end=list(map(int,input().split(" ")))
    out.append(cost[end]-cost[start])

for i in out:
    print(int(i))


Measured memory_bytes: 55856
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int i, j;
		for(i=1; i<10; i++)
		{
			for(j=1; j<10; j++)
			{
				System.out.println(i + "x" + j + "=" + i*j);
			}
		}

	}

}

Measured memory_bytes: 9028
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val b = next()
    val ret = when {
        b == "A" -> "T"
        b == "C" -> "G"
        b == "T" -> "A"
        b == "G" -> "C"
        else -> ""
    }
    println(ret)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31260
#include <stdio.h>
int a[100];
int main()
{
	int n,m,sum,i,j,k;
	while(~scanf("%d",&n))
	{
		for(i=1;i<=n;i++) scanf("%d",&a[i]);
		sum=0;
		for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++) sum+=(a[i]*a[j]);
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
mod=10**9+7
n=int(input())
l=[0]*(n+1)
for i in range(2,n+1):
    c=Counter(prime_factorize(i)).items()
    for a,b in c:
        l[a]+=b
ans=1
for v in l:
    ans*=(v+1)
    ans=ans%mod
print(ans%mod)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
ll h,n,sum;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    cin>>h>>n;
    for(int i=1;i<=n;i++){
        ll temp; cin>>temp;
        sum += temp;
    }
    if(sum >= h) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a_min = 1
a_max = n
for _ in range(m):
  l,r = map(int,input().split())
  a_min = max(a_min,l)
  a_max = min(a_max,r)
if a_min>a_max:
  print(0)
else:
  print(a_max-a_min+1)


Measured memory_bytes: 3060
S = input()[::-1]

cand = {'maerd', 'remaerd', 'esare', 'resare'}

res = 'YES'

while len(S):
    orig = S
    for w in cand:
        if S.startswith(w):
            S = S[len(w):]
    if orig == S:
        res = 'NO'
        break

print(res)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int dp[5005][5005];
int main(){
    int n;cin >> n;
    string s;cin >> s;
    for(int i=n-1; i>=0; i--){
        for(int j=n-1; j>=0; j--){
            if(s[i]!=s[j]) dp[i][j]=0;
            else dp[i][j]=dp[i+1][j+1]+1;
        }
    }
    int ans=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i>=j) continue;
            int now=min(dp[i][j],j-i);
            ans=max(ans,now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 98048
#include<bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i=0;i<n;++i)
int main(){string s;vector<int>v[2][256];f(i,2){cin>>s;f(j,s.length())v[i][s[j]].push_back(j);}f(i,2)sort(v[i],v[i]+256);puts(equal(v[0],v[0]+256,v[1])?"Yes":"No");}

Measured memory_bytes: 2692
#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;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s;cin>>s;
	if(s.size()%2){
		puts("No");return 0;
	}
	for(int i=0;i<s.size();i+=2){
		if(s[i]!='h'||s[i+1]!='i'){
			puts("No");return 0;
		}
	}
	puts("Yes");
}

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

#define S 0
#define H 1
#define C 2
#define D 3

int main() {

	int n;
	cin >> n;

	int cards[4][13];
	char suit[10];
	int value;

	// 初期化
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 13; j++)
			cards[i][j] = 0;

	for (int i = 0; i < n; i++) {
		cin >> suit >> value;
		value--; // 0オリジンにする
		if (suit[0] == 'S')	cards[S][value] = 1;
		else if (suit[0] == 'H') cards[H][value] = 1;
		else if (suit[0] == 'C') cards[C][value] = 1;
		else if (suit[0] == 'D') cards[D][value] = 1;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (cards[i][j] == 0) {
				if (i == 0) cout << "S " << j + 1 << endl;
				else if (i == H) cout << "H " << j + 1 << endl;
				else if (i == C) cout << "C " << j + 1 << endl;
				else cout << "D " << j + 1 << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

struct edge { int to, cost; };
typedef pair<int, int> P;

int V;
vector<edge> G[100010];
vector<edge> Z[100010];
int d[100010];
int ST[100010];
int GL[100010];
int u[100010];
int v[100010];
int a[100010];
int b[100010];


void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V + 1, INF2);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void dijkstra2(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V + 1, INF2);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < Z[v].size(); i++) {
			edge e = Z[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	V = n;
	rep(i, m) cin >> u[i] >> v[i] >> a[i] >> b[i];

	rep(i, m) {
		G[u[i]].push_back({ v[i], a[i] });
		G[v[i]].push_back({ u[i], a[i] });
		Z[u[i]].push_back({ v[i], b[i] });
		Z[v[i]].push_back({ u[i], b[i] });
	}
	dijkstra(s);
	rep(i, n) ST[i + 1] = d[i + 1];
	dijkstra2(t);
	rep(i, n) GL[i + 1] = d[i + 1];
	int ans[n + 1];
	rep(i, n + 1) ans[i] = INF2;
	ans[n] = ST[n] + GL[n];
	rrep(i, n) ans[i - 1] = min(ans[i], ST[i - 1] + GL[i - 1]);
	rep(i, n) {
		// cout << i + 1 << " " << ST[i + 1] + GL[i + 1] << " " << ans[i + 1] << endl;
		cout << (int)(pow(10, 15) + 0.5) - ans[i + 1] << endl;
	}


    return 0;
}


Measured memory_bytes: 23240
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,S[1000];
void push(int x){
  S[++top]=x;
}
int pop(){
  top--;
  return S[top+1];
}
int main(){
int a,b;
top=0;
char s[100];
while(scanf("%s",s)!=EOF){
  if(s[0]=='+'){
    a=pop();
    b=pop();
    push(a+b);
  }else if(s[0]=='-'){
    b=pop();
    a=pop();
    push(a-b);
  }else if(s[0]=='*'){
    a=pop();
    b=pop();
    push(a*b);
  }else{
    push(atoi(s));
  }
}
printf("%d\n",pop());
return 0;
}



Measured memory_bytes: 2128
from math import gcd

N = int(input())
A = list(map(int, input().split()))

prime = list(range(max(A) + 1))

for i in range(2, len(prime)):
    if prime[i] != i:
        continue
    for j in range(i, len(prime), i):
        if prime[j] != j:
            continue
        prime[j] = i

used = set()
pc = True
for a in A:
    used_this = set()
    while a != 1:
        div = prime[a]
        if div in used:
            pc = False
            break
        used_this.add(div)
        a //= div
    used.update(used_this)

if pc:
    print('pairwise coprime')
    exit()

buf = A[0]
for a in A[1:]:
    buf = gcd(buf, a)
if buf == 1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 132808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << v[n-1] << endl;
}

Measured memory_bytes: 256
//35
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<utility>

using namespace std;


int main(){
  for(int n,h;cin>>n>>h,n|h;){
    set<pair<pair<int,int>,int> > s;
    for(int i=0;i<h;i++){
      string c;
      cin>>c;
      int tp[3]={};
      int d[3]={};
      if(c=="xy"){
	cin>>tp[0]>>tp[1];
	d[2]=1;
      }else if(c=="yz"){
	cin>>tp[1]>>tp[2];
	d[0]=1;
      }else{
	cin>>tp[0]>>tp[2];
	d[1]=1;
      }
      for(int i=1;i<=n;i++){
	s.insert(make_pair(make_pair(tp[0]+d[0]*i,tp[1]+d[1]*i),tp[2]+d[2]*i));
      }
    }
    cout<<n*n*n-s.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 4332
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if ( S.substring(2,3).equals(S.substring(3,4)) ){
      if (S.substring(4,5).equals(S.substring(5,6)) )
      { System.out.println("Yes");
      }
      else
        System.out.println("No");
    }
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 22996
import sys
from io import StringIO
import unittest

def resolve():

    n = int(input())

    dict = {}
    for i in range(n):
        dict[input()] = 1

    print(len(dict.items()))



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
apple
orange
apple"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5
grape
grape
grape
grape
grape"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """4
aaaa
a
aaa
aa"""
        output = """4"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

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

    ll a[n];
    map<ll, int> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        auto itr = m.find(a[i]);

        if(itr == m.end()){
            m[a[i]] = 1;
        }else{
            m[a[i]]++;
        }
    }

    vector<pair<ll, int> > p;
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        p.push_back(make_pair(itr->first, itr->second));
    }

    map<ll ,int> sea;

    sort(p.begin(), p.end());
    int s = p.size();
    ll max = p[s - 1].first;

    int ans = 0;
    for(int i = 0; i < s; i++){
        if(p[i].second == 1){
            auto itr = sea.find(p[i].first);
            if(itr == sea.end()){
                ans++;
            }
        }

        ll k = p[i].first;
        ll t = k;
        while(1){
            if(k > max){
                break;
            }
            sea[k] = 1;
            k += t;
        }
    }

    cout << ans << endl;
}

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

typedef long long int ll;

int main(){

  string s;
  cin >> s;
  int ans;
  if(s == "SUN")ans = 7;
  else if(s == "MON")ans = 6;
  else if(s == "TUE")ans = 5;
  else if(s == "WED")ans = 4;
  else if(s == "THU")ans = 3;
  else if(s == "FRI")ans = 2;
  else if(s == "SAT")ans = 1;
  cout << ans << endl;
}


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

int main()
{
  int a[3],i=0,sum=0;
  for(i=0;i<3;i++){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum<22){
    cout<<"win\n";
  }
  else
  {
    cout<<"bust\n";
  }
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;


int main() {
	int X, A; cin >> X >> A;
	if (X < A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<functional>
#include<numeric>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1};
const int _dy[] = {1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

string randomw(){
  int len = 1 + rand() % 8;

  char buff[12];

  REP(i,len) buff[i] = 'a' + rand() % ('z' - 'a' + 1);
  buff[len] = '\0';

  return string(buff);
}

int main(){
  set<string> word;

  word.insert("a");
  printf("?a\n"); fflush(stdout);

  char last = 'a';

  while(true){
    char str[64];
    scanf("%s", str);

    if(last != str[0] || word.count(str) != 0){
      printf("!OUT\n"); fflush(stdout);
      break;
    }

    string tmp = string(str);
    string next;
    word.insert(tmp);
    while(true){
      next = tmp.substr(tmp.size() - 1) + randomw() + "a";

      if(word.count(next) == 0){
	break;
      }
    }

    word.insert(next);
    last = next[next.size() - 1];

    printf("?%s\n", next.c_str()); fflush(stdout);
  }

  return 0;
}

Measured memory_bytes: 0
n = gets.to_i
DS = gets.split.map(&:to_i)
def median(a)
  return a[a.size/2]
end
def fplus(m)
  left = DS.select{|i| i < m}.sort
  right = DS.select{|i| i >= m}.sort
  while(left.length != right.length) do
  	if left.length < right.length
		left << right.first
    	right.delete_at(0)
  	elsif left.length > right.length
    	right << left.last
    	left.delete_at(left.length-1)
  	end
  end
  return right.sort.first - left.sort.last
end
puts fplus(median(DS))


Measured memory_bytes: 12212
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

using namespace std;
using ll = long long;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main(){
  int n;
  cin >> n;
  ll ans=0;
  repo(c, n-1){
    int num=0;
    for (int i =1; i*i<= n-c; i++)
    {
        if ((n-c) % i == 0 )
        {
            if(i*i== n-c){
              num++;
            } else {
              num+=2;
            }
        }
    }

    ans+=num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def getScore(n):
    c = 0
    for i in range(1, 100):
        c += i
        if n < c:
            return i-1
    return 0


from collections import defaultdict
factors = defaultdict(int)
res = prime_factorize(N)
for n in res:
    factors[n] += 1


ans = 0
for k in factors.keys():
    ans += getScore(factors[k])

print(ans)



Measured memory_bytes: 9464
#include <stdio.h>
#define MAX_N (105)

int n;
int G[MAX_N + 1][MAX_N + 1];
int d[MAX_N + 1];		// ????????????
int f[MAX_N + 1];		// ????????????
int time;
int dfs(int cur)
{
    d[cur] = time;
    for ( int i = 1; i <= n; i++ ) {
	if ( G[cur][i] && (d[i] == 0)) {
	    time++;
	    dfs(i);
	}
    }
    time++;
    f[cur] = time;
}

int main()
{
    scanf("%d", &n);
    
    for ( int i = 0; i < n; i++ ) {
	int u, k;
	scanf("%d %d", &u, &k);
	for ( int j = 0; j < k; j++ ) {
	    int v;
	    scanf("%d", &v);
	    G[u][v] = 1;
	}
    }

    time = 0;

    for ( int i = 1; i <= n; i++ ) {
	if ( d[i] == 0 ) {
	    time++;
	    dfs(i);
	}
    }


    for ( int i = 1; i <= n; i++ ) {
	printf("%d %d %d\n", i, d[i], f[i]);
    }

    return 0;
}

Measured memory_bytes: 1068
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        String N = scanner.nextLine();
        int count = 0;
        int L = N.length();
       
        for(int i=0; i<L; i++){
            if(N.charAt(i)!=N.charAt(L-1-i)){
                count = count + 1;
            }
        }
        
        System.out.println(count/2);
        
    }
}


Measured memory_bytes: 23892
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] A;
	int m,cnt;
	int h;
	public ArrayList<Integer> G  = new ArrayList<Integer>();
	
	public void input() {
		n = sc.nextInt();
		A = new int[n];
		for(int i=0; i<n; i++) {A[i] = sc.nextInt();}
	}
	
	public void shellSort() {
		cnt = 0;
		m = 0;
		for(h =1; h<=n; h=h*3+1) {
			m++;
			G.add(h);
		}
		for(int i=m-1; i>=0; i--) {insertSort(G.get(i));}
	}
	
	public void insertSort(int g) {
		for(int i=g; i<n; i++) {
			int v = A[i];
			int j = i -g;
			while(j>=0 && A[j] > v) {
				A[j+g]  =A[j];
				j -= g;
				cnt++;
			}
			A[j+g] = v;
		}
	}
	
	public void output() {
		System.out.println(m);
		for(int i=G.size()-1; i>=0; i--) {
			if(i == 0) System.out.println( G.get(i) );
			else System.out.print(G.get(i)+" ");
		}
		System.out.println(cnt);
		for(int i=0; i<n; i++) System.out.println(A[i]);
		System.out.println();
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.shellSort();
		obj.output();
	}
}



Measured memory_bytes: 306988
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int col[1000];
main()
{
    int n;
    cin>>n;
    for(int i=1;i<=20;i++)
    {
        int st=(1<<i);
        while(st<n)
        {
            col[st]=i;
            st+=(1<<i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            cout<<col[j-i]+1<<" ";
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 512
using System;

class E
{
	static void Main()
	{
		var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int h = a[0], w = a[1], k = a[2];

		Func<MInt, MInt, MInt> c = (x, y) => x * (x * x - 1) / 6 * y * y;
		Console.WriteLine(((c(h, w) + c(w, h)) * MInt.MNcr(h * w - 2, k - 2)).V);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x) => x;
	public static MInt operator -(MInt x) => -x.V;
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Pow(int i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}

	public static long MFactorial(int n) { for (long x = 1, i = 1; ; x = x * ++i % M) if (i >= n) return x; }
	public static long MNpr(int n, int r)
	{
		if (n < r) return 0;
		for (long x = 1, i = n - r; ; x = x * ++i % M) if (i >= n) return x;
	}
	public static MInt MNcr(int n, int r) => n < r ? 0 : n - r < r ? MNcr(n, n - r) : (MInt)MNpr(n, r) / MFactorial(r);
}


Measured memory_bytes: 13140
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: usize,
      a: [usize; n]
   }
   let mut f: usize = 0;
   for a in a {
      f += a-1;
   }
   println!("{}", f);
}


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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<pair<ll, ll>> vp;
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		vp.emplace_back(a + b, a);
	}
	sort(vp.rbegin(), vp.rend());
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) ans += vp[i].second;
		else ans -= vp[i].first -vp[i].second;
	}
	cout << ans;
	
	return 0;
}

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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_io;
    int n,x, t;
    cin >> n >> x >> t;
    int temp = n % x;
    int ans =0 ;
    if(temp > 0)
    {
        ans = (n / x) * t + t;
        cout << ans << "\n";
    }
    else
    {
        ans = (n / x) * t ;
        cout << ans << "\n";
    }

}


Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
from collections import deque

N, D, A = map(int, input().split())
X = []
for _ in range(N):
    x, h = map(int, input().split())
    X.append((x, h))
X = sorted(X)[::-1]
Q = deque([])

ans = 0
k = 0
while X:
    if len(Q) == 0 or X[-1][0] <= Q[0][0]:
        x, h = X.pop()
        h = max(h - k * A, 0)
        a = (h + A - 1) // A
        ans += a
        k += a
        deque.append(Q, (x + 2 * D, a))
    else:
        x, a = deque.popleft(Q)
        k -= a

print(ans)

Measured memory_bytes: 35012
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
  	int a[3][3];
  	int n, b,c[3][3]={0}, count;
	 
  	for(int i = 0; i < 3; i++)
  	{
	    for(int j = 0; j < 3; j++)
		{
	      scanf("%d", &a[i][j] );
	    }
  	}
  	scanf("%d",&n );
 
 	/*84 97 66
	79 89 11
	61 59 7*/
	
  	for (int k = 0; k < n; k++)
  	{
	    scanf("%d",&b);
	    for (int i = 0; i < 3; i++)
		{
	      	for (int j = 0; j < 3; j++)
		  	{
		        if (a[i][j] == b)
				{
		          c[i][j] = 1;
		        } /* 1 1 1    //a[0][0] = 84, c[0][0] = 1;
		                            0 0 0        //a[0][1] = 97, c[0][1] = 1
		                            0 0 0*/    //a[0][2] = 66, c[0][2] = 1;
		    }
	    }
  	}
	 
  	if (c[0][0] + c[1][1] + c[2][2]== 3 || c[0][2] + c[1][1] + c[2][0] == 3)
	{
	    //dalam keadaan diagonal//
	    puts("Yes");
	    return 0;
	}
	 
  	for (int i = 0; i < 3; i++)
	{
	    if (c[i][0] + c[i][1] + c[i][2] == 3 || c[0][i] + c[1][i] + c[2][i] == 3)
		{
	        //dalam keadaan sebaris || dalam keadaan sekolom//
	       	puts("Yes");
	        return 0;
	    }
    }
 	
	puts("No");
	 
	    return 0;
	}

Measured memory_bytes: 1664
printCmd :: [String] -> String -> IO String
printCmd (a:b:_) s = putStrLn res >> return (s)
  where
    res = drop (read a) . take (read b+1) $ s

reverseCmd :: [String] -> String -> IO String
reverseCmd (a:b:_) s = return (pre ++ (reverse rev) ++ aft)
  where
    pre = take (read a) s
    rev = drop (read a) . take (read b+1) $ s
    aft = drop (read b+1) s

replaceCmd :: [String] -> String -> IO String
replaceCmd (a:b:r:_) s = return (pre ++ r ++ aft)
  where
    pre = take (read a) s
    aft = drop (read b+1) s

command :: Int -> String -> IO ()
command 0 _ = return ()
command n s = do
  c <- getLine
  case getCommand c of
    "print"   -> printCmd (getArgument c) s >>= command (n-1)
    "reverse" -> reverseCmd (getArgument c) s >>= command (n-1)
    "replace" -> replaceCmd (getArgument c) s >>= command (n-1)
  where getCommand = head . words
        getArgument = tail . words

main = do
  w <- getLine
  n <- getLine
  command (read n) w

Measured memory_bytes: 5488
while True:
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)

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

using namespace std;

int n, a, b, c, d;

int main(){
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	
	printf("%d\n", min((int)ceil(n * 1.0 / a) * b, (int)ceil(n * 1.0 / c) * d));
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

ll pp[202020],mm[202020];

int solve(int X){
  if(X==0) return 0;
  int pc=__builtin_popcount(X);
  return (solve(X%pc)+1);
}

int main(){
  int N; cin>>N;
  string S; cin>>S;
  int pc=0;
  rep(i,N) pc+=(S[i]=='1');
  ll m=0,p=0;
  pp[0]=1;
  mm[0]=1;
  rep(i,N){
    p=(p+pp[i]*(S[N-1-i]=='1'))%(pc+1);
    pp[i+1]=pp[i]*2%(pc+1);
    if(pc>1) m=(m+mm[i]*(S[N-1-i]=='1'))%(pc-1);
    if(pc>1) mm[i+1]=mm[i]*2%(pc-1);
  }
  rep(i,N){
    int tmp=0;
    if(S[i]=='1'){
      if(pc>1) tmp=(m-mm[N-1-i]+(pc-1))%(pc-1);
      else{
        cout<<"0\n";
        continue;
      }
    }else{
      tmp=(p+pp[N-1-i])%(pc+1);
    }
    cout<<solve(tmp)+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 6728