akhauriyash/Code-Regression huggingface dataset:
class Dice:
    def __init__(self,u,s,e,w,n,d):
        self.u = u
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.d = d
    
    def rot(self,way):
        # vertically
        if way == 0:
            c = self.u
            self.u = self.n
            self.n = self.d
            self.d = self.s
            self.s = c
        #rotate
        if way == 1:
            c = self.e
            self.e = self.n
            self.n = self.w
            self.w = self.s
            self.s = c
        #holizantally
        if way == 2:
            c = self.w
            self.w = self.d
            self.d = self.e
            self.e = self.u
            self.u = c

def compare(inp1,inp2):
    if not inp1[0] in inp2:
        return 'No'
    dice1 = Dice(inp1[0],inp1[1],inp1[2],inp1[3],inp1[4],inp1[5])
    dice2 = Dice(inp2[0],inp2[1],inp2[2],inp2[3],inp2[4],inp2[5])
    count = 0
    flag = 0
    while True:
        if dice1.u == dice2.u:
            for s in range(5):
                if dice1.s == dice2.s and dice1.e == dice2.e and dice1.w == dice2.w and dice1.n == dice2.n:
                    if dice1.d == dice2.d:
                        flag = 1
                        return 'Yes'
                    break
                else:
                    dice2.rot(1)
            if not flag:
                if dice1.d == dice2.s and dice1.u == dice2.n:
                    if (dice1.s == dice2.u) and (dice1.n == dice2.d) and (dice1.e == dice2.e) and (dice1.w == dice2.w):
                        return 'Yes'
                    else:
                        return 'No'
                elif dice1.d == dice2.e and dice1.u == dice2.w:
                    if (dice1.s == dice2.s) and (dice1.n == dice2.n) and (dice1.e == dice2.u) and (dice1.w == dice2.d):
                        return 'Yes'
                    else:
                        return 'No'
                elif dice1.d == dice2.w and dice1.u == dice2.e:
                    if (dice1.s == dice2.s) and (dice1.n == dice2.n) and (dice1.e == dice2.d) and (dice1.w == dice2.u):
                        return 'Yes'
                    else:
                        return 'No'
                elif dice1.d == dice2.n and dice1.u == dice2.s:
                    if (dice1.s == dice2.d) and (dice1.n == dice2.u) and (dice1.e == dice2.e) and (dice1.w == dice2.w):
                        return 'Yes'
                    else:
                        return 'No'
                else:
                    return 'No'
            break
        elif count < 5:
            dice2.rot(0)
            count += 1
        else:
            dice2.rot(1)
            count = 0
            
times = int(input())
input_list = list()
results = list()
for t in range(times):
    inp = list(map(int,input().split()))
    input_list.append(inp)

for il in input_list:
    for l in input_list:
        if input_list.index(il) != input_list.index(l):
            results.append(compare(il,l))

if 'Yes' in results:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5688
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b;
	cin >> a >> b;
	int k = b - a;
	cout << (1 + k)*k / 2 - b << endl;
}

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

class BigInt {
    static const int base = 10;
    public:
    deque<int> digits;
    BigInt() {
    }
    BigInt(int n) {
        for (;n; n /= base)
            digits.push_back(n % base);
    }
    BigInt operator +(const BigInt x) const {
        BigInt res;

        // add
        auto di = digits.begin(), xi = x.digits.begin(), end = digits.end();
        for (; di != end && xi != x.digits.end(); di++, xi++)
            res.digits.push_back(*di + *xi);

        // set rest
        if (di == end) {
            di = xi;
            end = x.digits.end();
        }
        for (; di != end; di++)
            res.digits.push_back(*di);

        res.normalize();

        return res;
    }
    void operator *=(const int x) {
        for (auto &a : digits)
            a *= x;
        normalize();
    }
    void normalize() {
        int carry = 0;
        for (int i = 0; i < size(); i++) {
            digits[i] += carry;
            carry = digits[i] / base;
            digits[i] %= base;
        }
        if (carry)
            digits.push_back(carry);
    }
    int size() const {
        return digits.size();
    }
    istream &read(istream &is) {
        digits.clear();
        cin.ignore();

        int s;
        while (s = cin.get(), isdigit(s))
            digits.push_front(s - '0');
        is.putback(s);

        return is;
    }
    ostream &write(ostream &os) const {
        for (auto di = digits.rbegin(); di != digits.rend(); di++)
            os << *di;
        return os;
    }
};

istream &operator>>(istream &is, BigInt &b) { return b.read(is); }
ostream &operator<<(ostream &os, const BigInt &b) { return b.write(os); }

