akhauriyash/Code-Regression huggingface dataset:
/**
*   @Author : MeGaCrazy
*   @InitTime : Tue Jan 08 22:56:23 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;

long long gcd(long long a,long long b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
long long lcm(long long  a,long long b){
	return a/gcd(a,b)*b;
}
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
     int n;
     cin>>n;
     long long ans=1ll;
     long long v;
     for(int i=0;i<n;i++){
     	cin>>v;
        ans=lcm(ans,v);	
     }
     cout<<ans<<endl;
	
     
}

Measured memory_bytes: 256
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;


int main()
{
	
	int a;
	cin>>a;
	
	cout<<a+pow(a,2)+pow(a,3)<<endl;
	return 0;
	
}


Measured memory_bytes: 4188
def main():
    while 1:
        d,e= map(int, input().split())
        if d == e == 0:
            break
        x = d
        y = 0
        ans = abs(d-e)
        while y != d:
            a = abs((x ** 2 + y ** 2) ** 0.5 - e)
            ans = min(a,ans)
            x -= 1
            y += 1
        print(ans)

main()



Measured memory_bytes: 5660
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=100005;
vector<int>w[MAXN];
int n;
int dep[MAXN];
int a[MAXN];
bool cmp(int a,int b)
{
	return a>b;
}
void dfs(int u)
{
	int l=int(w[u].size());
	for(int i=0;i<l;i++)
	{
		int v=w[u][i];
		dfs(v);
	}
	for(int i=0;i<l;i++)
	{
		int v=w[u][i];
		a[i]=dep[v];
	}
	sort(a,a+l,cmp);
	dep[u]=0;
	for(int i=0;i<l;i++)
	{
		dep[u]=max(dep[u],a[i]+i+1);
	}
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int v;
		scanf("%d",&v);
		w[v].push_back(i);
	}
	dfs(1);
	printf("%d\n",dep[1]);
	//fclose(stdin);
	//fclose(stdout);
}

Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> v(n);
    rep(i,n){
        ll a;
        cin >> a;
        v[i]=a/2;
    }
    int y=0;
    while(true){
        int x=0;
        rep(i,n){
            if(v[i]%2==0)x++;
        }
        if(x==n){
            rep(i,n) v[i]/=2;
            y++;
        }
        else break;
    }      
    ll g=v[0];
    ll c=0;
    rep(i,n){
        g=g/__gcd(g,v[i])*v[i];
        if(g>m){
            cout << 0 << endl;
            return 0;
        }
    }
    if(g%2==0){
        cout << 0 << endl;
        return 0;
    }
    g*=pow(2,y);
    ll count=((m/g)+1)/2;
    cout << count << endl;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int A[maxn];

map<ll,int> mp;

int main(){
	read(n);
	REP(i,1,n)read(A[i]);
	mp[0]=1;
	ll t=0;
	ll ans=0;
	REP(i,1,n){
		t+=A[i];
		ans+=mp[t];
		mp[t]++;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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

int main( void )
{
	ll n, k;
	cin >> n >> k;

	vector<ll> p(n);
	rep( i, n ) {
		cin >> p[i];
	}
	sort(all(p));

	ll cnt = 0;
	rep( i, k ) {
		cnt += p[i];
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> a(N);
  REP(i,N) cin >> a[i];
  sort(ALL(a));
  ll ng = -1, ok = N, m;

  auto is_need = [&]{
    //m番目以外の要素の総和TをK-a[m]<=T<=K-1とできるか？
    //dp[i][j]: i番目まで見て和をjにできるか？
    vector<vector<bool>> dp(N+1, vector<bool>(K,false));
    dp[0][0] = true;
    REP(i,N){
      REP(j,K){
        dp[i+1][j] = dp[i+1][j] || dp[i][j];
        if(i != m && dp[i][j] && j+a[i] <= K-1){
          dp[i+1][j+a[i]] = true;
        }
      }
    }
    FOR(j,max(K-a[m],0LL),K){
      if(dp[N][j]) return true;
    }
    
    return false;
  };
  
  while(ng+1!=ok){
    m = (ok+ng)/2;
    //a[m]は必要か？判定する
    if(is_need())
      ok = m;
    else
      ng = m;
  }
  cout << ng + 1 << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  300005
ll gcd(ll a,ll b)
{
if(b==0)return a;
else return gcd(b,a%b);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	a--;
	ll k=gcd(c,d);
	k=(c*d)/k;
	ll ans=b/c-a/c+b/d-a/d+a/k-b/k;
	cout<<b-a-ans;
}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[]$){
		Scanner c=new Scanner(System.in);
		int n=c.nextInt(),i=4,j,k;
		String s=c.next();
		while(i-->0){
			boolean[]a=new boolean[n+2];
			a[0]=(i&1)==0;
			a[1]=(i&2)==0;
			j=k=0;
			while(j<n)a[j+2]=s.charAt(j)=='o'^a[j]^a[++j];
			if(a[0]==a[n]&&a[1]==a[n+1]){
				while(k<n)System.out.print(a[++k]?'S':'W');
				System.out.println();
				return;
			}
		}
		System.out.println(-1);
	}
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  priority_queue<double, vector<double>, greater<double> > q;
  double v;
  for(int i=0;i<n;i++){
    cin >> v;
    q.push(v);
  }
  
  while(q.size()>=2){
    double x = q.top();q.pop();
    double y = q.top();q.pop();
    double avg = (x+y)/2.0;
    q.push(avg);
  }
  
  cout << fixed << setprecision(10) << q.top() << endl;
  
  return 0;
}




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

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

	cout << min(c,b/a) << endl;

	return 0;
}

Measured memory_bytes: 256
def witness(a, n, t, u):
    x = pow(a, u, n)  # x0 = a^u mod nを計算

    for _ in range(0, t):
        y = (x * x) % n

        # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
        if y == 1 and x != 1 and x != (n - 1):
            return True
        x = y
    return y != 1

def is_probably_prime(n, witnesses):
    t = 1
    u = n >> 1
    while u & 1 == 0:
        t = t + 1
        u >>= 1
    assert(2**t * u == n - 1)

    for a in witnesses:
        if a < n and witness(a, n, t, u):
            return False
    return True

def is_definitely_prime(n):
    if ((not (n & 1)) and n != 2) or (n < 2) or ((n % 3 == 0) and (n != 3)):
        return False
    elif n <= 3:
        return True
    else:
        return is_probably_prime(n, [2, 7, 61])


n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_definitely_prime(m):
        answer = answer + 1
print(answer)


Measured memory_bytes: 5620
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;

int main() {

	string a;
	int ct = 0;
	int maxct = 0;
	cin >> a;
	char b = 'a';
	for(int i=0; i<a.size(); i++){
		if(a[i] == 'A' || a[i] == 'T' || a[i] == 'G' || a[i] == 'C'){
			ct += 1;
		}else{
			maxct = max(ct, maxct);
			b = a[i+1];
			ct = 0;
		}
	}
	maxct = max(ct, maxct);
	cout << maxct;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define For(i,x,y) for(int i=x; i<y; ++i)
#define mem(x,y) memset(x,y,sizeof(x))
#define ALL(a) a.begin(),a.end()
#define PII pair<int,int>
#define INF 0x3f3f3f3f
#define DOF 0x7f7f7f7f
#define se second
#define fi first
#define endl '\n'
 
template <typename T>
inline void read(T &r){
    static char c; r=0; int f=1;
    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1;
    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());
    r*=f;
} // -_- 

const int N = 1e9 - 1;
int main(){
    int n, k, s;
    scanf("%d%d%d", &n, &k, &s);
    for(int i = 1; i <= n; ++i){
        if(i > 1) printf(" ");
        if(i <= k) printf("%d", s);
        else{
            if(s == N) printf("%d", N + 1);
            else printf("%d", N);
        }
    }
    // system("pause");
    return 0;
}


Measured memory_bytes: 1280
object Main extends App {
	val N = scala.io.StdIn.readLine.toList

	def test(x: List[Char]): Boolean = {
		if(x.size % 2 == 1) return false;

		val t = x.size/2

		for(i <- 0 until t){
			if(x(i) != x(t + i)) return false;
		}

		return true;
	}

	def get(x: List[Char]): List[Char] = {
		x match {
			case rest:+r => rest
			case _ => Nil
		}
	}

	var temp = get(N)

	while(!test(temp)){
		temp = get(temp)
	}

	println(temp.size)
}

Measured memory_bytes: 26600
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[22];

int uku=0;

unordered_map<int,int>dp;
int dfs(int l,int r,int a,int b){
	int h=((l*10000+r)*10000+a)*10000+b;
	if(dp.find(h)!=dp.end())return dp[h];

	if(l+1==r){
		return dp[h]=A[l]*a+A[r]*b;
	}

	int ans=1001001001001001001ll;
	for(int k=l+1;k<r;k++){
		chmin(ans,dfs(l,k,a,a+b)+dfs(k,r,a+b,b)-A[k]*(a+b));
	}
	return dp[h]=ans;
}

signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];
	
	cout<<dfs(0,N-1,1,1)<<endl;

	return 0;
}

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

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

    // input train info
    vector<vector<int>> trains(n+1, vector<int>(n+1));// trains[i][0] = 0, trains[0][j] = 0
    for(int i=0; i<m; i++){
        int l, r;
        cin >> l >> r;
        trains[l][r] += 1;
    }

    // cumulative sum
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            trains[i][j] += trains[i][j-1];
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            trains[i][j] += trains[i-1][j];
        }
    }

    // answer the questions
    for(int i=0; i<q; i++){
        int l, r;
        cin >> l >> r;
        cout << trains[r][r] - trains[l-1][r] - trains[r][l-1] + trains[l-1][l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static ArrayList<String> strList = new ArrayList<String>();
	static ArrayList<String> strList2 = new ArrayList<String>();
	static ArrayList<Integer> intList = new ArrayList<Integer>();
	static HashMap<String,Integer> Hmap = new HashMap<String,Integer>();
	public static void main(String[] args) {


		int a = sc.nextInt();
		int ans=0;

		for(int i=1;i<=a;i++) {
			int b = sc.nextInt();
			intList.add(b);
		}

		int i =1;
		for(int disp : intList) {
			if(i%2 != 0 && disp%2 != 0) {
				ans++;
			}
			i++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 27060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws IOException {
		
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line=br.readLine()) != null){
        	
        	line = line.replaceAll("apple", "apple2");
        	line = line.replaceAll("peach", "apple");
        	line = line.replaceAll("apple2", "peach");
        	System.out.println(line);
        	
        }
        
	}

}

Measured memory_bytes: 16900
/*
	author: parv2809
*/

