akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

Int gcd(Int a, Int b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}

}

Int lcm(Int a, Int b) {
	Int temp = a / gcd(a, b)*b;
	return temp;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> T(N);
	for (Int i = 0; i < N; i++) {
		cin >> T[i];
	}

	vector<Int> L(N);
	L[0] = T[0];

	for (Int i = 1; i < N; i++) {
		L[i] = lcm(L[i - 1], T[i]);
	}

	cout << L[N - 1] << "\n";
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <set>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		set<int> x, y;
		int cnt[256] = {};
		for (int j = 0; j < n; ++j) {
			if (j < i) {
				x.insert(s[j]);
			} else if (x.find(s[j]) != x.end()) {
				y.insert(s[j]);
			}
			ans = max(ans, (int)y.size());
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
order_list = []
for _ in range(5):
    order_list.append(int(input()))
    
a = []
b = []
for i in range(5):
    a.append(((order_list[i]-1)//10+1)*10)
    b.append((order_list[i]-1)%10)
    
if min(b) != 9:
    ans = sum(a) + min(b) - 9
else:
    ans = sum(a)
print(ans)

Measured memory_bytes: 3064
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

a,b = get_nums_l()
print(max(0, a - 2*b))

Measured memory_bytes: 3572
import java.util.Arrays

const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toLong()}

    val b = Array(n-1, {a[it] + a[it+1]})
    var cnt = 0L
    for (i in 0..n-2) {
        if (b[i] <= x) continue

        cnt += b[i] - x
        if (i == n-2) {
            break
        }
        if (a[i+1] < b[i] - x) {
            b[i+1] -= a[i+1]
        } else {
            b[i+1] -= b[i] - x
        }
    }

    println(cnt)
}


Measured memory_bytes: 71936
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
  string line;
  getline( cin, line );
  replace( line.begin(), line.end(), ',', ' ' );
  replace( line.begin(), line.end(), '.', ' ' );
  istringstream iss( line );
  string s1, s2, s3;
  cout << s1 << s2 << s3;
  string word;
  bool is_first = true;
  while( iss >> word ) {
    int len = word.size();
    if( 3 <= len && len <= 6 ) {
      if( !is_first ) { cout << " " << flush; }
      cout << word << flush;
      is_first = false;
    }
  }
  cout << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
import sys
from collections import deque

input = sys.stdin.readline


def bfs(G, v, p, counter):
    queue = deque([(v, p)])
    while queue:
        v, p = queue.popleft()
        for c in G[v]:
            if c == p:
                continue
            counter[c] += counter[v]
            queue.append((c, v))


def main():
    N, Q = map(int, input().split())

    G = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)

    counter = [0] * (N + 1)
    for _ in range(Q):
        p, x = map(int, input().split())
        counter[p] += x

    bfs(G, 1, -1, counter)

    print(" ".join(map(str, counter[1:])))


if __name__ == "__main__":
    main()


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

long int getans(long int a,long int b){
    long temp=0;
    while(b!=0){
        a%=b;
        temp=a;
        a=b;
        b=temp;
    }
    return a;
}

int main(){
    long int a,b;
    cin>>a>>b;
    cout<<getans(a,b)<<endl;
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int r,g,b;
    cin>>r>>g>>b;
    int ans = r*100+g*10+b;
    if (ans%4 == 0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    if (N % K == 0)
    {
        writeln(0);
        return;
    }
    writeln(min(N % K, -(N % K - K)));
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
int cnt[5];
int main(){
	ios::sync_with_stdio(false);
	for (int i=1;i<=3;++i){
		int a,b;cin>>a>>b;
		++cnt[a];++cnt[b];
	}
	for (int i=1;i<=4;++i) if (cnt[i]==3) {
		cout<<"NO";return 0;
	}
	cout<<"YES";
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>

using namespace std;

inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) f=ch=='-'?-1:f,ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

const int N=500005;

int pre[N],suf[N],d[N];
int n,q,D;

inline int iabs(int x){return x>0?x:-x;}

int main()
{
	//freopen("linear.in","r",stdin),freopen("linear.out","w",stdout);
	n=read(),D=read();
	for (int i=1;i<=n;++i) d[i]=read();
	pre[0]=D;
	for (int i=1;i<=n;++i) pre[i]=min(pre[i-1],iabs(pre[i-1]-d[i]));
	suf[n+1]=1;
	for (int i=n;i>=1;--i) suf[i]=(suf[i+1]<<1)<=d[i]?suf[i+1]:suf[i+1]+d[i];
	q=read();
	for (int i=1,x;i<=q;++i)
	{
		x=read();
		printf(pre[x-1]>=suf[x+1]?"YES\n":"NO\n");
	}
	//fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void ABC054D()
{
	const int INF = 100000;
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<int> a(N), b(N), c(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<vector<int> > > dp(N, vector<vector<int> >(401, vector<int>(401, INF)));
	dp[0][a[0]][b[0]] = c[0];
	dp[0][0][0] = 0;
	for (int i = 1; i < N; ++i)
	{
		for (int j = 0; j < 400; ++j)
		{
			for (int k = 0; k < 400; ++k)
			{
				if (j >= a[i] && k >= b[i])
					dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i]][k - b[i]] + c[i]);
				else
					dp[i][j][k] = dp[i - 1][j][k];
			}
		}
	}

	int ret = INF;
	for (int i = 1; i <= 4000; ++i)
	{
		int a = Ma * i;
		int b = Mb * i;
		if (a > 400 || b > 400)
			break;
		ret = min(ret, dp[N - 1][a][b]);
	}
	if (ret == INF)
		cout << "-1" << endl;
	else
		cout << ret << endl;
}

int main()
{
	ABC054D();
	return 0;
}

Measured memory_bytes: 26624
/*
 *  Author :: Kattu37
 */

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

#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortallr(x) sort(allr(x))
#define PI 3.1415926535897932384626
#define mod 1000000007

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pll>   vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

void solve()
{
	string s, t;
	cin >> s;
	cin >> t;
	int count = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] != t[i])
			count++;
	}
	cout << count << "\n";
}

