akhauriyash/Code-Regression huggingface dataset:
// tenka1_2019_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> stone(N), cumsum0(N+1,0), cumsum1(N+1,0);
    REP(i, N) {
        stone[i] = (S[i] == '#' ? 1 : 0);
        cumsum0[i+1] = cumsum0[i] + (S[i] == '#' ? 0 : 1);
        cumsum1[i+1] = cumsum1[i] + (S[i] == '#' ? 1 : 0);
    }

    int ans = INF;
    REP(i, N){
        ans = min(ans, cumsum1[i] + cumsum0[N] - cumsum0[i]);
    }

    ans = min(ans, cumsum0[N]);
    ans = min(ans, cumsum1[N]);

    print(ans);

    return 0;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define ll long long


using namespace std;

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

    int n;cin>> n;
    string s;cin >> s;
    if(n<3200)return cout << "red",0;
    cout << s;

    return 0;
}


Measured memory_bytes: 256
N,L=list(map(int, input().split()))
A=list(map(int, input().split()))
for i in range(N-1):
  if A[i]+A[i+1]>=L:
    print('Possible')
    k=i
    break
else:
  print('Impossible')
  exit()
ans=[0]*(N-1)
ans[k]=N-1
for i in range(k):
  ans[i]=i+1
for i in range(N-2-k):
  ans[N-i-2]=k+i+1
for i in range(N-1):
  print(ans[i])

Measured memory_bytes: 86620
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
class Sort
  def initialize(v)
    @n = v.length
    @a = Array.new(@n, 0)
    (0..(@n-1)).each {|i| @a[i] = v[i]}
  end


  def bubble(e,debug)
    f = @a.dup()
    0.upto(@n-1).each{|i|
      (@n-1).downto(i+1).each{|j|
        if e.call(f[j],f[j-1]) <0 then
          tmp = f[j]
          f[j] = f[j-1]
          f[j-1] = tmp
        end
      }
      puts f.map{|x| x.to_s}.join(" ") if debug
    }
    f
  end

  def selection(e,debug)
    f = @a.dup()
    0.upto(@n-1).each{|i|
      mini = i
      i.upto(@n-1).each{|j|
        if e.call(f[j], f[mini]) < 0 then
          mini = j
        end
      }
      if i != mini then
        tmp = f[i]
        f[i] = f[mini]
        f[mini] = tmp
      end
      puts f.map{|x| x.to_s}.join(" ") if debug
    }
    f
  end

  def insertion(e,debug)
    f = @a.dup()
    (0..(@n-1)).each{|i|
      key = f[i]
      j = i-1
      while j>=0 and e.call(f[j], key)>0
        f[j+1] = f[j]
        j -= 1
      end
      f[j+1]=key

      puts f.map{|x| x.to_s}.join(" ") if debug
    }
    f
  end

end

class Main
  def initialize()
    #fh = open("x.txt")
    fh = STDIN
    n = fh.gets.chomp.to_i
    #count=0
    fl = fh.gets.chomp.split
    abort if fl.length != n
    st = Sort.new(fl)
    cmp = lambda {|x,y|x.slice(1,1) <=> y.slice(1,1) }

    ans_b = st.bubble(cmp, false)
    puts ans_b.map{|x|x.to_s}.join(" ")
    puts "Stable"
    ans_s = st.selection(cmp, false)
    puts ans_s.map{|x|x.to_s}.join(" ")

    if ans_b == ans_s then
      puts "Stable"
    else
      puts "Not stable"
    end

  end
end

if $0==__FILE__ then
  Main.new()
end
#    ans = st.insertion(cmp, true)

Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


string Sd, T;


bool judge(string sub){
	rep(i, 0, SIZE(T))
		if(sub[i] != '?' && sub[i] != T[i]) return false;
	return true;
}


string solve(){
	set<string> ans;
	repe(i, 0, SIZE(Sd)-SIZE(T)){
		string sub;
		rep(j, 0, SIZE(T)) sub.pb(Sd[i+j]);
		if(!judge(sub)) continue;
		rep(j, 0, SIZE(sub))
			if(sub[j] == '?') sub[j] = T[j];
		string s1 = "", s2 = "";
		rep(j, 0, i) s1.pb((Sd[j]=='?' ? 'a' : Sd[j]));
		rep(j, i+SIZE(T), SIZE(Sd)) s2.pb((Sd[j]=='?' ? 'a' : Sd[j]));
		ans.insert(s1+sub+s2);
	}
	if(ans.empty()) return "UNRESTORABLE";
	return *ans.begin();
}


