akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

long long int gcd(long long int a,long long int b){
  long long int tmp,r;
	if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
	return b;
}

long long int lcd(long long int a,long long int b){
  return a/gcd(a,b)*b;
}

int main(){
  int i,j,k;
  int N;
  scanf("%d",&N);
  long long int A[N],lcdd,tmp;
  for(i=0;i<N;i++){
    scanf("%lld",&A[i]);
    if(i == 0){
      lcdd=A[i];
    }
    else
      lcdd = lcd(lcdd,A[i]);
  }
  printf("%lld\n",lcdd);
  return 0;
}
      

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

using namespace std;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	int r,g,b;
	cin >> r >> g >> b;

	if (((r * 100) + (g * 10) + b) % 4 == 0) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int max = 0;
	chmax(max, a*b);
	chmax(max, c*d);
	cout << max;
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
V=n1()
V0=[V[i] for i in range(n) if i%2==0]
V1=[V[i] for i in range(n) if i%2==1]

c0=list(Counter(V0).items())
c1=list(Counter(V1).items())
c0.sort(key=lambda x:-x[1])
c1.sort(key=lambda x:-x[1])

if c0[0][0]!=c1[0][0]:
    ans=n-c0[0][1]-c1[0][1]
else:
    if len(c0)==1 or len(c1)==1:
        if len(c0)==len(c1)==1:
            ans=n-c0[0][1]
        elif len(c0)==1:
            ans=n-c1[1][1]
        else:
            ans=n-c0[1][1]        
    elif c0[0][1] > c1[0][1]:
        ans=n-c0[0][1]-c1[1][1]
    elif c0[0][1] < c1[0][1]:
        ans=n-c0[1][1]-c1[0][1]
    else:
        if c0[1][1] > c1[1][1]:
            ans=n-c0[1][1]-c1[0][1]
        else:
            ans=n-c0[0][1]-c1[1][1]
print(ans)

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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}


int main() {
  ll A;
  double B;
  cin >> A >> B;
  ll A2 = A;
  ll B2 = B*100 + 0.001;
  ll result = A2 * B2 / 100;
  print(result);
}

Measured memory_bytes: 3708
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;