int main(void)
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}


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

using namespace std;
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string T; cin >> T;

    for (auto & ch: T) {
        if (ch == '?') ch = 'D';
    }
    cout << T << '\n';
}

Measured memory_bytes: 3748
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

void B() {
	int X, Y; cin >> X >> Y;
	if (Y % 2 != 0) {
		pNo; return;
	}
	// now Y is even number

	if (Y / 2 >= X and 2 * X >= Y / 2) {
		pYes; return;
	}
	else {
		pNo; return;
	}
}

int main() {
	B();
}

Measured memory_bytes: 3632
S = input()
MOD = 10**9 + 7
lenS = len(S)

dp = [[0 for _ in range(13)] for _ in range(lenS + 1)]  # dp[digit][d] = digit桁までの mod=d の数
dp[0][0] = 1

digitMask = 1

for digit in range(1, lenS + 1) :
    if(S[-digit] == '?') :
        for d in range(13) :
            for k in range(10) :
                dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - k * digitMask) % 13]) % MOD
    else :
        a = int(S[-digit])
        for d in range(13) :
            dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - a * digitMask) % 13]) % MOD
    digitMask *= 10
    digitMask %= 13

ans = (dp[len(S)][5]) % MOD
print(ans)



Measured memory_bytes: 66268
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int main(){
	LL x,y;
	cin >> x >> y;
	LL ans = x * y / __gcd(x,y);
	if((ans + x) % y == 0) cout << -1 << endl;
	else{
		cout << ans + x << endl;
	}
}

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

using namespace std;

typedef pair <int, int> pii;