int main()
{
    int n;
    BigInt factorial(1);
    cin >> n;

    for (; n; n--)
        factorial *= n;

    cout << factorial << endl;

    return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[10],i,max1=0,max2=0,max3=0;
    for(i=0;i<10;i++){
        scanf("%d",&a[i]);
        if(a[i]>max1){
            max3=max2;
            max2=max1;
            max1=a[i];
        }
        else if(a[i]>max2){
            max3=max2;
            max2=a[i];
        }
        else if(a[i]>max3)
            max3=a[i];
    }
    printf("%d\n",max1);
    printf("%d\n",max2);
    printf("%d\n",max3);
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader
import java.io.InputStreamReader

fun bubbleSort(a: IntArray): Int {
    var cnt = 0
    var isSorted = false

    for (i in 0 until a.size) {
        if (isSorted) break
        isSorted = true
        for (j in a.size-1 downTo i+1) {
            if (a[j] < a[j-1]) {
                run { val t = a[j]; a[j] = a[j - 1]; a[j - 1] = t }
                isSorted = false
                cnt++
            }
        }
    }
    println(a.joinToString(separator = " "))
    return cnt
}

fun main(args: Array<String>) {
    val a = BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())
            .map { it.toInt() }
            .drop(n = 1)
            .toIntArray()

    println(bubbleSort(a))
}


Measured memory_bytes: 29772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve();
        }

        void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            var list = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                var tmp = int.Parse(Console.ReadLine());
                list.Add(tmp);
            }

            Console.WriteLine(list.Distinct().Count());
        }
    }
}


Measured memory_bytes: 13152
x, k, d = map(int, input().split())
mnum = x//d
if k > abs(mnum):
    x %= d
    k -= abs(mnum)
    if k%2 == 0:
        print(abs(x))
    else:
        print(abs(x-d))
else:
    if x < 0:
        x = x+k*d
    else:
        x = x-k*d
    print(abs(x))


Measured memory_bytes: 9136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int hk=5; //0:上 1:右 2:下 3:左
int cnt=0;
string  w[12],ans="";
string shk[4]={"U","R","D","L"};

	rep(i,9) {
		cin >> w[i+1] ;
		w[i+1] = " " + w[i+1];
	}

	int x=1, y=1;
	if(w[1][1]=='1') { hk = 1; cout <<"R";}
	else			 {hk = 2; cout << "U";}

	while(1){
//		printf("\n%d h=%d (%d,%d) %c:",cnt,hk,y,x,w[y][x]);
		switch( hk){
		case  0:
			if(w[y-1][x-1] == '1' ) {
				hk = 3; y--; x--;}
			else if(w[y-2][x] == '1') {
				hk = 0; y -=2;}
			else if(w[y-1][x] == '1'){
				hk = 1; y--;}
			else {
				hk = 2; }
			break;
		case 1:
			if(w[y-1][x+1] == '1' ){
				hk = 0; y--; x++;}
			else if(w[y][x+1] == '1') {
				hk = 1; x++;}
			else if(w[y+1][x+1] == '1'){
				hk = 2; y++; x++;}
			else {
				hk = 3; }
			break;
		case 2:
			if(w[y+1][x] == '1' ) {
				hk = 1; y++; }
			else if(w[y+2][x] == '1' ) {
				hk = 2; y +=2;}
			else if( w[y+1][x-1] == '1'){
				hk = 3; y++; x--;}
			else {
				hk = 0;}
			break;
		case 3:
			if(w[y+1][x] == '1' ){
				hk = 2; y++; }
			else if(w[y][x-1] == '1') {
				hk = 3; x--;}
			else if( w[y-1][x] == '1'){
				hk = 0; y--; }
			else {
				hk = 1; }
			break;
		}
		cout << shk[hk];
//		ans = ans + shk[hk];
		cnt++; if(cnt>200) break;
		if(x==1 && y ==1) break;
	}	
	cout << endl;
//	cout << ans << endl;
	
	return 0;
	
	
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, s, x, y, z;
            string[] word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            s = 0;
            x = a + b;
            y = a + c;
            z = b + c;
            s = x;
            if (s>y)
                s = y;
            if (s>z)
                s = z;
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 27160
#include<stdio.h>
#include<stdlib.h>

int main(){
 int N,K;
 
  scanf("%d %d",&N,&K);
  
  char S[N];
  
  scanf("%s",S);
  
  if(S[K-1]=='A') S[K-1]='a';
  if(S[K-1]=='B') S[K-1]='b';  
  if(S[K-1]=='C') S[K-1]='c';  
  
  printf("%s",S);
  
}

Measured memory_bytes: 128
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> B(N+1, BIGP);
    rep(i, N - 1) cin >> B[i+1];
    ll total = 0;
    rep(i, N) total += min(B[i], B[i+1]);
    cout << total;
    return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
#define N 200002
#define M 1000000007
typedef long long LL;


LL f[N], ans, invf[N], sum, t1, t2;

LL qpow(LL x, int y)
{
	if(!y) return 1;
	LL t = qpow(x, y >> 1);
	t = t * t % M;
	if(y & 1) t = t * x % M;
	return t;
}