#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

int min(int a, int b) {
	if (a < b)
		return a;
	return b;
}

int powmd(int a, int b) {
	if (b == 1)	return a;
	if (b == 0)	return 1;

	int half = powmd(a, b / 2);
	int ans = half * half;
	ans %= mod;
	if (b & 1) {
		ans *= a;
	}
	ans %= mod;
	return ans;
}

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

int solve(vector<vector<int> >& gr, int curr_node, vector<int>& dp) {

	if (dp[curr_node] != -1)
		return dp[curr_node];

	int ans = -1;
	for (auto node : gr[curr_node]) {
		ans = max(ans, solve(gr, node, dp));
	}
	ans++;
	return dp[curr_node] = ans;

}


int32_t main() {

	fastIO();
	int t = 1;
	w(t) {

		int n, m;
		cin >> n >> m;
		vector<vector<int> > gr(n);
		int a, b;
		for (int i = 0; i < m; i++) {
			cin >> a >> b;
			gr[--a].pb(--b);
		}
		vector<int> dp(n, -1);

		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans = max(ans, solve(gr, i, dp));
		}

		cout << ans << endl;
	}

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;

Measured memory_bytes: 12112
# = int(input())
A, B, C, K = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if A >= K:
    print(K)

elif A + B >= K:
    print(A)