int main(){
    int n;
    cin>>n;
    vector <pii> a(n);
    for(int i=1;i<=n;i++){
        cin>>a[i-1].first;
        a[i-1].second=i;
    }
    sort(a.begin(), a.end());
    for(int i=0;i<n;i++){
        cout<<a[i].second;
        if(i!=n-1){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main(void) {

	int seat = 0, n;

	cin >> n;

	int l[n], r[n];

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

		seat += (r[i] - l[i] + 1);
	}
	
	cout << seat << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;
 
const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;
 
/*
  filippos
  Contest : AtCoder DP contest
  Task : L - Deque
*/
 
int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n; cin >> n;
  vi v(n);
  for(int &i : v)
    cin >> i;

  ll tot = accumulate(v.begin(), v.end(), 0LL);

  vvl memo(n, vll(n, -1));
  function<ll(int, int)> dp = [&](int i, int j){
    if(i > j) return 0LL;
    ll &ans = memo[i][j];
    if(ans != -1) return ans;
    return ans = max(
      v[i] + min(dp(i + 2, j), dp(i + 1, j - 1)),
      v[j] + min(dp(i, j - 2), dp(i + 1, j - 1)));
  };

  ll x = dp(0, n-1);
  ll y = tot - x;

  cout << x - y;

  return cout << endl, 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll LINF=1e18;
const int INF=1e9;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}

int A, B;

int main(){
    cin >> A >> B;
    cout << (A > 9 || B > 9 ? -1 : A*B) << endl;
    return 0;
}

Measured memory_bytes: 256
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   文件名称：A.cpp
*   创 建 者： badcw
*   创建日期：2019年05月01日
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 1e5+5;
const int mod = 998244353;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

template <class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    putchar(x % 10 + '0');
}

pair<ll, ll> p[3];

int main()
{
    ll s;
    scanf("%lld", &s);
    ll t = sqrt(s);
    if (t * t != s) t ++;
    p[1].first = p[2].second = t;
    p[1].second = 1;
    p[2].first = t * t - s;
    for (int i = 0; i < 3; ++i) {
        printf("%lld %lld ", p[i].first, p[i].second);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    unsigned long long n,i,m,p,x,j,ara[102]={0},sum;
    scanf("%llu",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%llu",&ara[i]);
    }
    scanf("%llu",&m);
    for(i=1;i<=m;i++)
    {
        sum=0;
        scanf("%llu%llu",&p,&x);
        for(j=1;j<=n;j++)
        {
            if(j!=p)
            {
            sum=sum+ara[j];
            }
        }
        printf("%llu\n",sum+x);
    }
    return 0;
}


Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int a, b, ans;
int main() {
	cin >> a >> b;
	for (int i = 1; i <= a; ++i) {
		for (int j = 1; j <= b; ++j) {
			if (j % 10 >= 2 && j >= 20 && j % 10 * (j - j % 10) / 10 == i) { ++ans; }
		}
	}

	cout << ans << endl;
}

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

int main(){
  int n,ans;
  cin >> n;
  n%2==0 ? ans=n/2 : ans=n/2+1;
  cout <<ans << endl;
}

Measured memory_bytes: 3620
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n = int(readline())
a = list(map(int,readline().split()))
b = list(map(int,readline().split()))

c = [0]*(n+1)
d = [0]*(n+1)

for ai in a:
    c[ai] += 1

for bi in b:
    d[bi] += 1

for i in range(n+1):
    if (c[i]+d[i] > n):
        print("No")
        exit()
print("Yes")

for i in range(n):
    c[i+1] += c[i]
    d[i+1] += d[i]

divi = 0

for i in range(1,n+1):
    divi = max(divi, c[i]-d[i-1])

ans = [-1]*n

for i in range(n):
    ans[(i+divi)%n] = b[i]

print(" ".join(map(str, ans)))


Measured memory_bytes: 124020
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	int n,k;
	cin >> n>>k;
	int a = 0, b = 0,t = 1;
	for (int i = 0; i < n; i++) {
		a = t * 2;
		b = t + k;
		t = min(a, b);
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define NIL NULL/*ポインタに入れる番兵なのでNULL*/
struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
};
 
typedef struct node * Node;
 
void insert(Node,int);
Node Find(Node,int);
void PrintInorder(Node );
void PrintPreorder(Node );
Node Delete(Node,Node);
Node Successor(Node);
Node Minimum(Node);

Node root,newnode;
main()
{
  int number,k,i;
  char str[20];
   
  scanf("%d",&number);
  root = malloc(sizeof(struct node));
  for(i=0;i<number;i++)
    {
      scanf("%s",str);
      if(str[0]=='i')
    {
      scanf("%d",&k);
      if(i !=0) {
         
        insert(root,k);
      }                  /*挿入ごとにrootを入れる*/
      else root->key = k;
      
       
    }
      else if(str[0] == 'p'){
	PrintInorder(root);
	printf("\n");
	PrintPreorder(root);
	printf("\n");
    }  
      else if(str[0] == 'f')
	{
	  scanf("%d",&k);
	  if(Find(root,k)==NIL)printf("no\n");
	  else printf("yes\n");
	}

      else if(str[0] == 'd')
	{
	  scanf("%d",&k);
	  Delete(root,Find(root,k));

	}
    }
return 0;
}
 
void insert(Node t,int k)
{
  Node y,x,z;
  /*zを実態化させて*/
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = z->right = NIL;
  
   
 
  y = NIL;/*yはxの親とする*/
  x = t;/*T=root*/
   
  while(1)
    {
      y = x;/*子を親にする*/
       
      if(z->key < x->key) x = x->left;
      else x = x->right;
       
      if(x == NIL)break;
    }
 
   z->parent = y;
   if(y == NIL)t = z;/*??????????¨???????????????¨??§??????root?????£??\??§?????????*/
 
   else if(z->key < y->key) y->left = z;
   else y->right = z;
 
 
}
 
void PrintInorder(Node T)
{
  if(T != NIL){
     PrintInorder(T->left);
   
   
  printf(" %d",T->key);
  
  
   PrintInorder(T->right);
  }
  else return;
   
}
 
void PrintPreorder(Node T)
{
  if(T != NIL){
    printf(" %d",T->key);
 
    PrintPreorder(T->left);
    PrintPreorder(T->right);
 
  }
  else return ;
  
}
 
 
Node Find(Node T,int k)
{
  if(T == NIL || k == T->key)return T;
  if(k < T->key)return Find(T->left,k);
  else return Find(T->right,k);
 
}

Node Delete(Node T, Node z)
{
  Node x,y; 

  if(z->left == NIL || z->right == NIL)y = z; /*ここが case1 とcase2 */
  else y = Successor(z);

  if(y->left != NIL )x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;
  
  if(y->parent == NIL)T = x;   /*Tとはrootのこと*/
  else if( y == y->parent->left ) y->parent->left = x;
  else y->parent->right = x;
 
  if(y != z)
      z->key = y->key;

  return y;

}

Node Successor(Node x)
{
  Node y;

  if(x->right != NIL)return Minimum(x->right);
  
  y = x->parent;

  while( y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }

  return y;
    
}

Node Minimum(Node x)
{
  while (x->left != NIL)
    {
      x = x->left;
    }
  return x;

}

Measured memory_bytes: 19364
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=55,inf=0x3f3f3f3f;
int a[N],b[N],st[N],ans[N],vis[N];
int n,top;ll res;
inline bool ck(R int x){
	memset(vis,0,sizeof(vis));
	vis[a[x]]=1;
	fp(i,1,top)fp(j,st[i],50)vis[j%st[i]]|=vis[j];
	return vis[b[x]];
}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	fp(i,1,n)scanf("%d",&b[i]);
	top=0;fd(i,50,1)st[++top]=i;
	fp(i,1,n)if(!ck(i))return puts("-1"),0;
	fd(i,50,1){
		top=0;
		fd(j,50,i+1)if(ans[j])st[++top]=j;
		fd(j,i-1,1)st[++top]=j;
		fp(j,1,n)if(!ck(j)){ans[i]=1;break;}
	}
	fd(i,50,1)if(ans[i])res|=1ll<<i;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
typedef long long int lli;

int main(){
    int a, b;
    cin >> a >> b;

    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6){
        cout << b / 2 << endl;
    }else{
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int n;
int m;
int sosu[1010];
vector<int> sosus;
int main(){


	scanf("%d",&n);

	sosu[1] = 1;
	for(int i = 2; i <= 1000 ; i++){
		if(sosu[i])	continue;
		sosus.push_back(i);
		for(int j = i+i; j <= 1000; j+= i){
			sosu[j] = 1;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n ; i++){
		int now = i;
		if(now %2 == 0)	continue;
		int val = 1;
		for(auto nowsosu : sosus){
			int cnt = 0;
			if(now < nowsosu)	break;
			while( (now % nowsosu) == 0){
				now /= nowsosu;
				cnt++;
			}
			val *= (cnt+1);
		}
		if(val == 8){
			ans++;
		}
	}
	printf("%d",ans);



}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{

	public static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

		var N = input[0];
		var M = input[1];
		var C = input[2];

		input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		var B = new int[M];

		// B代入
		for (int i = 0; i < M; i++)
		{
			B[i] = input[i];
		}

		var answer = 0;

		for (int i = 0; i < N; i++)
		{
			input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var result = 0;
			// B代入
			for (int x = 0; x < M; x++)
			{
				result += input[x] * B[x];
			}
			if (result + C > 0)
				answer++;
		}

		Console.WriteLine(answer);

	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];
    
    vector<int> ret(N);
    rep(i, N - 1){
        int cur = S[i];
        cur += C[i];
        rep(j, i + 1, N - 1){
            if(cur <= S[j]) cur = S[j];
            else {
                int K;
                if((cur - S[j]) % F[j] == 0){
                    K = (cur - S[j]) / F[j];
                }
                else {
                    K = (cur - S[j]) / F[j] + 1;
                }
                cur = S[j] + K * F[j];
            }
            cur += C[j];
        }
        ret[i] = cur;
    }
    ret[N - 1] = 0;
    rep(i, N){
        output(ret[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string k; cin >> k;
    vector<char>A(15,'o');
    rep(i, k.size())A[i]=k.at(i);
    int ans = 0;
    rep(i, 15) {
        if (A[i] == 'o')ans++;
    }
    cout << (ans>7? "YES":"NO") << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int a,b; cin >> a >> b;
    out(max({a+b,a-b,a*b}));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
using namespace std;

long long x[50];
long long y[50];
int main(){
    int N;
    int K;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    long long ans = LLONG_MAX;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            for(int k = 0; k < N; k++){
                long long x_min = min(x[i], x[j]);
                long long x_max = max(x[i], x[j]);
                long long y_min = y[k];
                vector <long long> ys;
                for(int l = 0; l < N; l++){
                    if(x_min <= x[l] && x[l] <= x_max && y_min <= y[l]){
                        ys.push_back(y[l]);
                    }
                }
                sort(ys.begin(), ys.end());
                if((ys.size() > K && ys[K - 1] < ys[K]) || ys.size() == K){
                    long long y_max = ys[K - 1];
                    ans = min(ans, (x_max - x_min) * (y_max - y_min));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){

  vector<int> vec = {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 i;
  cin >> i;
  cout << vec.at(i-1) << endl;

}

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

int judge(int x){
	int i;
	
	if(x==2){return 1;}
	else if(x%2==0) {return 0;}
	
	i=3;
	while(i<=sqrt(x)){
		if(x%i==0) {return 0;}
		i=i+2;
	}
	return 1;
}
int main(void)
{
	int i, x, N;
	int count=0;
	
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d", &x);
		if(judge(x)==1) {count++;}
	}
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 2032
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b,c;cin>>a>>b>>c;
  if((a*b)%2)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int main() {
    int a,b,k;
    scanf("%d%d%d", &a, &b, &k);
    for (int i = 1; i <= k; ++i) {
        if (i & 1) {
            if (a & 1) {
                --a;
            }
            a >>= 1;
            b += a;
        }
        else {
            if (b & 1) {
                --b;
            }
            b >>= 1;
            a += b;
        }
    }
    printf("%d %d\n", a, b);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=16;
int n,m;
int arc[1<<maxn];
int c[maxn][1<<maxn],f[1<<maxn][maxn];
void upd(int &x,int y){
	x=x<y?x:y;
}
int calc(int nS,int S){
	int res=0;
	rep2(i,0,n)if(nS>>i&1)res+=c[i][S];
	return res;
}
int main(){
	memset(f,127/2,sizeof f);
	read(n);read(m);
	rep2(i,0,n)arc[1<<i]=i;
	rep(i,1,m){
		int x,y,z;
		read(x);read(y);read(z);
		x--;y--;
		rep2(s,0,1<<n)if(s>>y&1)c[x][s]+=z;
		rep2(s,0,1<<n)if(s>>x&1)c[y][s]+=z;
	}
	f[1][0]=0;
	rep2(s,1,1<<n)rep2(t,0,n)if(s>>t&1){
		rep2(u,0,n)if((!(s>>u&1))&&c[u][1<<t])upd(f[s|(1<<u)][u],f[s][t]+c[u][s^(1<<t)]);
		for(int nxts=((1<<n)-1)^s;nxts;nxts=(((1<<n)-1)^s)&(nxts-1))upd(f[s|nxts][t],f[s][t]+calc(nxts,s^(1<<t)));
	}
	printf("%d\n",f[(1<<n)-1][n-1]);
	return 0;
}

Measured memory_bytes: 8448
class Unionfind:

    __slots__ = ['parents','sizes']

    def __init__(self, n):
        self.parents = list(range(n))
        self.sizes = [1]*n

    def root(self, x):
        if self.parents[x] == x:
            return x
        else:
            root_x = self.root(self.parents[x])
            self.parents[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    # 集合自体の数 ({1,2}, {3}, {4} : kind -> 3)
    def kind(self):
        for v in range(N):
            self.root(v)
        return len(list(set(self.parents)))

    # xが属する集合の要素の数　({1,2,3} : size(2) -> 3)
    def size(self, x):
        self.sizes[x] = self.sizes[self.root(x)]
        return self.sizes[x]

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sA = sorted(enumerate(A), key=lambda x : x[1])
sB = sorted(enumerate(B), key=lambda x : x[1])

# 必要条件
if not all(a <= b for (i, a), (j, b) in zip(sA, sB)):
    print("No")
    exit()

uf = Unionfind(N)
# i -> j　に移動する
for (i, a), (j, b) in zip(sA, sB):
    uf.unite(i, j)

# サイクル数が２つ以上なら高々N-2回で理想の列が作れる
if uf.kind() > 1:
    print("Yes")
    exit()

# 以下サイクル数が１つだがN-2回以下で条件を満たすような例を弾く
# sB[i] >= sA[i+1]のようなiが存在すれば sA[i] と sA[i+1]をスワップする(目標とする列)
# サイクルが２つに分かれるので条件を満たす
if any(sB[i][1] >= sA[i+1][1] for i in range(N-1)):
    print("Yes")
    exit()

#　任意のiについてsB[i] < sA[i+1]なら sB[i] と sA[i]を対応させるしかない
# AとBをそれぞれソートした列が目標の列となってこれはN-1回かかるので不適
print("No")

Measured memory_bytes: 37748
### constant

INF = 1 << 30
DXYS = [[1, 0], [0, -1], [-1, -1], [-1, 0], [0, 1], [1, 1]]

### subroutines

def gain(n, flds, c)
  used = n.times.map{|y| (y + 1).times.map{false}}
  gain = 0
  
  for y in (0...n)
    for x in (0..y)
      id = flds[y][x]
      next if used[y][x] || id == 0

      emp = false
      nst = 1
      used[y][x] = true
      q = [[x, y]]

      while ! q.empty?
        ux, uy = q.shift

        DXYS.each do |dx, dy|
          vx = ux + dx
          vy = uy + dy
          if vx >= 0 && vx <= vy && vy >= 0 && vy < n
            vid = flds[vy][vx]
            v = [vx, vy]
            if vid == 0
              emp = true
            elsif vid == id && ! used[vy][vx]
              nst += 1
              used[vy][vx] = true
              q << v
            end
          end
        end
      end

      if ! emp
        gain += (id == c) ? -nst : nst
      end
    end
  end

  gain
end

### main

loop do
  n, c = gets.split.map(&:to_i)
  break if (n | c) == 0

  flds = n.times.map{gets.split.map(&:to_i)}
  #p flds

  max_g = -INF

  for y in (0...n)
    for x in (0..y)
      if flds[y][x] == 0
        flds[y][x] = c
        g = gain(n, flds, c)
        max_g = g if max_g < g
        flds[y][x] = 0
      end
    end
  end

  puts max_g
end

Measured memory_bytes: 6148
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
//整数の割り算の切り上げ
int updiv(int a,int b){
    return (a+(b-1))/b;
}
int main(){
    int n,x,t;
    cin>>n>>x>>t;
    int k =updiv(n,x);
    cout<<t*k<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    map<int, int> mp;
    vector<ll> v;
    REP(i, N) {
        int x = ++mp[a[i]];
        if ((x & 1) == 0) {
            v.push_back(a[i]);
        }
    }
    sort(v.rbegin(), v.rend());
    if (v.size() >= 2)
        cout << (ll)v[0] * (ll)v[1] << endl;
    else
        cout << 0 << endl;
}

Measured memory_bytes: 8168
N=int(input())
A1=list(map(int, input().split()))
A2=list(map(int, input().split()))
ans=0
for i in range(N):
    X1=sum(A1[:i+1])
    X2=sum(A2[i:])
    ans=max(ans, X1+X2)
print(ans)

Measured memory_bytes: 3060
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////


/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int x; cin >> x;
	if(x>=400 && x < 600)cout << "8\n";
	if(x>=600 && x < 800)cout << "7\n";
	if(x>=800 && x < 1000)cout << "6\n";
	if(x>=1000 && x < 1200)cout << "5\n";
	if(x>=1200 && x < 1400)cout << "4\n";
	if(x>=1400 && x < 1600)cout << "3\n";
	if(x>=1600 && x < 1800)cout << "2\n";
	if(x>=1800 && x < 2000)cout << "1\n";

	

}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	sol := solver{}
	ee := make([][]Edge, n)
	sol.cc = make([]int, n)

	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		for j := 0; j < 2; j++ {
			ee[a] = append(ee[a], Edge{
				to: b,
				id: a,
			})
			a, b = b, a
		}
	}

	for i := 0; i < q; i++ {
		p := getNextInt(scanner) - 1
		x := getNextInt(scanner)
		sol.cc[p] += x
	}
	sol.ee = ee
	sol.dfs(0, -1)

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, sol.cc[i])
	}
}

type solver struct {
	cc []int
	ee [][]Edge
}

func (sol *solver) dfs(i, p int) {
	if p >= 0 {
		sol.cc[i] += sol.cc[p]
	}

	for _, e := range sol.ee[i] {
		if e.to == p {
			continue
		}
		sol.dfs(e.to, i)
	}
}

// Edge ...
type Edge struct {
	to, id int
}


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

int main() {
    int n, k;
    cin >> n >> k;
    if(n==1) {cout << k << endl; return 0;}
    ll ans = k;
    rep(i,n-1){
        ans*=(k-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll cur = 0;
	for(ll i = 1; i < 10000000; ++i){
		cur += i;
		if(cur >= x){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.next();
		int q = stdIn.nextInt();
		for(int i = 0; i < q; i++) {
			String stt = stdIn.next();
			if(stt.equals("print")) {
				int a = stdIn.nextInt();
				int b = stdIn.nextInt();
				String tmp = str.substring(a, b+1);
				System.out.println(tmp);
			}
			else if(stt.equals("reverse")) {
				int a = stdIn.nextInt();
				int b = stdIn.nextInt();
				String tmp = str.substring(a,b+1);
				String tmp2 = "";
				for(int j = tmp.length()-1; j >= 0; j--) {
					tmp2 += String.valueOf(tmp.charAt(j));
				}
				String ck1 = str.substring(0, a);
				String ck2 = str.substring(b+1,str.length());
				str = ck1 + tmp2 + ck2;
			}
			else if(stt.equals("replace")) {
				int a = stdIn.nextInt();
				int b = stdIn.nextInt();
				String p = stdIn.next();
				String ck1 = str.substring(0, a);
				String ck2 = str.substring(b+1,str.length());
				str = ck1 + p + ck2;
				
			}
		}
	}
}



Measured memory_bytes: 47656