void solve(){
    string s,t; cin>>s>>t;
    int cnt=0;
    for(int i=0;i<=2;i++){
        if(s[i]==t[i]) cnt++;
    }
    cout<<cnt;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

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

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	cin >>S;
	for (int i=1; i<S.size(); i++)
		if (('A'==S.at(i-1))&&('C'==S.at(i))) {
			cout <<"Yes" <<endl;
			return 0;
		}
	cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    const int MAX = 100001;

    vector<int> odd_hist(MAX, 0), even_hist(MAX, 0);
    rep(i,n) {
        if (i & 1) odd_hist[a[i]]++;
        else even_hist[a[i]]++;
    }

    vector<PII> odd, even;
    rep(i,MAX) {
        odd.push_back(PII(odd_hist[i], i));
        even.push_back(PII(even_hist[i], i));
    }
    sort(odd.begin(), odd.end(), greater<PII>());
    sort(even.begin(), even.end(), greater<PII>());

    if (odd[0].second != even[0].second) {
        cout << n - (odd[0].first + even[0].first) << endl;
    }
    else {
        cout << n - max(odd[0].first + even[1].first,
                odd[1].first + even[0].first) << endl;
    }

    return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int k=max(max(a,b),c);
  if(k==a+b+c-k)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

set<pair<ll,ll>> S;
void dfs(ll N, ll K, ll num, ll last, ll sum) {
    if (num > N + 1) return;
    for (ll i = last + 1; i <= N; i++) {
        if (num >= K) S.insert({num, sum + i});
        dfs(N, K, num+1, i, sum + i);
    }
}

ll solve(ll N, ll K) {
    dfs(N, K, 1, -1, 0);
    return S.size();
}

ll solve2(ll N, ll K) {
    ll res = 0;
    for (int i = K; i <= N + 1; i++) {
        /*
        ll low = i * (i + 1) / 2;
        ll hig = (N - i + 1) * i + (i * (i + 1) / 2);
        res += hig - low + 1;
        */
        res += (N - i + 1) * i + 1;
        res %= 1000000007;
    }
    return res;
}

int main() {
    ll N, K; cin >> N >> K;
    cout << solve2(N, K) << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,K,answer=100000;
  cin>>H>>W>>K;
  vector<vector<int>> chocolate(H,vector<int>(W));
  for(int i=0;i<H;i++){
    string S;
    cin>>S;
    for(int j=0;j<W;j++){
      chocolate.at(i).at(j)=S.at(j)-'0';
    }
  }
  //分ける場合
  for(int bit=0;bit<(1<<(H-1));bit++){
    queue<int> q;
    for(int i=0;i<H-1;i++){
      if(bit&1<<i){q.push(i);}
    }
    int ans=q.size();
    q.push(H-1);
    queue<int> qcopy=q;
    unordered_map<int,int> mp;
    int check=-1;
    for(int h=0;h<W;h++){
      int a=0,b=q.front(),c=q.size();
      for(int j=0;j<c;j++){
        for(int i=a;i<=b;i++){
          if(chocolate.at(i).at(h)==1){mp[a]++;}
        }
        if(mp[a]>K){
          if(h==check){check=-2;break;}
          check=h;
          h--;
          mp.clear();
          ans++;
          break;
        }
        a=b+1;
        q.pop();
        b=q.front();
      }
      if(check==-2){ans=10000;break;}
      q=qcopy;
    }
    answer=min(answer,ans);
    mp.clear();
  }
  cout<<answer<<endl;
}

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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n){
        cin >> d[i];
    }
    int sum = 0;
    rep(i, n-1){
        rep(j, n-i-1){
            sum += d[i] * d[i+j+1];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


bool isprime(int x){
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return 0;
  }
  return 1;
}
int main(){
  int i,j;
  int x;
  cin>>x;
  while(1){
    if(isprime(x)){
      cout<<x<<endl;
      return 0;
    }
    x++;
  }
  
  return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[120][10200] = {};
int main() {
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC";
	}
	else if (r < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
}

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

int main(){
  int N, fl = 0, sl = 0;
  scanf("%d",&N);
  vector<int> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
    if (fl <= A[i]){
      sl = fl;
      fl = A[i];
    }
    else if (sl <= A[i]){
      sl = A[i];
    }
  }
  for (int i = 0; i < N; i++){
    if (fl == A[i]){
      printf("%d\n", sl);
    }
    else{
      printf("%d\n", fl);
    }
  }
  return 0;
}


Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

int dp[maxn];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k; 
	cin >> n >> k;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < a[0]; i++) {
		dp[i] = 0;
	}
	for (int i = a[0]; i < maxn; i++) {
		bool can = false;
		for (int x : a) {
			if (x > i) break;
			if (dp[i - x] == 0) can = true;
		}
		dp[i] = can;
	}

	cout << (dp[k] == 1 ? "First" : "Second") << endl;


	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 1408
import Control.Applicative
import Control.Monad
import Data.List
import Data.Bool (bool)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main :: IO ()
main = do
  xs <- f
  ys <- f
  zs <- f
  n <- readLn
  solve (V.fromList (xs ++ ys ++ zs)) <$> replicateM n readLn >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: Vector Int -> [Int] -> String
solve v xs = bool "No" "Yes" $ vv ! 0 == 0 && vv ! 1 == 0 && vv ! 2 == 0 ||
                               vv ! 3 == 0 && vv ! 4 == 0 && vv ! 5 == 0 ||
                               vv ! 6 == 0 && vv ! 7 == 0 && vv ! 8 == 0 ||
                               vv ! 0 == 0 && vv ! 3 == 0 && vv ! 6 == 0 ||
                               vv ! 1 == 0 && vv ! 4 == 0 && vv ! 7 == 0 ||
                               vv ! 2 == 0 && vv ! 5 == 0 && vv ! 8 == 0 ||
                               vv ! 0 == 0 && vv ! 4 == 0 && vv ! 8 == 0 ||
                               vv ! 2 == 0 && vv ! 4 == 0 && vv ! 6 == 0
  where
    vv = foldl' f v xs
    f t x = case V.findIndex (== x) t of
             Just i -> t // [(i, 0)]
             Nothing -> t


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;