else:
    print(A-(K-(A+B)))


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=(int)((int)1e5 +5);
int dp[N][3];
 int n,a,b,c;

int arr[N][3];
int solve(int index,int i)
{
    
        if(dp[i][index]!=0)return dp[i][index];
        else
        {
            if(i==0)dp[i][index]= arr[index][i]+max(solve(index-1,1),solve(index-1,2));
            else if(i==1)dp[i][index]=arr[index][i]+max(solve(index-1,0),solve(index-1,2));
            else dp[i][index]=arr[index][i]+max(solve(index-1,0),solve(index-1,1));
            return dp[i][index];
        }
    
    return 0;
}

int main()
{ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
int n,a,b,c;
cin>>n;
int arr[n][3];
for(int i=0;i<n;i++)
{
    cin>>a>>b>>c;
    arr[i][0]=a,arr[i][1]=b,arr[i][2]=c;
}
dp[0][0]=arr[0][0],dp[0][1]=arr[0][1],dp[0][2]=arr[0][2];
for(int i=1;i<n;i++)
{
    dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
}

cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
using ll = long long;
using pbi = pair<bool,ll>;
vector<ll> conv;


constexpr ll lsb(ll x){ return x&(-x);}

struct fenwick{
  vector<ll> ft;

  void init(int n){
    ft.resize(n+10);
  }

  void add(ll k,ll val){
    for(++k;k<ft.size();k+=lsb(k))
      ft[k] += val;
  }

  ll query(ll k){
    ll ans = 0;
    for(++k;k;k-=lsb(k))
      ans += ft[k];
    return ans;
  }
};

fenwick m,q;
ll bsum;

vector<tuple<bool,ll,ll>> query;

ll eval(ll x){
  return m.query(x) * conv[x] + q.query(x);
}


int main() {
  int nq;
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> nq;
  query.resize(nq);
  conv.push_back(-1e9-10);
  conv.push_back(1e9+10);

  for(auto& el : query){

    ll t,a,b;
    cin >> t;
    if(t == 1){
      cin >> get<1>(el) >> get<2>(el);
      conv.push_back(get<1>(el));
      get<0>(el) = true;
    }else{
      a = b = 0;
      get<0>(el) = false;
    }
  }

  sort(conv.begin(),conv.end());
  conv.erase(unique(conv.begin(),conv.end()),conv.end());
  m.init(conv.size());
  q.init(conv.size());

  for(const auto&el : query){
    ll a = get<1>(el);
    bsum += get<2>(el);

    if(get<0>(el)){
      ll pa = lower_bound(conv.begin(),conv.end(),a) - conv.begin();
      //cout<<"pa: "<<pa<<endl;
      m.add(0,-1);
      m.add(pa,2);
      q.add(0,a);
      q.add(pa,-2*a);
    }else{
      ll l = 0;
      ll r = conv.size();
      //for(int i=0;i<conv.size();i++) cout<<conv[i]<<": "<<eval(i)<<" || "<<m.query(i)<<endl;cout<<endl;
      while(l<r){
        ll mid = l + (r-l)/2;
        if(eval(mid) <= eval(mid + 1)){
          r = mid;
        }else{
          l = mid+1;
        }
      }
      cout<<conv[l]<<" "<<eval(l) + bsum<<'\n';
    }
  }

  return 0;
}


Measured memory_bytes: 9844
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

map<pair<int, int>, int> dp;
vector<int> weight, value;

int solve(int next, int remain) {
	auto p = make_pair(next, remain);
	if (dp.find(p) != dp.end()) {
		return dp[p];
	} else if (next == weight.size()) {
		return 0;
	} else if (remain < weight[next]) {
		int ans = solve(next + 1, remain);
		dp[p] = ans;
		return ans;
	} else {
		int ans = max(solve(next + 1, remain - weight[next]) + value[next],
					  solve(next + 1, remain));
		dp[p] = ans;
		return ans;
	}
}

int main() {
	int n, knap;
	cin >> n >> knap;
	weight.resize(n);
	value.resize(n);
	for (int i = 0; i < weight.size(); i++) {
		cin >> weight[i] >> value[i];
	}
	cout << solve(0, knap) << endl;
}


Measured memory_bytes: 6272
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    String a = scanner.next();
    int n = a.length();
    char[] b = a.toCharArray();
    scanner.close();

    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int k = solve(b,i,j);
        if (ans < k) ans = k;
      }
    }
    System.out.println(ans);
  }

  private static int solve(char[] a, int i, int j) {
    for (int k = i; k <= j; k++) {
      if (a[k] == 'A' || a[k] == 'G' || a[k] == 'C' || a[k] == 'T') continue;
      return 0;
    }
    return j - i + 1;
  }
}

