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

int main()
{
	long long n; 
	scanf("%lld", &n);
	int cnt = 0;
	long long sq = sqrt(n)+2;
	for(int i = 2; i < sq; i++) {
		int c = 0;
		while(n % i == 0) {
			c++;
			n/=i;
		}
		int k = 1;
		while(c > 0) {
			c -= k;
			k++;
		}
		if(c < 0) k--;
		cnt += k-1;
		if(!n) break;
	}
	if(n > 1) cnt++;
	printf("%d\n", cnt);
}

Measured memory_bytes: 3816
N = int(input())
A = list(map(int, input().split()))

def main():
    absA = [abs(a) for a in A]
    total = sum(absA)
    if 0 in A or not len([a for a in A if a < 0]) % 2:
        print(total) 
    else:
        print(total - 2*min(absA))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14412
#include<iostream>

using namespace std;

int main() {
	int N, D;
	cin >> N >> D;

	int d = 2 * D + 1;

	if (N % d == 0) {
		cout << N/d << endl;
	}
	else {
		cout << N/d + 1 << endl;
	}
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

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

    int ans = 0;
    rep(i, n-2) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3520
MOD = 10 ** 9 + 7

n, k = map(int, input().split())
out = 0

for i in range(k, n + 2):
    MIN = (i * (i - 1))//2
    MAX = (n * i) - MIN
    out += MAX - MIN + 1
    out %= MOD
print(out)



Measured memory_bytes: 63468
import heapq
import collections
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
L = [collections.deque() for i in range(n)]

queries = list()
for i in range(q):
    queries.append(list(map(int, input().split())))

for query in queries:
    if query[0] == 0:
        L[query[1]].append(query[2])
    elif query[0] == 1:
        print(*L[query[1]])
    elif query[0] == 2:
        if L[query[2]]:
            if len(L[query[1]]) == 1:
                L[query[2]].append(L[query[1]][0])
            elif len(L[query[2]]) == 1:
                L[query[1]].appendleft(L[query[2]][0])
                L[query[2]] = L[query[1]]
            else:
                L[query[2]].extend(L[query[1]])
        else:
            L[query[2]] = L[query[1]]
        L[query[1]] = collections.deque()


Measured memory_bytes: 97304
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

n=gets.to_i
a=get_i

ans=0
min=1
a.each do|i|
  if min==i
    min+=1
  else
    ans+=1
  end
end
puts (ans==n ? "-1" : ans)


Measured memory_bytes: 18564
#include<stdio.h>
#include<string.h>
int main(void)
{
	char n[10001],joi[4]="JOI",ioi[4]="IOI";
	int c,flg,i,a,j,c2;
	while(scanf("%s",n) != EOF){	
	a=strlen(n);
	c=0; c2=0;
	for(i=0;i<a;i++){
		if(n[i]=='J'){
			flg=1;
			for(j=0;j<3;j++){
				if(i+j>a) break;
				if(n[i+j]!=joi[j]){
					flg=0; break;
				}
			}
			if(flg==1) c++;
		}
		if(n[i]=='I'){
			flg=1;
			for(j=0;j<3;j++){
				if(i+j>a) break;
				if(n[i+j]!=ioi[j]){
					flg=0; break;
				}
			}
			if(flg==1) c2++;
		}
	}
	printf("%d\n",c);
	printf("%d\n",c2);
	}
	return 0;
}

Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int h, w;
char c[30][30];

int main() {
    cin >> h >> w;
    rep(i,h) rep(j,w) cin >> c[i][j];
    int ans = 0;
    rep(i,h) rep(j,w) rep(k,h) rep(l,w) {
        if (c[i][j] == '.' || c[k][l] == '.') continue;
        ans = max(ans, abs(k-i)+abs(l-j));
    }
    cout << ans << endl;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main(void)
{
  long long body, legs, N, max, min;
  scanf("%lld %lld", &body, &legs);
  N = legs % 2;
  max = body * 4;
  min = body * 2;
  if (N == 1)
  {
    printf("No");
  }
  else
  {
    if (legs >= min && legs <= max)
    {
      printf("Yes");
    }
    else
    {
      printf("No");
    }
  }
  return 0;
}


Measured memory_bytes: 1728
# include <bits/stdc++.h>
# define rr register
# define int long long
const int N=100010,INF=0x3f3f3f3f;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
signed main(void){
	int x;
	x=read();
	int s=x/500;
	x%=500;
	int t=x/5;
	printf("%lld",s*1000+t*5);
	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    stdin
        .read_line(&mut buf)
        .unwrap();

    let n: usize = buf.trim().parse().unwrap();

    let mut m = 1;

    for i in 1..n {
        if m * 2 <= n {
            m *= 2;
        } else {
            break;
        }
    }

    println!("{}", m);
}

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

int main(){
	int n, input, bf = 0;
	ll ans = 0;
	cin >> n;
	rep(i, n){
		cin >> input;
		ans += (input+bf)/2;
		if(input == 0) bf = 0;
		else bf = (input+bf) % 2;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let n = read::<i64>();
  let k = read::<i64>();

  let mut a: Vec<i64> = vec![0; n as usize];
  for i in 0..n {
    a[i as usize] = read::<i64>();
  }

  let ans = (n - 1) / (k - 1) + (if (n - 1) % (k - 1) > 0 { 1 } else { 0 });
  println!("{}", ans);
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll h,w;
    cin>>h>>w;
    if(h==1|| w==1){
        cout<<1<<endl;
        return 0;
    }
    ll h0=h/2;
    ll h1=h-h0;
    ll w0=w/2;
    ll w1=w-w0;
    //cout<<h0<<endl;
    //cout<<w0<<endl;
    //cout<<h1<<endl;
    //cout<<w1<<endl;
    cout<<h0*w0+h1*w1<<endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    n = inp()
    g = [[] for _ in range(n)]
    color = [0 for _ in range(n)]
    did = [0 for _ in range(n)]
    dic = defaultdict(str)
    p = []
    for _ in range(n-1):
        a,b = inpm()
        a -= 1
        b -= 1
        g[b].append(a)
        g[a].append(b)
        if a<b:
            a,b = b,a
        key = [str(a)]
        key.append(' ')
        key.append(str(b))
        key = ''.join(key)
        p.append(key)
        dic[key] = 1
    que = deque([])
    did[0]=1
    que.append(0)
    ans = 0
    while que:
        start = que.pop()
        go = g[start]
        c = 1
        for i in range(len(go)):
            t = go[i]
            if did[t]:
                continue
            else:
                if c == color[start]:
                    c += 1
                did[t] = 1
                que.append(t)
                color[t] = c
                ans = max(ans,c)
                key = []
                x = start
                y = t
                if x<y:
                    x,y = y,x
                key.append(str(x))
                key.append(' ')
                key.append(str(y))
                key = ''.join(key)
                dic[key] = c
                c += 1
    print(ans)
    for i in range(n-1):
        key = p[i]
        print(dic[key])

if __name__ == "__main__":
    main()

Measured memory_bytes: 98208
// C - Half and Half

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	ll ans = INF;
	for (int c=0; c <= max(X * 2, Y * 2); c+=2) {
		int a = max(0LL, X - (c / 2));
		int b = max(0LL, Y - (c / 2));

		ll cost = A * a + B * b + C * c;
		ans = min(ans, cost);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
using namespace std;

int main() {
	int n, cnt = 0;
	cin >> n;
	vector <int> a(n);
	int next = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < n; j++) {
		next = a[next - 1];
		cnt++;
		if (next == 2) {
			break;
			cnt++;
		}
	}
	if (next != 2) {
		cnt = -1;
	}
	cout << cnt << endl;
}

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

using namespace std;

int main() {

	int n;

	cin >> n;

	unordered_map<string,int> d;

	for(int i=0;i<n;i++) {
		
		string t;
		cin >> t;
		d[t]++;

	}

	vector<string> con={"AC","WA","TLE","RE"};

	for(int i=0;i<con.size();i++) {

		cout<< con[i] << " x " <<d[con[i]] <<"\n";

	}
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		if(n == m ) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

	
}

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

int main() {
	string s;
	cin >> s;
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout << "Yes";
	else cout << "No";
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> par;
typedef vector<ll> vi;
typedef vector<par> vp;
typedef vector<vi> graph;
typedef vector<vp> wgraph;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repx(i, a, b) for (size_t i = a; i < (size_t)b; i++)
#define invrep(i, a, b) for (int i = b; i-- > (int)a;)

#define pb push_back
#define eb emplace_back
#define ppb pop_back

#define umap unordered_map

#define lg(x) (31 - __buitlin_clz(x))
#define lgg(x) (63 - __buitlin_clzll(x))
#define gcd __gcd

//ios::sync_with_stdio(0); cin.tie(0);
//cout.setf(ios::fixed); cout.precision(4);

#define debugx(x) cerr << #x << ": " << x << endl
#define debugv(v)         \
    cerr << #v << ":";    \
    for (auto e : v)      \
        cerr << " " << e; \
    cerr << endl
#define debugm(m)  //\
    cerr << #m << endl;                                  \
    rep(i, (int)m.size())                                \
    {                                                    \
        cerr << i << ":";                                \
        rep(j, (int)m[i].size()) cerr << " " << m[i][j]; \
        cerr << endl;                                    \
    }
#define debugmp(m) //\
    cerr << #m << endl;                                                                         \
    rep(i, (int)m.size())                                                                       \
    {                                                                                           \
        cerr << i << ":";                                                                       \
        rep(j, (int)m[i].size()) cerr << " {" << m[i][j].first << "," << m[i][j].second << "}"; \
        cerr << endl;                                                                           \
    }
#define print(x) copy(x.begin(), x.end(), ostream_iterator<int>(cout, “”)), cout << endl

ll MOD = (int)1e9 + 7;
ll N;

vi DP;
vector<bool> steps;
ll func(ll n)
{
    if (n >= N)
        return 1;
    if (DP[n] != -1)
        return DP[n];

    if (steps[n + 1] and steps[n + 2])
        return DP[n] = 0;

    if (steps[n + 1])
        return DP[n] = (func(n + 2) % MOD);

    if (steps[n + 2])
        return DP[n] = (func(n + 1) % MOD);

    if (n + 2 <= N)
        return DP[n] = ((func(n + 1) + func(n + 2)) % MOD);

    return DP[n] = (func(n + 1) % MOD);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int m;
    cin >> N >> m;
    DP.assign(N + 1, -1);
    steps.assign(N + 2, false);
    rep(i, m)
    {
        int t;
        cin >> t;
        steps[t] = true;
    }
    cout << func(0) << endl;
}

Measured memory_bytes: 4224
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    map<ll, vector<ll>> ind;
    vector<ll> jmp(n, -1);
    REP(i, n) {
        ind[a[i]].push_back(i);
    }
    REP(i, n) {
        auto &aind = ind[a[i]];
        ll ij = upper_bound(ALL_OF(aind), i) - aind.begin();
        if (ij != aind.size()) {
            jmp[i] = aind[ij];
        }
    }
    vector<ll> remf(n+1, -1);
    DSRNG(i, n-1, 0) {
        if (jmp[i] != -1) {
            remf[i] = remf[jmp[i] + 1];
        } else {
            remf[i] = a[i];
        }
    }
    // DUMPALL(remf);
    map<ll, ll> nxt;
    for (auto v : ind) {
        ll ai = v.first;
        auto &aind = v.second;
        nxt[ai] = remf[aind.front() + 1];
    }
    nxt[-1] = remf.front();

    vector<ll> hsh; hsh.reserve(n);
    ll afr = -1;
    while (1) {
        hsh.push_back(afr);
        afr = nxt[afr];
        if (afr == -1) break;
    }

    ll prev = hsh[(k-1) % hsh.size()];
    vector<ll> ans; ans.reserve(n);
    for (ll i = prev == -1 ? 0 : ind[prev].front() + 1; i < n; ) {
        if (jmp[i] != -1) {
            i = jmp[i] + 1;
        } else {
            ans.push_back(a[i]);
            i++;
        }
    }
    REP(i, ans.size()) {
        cout << ans[i] << " \n"[i == i_len - 1];
    }
    
}

Measured memory_bytes: 44516
def main():
    while True:
        n, x = map(int, input().split())
        if n == 0 and x == 0:
            break
        ans = solve(n, x)
        print(ans)


def solve(n, x):
    if x < 6:
        return 0
    M = n - 3
    S = x - 6
    dp = [[0 for i in range(S + 1)] for j in range(4)]
    dp[0][0] = 1
    for i in range(1, 4):
        for j in range(S + 1):
            if j - i < 0:
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = dp[i - 1][j] + dp[i][j - i]
                if j - i - M >= 0:
                    dp[i][j] -= dp[i - 1][j - i - M]
    ret = dp[3][S]
    return ret


main()



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i <= (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int gcd(int a,int b) { 

    if(a>b) swap(a,b); 

    if(a%b==0) return b;        //最大公約数 

    else return gcd(a,b); 

} 

int main() {
	ll n; cin >> n;
	ll ans=0;
	rrep(i,1,n)rrep(j,1,n)rrep(k,1,n) {
		ans+=gcd(i,gcd(j,k));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n, ans;
    while(cin >> n, n){
        ans = 0;
        range(i, 1, n){
            int sum = 0;
            range(j, i, n){
                sum+= j;
                if(sum == n) ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, z, w = map(int, input().split())
    A = list(map(int, input().split()))

    res = abs(w - A[-1])
    if n > 1:
        res = max(res, abs(A[-2] - A[-1]))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9152
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
int main(){
		LL n,m;
		cin >> n;
		cout << (1 + n) * n / 2 << endl;
		return 0;
	}//

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include<algorithm>
using namespace std;
int main(){

    
    long n,x;
    cin>>n>>x;
    long city[n];
    long long citysa[n];
    for(int i=0;i<n;i++){
        cin>>city[i];
        citysa[i]=abs(city[i]-x);
    }
    long long cmax=0;
    long long cmin=citysa[0];
    
    for(int i=0;i<n;i++){
        if(cmax<=citysa[i]){
        cmax=citysa[i];
        }
        if(cmin>=citysa[i]){
            cmin=citysa[i];
        }
    }

    long kouyaku;
    if(n==1){
        cout<<cmax;
        return 0;
    }
    
    for(int i=1;i<=cmin;i++){
        int flag = 0;
        if(i>cmin)break;
        for(int j=0;j<n;j++){
            if(citysa[j]%i!=0){
                flag=1;
                break;
            }
        }
        if(flag==0){
            kouyaku=i;
        }
        
    }
    cout<<kouyaku;
    
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
const int maxn=1e3+10;
int a[maxn];
int main()
{
    int n,k,d,s;
    cin>>n>>k;
    For(i,1,k)
    {
        cin>>d;
        For(j,1,d)
        {
            cin>>s;
            a[s]++;
        }
    }
    int ans=0;
    For(i,1,n)if(a[i]==0)ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3536
#include <iostream>

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

int main () {
  int N, A;
  std::cin >> N >> A;
  REP(i, A+1) {
      if ((N - i) % 500 == 0) {
          std::cout << "Yes" << std::endl;
          return 0;
      }
  }
  std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 3596
<?php
while(fscanf(STDIN,"%d %s %d", $a, $op, $b)){
    if($op == "?"){ break; }
    echo keisan($a, $op, $b).PHP_EOL;
}

function keisan($A, $OP, $B){
    if($OP == "+"){
        return $A + $B;
    }elseif ($OP == "-") {
        return $A - $B;
    }elseif ($OP == "*") {
        return $A * $B;
    }elseif ($OP == "/") {
        return floor($A / $B);
    }
}

Measured memory_bytes: 15188
import java.util.*;

public class Main {
	final int INF = Integer.MAX_VALUE / 2;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;
			int [] nlist = new int[n];
			int [] mlist = new int[m];
			for(int i=0; i < m; i++){
				mlist[i] = sc.nextInt();
			}
			for(int i = 0; i < n; i++){
				nlist[i] = sc.nextInt();
			}
			int [][] dp = new int[n+1][256];
			for(int i=0; i <= n; i++){
				for(int j=0; j < 256; j++){
				dp[i][j] = INF;
				}
			}
			dp[0][128] = 0;
			for(int i=0; i < n; i++){
				for(int j=0; j < 256;j++){
					if(dp[i][j] == INF) continue;
					
					for(int k=0; k < m; k++){
						int ind = j +mlist[k];
						if(ind < 0) ind = 0;
						if(ind > 255) ind = 255;
						
						int diff = ind - nlist[i];
						int value = dp[i][j] + (diff * diff);
						dp[i+1][ind] = Math.min(dp[i+1][ind], value);
						//System.out.println("dp=" + dp[i+1][ind] + " " + (i+1));
					}
				}
			}
//			for(int i=0; i <= n; i++){
//				for(int j=0; j < 255; j++){
//					if(dp[i][j] == INF){
//						System.out.print("INF ");
//					}
//					else{
//						System.out.print(dp[i][j] + " ");
//					}
//					
//				}
//				System.out.println();
//			}
			int ans = INF;
			for(int i=0; i < 256; i++){
				ans = Math.min(ans, dp[n][i]);
			}
			System.out.println(ans);
		}
	}

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

Measured memory_bytes: 38000
def gcd(m,n):
    if m < n:
        m,n=n,m
    if n==0:
        return m
    if m % n == 0:
        return n
    else:
        return gcd(n,m%n)

A,B,C,D=map(int,input().split())
X=B-(B//C)-(B//D)+ B//(C*D//gcd(C,D))
Y=(A-1)-((A-1)//C)-((A-1)//D)+(A-1)//(C*D//gcd(C,D))
print(X-Y)


Measured memory_bytes: 3060
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_6-B
Array - Finding Missing Cards
Time Limit : 1 sec, Memory Limit : 65536 KB
????¶???????????????????????????????

???????????±?????¨?????????????????????????????????????????¨????????¨?????????52?????????????????????????????? n ???????????????????????????????????????????????????????????? n ????????????????????\?????¨??????????¶??????????????????????????????????????????°?????????????????????????????????

???????????????????????£?????????????????????????????§??????????????????52?????????????????§??????

52??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????13??????????????????????????????
Input

?????????????????????????????£??????????????????????????° n (n ??? 52)????????????????????????

?¶??????? n ??????????????????????????????????????????????????????????????????????????????????????§???????????????????????¨??´??°??§??????????????????????????????????????¨?????????????????????'S'???????????????'H'???????????????'C'???????????????'D'??§??¨???????????????????????´??°??????????????????????????????(1 ??? 13)?????¨??????????????????
Output

?¶??????????????????????????????????1???????????????????????????????????????????????\?????¨????§?????????????????????§???????????????????????¨??´??°??§?????????????????????????????????????????\????????¨????????¨????????????

    ????????????????????????????????????????????????????????????????????§???????????????????????????
    ?????????????????´??????????????????????°????????????????????????????

Sample Input

47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13

Sample Output

S 1
H 3
H 7
C 12
D 8

=end

card = Hash.new
n = gets.to_i
while $_ = STDIN.gets do
  f = $_.chomp.split
  kind = f[0]
  rank = f[1]
  card[kind + rank] = true
end

["S","H","C","D"].each {|k|
  (1..13).each {|r|
    if not card[k + r.to_s] then
      printf("%s %d\n", k, r)
    end
  }
}

Measured memory_bytes: 8628
package main

import "fmt"

func main() {
	var str string
	fmt.Scan(&str)
	var a, b int
	for i := 0; i < len(str); i++ {
		if str[i] == '1' {
			a++
		}
		if str[i] == '0' {
			b++
		}
	}
	var ret int
	if a < b {
		ret = a * 2
	} else {
		ret = b * 2
	}
	fmt.Println(ret)
}


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

#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define mk make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

const int M = 7400000;
int v[M];
int main(){
	int n,m;
	while(cin >> m >> n, m){
		fill(v, v+M, 0);
		reps(i, m, M){
			if(!v[i]){
				for(int j=i+i; j< M; j+= i)v[j] = 1;
				n--;
			}
			if(n<0){
				cout << i <<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 31988
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec X(N); cin >> X;
    
    int ans = INF;
    FOR(x, 1, 101){
        int tmp = 0;
        REP(i, N) tmp += (X[i] - x) * (X[i] - x);
        Min(ans, tmp);
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappush,heappop
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(N)]
arr = [[] for _ in range(M+1)]
for a, b in AB:
    if M-a>=0:
        arr[M-a].append(b)

ans=0
h=[]
for i in reversed(range(M+1)):
    for a in arr[i]:
        heappush(h,-a)
    if len(h)>0:
        ans += (-1)*h[0]
        heappop(h)
print(ans)


Measured memory_bytes: 80472
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<60;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n;
  cin>>n;
  vector<P> A(n);
  cin>>A;
  for(auto &p:A) if(p.first > p.second) swap(p.first,p.second);
    
  sort(A.begin(),A.end());
  multiset<int> B,R;
  for(auto &p:A) B.insert(p.first), R.insert(p.second);
  set<P> Idx; 
  for(int i=0;i<n;i++) Idx.insert(P(A[i].first,i));

  int ans = INF;
  for(auto p:Idx){
    int idx = p.second;
    B.erase(B.find(A[idx].first));
    R.erase(R.find(A[idx].second));
      
    B.insert(A[idx].second);
    R.insert(A[idx].first);
    int Rmin = *R.begin();
    int Rmax = *(--R.end());
    int Bmin = *B.begin();
    int Bmax = *(--B.end());
    int val = (Rmax - Rmin) * (Bmax - Bmin);
    Min(ans,val);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 34688
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <cstdlib>


using namespace std;

int main() {
    

    long long n;
    cin >> n;
    long long a;
    cin >> a;
    long long max_n, min_n, sum;
    max_n = a;
    min_n = a;
    sum = 0;
    sum += a;
    for (int i = 1; i < n; i++) {
        cin >> a;
        sum += a;
        if (max_n < a) {
            max_n = a;
        }
        if (min_n > a) {
            min_n = a;
        }
    }
    cout << min_n << " " << max_n << " " << sum << endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<ctime>
#include<vector>

using namespace std;

#define eps 0.0000000001

struct vec{
  double x, y;
  void nextvec(){ scanf("%lf %lf", &x, &y); return; }
  vec operator+(const vec& a) const { return (vec){x + a.x, y + a.y}; }
  vec operator-(const vec& a) const { return (vec){x - a.x, y - a.y}; }
  vec operator*(const double& k) const { return (vec){k * x, k * y}; }
  vec sca(double t){ return (vec){t * x, t * y}; }
  double dot(vec a){ return x * a.x + y * a.y; }
  double cross(vec a){ return x * a.y - y * a.x; }
  double norm(){ return sqrt(x * x + y * y); }
  double norm2(){ return x * x + y * y; }
};

bool xsort(vec qwe, vec rty){ return qwe.x < rty.x; }
bool ysort(vec qwe, vec rty){ return qwe.y < rty.y; }

vec pt[500000];
vec ytmp[500000];
vec ymerge[500000];
double ma = 100000000000.0;

double closestpair(int l, int r){
  if(r - l <= 1)return ma;
  int m = l + (r - l) / 2;
  double xm = pt[m].x;
  double res = min(closestpair(l, m), closestpair(m, r));
  double d = sqrt(res);

  int hdmerge = 0, hdtmp = 0, lhd = l, rhd = m;
  vec now;
  for(;;){
    if(lhd == m && rhd == r)break;
    else if(rhd == r)now = pt[lhd++];
    else if(lhd == m)now = pt[rhd++];
    else if(ysort(pt[lhd], pt[rhd]))now = pt[lhd++];
    else now = pt[rhd++];

    ymerge[hdmerge++] = now;
    if(abs(now.x - xm) <= res + eps){
      ytmp[hdtmp++] = now;
      for(int i = hdtmp - 2;i >= 0;--i){
        if(abs(ytmp[i].y - now.y) >= d - eps)break;
        res = min(res, (now - ytmp[i]).norm2());
        d = sqrt(res);
      }
    }
  }
  for(int i = l;i < r;++i)pt[i] = ymerge[i - l];

  return (int)res;
}

signed main(void){
  int n;
  scanf("%d", &n);
  for(int i = 0;i < n;++i)pt[i].nextvec();
  sort(pt, pt + n, xsort);
  printf("%d\n", (int)closestpair(0, n));

  return 0;
}

Measured memory_bytes: 19248
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
long long int s,w;
cin>>s>>w;
if(w>=s)

    cout<<"unsafe"<<endl;

else
 cout<<"safe"<<endl;
     return 0;
}


Measured memory_bytes: 3640
comb = []
def f(n,cnt,ls):
    if cnt == n:
        comb.append(ls)
        return
    for i in range(ls[cnt-1],m+1):
        tmp = ls.copy()
        tmp[cnt] = i
        f(n,cnt+1,tmp)
    return
ma = lambda :map(int,input().split())
ni = lambda:int(input())

n,m,q = ma()
abcd = []
for i in range(q):
    abcd.append(list(ma()))
ls = [1]*(n+1)
f(n,0,ls)
ans = 0
for A in  comb:
    tmp = 0
    for a,b,c,d in abcd:
        if A[b-1] - A[a-1] ==c:
            tmp +=d
    ans = max(ans,tmp)
print(ans)


Measured memory_bytes: 24256
// ABC_142_D

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

using ll = long long;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x%y) : x;
}

vector<pair<ll, ll>> prime_factori(ll n) {
	vector<pair<ll, ll>> res;

	for(ll i = 2; i * i <= n; ++i) {
		if(n % i != 0) continue;

		ll exp = 0;
		while(n % i == 0){
			++exp;
			n /= i;
		}
		res.push_back({i, exp});
	}

	if(n != 1) res.push_back({n, 1});

	return res;
}


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

	ll gcd_num = gcd(n, m);
	const auto &res = prime_factori(gcd_num);

	cout << res.size() + 1 << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); 
        String nyu = sc.next();
        int cnt = 0 , mem = 0 , leng;
        leng = nyu.length();
        for(int i=0 ; i < leng ; i++){
            char top = nyu.charAt(i);
            switch(top){
                case 'A':
                    cnt += 1;
                    break;
                case 'C':
                    cnt += 1;
                    break;
                case 'G':
                    cnt += 1;
                    break;
                case 'T':
                    cnt += 1;
                    break;
                default :
                    if(cnt > mem){
                        mem = cnt;
                        cnt = 0;
                    }
            }
        }
      if(cnt > mem){
            mem = cnt;
        }
        System.out.println(mem);
    }
    
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m>>k;

	si st;

	f(i,n,m){
        if(count<k) st.insert(i),count++;
        if(count==k) break;
	}
	count=0;
	rf(i,m,n){
        if(count<k) st.insert(i),count++;
        if(count==k) break;
	}
	for(auto x:st) cout<<x<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,M;
int A[110];
signed main(){
    scanf("%lld %lld",&N,&M);
    int sum=0;
    rep(i,N){
        scanf("%lld",&A[i]);
        sum+=A[i];
    }
    sort(A,A+N,greater<int>());
    if(A[M-1]*4*M>=sum)printf("Yes\n");
    else printf("No");
    return 0;
}


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

#define fi first
#define se second
typedef pair<int,int> PII;


int n, prv[1<<20], nxt[1<<20], a[1<<20];
long long ans;

int main() {
    cin >> n;
    deque <PII> dq;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int it = i;
        while (!dq.empty() && a[dq.back().fi] > a[i]) {
            int l = dq.back().se, m = dq.back().fi, r = i;
            ans += 1LL * a[m] * (m - l + 1) * (r - m);
            it = l, dq.pop_back();
        }
        dq.push_back({i,it});
    }
    while (!dq.empty()) {
            int l = dq.back().se, m = dq.back().fi;
            ans += 1LL * a[m] * (m - l + 1) * (n - m);
            dq.pop_back();
        }

    cout << ans;
}


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

void insertionSort(int* A, int N){
    int i,j,v;
    for(i=1;i<N;i++){
        v = A[i];
        j = i - 1;
        while(j>=0&&A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(j=0;j<N;j++){
            cout << A[j];
            if(j!=N-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}

int main(){
    int N,*A,i;
    cin >> N;
    A = new int[N];
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    for(i=0;i<N;i++){
        cout << A[i];
        if(i!=N-1){
            cout << " ";
        }
    }
    cout << endl;
    insertionSort(A,N);
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll x;
	cin >> x;
	ll t = x % 11;
	if (t > 0 && t <= 6) t = 1;
	else if (t > 6) t = 2;
	cout << (x / 11) * 2 + t << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int NIL=-1;
int n,pos=0;
vector<int> pre,in,post;

void set_tree(int idx,int idy){//右端は含まないクチ.
    if(idy<=idx)return;
    int root=pre[pos++];
    int m=distance(in.begin(),find(in.begin(),in.end(),root));
    set_tree(idx,m);
    set_tree(m+1,idy);
    post.push_back(root);
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){int k;cin>>k;pre.push_back(k);}
    for(int i=0;i<n;i++){int k;cin>>k;in.push_back(k);}
    set_tree(0,n);
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<post[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3156
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n, k;
	cin >> n >> k;
	long long int ans = k;
	for(int i = 2; i <= n; i++){
		ans = ans * (k - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    A,B,M = map(int,input().split())
    re = list(map(int,input().split()))
    de = list(map(int,input().split()))
    ans = min(re)+min(de)
    for _ in range(M):
        a,b,c = map(int,input().split())
        ans = min(ans,re[a-1]+de[b-1]-c)
    
    print(ans)
    
if __name__ == "__main__":
    main()


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

int main(){
  ll a;
  double b;
  cin >> a >> b;
  ll c = b*100 + 0.1;
  cout << a*c/100 << endl;
  return 0;
}


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

#define ll long long

using namespace std;

const ll MOD = 1e9 + 7;

int main()
{
	ll n, ans = 1;
	cin >> n;
	

	for (int i = 1; i <= n; ++i) {
		ans = (ans * i) % MOD;
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int num,a,b,c,d;
	scanf("%d",&num);
	a=num/1000;
	b=(num-a*1000)/100;
	c=(num-a*1000-b*100)/10;
	d=num-a*1000-b*100-c*10;
	//printf("%d %d %d %d \n", a,b,c,d);
	if(a+b+c+d==7){
		printf("%d+%d+%d+%d=7\n",a,b,c,d);
	}else if(a-b+c+d==7){
		printf("%d-%d+%d+%d=7\n",a,b,c,d);
	}else if(a+b+c-d==7){
		printf("%d+%d+%d-%d=7\n",a,b,c,d);
	}else if(a-b+c-d==7){
		printf("%d-%d+%d-%d=7\n",a,b,c,d);
	}else if(a+b-c+d==7){
		printf("%d+%d-%d+%d=7\n",a,b,c,d);
	}else if(a-b-c+d==7){
		printf("%d-%d-%d+%d=7\n",a,b,c,d);
	}else if(a+b-c-d==7){
		printf("%d+%d-%d-%d=7\n",a,b,c,d);
	}else if(a-b-c-d==7){
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	}else{
		printf("Error\n");
	}
	return 0;
}

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

using namespace std;

int a[8] = {0}, b = 0;

int main() {
	int n; scanf( "%d", &n );
	while( n-- ) {
		int x; scanf( "%d", &x );
		if( x >= 1 && x <= 399 ) ++a[0];
		else if( x >= 400 && x <= 799 ) ++a[1];
		else if( x >= 800 && x <= 1199 ) ++a[2];
		else if( x >= 1200 && x <= 1599 ) ++a[3];
		else if( x >= 1600 && x <= 1999 ) ++a[4];
		else if( x >= 2000 && x <= 2399 ) ++a[5];
		else if( x >= 2400 && x <= 2799 ) ++a[6];
		else if( x >= 2800 && x <= 3199 ) ++a[7];
		else ++b;
	}
	int cnt = 0;
	for( int i = 0; i < 8; ++i ) if( a[i] ) ++cnt;
	printf( "%d %d\n", max(cnt, 1), cnt+b );
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	start := 1
	fmt.Scan(&n, &k)
	a := make([]int, n+1)
	state := make([]int, n+1)
	tmp := make([]int, 5000000)
	tmp[0] = 1
	state[1] = 1
	loopLength := 0

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

	for i := 0; i < k; i++ {
		start = a[start]
		tmp[i+1] = start
		if state[start] == 1 {
			for j := 0; j < i+1; j++ {
				if tmp[j] == start {
					tmp = tmp[j : i+1]
					loopLength = len(tmp)
					break
				}
			}
			// fmt.Println(tmp)
			fmt.Println(tmp[(k-i-1)%loopLength])
			return
		} else {
			state[start] = 1
		}
	}
	fmt.Println(start)
}


Measured memory_bytes: 18920
#include "bits/stdc++.h"
#define r(i,a,n) for(int i=a;i<(int)(n);i++)
using namespace std;
const int MAX_N = 1E+5;
typedef long long ll;
ll x[MAX_N];
ll dist[MAX_N];
int N;
ll X,D;
int gcd(int n,int m){
        if(m==0) return n;
        return gcd(m,n%m);
}
int main(){
        cin>>N>>X;
        r(i,0,N){
                cin>>x[i];
                dist[i]=abs(X-x[i]);
        }
        int divis=dist[0];
        r(i,1,N){
                int n=dist[i],m=divis;
                divis=gcd(n,m);
        }
        D=divis;
        cout<<D<<endl;
        return 0;
}


Measured memory_bytes: 1792
#! usr/bin/env pyhton
# -*- coding: utf-8 -*-

from collections import deque


def main():
    a, b, c = map(int, input().split())
    if c <= a + b:
        print(b+c)
    else:
        print(a+2*b+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#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;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::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;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<string> a(n);
  REP(i, n) cin>>a[i];
  
  long long b[n];
  REP(i, n){
    string s = a[i];
    if(count(ALL(s), '.') != 0){
      string g;
      while(s.back() != '.'){
        g.push_back(s.back());
        s.pop_back();
      }
      s.pop_back();
      reverse(ALL(g));
      while((int)g.size() < 9) g.push_back('0');
      b[i] = 1000'000'000LL * stoi(s) + stoi(g);
    }else{
      b[i] = 1000'000'000LL * stoi(s);
    }
  }
  
  vector<vector<long long>> cnt(19, vector<long long>(19, 0));
  REP(i, n){
    long long temp = b[i];
    int c = 0, d = 0;
    while(temp % 2 == 0){
      temp /= 2;
      c++;
    }
    while(temp % 5 == 0){
      temp /= 5;
      d++;
    }
    c = min(c, 18); d = min(d, 18);
    cnt[c][d]++;
  }
  
  long long ans = 0;
  //int c[2], d[2];
  for(int c0 = 0; c0 <= 18; c0++){
    for(int d0 = 0; d0 <= 18; d0++){
      for(int c1 = 0; c1 <= 18; c1++){
        for(int d1 = 0; d1 <= 18; d1++){
          
          if(c0 + c1 < 18 || d0 + d1 < 18) continue;
          
          if(c0 == c1 && d0 == d1){
            ans += cnt[c0][d0] * (cnt[c0][d0] - 1);
          }else{
            ans += cnt[c0][d0] * cnt[c1][d1];
          }
          
        }
      }
    }
  }
  ans /= 2;
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 11096