void solve(){
    int n;
    cin >> n;
    graph gra(n);
    rp(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        gra[u].pb(edge(v,w));
        gra[v].pb(edge(u,w));
    }
    vi ans(n,-1);
    ans[0]=0;
    queue<int> que;
    int fr=0;
    do{
        if(!que.empty()){
            fr=que.front();
            que.pop();
        }
        for(auto nxt:gra[fr]){
            if(ans[nxt.to]!=-1) continue;
            if(nxt.cost&1){
                if(ans[fr]&1) ans[nxt.to]=0;
                else ans[nxt.to]=1;
            }else{
                if(ans[fr]&1) ans[nxt.to]=1;
                else ans[nxt.to]=0;
            }
            que.push(nxt.to);
        }
    }while(!que.empty());
    for(auto a:ans){
        print(a);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 9444
fun main(args: Array<String>) {

    val (idCardAmount, gateAmount) = readLine()!!.split(" ").map { Integer.parseInt(it) }
    val L = mutableListOf<Int>()
    val R = mutableListOf<Int>()
    val i = 0
    val LRList = mutableListOf<Pair<Int, Int>>()

    for (i in 0 until gateAmount) {
        val (L_, R_) = readLine()!!.split(" ").map { Integer.parseInt(it) }
        L.add(L_)
        R.add(R_)
        LRList.add(Pair(L_, R_))
    }
    val LMax = L.max()
    val RMin = R.min()
    LMax?.let {
        RMin?.let {
            print(Math.max(RMin - LMax + 1, 0))
        }
    }
}

Measured memory_bytes: 66472
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  vector<ll> x(n), y(n), p(n);
  rep(i, n) cin >> x[i] >> y[i] >> p[i];

  vector<vector<ll>> cx((1 << n)), cy((1 << n));
  rep(S, (1 << n)) {
    vector<ll> rx(n), ry(n);
    rep(i, n) rx[i] = abs(x[i]);
    rep(i, n) ry[i] = abs(y[i]);
    rep(i, n) if (S >> i & 1) rep(j, n) chmin(rx[j], abs(x[j] - x[i]));
    rep(i, n) if (S >> i & 1) rep(j, n) chmin(ry[j], abs(y[j] - y[i]));
    cx[S] = rx;
    cy[S] = ry;
    //rep(i, n) cout << rx[i] << (i == n - 1 ? "\n" : " ");
  }
  vector<ll> ans(n + 1, INF);
  rep(S, (1 << n)) {
    int cnt = 0;
    rep(i, n) if (S >> i & 1) cnt++;
    repr(T, S) {
      T &= S;
      ll res = 0;
      rep(i, n) if (!(T >> i & 1)) res += min(cx[T][i], cy[S - T][i]) * p[i];
      chmin(ans[cnt], res);
    }
  }
  rep(i, n + 1) cout << ans[i] << '\n';


  




  
  return 0;
}

Measured memory_bytes: 12940
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int i,a,b,s1,s2,s4,s5,nr=0;
  
  cin>>a>>b;
  for(i=a;i<=b;i++){
    s1 = i/10000;
    s2 = i/1000%10;
    s4 = i/10%10;
    s5 = i%10;
	if(s1==s5 && s2==s4)nr++;
  }
  cout<<nr;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
ans = 0
l = [0]*(10**5+2)
for i in range(n):
    l[a[i]] +=1
for i in range(10**5):
    x = l[i] +l[i+1]+l[i-1]
    ans = max(ans,x)
print(ans)

Measured memory_bytes: 20744
n = gets.to_i
arr = []
n.times {arr << gets.strip.split.map(&:to_i)}
sum = 0
ps = []

(0..n-1).to_a.permutation(n) do |arr|
  ps << arr
end

ps.each do |nums|
  (nums.length-1).times do |num|
    cx = arr[nums[num]][0]
    cy = arr[nums[num]][1]
    nx = arr[nums[num+1]][0]
    ny = arr[nums[num+1]][1]
    dx = (nx - cx) ** 2
    dy = (ny - cy) ** 2
    d = dx + dy
    sum += Math.sqrt(d)
  end
end

p sum.to_f / ps.size


Measured memory_bytes: 6780
var
i,j,c,d,e,b,x,y,z:longint;
s,s1,s2,s3:ansistring;
begin
read(s);
x:=pos('C',s); y:=pos('F',s);
if (x=0) or (y=0) then begin writeln('No');exit;end;
while(i<>1000) do
begin
inc(i);
if i=500 then begin writeln('No');exit;end;
x:=pos('C',s); y:=pos('F',s);
if (x=0) or (y=0) then begin writeln('No');exit;end;
if (x<y) then begin delete(s,x,1); writeln('Yes');break;end
else
delete(s,y,1);
end;
end.

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int *fG[100000];
int *bG[100000];
int label[100000], mcnts[100000] = {0}, mpos[100000] = {0}, kcnts[100000] = {0},
				   kpos[100000] = {0}, a[100000] = {0}, b[100000] = {0},
				   c[100000] = {0}, d[100000] = {0};
int nextL = 1;
void dfs(int node, int l) {
	if (label[node] != 0)
		return;
	int i = 0;
	label[node] = l;
	while (fG[node][i] != -1) {
		dfs(fG[node][i], l);
		i++;
	}
	if (nextL == l)
		nextL++;
	return;
}
int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
		mcnts[a[i]]++;
		mcnts[b[i]]++;
	}
	for (int i = 0; i < n; i++) {
		fG[i] = malloc(sizeof(int) * (mcnts[i] + 1));
		if (fG[i] == NULL) {
			return -1;
		}
	}
	for (int i = 0; i < m; i++) {
		fG[a[i]][mpos[a[i]]] = b[i];
		mpos[a[i]]++;
		fG[b[i]][mpos[b[i]]] = a[i];
		mpos[b[i]]++;
	}
	for (int i = 0; i < n; i++) {
		fG[i][mpos[i]] = -1;
	}
	for (int i = 0; i < k; i++) {
		scanf("%d%d", &c[i], &d[i]);
		c[i]--;
		d[i]--;
		kcnts[c[i]]++;
		kcnts[d[i]]++;
	}
	for (int i = 0; i < n; i++) {
		bG[i] = malloc(sizeof(int) * (kcnts[i] + 1));
		if (bG[i] == NULL) {
			return -1;
		}
	}
	for (int i = 0; i < k; i++) {
		bG[c[i]][kpos[c[i]]] = d[i];
		kpos[c[i]]++;
		bG[d[i]][kpos[d[i]]] = c[i];
		kpos[d[i]]++;
	}
	for (int i = 0; i < n; i++) {
		bG[i][kpos[i]] = -1;
	}

	for (int i = 0; i < n; i++) {
		dfs(i, nextL);
	}
	int labelCnt[100000] = {0};
	for (int i = 0; i < n; i++) {
		// printf("%d ", label[i]);
		labelCnt[label[i] - 1]++;
	}
	// printf("\n");
	for (int i = 0; i < n; i++) {
		int ans, fCnt = 0, fbCnt = 0, bCnt = 0;
		while (fG[i][fCnt] != -1)
			fCnt++;
		while (bG[i][bCnt] != -1) {
			if (label[bG[i][bCnt]] == label[i])
				fbCnt++;
			bCnt++;
		}
		// printf("l:%d f:%d b:%d ", labelCnt[label[i] - 1], fCnt, fbCnt);
		ans = labelCnt[label[i] - 1] - fCnt - fbCnt - 1;
		printf("%d ", ans);
	}
	return 0;
}