int main()
{		
	int T, i, j, x, a, b, c, d, y, m, t;
	
	scanf("%d%d%d%d", &a, &b, &c, &d);
	x = a - c - 1, y = c - 1;
	m = b - d - 1 + y;
	t = b - 1 + x;
	if(t > m) m = t;
	f[0] = f[1] = 1;
	for(i = 2, j = 1; i <= m; j = i++){
		f[i] = f[j] * (LL)i % M;
	} 
	invf[m] = qpow(f[m], M - 2);
	for(i = m, j = m - 1; j >= 0; i = j--){
		invf[j] = invf[i] * (LL)i % M;
	}
	
	ans = invf[x] * invf[y] % M;
	for(i = d, sum = 0, j = b - 1 - d; i < b; i++, j--){
		t1 = f[i + x] * invf[i] % M;
		t2 = f[j + y] * invf[j] % M;
		sum += t1 * t2 % M;
	}
	ans = sum % M * ans % M;
	printf("%lld\n", ans);
			
	return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	long long a=n*2;
	if(n==0||m==0)
		printf("0\n");
	else if(a>=m)
		printf("%lld\n",m/2);
	else
	{
		printf("%lld\n",n+(m-2*n)/4);
	}
	return 0;
}

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

using namespace std;

const int N = 500005;

char s[N];
int n;
int st[2*N];

int query(int l, int r){
    int ans = 0;
    for(l += n, r += n+1; l < r; l >>= 1, r >>= 1){
        if(l & 1) ans |= st[l++];
        if(r & 1) ans |= st[--r];
    }
    return ans;
}

void build(){
    for(int p = n-1; p > 0; p--)
        st[p] = st[2*p] | st[2*p+1];
}

void update(int p, int val){
    st[p += n] = val;
    while(p >>= 1) st[p] = st[2*p] | st[2*p+1];
}

int main() {
	scanf("%d %s", &n, s);

	for(int i = 0; i < n; i++) {
		st[i + n] = 1 << int(s[i] - 'a');
	}
	build();
	int q;

	scanf("%d", &q);
	while(q--) {
		int t;
		scanf("%d", &t);
		if(t == 1) {
			int x; char c;
			scanf("%d %c", &x, &c);
			x--;
			s[x] = c;
			update(x, 1 << int(c - 'a'));
		}
		else {
			int l, r;
			scanf("%d %d", &l, &r);
			printf("%d\n", __builtin_popcount(query(l - 1, r - 1)));
		}
	}
}


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

void solve(){
    
    int n;
    cin>>n;


    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    

    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    
    vector<int> da(n,0);
    vector<int> db(n,0);
    vector<int> dc(n,0);
    
    da[0] = a[0];
    db[0] = b[0];
    dc[0] = c[0];
    
    for(int i=1 ; i<n; i++){
        da[i] = max(db[i-1],dc[i-1]) + a[i];
        db[i] = max(da[i-1],dc[i-1]) + b[i];
        dc[i] = max(db[i-1],da[i-1]) + c[i];
    }
    
    int p = max(da[n-1], db[n-1]);
    p = max(p, dc[n-1]);
    
    cout<<p<<endl;
    
return;

}
int main() {
	// your code goes here
        solve();
    
    return 0;
}


Measured memory_bytes: 5600
ans = Hash.new(0)
ALPHABET = [*'a'..'z']

loop do
  s = gets
  break if s.nil? || s.length == 0
  s.downcase.chars.each do |c|
    ans[c] += 1 if ALPHABET.include?(c)
  end
end
ALPHABET.each do |k|
  puts "#{k} : #{ans[k]}"
end

Measured memory_bytes: 8668
#include <bits/stdc++.h>
    using namespace std;
    int main(){
    long a,b;cin>>a>>b;
    long c=__gcd(a,b),ans=1;
    for(int i=2;i<=1e6;i++){if(c%i!=0)continue;while(c%i==0)c/=i;ans++;}
    cout<<ans+(c>1)<<endl;
    }

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var dishes [5]int
	var moddishes [5]int
	var min int
	min = 10000
	var minnumber int
	for i := 0; i < 5; i++ {
		fmt.Scan(&dishes[i])
		if dishes[i]%10 != 0 {
			moddishes[i] = dishes[i] % 10
		} else {
			moddishes[i] = 10
		}
		if min > moddishes[i] {
			minnumber = i
		}
		if moddishes[i] != 0 {
			min = int(math.Min(float64(min), float64(moddishes[i])))
		}
	}
	var ret int
	for i := 0; i < 5; i++ {
		if i != minnumber {
			ret += dishes[i] + (10 - moddishes[i])
		}
	}
	ret += dishes[minnumber]
	fmt.Println(ret)
}


Measured memory_bytes: 512
use std::io;

fn power(x: i32) -> i32 {
    if x == 1 { 14 } else { x }
}