Measured memory_bytes: 22228
#include <cstdio>
long long n, a, b, c, x, y;
int main() {
	scanf("%lld", &n);
	for(a=1; a<=3500; a++) for(b=a; b<=3500; b++) {
		x = n*a*b;
		y = 4*a*b - n*a - n*b;
		if(y>0 && x%y==0) return !printf("%lld %lld %lld", a, b, x/y);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
# define ll long long int
#define mp	make_pair
#define pb	push_back
ll mod=1000000007;

int main() {
   
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s,t;
	
	cin>>s>>t;
	int n=s.size();
	int m=t.size();
	//int ans[m+1];
	ll dp[n+1][m+1];
	dp[0][0]=0;
	for(int i=1;i<=n;i++) dp[i][0]=0;
	for(int i=1;i<=m;i++) dp[0][i]=0;
	for(int i=1;i<=n;i++){
	   for(int j=1;j<=m;j++){
	      if(s[i-1]==t[j-1]){
	         dp[i][j]=dp[i-1][j-1]+1;
	      }else
	         dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
	   }
	}
	//cout<<dp[n][m];
	string str="";
	int i=n;int j=m;
	while(i>0 && j>0){
	   if(dp[i][j]==dp[i-1][j])
	   i--;
	   else if(dp[i][j]==dp[i][j-1])
	   j--;
	   else {
	      str=t[j-1]+str;i--;j--;
	   }
	}
   
	cout<<str;

}

Measured memory_bytes: 70656
#include <stdio.h>

int main(){
  int n,s=0;
  scanf("%d",&n);
  while(n>=500){
    n-=500;
    s+=1000;  
  }
  while(n>=5){
    n-=5;
    s+=5;
  }
  printf("%d",s);
  return 0;
}


Measured memory_bytes: 1692
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;


long long int l , r;
long long int ans = 0x3f3f3f3f;
int main()
{
	scanf("%lld%lld",&l,&r);
	for(int i = l ; i <= min(l+2019,r);i++)
	{
		for(int j = i+1;j<=min(l+2019,r);j++)
		{
			ans = min(ans,1ll*i*j%2019);
		}
		
	}
	
	printf("%lld",ans);
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String S = saori.nextHayami();
 
		for(int i = 0;i < S.length()-1; i++) {
			if(S.charAt(i) == S.charAt(i+1)) {
				System.out.println("Bad");
				return;
			}
		}
		System.out.println("Good");
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int main()
{
	LL k,a,b;
	cin>>k>>a>>b;
	if (a>=k) puts("1");
	else if (a<=b) puts("-1");
	else cout<<((k-a-1)/(a-b)+1)*2+1;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = new int[n];
        for(int i=0; i<n; i++) {
            ary[i] = int.Parse(input.ReadLine());
        }

        var hash = new HashSet<int>();

        var p = 0;
        var c = 0;
        while (true) {
            if(p == 1) break;
            if(hash.Contains(p)) return -1;
            hash.Add(p);

            p = ary[p]-1;
            c++;
        }

        return c;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 18016
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int main() {
  stack<int> s;
  while (true) {
    string t;
    cin >> t;
    if (!cin) {
      break;
    }

    if (t == "+" || t == "-" || t == "*") {
      int b = s.top(); s.pop();
      int a = s.top(); s.pop();
      if (t == "+") {
        s.push(a + b);
      } else if (t == "-") {
        s.push(a - b);
      } else {
        s.push(a * b);
      }
    } else {
      s.push(atoi(t.c_str()));
    }
  }
  int ans = s.top(); s.pop();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3212
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if ( u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if ( T[u].left != NIL ) h1 = setHeight(T[u].left) + 1;
  if ( T[u].right != NIL ) h2 = setHeight(T[u].right) + 1;
  return H[u] = ( h1 > h2 ? h1 : h2 );
}

int getSibling(int u) {
  if ( T[u].parent == NIL ) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL ) {
    return T[T[u].parent].left;
  }
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent == NIL ) {
    printf("root\n");
  } else if ( T[u].left == NIL && T[u].right == NIL ) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) T[i].parent = NIL;

  for ( int i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL ) T[l].parent = v;
    if ( r != NIL ) T[r].parent = v;
  }

  for ( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;

  setDepth(root, 0);
  setHeight(root);

  for (int i = 0; i < n; i++ ) print(i);

  return 0;
}


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

int main(void)
{
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int h,n;
	cin>>h>>n;
	
	int sum=0;
	REP(i,n){
		int a;
		cin>>a;
		sum+=a;
	}
	
	if(h>sum) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int r, s, p;
int solve(char c){
    if (c == 'r') return p;
    else if (c == 's') return r;
    else return s;
}

int main(){
    bool check;
    int n, k, ans = 0, even, odd, tmp;
    sc(n), sc(k), sc(r), sc(s), sc(p);
    string t; cin >> t;
    rep(i, 0, k){
        tmp = i, check = false;
        for (int j = i+k; j < n; j+=k){
            if (t[j] == t[tmp]){
                if (!check){
                    even = solve(t[tmp]), odd = solve(t[j]);
                    check = true;
                }else{
                    if ((j-tmp)/k % 2) odd += solve(t[j]);
                    else even += solve(t[j]);
                }
            }else{
                if (check) ans += max(even, odd);
                else ans += solve(t[tmp]);
                tmp = j, check = false;
            }
        }
        if (check) ans += max(even, odd);
        else ans += solve(t[tmp]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>

using namespace std;

int n;
double p[3005];
double dp[3005][3005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i];
	
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= n; j++){
			dp[i+1][j+1] += dp[i][j] * p[i+1];
			dp[i+1][j] += dp[i][j] * (1-p[i+1]);
		}
	}
	
	double ans = 0;
	for(int i = n/2+1; i <= n; i++) ans += dp[n][i];
	printf("%.11f\n", ans);
	
	return 0;
}

Measured memory_bytes: 70656
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include<set>
#include <unordered_map>
using namespace std;

int main(){
    int N;
    unordered_map<int, int> A;
    int t1;
    cin >> N;
    
    long initSum = 0;
    for(int i=0; i!=N; i++){
        cin >> t1;
        A[t1]++;
        initSum += t1;
    }

    int Q;
    cin >>Q;
    vector<int> B(Q), C(Q);
    for(int i=0; i!=Q; i++){
        cin >> B[i];
        cin >> C[i];
    }

    long out = initSum;
    for(int i=0; i!=Q; i++){
        out = (out + A[B[i]] * (C[i]-B[i]));
        A[C[i]] += A[B[i]];
        A[B[i]] = 0;
        cout << out;
        /*for(auto itr = A.begin(); itr != A.end(); ++itr) {
        std::cout << "(" << itr->first           // キーを表示
                        << ", " << itr->second << ") ";
        }*/
        cout << endl;
    }

    return 0; 
}

Measured memory_bytes: 7856
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int ans = INF;

	for (int i = 0; i < s.length()-2; i++) {
		int num= (int)(s[i]-'0')*100 + (int)(s[i + 1]-'0')*10 + (int)(s[i + 2]-'0');
		
		int diff = abs(num - 753);

		if (ans > diff) {
			ans = diff;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#define MAX 1000000
int main(void)
{
	int j,k,n,cnt;
	char s[MAX];
	while(scanf("%d",&n)!=EOF) {
		s[1]=0;
		for(j=2;j<=n;j++) {
			s[j]=1;
		}
		for(j=2;j*j<=n;j++) {
			if(s[j]!=0) {
				for(k=2*j;k<=n;k+=j) {
					s[k]=0;
				}
			}
		}
		cnt=0;
		for(j=2;j<=n;j++) {
			if(s[j]==1) {
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1568
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
const int mx=200005;
//abc176

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<t*((n+x-1)/x)<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
    int i,j,k;
    for(i=1; i<=9; i++)
    {
        for(j=1; j<10; j++)
        {
            cout<<i<<"x"<<j<<"="<<i*j<<endl;
        }
    }



    return 0;
}



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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

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

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	int N,D; cin >> N >> D;
	cout << (N + (2*D)) / (2*D+1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  int a = N % 10;
  
  if(a == 3) cout << "bon" << endl;
  else if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

/*
##########
#.#.#.#.#.
##########
#.#.#.#.#.
##########
..........
.#.#.#.#.#
..........
.#.#.#.#.#
..........
こんな感じのグリッドを作り、周りが他色で囲まれている部分の数を、a-1, b-1で調整
#:black
.:white
*/

int a, b;
char grid[105][105];

void init();

int main()
{
	scanf("%d %d", &a, &b);
	--a; --b;

	init();

	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 100; j++) {
			if (grid[i][j] == '.' && a) {
				a--;
			} else if (grid[i][j] == '.') {
				grid[i][j] = '#';
			}
		}
	}

	for (int i = 50; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (grid[i][j] == '#' && b) {
				b--;
			} else if (grid[i][j] == '#') {
				grid[i][j] = '.';
			}
		}
	}

	printf("%d %d\n", 100, 100);
	for (int i = 0; i < 100; i++) {
		printf("%s\n", grid[i]);
	}

	return 0;
}

void init()
{
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (i < 50) {
				grid[i][j] = '#';

				if (i % 2 == 0 && j % 2 == 0) {
					grid[i][j] = '.';
				}

			} else {
				grid[i][j] = '.';

				if (i % 2 == 1 && j % 2 == 0) {
					grid[i][j] = '#';
				}

			}
		}
	}

	return;
}


Measured memory_bytes: 128
n = int(input())
x = sorted(list(map(int, input().split())), reverse = True)
x_2 = list(map(lambda x:x ** 2, x))
ichi = sum(x)
jijou = sum(x_2)
re = 10 ** 100


#def ji(p, x):
#    ans = p * (p - 2 * x)
#    return ans

for p in range(1, x[0] + 1):
    second = n * (p ** 2)
    third = -2 * p * ichi
    summ = jijou + second + third

    if re > summ:
        re = summ

print(re)

#for i in range(x[i]):


Measured memory_bytes: 62064
#include <stdio.h>

int main()
{
  long long int H, i, plus_num = 1;
  long long int total = 0;
  int ret;

  ret = scanf("%lld", &H);
  while( H > 0 ) {
    total += plus_num;
    H /= 2;
    plus_num *= 2;
  }
  printf("%lld\n", total);

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
int main(int argc, char *argv[]) {
  int N;
  std::cin >> N;
  int min = 1000000000, max = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    std::cin >> a;
    min = std::min(min, a);
    max = std::max(max, a);
  }
  std::cout << abs(max - min) << std::endl;
}


Measured memory_bytes: 256
#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 <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n+2);
    for(int i = 1;i < n+1;i ++) cin >> a.at(i);

    int sum = 0;
    for(int i = 0;i < n+1;i ++){
        sum += abs(a.at(i+1) - a.at(i));
    }

    for(int i = 1;i < n+1;i ++){
        int ans = sum;
        ans -= abs(a.at(i) - a.at(i-1));
        ans -= abs(a.at(i+1) - a.at(i));
        ans += abs(a.at(i+1) - a.at(i-1));
        cout << ans << endl;
    }
}

Measured memory_bytes: 2048
a, b = map(int, input().split())
if a == 1 and b == 1:
    print('Draw')
elif a == 1:
    print('Alice')
elif b == 1:
    print('Bob')
elif a == b:
    print('Draw')
elif a < b:
    print('Bob')
elif a > b:
    print('Alice')


Measured memory_bytes: 2940