signed main(){
	cin >> Sd >> T;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int a[10005];
int b[10005];
int main()
{
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    for(int i=1;i<= n;++i)
        cin>>b[i];
    int temp=1;
    int j=1;
    for(int i=1;i<=n;++i)
    {
        while(b[i]>0)
        {
            a[j]=temp;
            j++;
            b[i]--;
        }
        temp++;
    }
    for(int i=1;i<=h;++i)
    {
        if (i%2==1)
        {
            for(int p=w*(i-1)+1;p<=i*w;++p)
            {
                cout<<a[p]<<" ";
            }
            if (i!=h)
                cout<<endl;
        }
        else if(i%2==0)
        {
            for(int p=w*i;p>=w*(i-1)+1;--p)
            {
                cout<<a[p]<<" ";
            }
            if (i!=h)
                cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 764
N=int(input())

T = list(map(int,input().split()))
A = list(map(int,input().split()))

count=0
for i in range(N):
    if A[i]==T[N-1] and T[i]==T[N-1]:
        count+=1


if count==0:
    print(0)
else:
    count=max(0,count-2)

    mod = 10**9+7
    d = pow(T[N-1],count,mod)

    from collections import Counter

    tc=Counter(T)

    for key in tc.keys():
        if key!=T[N-1]:
            d*=pow(key,tc[key]-1,mod)
            d%=mod

    ac=Counter(A)

    for key in ac.keys():
        if key!=T[N-1]:
            d*=pow(key,ac[key]-1,mod)
            d%=mod

    print(d)

Measured memory_bytes: 83408
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC diagnostic ignored "-Wunused-result"

#include <cstdio>
#include <chrono>
#include <random>

using namespace std;
using namespace chrono;

constexpr int c_max = 26;
constexpr int D = 365;
constexpr int INF = 1e9;
constexpr int time_limit = 1987;

int c[c_max];
int s[D][c_max];
int best_score[D];
int last[c_max];
int schedule[D];

inline int calc_score(const int &day, const int &examining) {
  int ret;
  if (day == 0) ret = s[day][examining];
  else ret = best_score[day - 1] + s[day][examining];
  
  for (int i = 0; i < c_max; i++) {
    if (i == examining) continue;
    ret -= (day - last[i]) * c[i];
  }

  return ret;
}

inline int calc_score_diff(const int &day1, const int &day2) {
  int prev_interval_1 = 0;
  for (int i = day1 - 1; i >= 0; i--) {
    prev_interval_1++;
    if (schedule[i] == schedule[day1]) break;
  }

  int prev_interval_2 = 0;
  for (int i = day2 - 1; i >= 0; i--) {
    prev_interval_2++;
    if (schedule[i] == schedule[day2]) break;
  }

  int new_interval_1 = 0;
  for (int i = day2 - 1; i >= 0; i--) {
    new_interval_1++;
    if (schedule[i] == schedule[day1]) break;
  }

  int new_interval_2 = 0;
  for (int i = day1 - 1; i >= 0; i--) {
    new_interval_2++;
    if (schedule[i] == schedule[day2]) break;
  }

  int ret = s[day1][schedule[day2]] + s[day2][schedule[day1]]
          - s[day1][schedule[day1]] - s[day2][schedule[day2]];
  
  ret += c[schedule[day1]] * ((prev_interval_1 + 1) * prev_interval_1 - (new_interval_1 + 1) * new_interval_1) / 2;
  ret += c[schedule[day2]] * ((prev_interval_2 + 1) * prev_interval_2 - (new_interval_2 + 1) * new_interval_2) / 2;

  return ret;
}

int main() {
  system_clock::time_point start = system_clock::now(), now;

  random_device seed;
  mt19937 rnd(seed());

  /* input */
  scanf("%*d");

  for (int i = 0; i < c_max; i++) {
    scanf("%d", &c[i]);
  }

  for (int i = 0; i < D; i++) {
    for (int j = 0; j < c_max; j++) {
      scanf("%d", &s[i][j]);
    }
  }

  /* calc initial solution */
  for (int d = 0; d < D; d++) {
    int best = -INF;
    int contest_to_hold = 0;
    for (int type = 0; type < c_max; type++) {
      int score = calc_score(d, type);
      if (best < score) {
        best = score;
        contest_to_hold = type;
      }
    }
    last[contest_to_hold] = d;
    schedule[d] = contest_to_hold;
  }

  /* try and error */
  int day1, score_diff, tmp;
  while (1) {
    now = system_clock::now();
    if (duration_cast<milliseconds>(now - start).count() > time_limit) break;
    day1 = rnd() % (D-1);
    // day2 = rnd() % D;
    score_diff = calc_score_diff(day1, day1 + 1);
    if (score_diff > 0) {
      tmp = schedule[day1];
      schedule[day1] = schedule[day1 + 1];
      schedule[day1 + 1] = tmp;
    }
  }

  /* output */
  for (const int &x : schedule) {
    printf("%d\n", x+1);
  }

  return 0;
}


Measured memory_bytes: 3408
# 2019/08/12
from math import factorial

n=int(input())
mod=(10**9+7)
def trial_div(n):
    div={}
    for i in range(2,n+1):
        res=i
        for j in range(2,i+1):
            while res%j==0:
                res//=j
                div[j]=div.get(j,0)+1
    return div

res=trial_div(n)
ans=1
for k,v in res.items():
    ans=(ans*(v+1))%mod
print(ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back

using ld = long double;
const ld EPS = 1e-8;
typedef vector<ld> vec;
typedef vector<vec> mat;

vec GaussJordan(mat A){
    int n = A.size();
    int m = A[0].size();
    for(int i = 0; i < n; i++){
        int pivot = i;
        for(int j = i; j < n; j++) {
            if(abs(A[j][i]) > abs(A[pivot][i])) pivot = j;
        }
        swap(A[i], A[pivot]);
        if(abs(A[i][i]) < EPS) return {};
        for(int j = i + 1; j < m; j++) A[i][j] /= A[i][i];
        for(int j = 0; j < n; j++) {
            if(i != j) {
                for(int k = i + 1; k < m; k++) A[j][k] -= A[j][i] * A[i][k];
            }
        }
    }
    vec x(n);
    for(int i = 0; i < n; i++) x[i] = A[i].back();
    return x;
}

int d;
vec b;

auto y = [](const vec &f, ld x){
    ld res = 0, cur = 1;
    rep(i,d+1){
        res += cur * f[i];
        cur *= x;
    }
    return res;
};

int solve(){
    mat A(d+3, vec(d+2));
    rep(i,d+3){
        ld cur = 1;
        rep(j,d+1){
            A[i][j] = cur;
            cur *= i;
        }
        A[i][d+1] = b[i];
    }
    vector<int> cnt(d+3);
    rep(i,d+3)rep(j,i){
        mat P;
        vector<pair<int,ld>> test;
        rep(k,d+3){
            if(k == i || k == j){
                test.eb(k,b[k]);
            } else {
                P.pb(A[k]);
            }
        }
        vec c = GaussJordan(P);
        rep(k,2){
            int x = test[k].first;
            ld resy = y(c, x);
            ld expy = test[k].second;
            cnt[x] += abs(expy - resy) > 1e-3;
        }
    }
    return max_element(all(cnt)) - cnt.begin();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(cin >> d && d){
        b.resize(d+3);
        rep(i,d+3) cin >> b[i];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){
	
	string S,T;
	cin>>S>>T;
	int ans = 0;
	for(int i=0;i<3;i++)if(S[i]==T[i])ans++;
	cout<<ans<<endl;
		
	
	return 0;
}


Measured memory_bytes: 256
input()
a = list(map(int,input().split()))
l = [0] * 100000
for c in a:
    if c-1<0:pass
    else:l[c-1]+=1
    l[c] += 1
    if c+1>99999:pass
    else:l[c+1]+=1
print(max(l))

Measured memory_bytes: 14008
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int ans = INF;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			string tmp = to_string(i);
			string tmp2 = to_string(n / i);
			chmin(ans, (int)max(tmp.size(), tmp2.size()));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
<>=~$";
@a=map[split],<>;
for(0..7){
	$x=(-1)**($_>>2&1);
	$y=(-1)**($_>>1&1);
	$z=(-1)**($_>>0&1);
	@_=map{$$_[0]*$x+$$_[1]*$y+$$_[2]*$z}@a;
	$s=0;
	$s+=$_ for(sort{$b<=>$a}@_)[0..$'-1];
	$s<$\or$\=$s
}
print


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

using namespace std;

int main()
{
  string S, T;
  int sum1[4001][26] = {{}}, sum2[4001][26] = {{}};

  cin >> S >> T;
  for(int i = 0; i < S.size(); i++) {
    for(int j = 0; j < 26; j++) sum1[i + 1][j] = sum1[i][j] + (S[i] == j + 'a');
  }
  for(int i = 0; i < T.size(); i++) {
    for(int j = 0; j < 26; j++) sum2[i + 1][j] = sum2[i][j] + (T[i] == j + 'a');
  }

  for(int i = min(S.size(), T.size()); i >= 0; i--) {
    set< vector< int > > sets;
    for(int j = 0; j <= S.size() - i; j++) {
      vector< int > array(26);
      for(int k = 0; k < 26; k++) array[k] = sum1[j + i][k] - sum1[j][k];
      sets.insert(array);
    }
    for(int j = 0; j <= T.size() - i; j++) {
      vector< int > array(26);
      for(int k = 0; k < 26; k++) array[k] = sum2[j + i][k] - sum2[j][k];
      if(sets.find(array) != sets.end()) {
        cout << i << endl;
        return (0);
      }
    }
  }
}

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

#define FOR(i,n)    for(lli i=0;i<(lli)(n);++i)
#define FORU(i,j,k) for(lli i=(j);i<=(lli)(k);++i)
#define FORD(i,j,k) for(lli i=(j);i>=(lli)(k);--i)

#define pb push_back
#define mt make_tuple

using namespace std;

using lli = long long int;
using pll = pair<lli, lli>;

using vi = vector<lli>;
using vvi = vector<vi>;
using pii = tuple<lli, lli>;
using vii = vector<pii>;
using vvii = vector<vii>;

#define X(a) get<0>(a)
#define Y(a) get<1>(a)
#define Z(a) get<2>(a)

string TYPE(const int*)          { return "%d";   }
string TYPE(const lli*)          { return "%lld"; }
string TYPE(const char*)         { return "%c";   }
string TYPE(const char**)        { return "%s";   }
string TYPE(const unsigned int*) { return "%u";   }

const int MAX_BUF = 100*1000+42;
char buf[MAX_BUF];

void RD() {}
template<typename T, typename... Args> 
void RD(T* v, Args... args)
{
    scanf((" " + TYPE(v)).c_str(), v);
    RD(args...);
}
template<typename... Args> 
void RD(string* v, Args... args)
{
    scanf(" %s", buf);
    (*v) = buf;
    RD(args...);
}

void PR(bool nl = true)
{ if(nl) printf("\n"); }
template<typename T, typename... Args> 
void PR(bool nl, T v, Args... args)
{
    printf((TYPE(&v) + " ").c_str(), v);
    PR(nl, args...);
}
template<typename... Args> 
void PR(bool nl, string& v, Args... args)
{
    printf("%s", v.c_str());
    PR(nl, args...);
}
template<typename... Args> 
void PR(Args... args)
{ PR(true, args...); }

const long long int oo = 1000*1000*1000;

struct Coord {
    int x, y;
    Coord(int x = 0, int y = 0) : x(x), y(y) {}
    Coord operator + (const Coord& droite) const
    { return Coord(x + droite.x, y + droite.y); }
};

struct AB {
    int k; vector<lli> arbre;
    AB(int _k = 20, lli def = 0) { k = _k;
        FOR(i, 1 << k)
            arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
        FORD(i, ((1 << (k-1)) - 1), 1)
            arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
    }
    void set(int i, lli x) { int feuille = i + (1 << (k-1));
        arbre[feuille] = x;
        iset(feuille >> 1);
    }
    void iset(int noeud) {
        if(noeud) {
            arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
            iset(noeud >> 1);
    }   }
    lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1) {
        if(q < p) q = 1 << (k-1);
        if(deb <= p && q <= fin) return arbre[noeud];
        if(deb >= q || fin <= p) return 0LL;
        int mil = (p + q) / 2;
        return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
    }
};

int main()
{
    string s; RD(&s);
    FOR(i, s.length()-8)
        printf("%c", s[i]);
    PR();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int k,a,b;
  scanf("%d%d%d",&k,&a,&b);
  if(a%k)
    a+(k-a%k)<=b?printf("OK\n"):printf("NG\n");
  else
    printf("OK\n");
  return 0;
}

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

int main(){
	int a[4][3][10] = {0};
	int n;
	int b, f, r, v;
	cin >> n;
	for (int x = 0; x < n; x++){
		cin >> b >> f >> r >> v;
		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 3; j++){
				for (int k = 0; k < 10; k++){
					if (i==b-1&&j==f-1&&k==r-1){
						a[i][j][k] += v;
					}
					//cout << " " << a[i][j][k];
				}
				//cout << endl;
			}
			//cout << "####################" << endl;
		}
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				if (i == b - 1 && j == f - 1 && k == r - 1){
					//a[i][j][k] += v;
				}
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i != 3)cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;


signed main(){
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		TreeMap<Long, Integer> map = new TreeMap<>();
			for(int i = 0 ; i < N ; i++){
				long cost = sc.nextLong();
				int num = sc.nextInt();
				//map.put(cost,num);
				map.put(cost,map.containsKey(cost)?num+map.get(cost):num);
				//map.compute(cost, (k,v) -> v==null? num : num+v);
			}
			sc.close();


			long totalcost = 0;
			int bought = 0;

			for(Map.Entry<Long,Integer> kv : map.entrySet()){
				long cost = kv.getKey();
				int maxnum = kv.getValue();

				int buycount = Math.min(maxnum, M-bought);
				totalcost += buycount * cost;
				bought += buycount;

				if(bought > M){
					break;
				}
			}
			System.out.println(totalcost);
	}

}


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

int main(){
  int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[N-1] - a[0] << endl;
}

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

using namespace std;

// https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_10_C

int lcs(int currX, int currY, const string& X, const string& Y, vector<vector<int>>& memo) {
    if (currX == X.size() || currY == Y.size()) {
        return 0;
    }
    if (memo[currX][currY] >= 0) {
        return memo[currX][currY];
    }

    int ret;
    if (X[currX] == Y[currY]) {
        ret = lcs(currX + 1, currY + 1, X, Y, memo) + 1;
    }
    else {
        int moveX = lcs(currX + 1, currY, X, Y, memo);
        int moveY = lcs(currX, currY + 1, X, Y, memo);
        ret = max(moveX, moveY);
    }
    memo[currX][currY] = ret;
    return ret;
}

void Main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        string X, Y;
        cin >> X;
        cin >> Y;

        vector<vector<int>> memo(1005, vector<int>(1005, -1));
        int ans = lcs(0, 0, X, Y, memo);
        cout << ans << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll csum[n + 1];
    ll x = 0, y = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (i == 0) csum[i] = a;
        else csum[i] = csum[i - 1] + a;
    }

    ll sum = csum[n - 1];
    ll ans = 1e18;
    rep(i, n - 1) {
        x = csum[i];
        y = sum - x;
        ans = min(ans, abs(x - y));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.awt.*;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(),W=sc.nextInt();
        int w[]=new int[n+1];int v[]=new int[n+1];
        int sum=0;
        for (int i=1;i<=n;i++){
            w[i]=sc.nextInt();
            v[i]=sc.nextInt();
            sum+=v[i];
        }
        long dp[]=new long[sum+1];Arrays.fill(dp,(long)1e18);dp[0]=0;
        for (int i=1;i<=n;i++){
            for (int j=sum;j>=v[i];j--){
                dp[j]=Math.min(dp[j],dp[j-v[i]]+w[i]);
            }
        }
        int ans=0;
        for (int i=0;i<=sum;i++){
            if (dp[i]<=W)ans=Math.max(i,ans);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include<cmath>
#include<vector>
#include<tuple>
#include <ctime>
#include<algorithm>
#include <initializer_list>
#include <cstring> 
 
#define tii tuple<int,int>
#define vi vector<int>
#define vii vector<vi>
#define ll long long int
#define vl vector<ll>
#define vll vector<vl>
 
#define mymod 1000000007
#define mx 99999999
#define mn -99999999
#define sz 101
 
using namespace std;
 
int main() {
    clock_t tstart = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // Start
    string s;
    cin>>s;
    if(s.find("RRR") != string::npos) {
        cout<<"3";
        return 0;
    }
    if(s.find("RR") != string::npos) {
        cout<<"2";
        return 0;
    }
    if(s.find("R") != string::npos) {
        cout<<"1";
        return 0;
    }
    cout<<"0";
    // cout<<"\n\nTotal Time Taken : "<<(double)(-tstart + clock())/CLOCKS_PER_SEC<<"sec\n\n";
    return 0;
}
 

Measured memory_bytes: 3648
#include<cstdio>
long long a,b,n;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&n);
	if(a<n)
	{
		n-=a;
		a=0;
	}
	else
	{
		a-=n;
		n=0;
	}
	b-=n;
	if(b<0)b=0;
	printf("%lld %lld",a,b);
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    string name;
    while(N) {
        N--;
        name.insert(name.begin(), 'a' + N % 26);
        N /= 26;
    }
    cout << name << endl;
    return 0;
}


Measured memory_bytes: 3620
program main
implicit none
integer:: i,ind,oc
integer(8):: k, ans
character(101):: rs
character(:), allocatable:: s
integer, allocatable:: counter(:)
character(1):: cfirst, cend, currentchar, os

read*, rs,k
allocate(character(len_trim(rs)):: s)
s = trim(rs)
! print*, len(s)
allocate(counter(len(s)))
cfirst = s(1:1)
cend = s(len(s):len(s))
ind = 0
counter(1:len(s)) = 0
currentchar = '0'
if (len(s) == 1)then
    print*, k/2
    stop
end if


do i=2, len(s)
    os = s(i-1:i-1)
    if (.not. os == s(i:i)) exit
    if (i==len(s))then
        if (mod(k*len(s),2) == 0)then
            print*, (len(s)*k)/2
        else
            print*, (len(s)*k)/2
        end if
        stop
    endif
    
end do





do i=1, len(s)
    if(currentchar == s(i:i))then
        ! print*, '#1-1'
        counter(ind) = counter(ind) + 1
    else
        ! print*, '#1-2'
        currentchar = s(i:i)
        ind = ind + 1
        counter(ind) = counter(ind) + 1
    end if
    ! print*, counter
end do

ans = sum(counter(1:len(s))/2)
! print*, counter 
if (cfirst == cend)then

    oc = counter(1)
    counter(ind) = counter(ind) + counter(1)
    counter(1) = counter(1) - oc
end if

ans = ans + sum(counter(1:len(s))/2)*(k-1)
! print*, counter 

print*, ans
end program

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


int main(){
    ll h,w;cin>>h>>w;
    ll a[555][555];
    rep(i,0,h)rep(j,0,w)cin>>a[i][j];
    vector<tuple<ll,ll,ll,ll> > an;
    rep(i,0,h){
        rep(j,0,w){
            if(i!=h-1){
                if(a[i][j]%2==1){
                    an.push_back(make_tuple(i,j,i+1,j));
                    a[i+1][j]++;
                }
            }
            else{
                if(j!=w-1){
                    if(a[i][j]%2==1){
                        an.push_back(make_tuple(i,j,i,j+1));
                        a[i][j+1]++;
                    }
                }
            }
        }
    }
    cout<<an.size()<<endl;
    rep(i,0,an.size()){
        cout<<get<0>(an[i])+1<<" "<<get<1>(an[i])+1<<" "<<get<2>(an[i])+1<<" "<<get<3>(an[i])+1<<endl;
    }
}







Measured memory_bytes: 8432
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var pf=new Pf(n);
		StringBuilder sb=new StringBuilder();
		sb.Append(n+":");
		pf.Get((k,v)=>{
			for(int i = 0;i<v;i++) {sb.Append(" "+k);}
		});
		Console.WriteLine(sb);
	}
}
public class Pf{
	public Dictionary<long,int> hs=new Dictionary<long,int>();
	public Pf(int n){
		while(n%2==0){
			n>>=1;
			if(hs.ContainsKey(2)){hs[2]++;}
			else{hs.Add(2,1);}
		}
		long q=(long)Sqrt(n)+1;
		int i=3;
		while(n!=1&&i<q){
			if(n%i==0){
				n/=i;
				q=(long)Sqrt(n)+1;
				if(hs.ContainsKey(i)){hs[i]++;}
				else{hs.Add(i,1);}
				i=3;
			}
			else{i+=2;}
		}
		if(n!=1){
			if(hs.ContainsKey(n)){hs[n]++;}
			else{hs.Add(n,1);}
		}
	}
	public void Get(Action<long,int> f){
		foreach(var e in hs){f(e.Key,e.Value);}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

int main() {
  int a[5];
  while(cin >> a[0] && a[0]) {
    for(int i=1; i<5; i++) cin >> a[i];
    set<int> s;
    for(int i=0; i<5; i++) {
      a[i]--;
      s.insert(a[i]);
    }
    for(int i=0; i<5; i++) {
      if(s.size()==1||s.size()==3) cout << 3 << endl;
      else {
        if(s.count((a[i]+1)%3)) cout << 1 << endl;
        else cout << 2 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		br.readLine();
		int count = 0;
		for(String s: br.readLine().split(" ")) {
			int kazu = Integer.parseInt(s);
			if(kazu%2 != 0) {
				count++;
			}
		}
		if(count%2 != 0) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    int ans = 1e9;
    int tmp;
    for (int i = 1; i <= 100; i++)
    {
        tmp = 0;
        for (int j = 0; j < n; j++)
        {
            tmp += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  map<P,int> ans;
  vint A(n);
  vint B(n);
  rep(i,n){
    cin >> A[i] >> B[i];
  }
  int ANS = 0;
  rep(i,n){
    rep(j,n){
      if(i != j){
        ans[make_pair(A[i]-A[j],B[i]-B[j])]++;
      }
    }
  }
  for(auto i:ans){
    ANS = max(ANS,i.second);
  }
  cout << n - ANS << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main()
{
	int	n;
	int	c, s;
	int	i, j;

	scanf("%d", &n);

	s = 0;
	for (i = 1; i <= n; i+=2) {
		c = 0;
		for (j = 1; j <= i; ++j) {
			if ((i % j) == 0) {
				c++;
			}
		}
		if (c == 8) {
			s++;
		}
	}

	printf("%d\n", s);

	return 0;
}


Measured memory_bytes: 128
import sys
def cul(p,q):
    tmp=0
    for i in range(1,N):
        for j in range(i):
            tmpp,tmpq=a[i][0]-a[j][0],a[i][1]-a[j][1]
            if tmpp==p and tmpq==q: tmp+=1
            elif tmpp==-p and tmpq==-q: tmp+=1
    return N-tmp

N=int(input())
if N==1: print(1),sys.exit()
ans=100

a=[list(map(int,input().split())) for i in range(N)]
for i in range(1,N):
    for j in range(i):
        p,q=a[i][0]-a[j][0],a[i][1]-a[j][1]
        ans=min(ans,cul(p,q))
    
print(ans)

Measured memory_bytes: 3064
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");

typedef long long ll;
typedef long double ld;

map<ll, ll> m, val;

ll n, a, b, c, d;

const ll INF = 6e18 + 1;

ll rec(ll x){
    if(x <= 0){
        return 0LL;
    }
    if(x == 1){
        return d;
    }
    if(m.find(x) != m.end()){
        return m[x];
    }
    ll best = INF;
    if(d < best / x){
        best = x * d;
    }
    for(auto y : val){
        ll k = y.first;
        ll mult = y.second;
        if(x % k == 0){
            best = min(best, mult + rec(x / k));
        }
        else{
            ll low = x - (x % k);
            ll high = low + k;
            best = min(best, (x - low) * d + rec(low / k) + mult);
            best = min(best, (high - x) * d + rec(high / k) + mult);
        }
    }
    m[x] = best;
    return best;
}

void solve(){
    cin >> n >> a >> b >> c >> d;
    m.clear();
    val.clear();
    m[0] = 0LL;
    m[1] = d;
    val[2] = a;
    val[3] = b;
    val[5] = c;
    cout << rec(n) << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}



Measured memory_bytes: 4396
n=int(input())
l=list(map(int,input().split()))
dp=[0 for i in range(n)]

dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))

print(dp[n-1])
#print(dp)


Measured memory_bytes: 13980
N,*L = map(int, open(0).read().split())
L.sort()
if N%2==0:
  A = L[:N//2]
  B = L[N//2:]
  a = 0
  b = -1
  m = 0
  n = 0
  p = B[0]
  for i in range(N-1):
    if i%2==0:
      m += p-A[a]
      p = A[a]
      a += 1
    else:
      m += B[b]-p
      p = B[b]
      b -= 1
  p = A[-1]
  a = 0
  b = -1
  for i in range(N-1):
    if i%2==0:
      n += B[b]-p
      p = B[b]
      b -= 1
    else:
      n += p-A[a]
      p = A[a]
      a += 1
  print(max(m,n))
else:
  A = L[:N//2]
  B = L[N//2:]
  a = 0
  b = -1
  m = 0
  n = 0
  p = B[0]
  for i in range(N-1):
    if i%2==0:
      m += p-A[a]
      p = A[a]
      a += 1
    else:
      m += B[b]-p
      p = B[b]
      b -= 1
  A = L[:N//2+1]
  B = L[N//2+1:]
  p = A[-1]
  a = 0
  b = -1
  for i in range(N-1):
    if i%2==0:
      n += B[b]-p
      p = B[b]
      b -= 1
    else:
      n += p-A[a]
      p = A[a]
      a += 1
  print(max(m,n))

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

int main(void){
  ll a, b, k;
  cin >> a >> b >> k;
  if(k > a){ 
    b -= k-a;
    a = 0;
    cout << a << " ";
    if(b < 0) cout << 0 << endl;
    else cout << b << endl;
  }
  else{
    a -= k;
    cout << a << " " << b << endl;
  }
  return 0;
}

Measured memory_bytes: 3540
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg int
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,x,p1;
int main()
{
	//yyj("A");
	cin>>n;
	for (llg i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x%2) p1++;
	}
	if (p1%2) cout<<"NO";else cout<<"YES";
	return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a , b;
    cin >> a >> b;

    if(a < 10 and b < 10)
        cout << a * b;
    else
        cout << -1;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

num = n//2

ans_r = sum(a[:num])
ans_l = sum(a[num:])

t = []

if ans_r == ans_l:
    print(0)
else:
    if ans_r > ans_l:
        for i in range(n):
            t.append(abs(sum(a[:num-i]) - sum(a[num-i:])))
    else:
        for i in range(n):
            t.append(abs(sum(a[:num+i]) - sum(a[num+i:])))
print(min(t))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
const int N=1e3+10;
int max(int a,int b){return a>b?a:b;}
string s[N],a[2];
bool same(int i,int j){return s[i][j]==a[0][0]&&s[i][j+1]==a[0][1]&&s[i+1][j]==a[1][0]&&s[i+1][j+1]==a[1][1];}
int main(){
	int ans=0,n,m,toj[N][N],toi[N][N],too[N][N],now=0;
	char temp;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)toj[i][j]=toi[i][j]=too[i][j]=0;
	cin>>a[0]>>a[1];
	for(int i=0;i<n-1;i++)for(int j=0;j<m-1;j++){
		if(same(i,j))now++;
		for(int x=0;x<2;x++)for(int y=0;y<2;y++){
			if(same(i,j)){
				toi[i+x][j+y]--;
				toj[i+x][j+y]--;
				too[i+x][j+y]--;
			}
			temp=s[i+x][j+y];
			s[i+x][j+y]='J';
			if(same(i,j))toj[i+x][j+y]++;
			s[i+x][j+y]='I';
			if(same(i,j))toi[i+x][j+y]++;
			s[i+x][j+y]='O';
			if(same(i,j))too[i+x][j+y]++;
			s[i+x][j+y]=temp;
		}
	}
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)ans=max(ans,max(toj[i][j],max(too[i][j],toi[i][j])));
	printf("%d\n",ans+now);	
}



Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<ll> A(N), B(N);
  REP(i,N) {
    cin>>A[i]>>B[i];
    A[i] *= 2LL;
    B[i] *= 2LL;
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  //  pp(A, N);
  //  pp(B, N);
  ll ans = 0;
  if(N % 2 == 0) {
    ans = ((B[N/2]+B[N/2-1])/2LL - (A[N/2]+A[N/2-1])/2LL) + 1LL;

  } else { // odd
    ans = (B[N/2] - A[N/2]) / 2LL + 1LL;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}



void solve(){
	ll n,x,t;
	cin>>n>>x>>t;
	ll time=n/x;
	if(n%x!=0)time++;

	ll ans=time*t;
	cout<<ans<<endl;


	
	
	
	return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, i;
    cin >> N >> i; 

    cout << (N-i+1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

void shuffle(std::string &s, int h) {
  s = s.substr(h,s.size()) + s.substr(0, h);
}

int main() {
  std::string s;
  while (std::cin >> s) {
    if (s == "-") break;

    int m, h;
    std::cin >> m;
    for (int i = 0; i < m; i++) {
      std::cin >> h;
      shuffle(s, h);
    }

    std::cout << s << std::endl;
  }
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f

using namespace std;

char s1[5005],s2[5005];
int a[5005],b[5005];

int main() {
  int n;
  scanf("%d%s%s",&n,s1+1,s2+1);
  int sz1=0,sz2=0;
  for(int i=1;i<n;i++)
    if (s1[i]!=s1[i+1]) a[++sz1]=i;
  for(int i=1;i<n;i++)
    if (s2[i]!=s2[i+1]) b[++sz2]=i;
  int ans=inf;
  for(int i=-sz1-1;i<=sz2+1;i++)
    if ((i&1)^(s1[1]==s2[1])) {
    	int s=0;
    	for(int j=min(1,1-i);j<=max(sz1,sz2-i);j++)
    	  s+=abs(((j<0)?0:((j>sz1)?n:a[j]))-((j+i<0)?0:((j+i>sz2)?n:b[j+i])));
    	ans=min(ans,s);
	}
  printf("%d\n",ans);
  return 0;
}

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

int main() {  
  int a,b;
  string s;

  cin >> a >> b;
  cin >> s;

  int n = s.size();

  for (int i = 0; i < n; i++) {
    if(i == a) {
      if (s[i] != '-') {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      if (s[i]!='0' && s[i]!='1' && s[i]!='2' && s[i]!='3' && s[i]!='4' && s[i]!='5' && s[i]!='6' && s[i]!='7' && s[i]!='8' && s[i]!='9') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  ll a, b, k;
  cin >> a >> b >> k;
  if(k<=a){
    cout << a-k <<" "<< b << endl;
  } else if(k<=a+b){
    cout << 0 <<" "<< b-(k-a) << endl;
  } else {
    cout << 0 <<" "<< 0 << endl;
  }

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<vector<char>> grid(h, vector<char>(w));
    vector<vector<int>> ans(h, vector<int>(w));
    int t = 1;
    bool placed = false;
    for (int i = 0; i < h; ++i) {
        bool ichigo = false;
        for (int j = 0; j < w; ++j) {
            cin >> grid[i][j];
            if (grid[i][j] == '#') {
                ichigo = true;
                if (placed) ++t;
            }
            if (ichigo) ans[i][j] = t, placed = true;
        }

        if (ichigo) ++t;
        placed = false;
    }
    
    for (int i = 0; i < h; ++i) {
        if (i == 0 || ans[i].back() != 0) continue;
        for (int j = 0; j < w; ++j) {
            ans[i][j] = ans[i - 1][j];
        }
    }

    for (int i = h - 1; i >= 0; --i) {
        if (i == h - 1 || ans[i].back() != 0) continue;
        for (int j = 0; j < w; ++j) {
            ans[i][j] = ans[i + 1][j];
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = w- 1; j >= 0; --j) {
            if (ans[i][j] == 0) ans[i][j] = ans[i][j + 1];
        }
    }

    for (int i = 0; i < h; ++i) {
        cout << ans[i][0];
        for (int j = 1; j < w; ++j) {
            cout << ' ' << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280