fn main() {
    let mut stdin = io::stdin();
    let input = &mut String::new();
    stdin.read_line(input);
    let mut iter = input.split_whitespace();
    let a = iter.next().unwrap().parse::<i32>().unwrap();
    let b = iter.next().unwrap().parse::<i32>().unwrap();
    let pa = power(a);
    let pb = power(b);
    if pa > pb {
        println!("Alice");
    } else if pa == pb {
        println!("Draw");
    } else {
        println!("Bob");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


int c[4005][4005];
void init() {
	c[0][0] = 1;
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= i; j++) {
			c[i + 1][j] += c[i][j];
			c[i + 1][j + 1] += c[i][j];
			c[i + 1][j] %= mod;
			c[i + 1][j + 1] %= mod;
		}
	}
}

int comb(int n, int k) {
	return c[n][k];
}

int f2(int n, int k) {
	return comb(n + k - 1, k - 1);
}


int f(int n, int k) {
	if (n < k)return 0;
	if (n == 0 && k == 0)return 1;
	if (k < 1)return 0;
	return f2(n - k, k);
}

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

	int N, K;
	cin >> N >> K;
	init();
	eFOR(i,1, K) {
		int blue = f(K, i)%mod;
		int red = f2(N - K - (i - 1), i + 1)%mod;
		int ans = blue * red%mod;
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 123776
#include<stdio.h>
#include<math.h>
int main(){

double a,b,x,c,p;
scanf("%lf %lf %lf",&a,&b,&x);
if(x==a*a*b/2){
	c=atan(b/a);
	printf("%lf",c*180.0/3.141592654);
}
if(x<a*a*b/2){
	p=2*x/(a*b);
	c=atan(b/p);
	printf("%lf",c*180.0/3.141592654);
}
if(x>a*a*b/2){
	p=2*b-(2*x)/(a*a);
	c=atan(a/p);
	printf("%lf",90-(c*180.0/3.141592654));
	}
return 0;}


Measured memory_bytes: 512
def main():
    N, K = list(map(int, input().split(' ')))
    S = input()
    # Find 0->1 / 1->0 patterns
    zero_one_indices = [0]
    one_zero_indices = [0] if S[0] == '0' else []
    before_c = None
    for i, c in enumerate(S):
        if (before_c, c) == ('0', '1'):
            zero_one_indices.append(i)
        elif (before_c, c) == ('1', '0'):
            one_zero_indices.append(i)
        before_c = c
    max_length = 0
    for k in range(len(zero_one_indices)):
        if k + K < len(one_zero_indices):
            # 1_seq + [0_seq, 1_seq] * K
            length = one_zero_indices[k + K] - zero_one_indices[k]
        else:
            length = N - zero_one_indices[k]
        max_length = max([length, max_length])
    print(max_length)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7216
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void)
{
    string s;
    cin >> s;
    if((s[0]==s[1] && s[2]==s[3])||
        (s[0]==s[2] && s[1]==s[3])||
        (s[0]==s[3] && s[1]==s[2])
    ){
        if(s[0]==s[1] &&s[1]==s[2]&&s[2]==s[3]){
            cout << "No";
        }else{
             cout << "Yes";
        }
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	String str = sc.next();
      	Integer cnt = 0;
      	Integer flag = 0;
		for(int i=0; i < N; i++){
          if(str.charAt(i)=='A'){
          	if((i+1!=N)&&(str.charAt(i+1)=='B')){
              if((i+2!=N)&&(str.charAt(i+2)=='C')){
                cnt++;
              }
          	}
          }
        }
		System.out.println(cnt);
      	return;
	}
}


Measured memory_bytes: 22612
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b, k] <- getIntList
    putStrLn . unwords . map show $ solve a b k


solve a b k | a + b <= k = [0, 0]
            | a >= k = [(a - k), b]
            | a < k = [0, (a + b- k) ]

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MX = 1005;
int n, k, e, b;
ll a[MX], c[MX*MX/2], ans;
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n){
		scanf("%lld", a+i+1);
		a[i+1] += a[i];
		rep(j,i+1) c[e++] = a[i+1] - a[j];
	}
	sort(c, c+e);
	for(int i = 39; i >= 0; i--){
		int tb = (int)(lower_bound(c+b, c+e, ans + (1LL<<i)) - c);
		if(e - tb < k){
			ll t1[MX*MX/2] = {}, t2[MX*MX/2] = {};
			for(int j = b; j < tb; j++) t1[j-b] = c[j];
			for(int j = tb; j < e; j++) t2[j-tb] = c[j] ^ (1LL<<i);
			merge(t1, t1+tb-b, t2, t2+e-tb, c+b);
		}else{
			ans += 1LL<<i;
			b = tb;
		}
	}
	printf("%lld\n", ans);
}

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

public class Main {
	public void maain(){

	}

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????