Measured memory_bytes: 14912
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int w, h, n; readV(w, h, n);

  auto x1 = 0, x2 = w, y1 = 0, y2 = h;
  foreach (_; 0..n) {
    int x, y, a; readV(x, y, a);
    switch (a) {
    case 1: x1 = max(x1, x); break;
    case 2: x2 = min(x2, x); break;
    case 3: y1 = max(y1, y); break;
    case 4: y2 = min(y2, y); break;
    default: assert(0);
    }
  }

  writeln(x2<x1 || y2<y1 ? 0 : (x2-x1)*(y2-y1));
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> xy;

    ll minX = INF, maxX = -INF, minY = INF, maxY = -INF;
    for (int i = 0; i < N; ++i) {
        ll x, y;
        cin >> x >> y;
        ll X = x + y;
        ll Y = x - y;
        xy.emplace_back(X, Y);
        chmin(minX, X);
        chmin(minY, Y);
        chmax(maxX, X);
        chmax(maxY, Y);
    }

    ll ans = max(maxY - minY, maxX - minX);
    cout << ans << endl;


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 6940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repd(a,b,c) for(int a=c;a>=b;a--)
/*******************************/
#define pi pair<int,int> 
#define vi vector<int>
#define vb vector<bool>
#define vp vector<pi>
#define vvi vector<vi>
#define vvp vector<vp>
/****************************/
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
//#define mp make_pair
#define pbb pop_back
/****************************************/
const int N = 5e5+100;
const int mod=1e9+7;
const int inf=1e18;
/****************************************/
vvp g;
vb vis;
vi dis,p,pp;
map<pair<pi,int>,int> mp;
int power(int a,int b)
{
  int ans=1;
  while(b)
  {
    if(b&1)ans*=a;
    a*=a;
    b/=2;
  }
  return ans;
}
// void dijkstra(int s,int n)
// {
//   dis.assign(n+1,inf);
//   p.assign(n+1,-1);
//   dis[s]=0;
//  // vis[s]=true;
//   priority_queue<pi,vp,greater<pi>> pq;
//   pq.push({dis[s],s});
//   while(!pq.empty())
//   {
//     int u = pq.top().S;
//     pq.pop();
//     if(vis[u])continue;
//     vis[u]=true;
//     int par=dis[u];
//     for(auto it:g[u])
//     {
//       int to = it.F;
//       int len = it.S;
//       if((mp[{{p[u],u},to}]))continue;
//       if(par+len<dis[to])
//       {
//         dis[to]=par+len;
//         p[to]=u;
//         pq.push({dis[to],to});
//       }
//     }
//   }