		//1???????????\????????¢
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);


        while(true){
        	String[] input = br.readLine().split(" ");
            int m = Integer.parseInt(input[0]);
            int f = Integer.parseInt(input[1]);
            int r = Integer.parseInt(input[2]);

            //?????????????????????
            if(m == -1 && f == -1 && r == -1){
            	return;
            }

            //???????????¨???
            if(m + f < 30 || (m == -1 || f == -1)){
            	System.out.println("F");
            }else if(m + f >= 80){
            	System.out.println("A");
            }else if(m + f >= 65 && m + f <= 80){
            	System.out.println("B");
            }else if(m + f >= 50 && m + f <= 65){
            	System.out.println("C");
            }else if(m + f >= 30 && m + f <= 50){
            	if(r >= 50){
            		System.out.println("C");
            	}else{
                	System.out.println("D");
            	}
            }
        }
	}
}

Measured memory_bytes: 24336
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<int,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint num[1050][1050];
int dat[3][2010][2010];
int d;
lint num2(int id,int lx,int ly,int hx,int hy){
	if(hx<0 || hy<0) return 0;
	int ret=dat[id][hx][hy];
	if(lx>0) ret-=dat[id][lx-1][hy];
	if(ly>0) ret-=dat[id][hx][ly-1];
	if(lx>0 && ly>0) ret+=dat[id][lx-1][ly-1];
	return ret;
}
bool cal(int mi){
	mi++;
	lint a=mi/d,b=mi%d;
	memset(dat,0,sizeof(dat));
	rep(i,d) rep(j,d) rep(k,2) rep(l,2){
		if(num[i][j]<=a*a) dat[0][i+k*d][j+l*d]++;
		if(num[i][j]<=a*(a+1)) dat[1][i+k*d][j+l*d]++;
		if(num[i][j]<=(a+1)*(a+1)) dat[2][i+k*d][j+l*d]++;
	}
	rep(i,d*2) rep(j,d*2) rep(k,3){
		if(i>0) dat[k][i][j]+=dat[k][i-1][j];
		if(j>0) dat[k][i][j]+=dat[k][i][j-1];
		if(i>0 && j>0) dat[k][i][j]-=dat[k][i-1][j-1];
	}
	rep(i,d) rep(j,d){
		if(num2(2,i,j,i+b-1,j+b-1)>=b*b && num2(1,i,j+b,i+b-1,j+d-1)>=b*(d-b) && num2(1,i+b,j,i+d-1,j+b-1)>=b*(d-b) && num2(0,i+b,j+b,i+d-1,j+d-1)>=(d-b)*(d-b)){
			return true;
		}
	}
	return false;
}
int main()
{
	memset(num,0,sizeof(num));
	int n,x,y;
	cin>>n>>d;
	/*if(d>30){
		cout<<0<<endl;return 0;
	}*/
	rep(i,n){
		cin>>x>>y;num[x%d][y%d]++;
	}
	int lo=0,hi=1001001001;
	//cal(0);
	while(hi>lo){
		lint mi=(hi+lo)/2;
		if(cal(mi)) hi=mi;else lo=mi+1;
	}
	cout<<lo<<endl;
}


Measured memory_bytes: 56320
using System;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[] x1 = new int[100];
			int[] y1 = new int[100];
			int[] h1 = new int[100];
			int n1 = 0;
			int[] x0 = new int[100];
			int[] y0 = new int[100];
			int n0 = 0;
			for (int i = 0; i < n; i++) {
				string[] s = Console.ReadLine().Split();
				int x = int.Parse(s[0]);
				int y = int.Parse(s[1]);
				int h = int.Parse(s[2]);
				if (h > 0) {
					x1[n1] = x;
					y1[n1] = y;
					h1[n1] = h;
					n1++;
				} else {
					x0[n0] = x;
					y0[n0] = y;
					n0++;
				}
			}
			if (n1 == 1) {
				Console.WriteLine(string.Format("{0} {1} {2}", x1[0], y1[0], h1[0]));
				return;
			}

			for (int Cy = 0; Cy <= 100; Cy++) {
				for (int Cx = 0; Cx <= 100; Cx++) {
					bool f = true;
					int Ch = 0;
					Ch = h1[0] + Math.Abs(x1[0] - Cx) + Math.Abs(y1[0] - Cy);
					for (int i = 1; i < n1; i++) {
						if (Ch != h1[i] + Math.Abs(x1[i] - Cx) + Math.Abs(y1[i] - Cy)) {
							f = false;
							break;
						}
					}
					if (f) {
						for (int i = 0; i < n0; i++) {
							if (Ch - Math.Abs(x0[i] - Cx) - Math.Abs(y0[i] - Cy) > 0) {
								f = false;
								break;
							}
						}
						if (f) {
							Console.WriteLine(string.Format("{0} {1} {2}", Cx, Cy, Ch));
							return;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 13140
def abc128_d():
    n, k = map(int, input().split())
    v = list(map(int, input().split()))
    ans = 0

    for a in range(max(1, k+1)):  # 左から取る個数
        for b in range(max(1, k-a+1)):  # 右から取る個数
            if a+b > n: break
            arr = []
            if a > 0: arr += v[:a]
            if b > 0 and a < n: arr += v[max(a, 0, n-b):]
            arr.sort()
            for j in range(max(1, a+b)):  # 戻す個数
                if a+b+j > k: break
                score = sum(arr[j:])
                ans = max(ans, score)
                #print(a, b, j, score, arr)
    print(ans)

if __name__ == '__main__':
    abc128_d()

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

/*
dfsで文字列を構築して、baseケースで文字列をパースして足す
*/

string S;
long long sum=0;

long long parse_eq(string x) {
    long long res = 0;
    string tmp = "";
    for (int i = 0; i < x.length(); i++)
    {
        if (x[i] == '+') {
            res += stoll(tmp);
            tmp = "";
        }
        else
        {
            tmp += x[i];
        }
    }
    res += stoll(tmp);
    return res;
}

void dfs(int pos, string x) {
    if (pos >= S.size()) {
        // parse add sum;
        sum += parse_eq(x);
        return;
    }

    // プラスを入れない
    dfs(pos+1, x+S[pos]);

    // プラスを入れる
    dfs(pos+1, x + '+' + S[pos]);
}

int main() {
    cin >> S;
    string c = "";
    dfs(1, c + S[0]);
    cout << sum << endl;
}

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

int main(void) {
  int h, w, n;
  cin >> h >> w >> n;
  int a[n + 1];
  rep (i, n) cin >> a[i + 1];

  vector<vector<int>> grid(h, vector<int>(w, 0));

  vector<int> nums;
  for (int i = 1; i <= n; i++) {
    rep (j, a[i]) nums.push_back(i);
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      grid[i][j] = nums[nums.size() - 1];
      nums.pop_back();
    }
  }

  rep (i, h) if (i % 2 == 1) sort(grid[i].begin(), grid[i].end());

  rep (i, h) {
    rep (j, w) cout << grid[i][j] << " ";
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,a[100100],memo[100100][2];
bool done[100100][2];

int solve(int p, int k){
	if(done[p][k]){
		return memo[p][k];
	}
	done[p][k] = true;
	if(p == n){
		return memo[p][k] = 1;
	}
	if(a[p] == a[p+1] || ((a[p]<a[p+1])^k)){
		return memo[p][k] = min(solve(p+1,k),solve(p+1,1-k)+1);
	}else{
		return memo[p][k] = min(solve(p+1,k),solve(p+1,1-k))+1;
	}
}

int main(void){
	int i;
	cin >> n;
	for(i=1; i<=n; ++i){
		cin >> a[i];
	}
	cout << min(solve(1,0),solve(1,1)) << endl;
	return 0;
}


Measured memory_bytes: 7808
/*
    A - Discount Fare
    https://atcoder.jp/contests/abc113/tasks/abc113_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int x, y;
    cin >> x >> y;
    cout << (x + y / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

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

int n;
ll bit[1000005];

ll upd(ll bit[],int i, ll x){
    for(int j=i;j<=4*n;j+=j&-j){
        bit[j]=max(bit[j],x);
    }
}

ll get(ll bit[],int i){
    ll ans=0;
    for(int j=i;j>0;j-=j&-j){
        ans=max(ans,bit[j]);
    }
    return ans;
}

int main(){
    IOS
    
    cin>>n;
    int a[n],h[n];
    FOR(i,0,n){
        cin>>h[i];
    }
    FOR(i,0,n){
        cin>>a[i];
    }
    FOR(i,0,n){
        ll x=get(bit,h[i]);
        upd(bit,h[i],x+a[i]);
    }
    cout<<get(bit,n);

    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 7552
'''
Accepted    　:No
difficult   　: 
ペナルティ　  　:5分
実際の回答時間  :分
WAの回数　     :回
合計時間　　  　:分
'''

def myAnswer(N:int,K:int,A:list,B:list) -> int:
   dic = {}
   for a,b in zip(A,B):
      if a in dic.keys():
         dic[a] += b
      else:
         dic[a] = b
   total = 0
   for a,b in sorted(dic.items()):
      total += b
      if K <= total:
         return a

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = []
   B = []
   for _ in range(N):
      a,b = map(int,input().split())
      A.append(a)
      B.append(b)
   print(myAnswer(N,K,A,B))
if __name__ == '__main__':
   main()

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

const llong MOD = 1e9+7;
const llong inf = 1<<30;

llong K, X;

int main() {
    cin >> K >> X;
    for (int i = max((llong)-1000000, X-K+1); i < X; i++) {
        cout << i << " ";
    }
    for (int i = X; i <= min((llong)1000000, X+K-1); i++) {
        if (i != min((llong)1000000, X+K-1)) cout << i << " ";
        else cout << i << endl;
    }
    return 0;
}

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

class Program
{
    public static void Main()
    {
        int[] data = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = data[0] * data[1];
        int b = data[0] * 2 + data[1] * 2;
        Console.WriteLine(a + " " + b);
    }
}


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

int A[26], B[26];

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        A[s[i] - 'a']++;
    }
    for (int i = 0; i < t.length(); i++) {
        B[t[i] - 'a']++;
    }
    sort(A, A + 26);
    sort(B, B + 26);
    for (int i = 0; i < 26; i++) {
        if (A[i] != B[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n; cin>>n;
    int m[n+1], h[n];
    For(i, 0, n+1){
        cin>>m[i];
    }
    int ans = 0;
    For(i, 0, n){
        cin>>h[i];
        int v = min(h[i], m[i]);
        ans += v;
        h[i] -= v;
        m[i] -= v;
        v = min(h[i], m[i+1]);
        ans += v;
        h[i] -= v;
        m[i+1] -= v;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
S=input()
N=len(S)
a=[]
b=[]
c=[0,1]
for i in range(N):
    a.append(c[i%2])
    b.append(c[(i+1)%2])

ans_a=0
ans_b=0


for i in range(N):
    s=int(S[i])
    if a[i]!=s:
        ans_a+=1
    if b[i]!=s:
        ans_b+=1
        
print(min(ans_a,ans_b))

Measured memory_bytes: 51696
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair < int , pair < int , int > > mp;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 123456;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;

int a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

    ll n;
    cin >> n;

    ll sum = 0;

    sum = (n * (n + 1)) / 2 - n;

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;

struct pare{
    int damage;
    bool throw_atk;
};

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

    vector<pare> d;
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        pare temp = {x, false};
        d.push_back(temp);
        temp = {y, true};
        d.push_back(temp);
    }

    sort(d.begin(), d.end(), [](const pare& a, const pare& b){return a.damage > b.damage;});

    int d_sum = 0;
    int cnt = 0;
    for(auto dd: d){
        while(!dd.throw_atk && d_sum < H) {
            d_sum += dd.damage;
            cnt++;
        }
        if(d_sum < H){
            d_sum += dd.damage;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14 
 
signed main(){
    string s;
    cin >> s;
 
    rep(i , 2){
        int va = s[0] - '0';
        string ans = "";
        ans += s[0];
        ans += (i ? "+" : "-");
        ans += s[1];
        va = (i ? s[1] - '0' : (s[1] - '0') * -1) + va;
        string ans_memo1 = ans;
        int va_memo1 = va;
        rep(j, 2){
            ans = ans_memo1;
            va = va_memo1;
            ans += (j ? '+' : '-');
            ans += s[2];
            va = (j ? s[2] - '0' : (s[2] - '0') * -1) + va;
            string ans_memo2 = ans;
            int va_memo2 = va;
            rep(k, 2){
                ans = ans_memo2;
                va = va_memo2;
                ans += (k ? "+" : "-");
                ans += s[3];
                va = (k ? s[3] - '0' : (s[3] - '0') * -1) + va;
                if(va == 7){
                    cout << ans << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll n, z, w;
    cin >> n >> z >> w;
    vector<ll> a;
    vin(a, n);
    if (n == 1) {
        cout << abs(a[n-1] - w) << endl;
        return 0;
    }
    cout << max(abs(a[n-1]-a[n-2]), abs(a[n-1]-w)) << endl;
}


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

struct uf_tree {
    std::vector<int> parent;
    int __size;
    uf_tree(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

signed main() {
    int n, m;
    while (cin >> n >> m) {
        uf_tree uf(n);
        vector<int> p(n), pos(n);
        rep(i, n) cin >> p[i], --p[i], pos[p[i]] = i;
        rep(i, m) {
            int a, b;
            cin >> a >> b;
            --a; --b;
            uf.unite(a, b);
        }
        int cnt = 0;
        rep(i, n) if (uf.is_same(i, pos[i])) ++cnt;
        cout << cnt << endl;
    }
    
}


Measured memory_bytes: 2560
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

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


ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
int a[10010];
int ans = 0;

int main() {
	cin >> N;
	REP(i, N) cin >> a[i];
	REP(i, N) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
}

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

#define sieve_ul int(1e6)
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define debug(x) do{cout<<#x<<" is "<<x<<endl;}while(false);
#define debugarr(x) do{ cout<<#x<<" array is \n";for(auto varl: x)cout<<varl<<' ';cout<<endl;}while(false);

// ll sieve_arr[sieve_ul + 10];
// vector<ll> primes;

ll fastexp(ll b, ll e)
{
    ll ans = 1;
    ll lpow = b;

    while(e)
    {
        if(e & 1)
            ans *= lpow;
        lpow *= lpow;
        e = (e >> 1);
    }
    return ans;
}

bool isprime(ll x)
{
    for(ll i=2; i <= sqrt(x); i++)
        if(x%i == 0)
            return false;
    return true;
}

// void sieve()
// {
//     primes.clear();
//     memset(sieve_arr, -1, sizeof(sieve_arr));

//     for(int i=2; i<= sieve_ul; i++)
//     {
//         if(sieve_arr[i] == -1)
//             for(int j=2; j*i <= sieve_ul; j++)
//                 sieve_arr[i*j] = 1;
//     }

//     for(int i=2; i<= sieve_ul; i++)
//         if(sieve_arr[i] == -1)
//             primes.push_back(i);
// }
vector<int> factorize(int n) {
    vector<int> res;
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

static bool cmp(pair<ll,ll>& a,pair<ll,ll>& b)
{
    return sqrt(a.first*a.first+a.second*a.second) <= sqrt(b.first*b.first+b.second*b.second);
}

void solve()
{
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans;
    if(n%x!=0)
        ans = (n/x) + 1;
    
    else
        ans = n/x;
    
    cout<<ans*t;
}

int main()
{

    //ll tc;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //cin>>tc;

    //for(ll i=1;i<=tc;i++)
    //{
        solve();
    //}

}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count=0;
  vector<int> L(N+2, 0);
  vector<int> R(N+2, 0);
  for(int i=1; i<=N; i++){
    if(S[i-1]=='#'){
      L[i]=L[i-1]+1;
    }else{
      L[i]=L[i-1];
    }
  }
  for(int i=N; i>=1; i--){
    if(S[i-1]=='.'){
      R[i]=R[i+1]+1;
    }else{
      R[i]=R[i+1];
    }
  }
  int ans = 1e9;
  for(int i=0; i<=N; i++){
    ans = min(ans, L[i]+R[i+1]);
  }
  cout << ans << endl;
  return 0;
}

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

int main()
{
    FASTIO;
    ll n,k,rem,dif;
    cin>>n>>k;
    rem=n%k;
    dif=rem-k;
    if(dif<0)
        dif=-dif;
    
    if(dif<rem)
        n=dif;
    else
        n=rem;
    
    cout<<n<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 25 Jul 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        st = new StringTokenizer(br.readLine(), " ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(br.readLine());
        br.close();

        while (b <= a) {
            b = b * 2;
            k--;
        }
        while (c <= b) {
            c = c * 2;
            k--;
        }

        if (k < 0) System.out.println("No");
        else System.out.println("Yes");
    }
}


Measured memory_bytes: 32548
#include <iostream>
int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int x,a,b,c;

    std::cin >> a;
    std::cin>> b;
    std::cin >> c;
    std::cin >> x;
    int i,j,k;
    i = x/500;
    j = (x-i*500)/100;
    int count =0;
    for(;i >= 0;) {
        k = j;
        if(i <= a) {
            for (; j >= 0;) {
                if( j <= b && (x-(i*500+j*100))/50 <= c)
                    count++;
                j--;
            }
        }
        j = k+5;
        i--;
    }
    std::cout << count;
    return 0;
}

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

class Main {

	static String[] nums ;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		 nums = br.readLine().split(" ");

		int q = Integer.parseInt(br.readLine());

		String[] target_nums = br.readLine().split(" ");

		for(int i=0; i<target_nums.length; i++){
			if(func(0, 0,Integer.parseInt(target_nums[i]))){
				System.out.println("yes");
			}else {
				System.out.println("no");
			}
		}
	}


	static boolean func(int i, int sum, int target){

/*		System.out.println(i+" "+sum);
*/
			if(sum == target){
				/*System.out.println("??????");*/
				return true;
			}

			if(i >nums.length-1){
				return false;
			}

			if(func(i+1, sum,target)){
				return true;
			}

			if(func(i+1, sum+Integer.parseInt(nums[i]),target)){
				return true;
			};


		return false;

	}

}

Measured memory_bytes: 27568
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N;
  cin>>N;
  int a[N];
  int ma=-1; int mai;
  rep(i,N){
    int aa;cin>>aa;
    a[i]=aa;
    if(chmax(ma,abs(aa))) mai=i;
  }
  cout<< 2*N-1<<"\n";
  rep(i,N){
    cout<< mai+1<<" "<<i+1<<"\n";
  }
  if(a[mai]>=0) rep(i,N-1){
    cout<< i+1<<" "<<i+2<<"\n";
  }
  else{
    repr(i,N-2,0){
      cout<< i+2<<" "<<i+1<<"\n";
    }
  }

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int m[2];
	int d[2];
	REP(i, 2) { scanf("%d %d", &m[i], &d[i]); }
	printf("%d\n", m[0] == m[1] ? 0 : 1);
	return 0;
}

Measured memory_bytes: 256