// }
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    while(T--)
    {
          int n;
          cin>>n;
          int sum=0;
          rep(i,1,n+1)
          {
            rep(j,1,n+1)
            {
              int val = __gcd(i,j);
              rep(k,1,n+1)
              {
                sum+=__gcd(val,k);
              }
            }
          }
          cout<<sum<<"\n";




    }
  
    
    
               

                

     

        
        
      
      
      
    
    

    
    
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=0; i<n+1; i++){
    cin >> a[i];
  }
  vector<int> b(n);
  for(int i=0; i<n; i++){
    cin >> b[i];
  }
  ll sum=0;
  for(int i=0; i<n; i++){
    if(a[i]<=b[i]){
      sum += a[i];
      b[i] -= a[i];
      if(a[i+1] >= b[i]){
        sum += b[i];
        a[i+1] -= b[i];
      }else{
        sum += a[i+1];
        a[i+1] = 0;
      }
    }else{
      sum += b[i];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << (x) << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n, k, R, S, P;
    string t;
    cin >> n >> k >> R >> S >> P >> t;
    map<char, int> rsp;
    map<char, char> rsp_r;
    rsp.insert({'r', R});
    rsp.insert({'s', S});
    rsp.insert({'p', P});
    rsp_r.insert({'r', 'p'});
    rsp_r.insert({'s', 'r'});
    rsp_r.insert({'p', 's'});

    vector<pair<char, bool>> ansst;

    for (int i = 0; i < k; i++) {
        ansst.push_back({rsp_r[t[i]], true});
    }

    for (int i = k; i < n; i++) {
        if (rsp_r[t[i]] == ansst[i - k].first) {
            ansst.push_back({rsp_r[t[i]], !ansst[i - k].second});
        } else {
            ansst.push_back({rsp_r[t[i]], true});
        }
    }

    Int ans = 0;
    for (int i = 0; i < n; i++) {
        if (ansst[i].second) {
            ans += rsp[ansst[i].first];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll x=inl(), y=inl(), z=inl(), k=inl();
        vll a(x), b(y), c(z);
        rep(i, x) a[i] = inl();
        rep(i, y) b[i] = inl();
        rep(i, z) c[i] = inl();

        vll ab;
        rep(i, x) rep(j, y) ab.eb(a[i] + b[j]);
        sort(all(ab), greater<>());
        sort(all(c), greater<>());

        vll ans(k);
        rep(i, min(x * y, k)) rep(j, min(z, k)) ans.eb(ab[i] + c[j]);
        sort(all(ans), greater<>());
        rep(i, k) cout << ans[i] << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 39928
use std::fmt;
use std::cmp;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let a:usize = scan.next();
	let b:usize = scan.next();
	let c:usize = scan.next();
	let d:usize = scan.next();

	let s = cmp::max(a,c);
	let e = cmp::min(b,d);

	if e < s {
		println!("0");
	} else {
		println!("{}",e-s);
	}
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

static const ll MAX = 200000;
static const ll waz = 76543217;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

struct Card { char suit, value; };

void bubble(struct Card A[], ll N) {
    rep(i, N) {
        for (ll j = N - 1; j >= i + 1; --j) {
            if (A[j].value < A[j - 1].value) {
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], ll N) {
    rep(i, N) {
        ll minj = i;
        for (ll j = i; j < N; ++j) {
            if (A[j].value < A[minj].value) {
                minj = j;
            }
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], ll N) {
    rep(i, N) {
        if (i) {
            cout << " ";
            cout << A[i].suit << A[i].value;
        }
        else {
            cout << A[i].suit << A[i].value;
        }
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], ll N) {
    rep(i, N) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main()
{
    IO;

    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    rep(i, N) cin >> C1[i].suit >> C1[i].value;

    rep(i, N) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }

}


Measured memory_bytes: 3212
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main()
{
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> R[i];
	int maxv = -2000000000;
	int minv = R[0];
	for (int i = 1; i < n; i++)
	{
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv<<endl;
	return 0;
}


Measured memory_bytes: 3916
// AOJ DPL_5_G: Balls and Boxes 7
// n 個の区別できるボールを k 個の区別できない箱に入れる
// とき、可能な入れ方の総数を求めてください。
// ただし、
//    どのボールも、必ずいずれかの箱に入れる。
//    ボールが1つも入っていない箱があってもよい。
// 2019.3.11 bal4u

#include <stdio.h>
#include <stdlib.h>

#define MOD 1000000007
int tbl[1001][1001];

int stirling2(int n, int k)
{
	int ans;

	if (k > n || k == 0) return 0;
	if (tbl[n][k]) return tbl[n][k];
	if (k == 1 || k == n) ans = 1;
	else ans = (((long long)k * stirling2(n - 1, k)) % MOD)
		+ stirling2(n - 1, k - 1);
	return tbl[n][k] = ans % MOD;
}

int main()
{
	int n, k, ans;

	scanf("%d%d", &n, &k);
	ans = 0; while (k > 0) {
		ans += stirling2(n, k--);
		if (ans >= MOD) ans -= MOD;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5688
#include<bits/stdc++.h>
#include<tuple>
#define INF  (int)1e8
#define EPS   1e-9
#define MOD 1000000007
#define Pi 3.14159
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define repk(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define IN(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printPI(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define vvvi vector<vvi>
#define vvvl vector<vvl>
#define vpi vector<pi>
#define vpl vector<pl>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define dbg(x, y) cout << x << " = " << y << endl
using namespace std;

const int N = 1e5 + 5;
ll gcd(ll a, ll b) {ll temp; while (b > 0) {temp = a % b; a = b; b = temp;} return a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll fpow(ll  b, ll exp, ll mod) {if (exp == 0) return 1; ll t = fpow(b, exp / 2, mod); if (exp & 1) return t * t % mod * b % mod; return t * t % mod;}
ll divmod(ll i, ll j, ll mod) {i %= mod, j %= mod; return i * fpow(j, mod - 2, mod) % mod;}


void sol() {

	int n, x, t; cin >> n >> x >> t;
	cout << ((n - 1) / x + 1)*t << '\n';



}

int main() {
	// fio
	int t = 1;
	// cin >> t;
	while (t--)
		sol();

	return 0;
}



Measured memory_bytes: 3632
#include<stdio.h>
 
int main(void){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a , &op , &b);
		if(op=='?')break;
		if(op=='+')printf("%d\n",a+b);
		if(op=='-')printf("%d\n",a-b);
		if(op=='*')printf("%d\n",a*b);
		if(op=='/')printf("%d\n",a/b);
	}
}

Measured memory_bytes: 1796
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

def main():
    N = int(readline())
    m = map(int,read().split())
    AB = zip(m,m)
    graph = [[] for _ in range(N+1)]
    # 1-indexでグラフかんり
    for a,b in AB:
        graph[a].append(b)
        graph[b].append(a)
    
    root = 1 # 根は適当に1とする
    stack = [root] # DFS用
    parent = [0]*(N+1) # 各頂点の親頂点を管理
    order = [] # DFSでおとづれた頂点を順番に格納
    while stack: 
        node = stack.pop()
        order.append(node)
        for child in graph[node]:
            if parent[node] == child:
                continue
            parent[child] = node
            stack.append(child)
    # これで各頂点の親情報とおとづれた順番がわかった

    pow_inv = [1]*(N+1) # 2^NをO(1)でとってこれるようにあらかじめ計算しておく
    for i in range(N):
        pow_inv[i+1] = pow_inv[i]*2%MOD
    
    # 各頂点を根とした部分木に含まれる頂点数を保持
    node_count = [1]*(N+1)
    for v in order[::-1]:
        node_count[parent[v]] += node_count[v]
    
    tmp = 0 # 各頂点について2^ci-1の和
    for target_node in range(1,N+1): # target_nodeがSに含まれる確率を計算していく
        child_par_sum = 0

        for child in graph[target_node]:
            if child == parent[target_node]:
                continue
            child_par_sum += node_count[child]
            tmp += pow_inv[node_count[child]]-1
        parent_par_sum = N-1-child_par_sum
        tmp += pow_inv[parent_par_sum]-1
        tmp%=MOD
    
    y = (pow_inv[N-1]-1)*N-tmp
    y %= MOD
    x = pow(pow_inv[N],MOD-2,MOD)
    z = x*y%MOD
    print(z)
    return

if __name__ == '__main__':
    main()


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


int main()
{
	ll n;
	cin>>n;
	ll h[n+1];
	for (int i = 1; i <= n; ++i)
	{
		cin>>h[i];
	}
	ll dp[n+1];
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for (int i = 3; i <= n; ++i)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define is(s) freopen((const char*)(s),"r",stdin)
#define os(s) freopen((const char*)(s),"w",stdout)
#define elif else if
#define pb push_back

using namespace std;
long long n,k,sum=0;
int h[200005];
int main()
{
	//is("");os("");
	//ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>n>>k;
	rep(i,n)
	cin>>h[i];
	sort(h,h+n);
	rep(i,n-k)
	sum+=h[i];
	cout<<sum<<endl;
	return 0;}


Measured memory_bytes: 1024
def game(card) : 
  player = 'a'
  while True :
    if len(card[player]) == 0 : 
      break
    player = card[player].pop(0)
  return player.upper()


card = dict()

card['a'] = list(input())
card['b'] = list(input())
card['c'] = list(input())

print(game(card))

Measured memory_bytes: 3060
S = input()

def findPos(s,char):
  l = []
  for i in range(len(s)):
    if s[i] == char:
      l.append(i)
  return l

A_pos = findPos(S,"A")
Z_pos = findPos(S,"Z")
print(max(Z_pos)-min(A_pos)+1)

Measured memory_bytes: 11464
#include<stdio.h>

int main(void){
  int i,j,tmp,n,a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(a[i]>a[j]){
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  printf("%d\n",a[n-1]-a[0]);
  
  return 0;
}

Measured memory_bytes: 128
require 'prime'
include Math
define_method :max, 			-> (a,b) { a > b ? a : b }
define_method :min, 			-> (a,b) { a < b ?  a : b }
define_method :swap, 			-> (a,b) { a, b = b, a }
define_method :gi, 				-> () { gets.split.map(&:to_i) }
define_method :gs, 				-> () { gets.chomp }
define_method :gc,				-> () { gets.chomp.split('') }
define_method :gif, 			-> () { gets.to_i }
define_method :pr,				-> (num) { num.prime_division }
define_method :darray,		-> (size1, size2, init = nil) { Array.new(size1){Array.new(size2){init}} }
define_method :array,			-> (size,init = nil) { Array.new(size){init} }
define_method :putall, 		-> (obj) { obj.each { |o| puts o } }
define_method :repl, 			-> (st,en, &block) { st.upto en do |i| block.call(i) end }
	define_method :rep, 		-> (num, &block) { num.times do |i| block.call(i) end }

		n = gif
		t = gi
		m = gif
		sum = 0
		t.each do |tt|
			sum += tt
		end

		rep m do
			d = gi
			puts sum - t[d[0]-1]+d[1]
		end




Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using node = tuple<int,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int n,m;
  cin >> n >> m;
  vector< int > ps = vector< int >(m);
  vector< int > id = vector< int >(m);
  vector< node > nodes = vector< node >(m);
  for(int i = 0;i < m;++i){
    int p, y;
    cin >> p >> y;
    ps[i] = p;
    nodes[i] = (node){p,y,i};
  }
  sort(nodes.begin(),nodes.end());
  int prev = -1;
  int cnt = -1;
  for(int i = 0;i < m;++i){
    int p,y,j;
    tie(p,y,j) = nodes[i];
    if(p != prev){
      cnt = 1;
      prev = p;
    }else{
      ++cnt;
    }
    id[j] = cnt;
  }
  for(int i = 0;i < m;++i){
    printf("%06d%06d\n", ps[i], id[i]);
  }
  return 0;
}


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

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

    int x = n/1.08;

    if ( (int)x*1.08 == n)
        cout << x;
    else if ( (int)((x+1)*1.08) == n)
        cout << x+1;
    else
        cout << ":(";

    return 0;
}


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

int main() {
  int N, M;
  scanf("%d %d", &N, &M);

  std::vector<double> L(N), a(N), b(N);
  for (int i=0; i<N; ++i) {
    scanf("%lf %lf %lf", &L[i], &a[i], &b[i]);
  }

  std::vector<std::vector<double>> D(N, std::vector<double>(N));
  auto dist=[](double x, double y)->double {
    return (x-y) * (x-y);
  };
  for (int i=0; i<N; ++i)
    for (int j=i+1; j<N; ++j)
      D[i][j] = dist(L[i], L[j]) + dist(a[i], a[j]) + dist(b[i], b[j]);

  std::vector<double> dp(1<<N);
  for (size_t i=0; i<dp.size(); ++i) {
    for (int j=0; j<N; ++j) {
      if (1<<j & i) continue;

      int next=(1<<j|i);
      dp[next] = dp[i];
      for (int k=0; k<N; ++k) {
        if (!(1<<k & i)) continue;

        dp[next] += D[j][k];
      }
    }
  }

  double res=0;
  for (unsigned i=0; i<dp.size(); ++i) {
    if (__builtin_popcount(i) != M) continue;
    if (res < dp[i]) {
      res = dp[i];
    }
  }

  printf("%.20f\n", res);
  return 0;
}

Measured memory_bytes: 10668
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
ll dp[1<<16],n,a[17][17];
ll mem[1<<16];
inline ll get(int mask){
	if(mem[mask]!=-1)return mem[mask];
	vector<int>rabbits;
	for(int i=0;i<n;i++)if((mask)&(1<<i))rabbits.push_back(i);
	ll ret=0;
	for(auto x:rabbits)for(auto y:rabbits)ret+=a[x][y];
	return mem[mask]=ret;
}
int main(){
	memset(mem,-1,sizeof(mem));
	scanf("%lld",&n);
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf("%lld",&a[i][j]);
	int full=(1<<n)-1;
	for(int i=0;i<(1<<n);i++){
		int rest=full^i;
		for(int j=rest;j;j=(j-1)&rest){
			dp[i|j]=max(dp[i|j],dp[i]+get(j));
		}
	}
	printf("%lld\n",dp[full]/2);
	return 0;
}

Measured memory_bytes: 1280