akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main()
{
    int N,X;
    cin >> N>>X;
    int L[N];
    REP(i,0,N){
      cin >> L[i];
    }
    int ans = 1;
    int D = 0;
    REP(i, 0, N)
    {
      D += L[i];
      if(D<=X){
        ans++;
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = gets.chomp.split.map(&:to_i)
AS = gets.chomp.split.map(&:to_i)

as_sum = AS.sum
num = N + K 
num_cut_float = AS.map { |a| 1.0 * num * a / as_sum }
                  .map { |a| a < 1 ? 1 : a}
num_cut_int = num_cut_float.map(&:to_i)

as_length = []
AS.size.times do |i|
  as_length << (1.0 * AS[i] / num_cut_int[i]).ceil 
end
as_length = as_length.sort.reverse
puts as_length[N + K - num_cut_int.sum]



Measured memory_bytes: 39344
import sys
import numpy as np
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    x,y = IL()
    a = np.array([
        [1,1],
        [2,4]
    ])
    b = np.array([
        [x],
        [y]
    ])
    try:
        ans = np.linalg.solve(a,b)
    except:
        exit()
    if np.all(0<=ans) and np.all(abs(ans-np.round(ans)<1e-5)):
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 27400
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for(int a=0; a <= N; ++a){
        for(int b=0; b + a <= N; ++b){
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if(total == Y){
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    String[] T = sc.nextLine().split(" ");
    System.out.println(S[0].equals(T[0]) ? 0 : 1);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
bool cmp(const vector<int> &a, const vector<int> &b)
{
    return a[0] < b[0];
}
int main()
{
  int N;
  cin >> N;
  vector<vector<int> > A(N,vector<int>(2));
  rep(i,N){
    cin >> A.at(i).at(0);
    A.at(i).at(1) = i + 1;
  }
  sort(A.begin(), A.end(),cmp);
  rep(i,N) cout << A.at(i).at(1) << " ";
  cout << endl;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int i =0;
  for (;i < N;i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
  }
  if (i == N) {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
import heapq
x,y,a,b,c = map(int,input().split())
pl = list(map(int,input().split()))
ql = list(map(int,input().split()))
rl = list(map(int,input().split()))

pp = sorted(pl,reverse=True)[:x]
qq = sorted(ql,reverse=True)[:y]
al = pp + qq + rl
#print(al,pp,qq,rl)
print(sum(sorted(al,reverse=True)[:x+y]))

Measured memory_bytes: 24240
#include<bits/stdc++.h>
using namespace std;
int main()
{


   char ara[1000006];
   int n,i,j,len;

    cin>>ara>>n;
    len=strlen(ara);

     for(i=0;i<len;i+=n){

        cout<<ara[i];

     }


return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#pragma GCC optimize ("O2")
int main(void)
{
  int div,K,N;long long a=0;K=scanf("%d",&N);
  if(N<2)return printf("%d\n",N),0;
  while(K*K<=N){div=N/K;a+=1ll*K*(div+K)*(div-K+1);K++;}
  K--;a-=1ll*K*(K+1)*(2*K+1)/6;
  return printf("%lld\n",a),0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
 
int main() {
    string T;
    cin >> T;
    long long ans = 0;
    for (long long i=0; i<T.length(); i++) {
        if (T[i] == '?') {
            T[i] = 'D';
        }
    }
    cout << T << endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1005;
const int MOD = 1e9+7;
int main()
{
    int n;
    cin >> n;
    long long res = 1;
    for(int i = 2; i <= n; ++i)
        {res *= i; res %= MOD;}
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n, a, b, c;
string t[100000];
string ans[100000];

int main(){
  cin >> n >> a >> b >> c;
  bool flag = true;
  rep(i, n) cin >> t[i];
  for(int i = 0; i < n; i++){
    string s = t[i];
    if(s == "AB"){
      if(a>b){
        a--;b++;
        ans[i] = "B";
      }else if(a<b){
        b--;a++;
        ans[i] = "A";
      }else{
        if(a == 0){
          flag = false;
          break;
        }
        if(i == n-1) ans[i] = "A";
        else{
          if(t[i+1] == "BC"){
            b++;a--;
            ans[i] = "B";
          }else if(t[i+1] == "AC"){
            a++;b--;
            ans[i] = "A";
          }else{
            ans[i] = "A";
            a++;b--;
          }
        }
      }
    }
    if(s == "BC"){
      if(b>c){
        b--;c++;
        ans[i] = "C";
      }else if(b<c){
        c--;b++;
        ans[i] = "B";
      }else{
        if(b == 0){
          flag = false;
          break;
        }
        if(i == n-1) ans[i] = "B";
        else{
          if(t[i+1] == "AB"){
            b++;c--;
            ans[i] = "B";
          }else if(t[i+1] == "AC"){
            c++;b--;
            ans[i] = "C";
          }else{
            ans[i] = "B";
            b++;c--;
          }
        }
      }
    }
    if(s == "AC"){
      if(a>c){
        a--;c++;
        ans[i] = "C";
      }else if(a<c){
        ans[i] = "A";
        c--;a++;
      }else{
        if(c == 0){
          flag = false;
          break;
        }
        if(i == n-1) ans[i] = "C";
        else{
          if(t[i+1] == "BC"){
            c++;a--;
            ans[i] = "C";
          }else if(t[i+1] == "AB"){
            a++;c--;
            ans[i] = "A";
          }else{
            ans[i] = "C";
            c++;a--;
          }
        }
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
    rep(i, n) cout<<ans[i]<<endl;
  }else{
    cout<<"No"<<endl;
  }
}



Measured memory_bytes: 9892
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;


public class Main {


    static void solve() {
        Scanner scan = new Scanner(System.in);
        long x = scan.nextLong();
        long sum = 100;
        long cnt = 0;
        while(sum<x) {
           sum = (long)(1.01*sum);
           cnt++;
        }

        System.out.println(cnt);
//        for (int i = 0; i < t; i++) {
//            int x = scan.nextInt();
////            int res = scase(n);
////            System.out.println(res);
////            solveCase(i, x,y,s);
//        }
    }


    static void solveCase(int t, int x, String s) {

    }


//    static int scase(int n) {
//
//    }

    public static void main(String[] args) {

//
        solve();

        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


//
//    class Counter extends HashMap<Integer, Integer> {
//        public int get(int k) {
//            return containsKey(k) ? super.get(k) : 0;
//        }
//
//        public void add(int k, int v) {
//            put(k, get(k) + v);
//        }
//    }


//    static class Node {
//        int val;
//        Node next;
//        Node random;
//
//        public Node(int val) {
//            this.val = val;
//            this.next = null;
//            this.random = null;
//        }
//    }

//    static class Node {
//        int key;
//        int data;
//        Node next;
//        Node prev;
//
//        Node(int key, int data) {
//            this.key = key;
//            this.data = data;
//        }
//    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }
}


Measured memory_bytes: 27072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

template<class G>
struct LowLink {
  const G& g;
  vector<int> ord, low;
  int next_ord;
  bool ran = false;

  LowLink(const G& g) : g(g) {}

  void run() {
    ran = true;
    int n = g.size();
    ord.assign(n, -1);
    low.assign(n, -1);
    next_ord = 0;
    for (int u = 0; u < n; ++u) {
      dfs(u, -1);
    }
  }

  int dfs(int u, int p) {
    if (low[u] >= 0) return low[u];
    low[u] = ord[u] = next_ord++;
    for (int v : g[u]) {
      if (v == p) continue;
      low[u] = min(low[u], dfs(v, u));
    }
    return low[u];
  }

  vector<pair<int, int>> bridges() {
    if (!ran) run();
    vector<pair<int, int>> res;
    for (int u = 0; u < (int)g.size(); ++u) {
      for (int v : g[u]) {
        if (ord[u] < low[v]) res.emplace_back(u, v);
      }
    }
    return res;
  }
};

int n, m;
vector<vector<int>> g;
int main() {
  cin >> n >> m;
  init_n(g, n);
  for (int i = 0; i < m; ++i) {
    int a, b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  LowLink<vector<vector<int>>> ll(g);
  auto bs = ll.bridges();
  for (auto& e : bs) {
    if (e.first > e.second) swap(e.first, e.second);
  }
  sort(begin(bs), end(bs));
  for (auto e : bs) cout << e.first << ' ' << e.second << '\n';
  return 0;
}



Measured memory_bytes: 4408
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// str.substr(start,length) .... read the full question
int main(){
    string S;
    cin >> S;
    int F2 = stoi(S.substr(0,2));
    int L2= stoi(S.substr(2,2));
    if (F2 > 0 && L2 > 0 && F2<=12&&L2<=12){
        cout << "AMBIGUOUS"; rn 0;
    }
    else if (F2<=12 && F2 > 0){
        cout << "MMYY"; rn 0;
    }
    else if (L2<=12&& L2 > 0){
        cout << "YYMM"; rn 0;
    }
    else{
        cout << "NA"; rn 0;
    }
    
    
    rn 0;
}

// tolower()
int mainA(){
    int N,K; string S;
    cin >> N >> K >> S;
    S[K-1] = tolower(S[K-1]);
    cout << S;
    rn 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  char n;
  cin >> n;
  if(n=='A') cout << 'T' << endl;
  if(n=='T') cout << 'A' << endl;
  if(n=='G') cout << 'C' << endl;
  if(n=='C') cout << 'G' << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter


n = int(input())
v = list(map(int, input().split()))
v_former = sorted([(v, k) for k, v in Counter(v[::2]).items()], reverse=True) + [(0, 0)]
v_latter = sorted([(v, k) for k, v in Counter(v[1::2]).items()], reverse=True) + [(0, 0)]
if v_former[0][1] != v_latter[0][1]:
    print(n - v_former[0][0] - v_latter[0][0])
else:
    print(n - max(v_former[0][0] + v_latter[1][0], v_former[1][0] + v_latter[0][0]))



Measured memory_bytes: 20572
//author: chinmay0402
//One day your whole life will flash before your eyes, make sure you make it worth watching
#include<bits/stdc++.h>
using namespace std;

//policy based data structures
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define ll long long int
#define lld long double
#define fl float
#define vs vector<string>
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define fst first
#define scd second
#define sll set<ll>
#define mll map<ll,ll>
#define flash ios_base::sync_with_base(false);cin.tie(NULL);
#define INF (ll)10000000000000000
#define MOD (ll)1000000007
#define pb push_back
#define mll map<ll,ll>
#define test ll t;cin>>t;while(t--)
#define sortv(v) sort(v.begin(),v.end())
#define max3(a,b,c) max(a,max(b,c))

#define forn(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define fornr(i,n) for(ll i=n-1;i>=0;i--)
#define forab(i,a,b,c) for(ll i=a;i<=b;i+=c)

template<typename T>
void read(T &x){
 cin>>x;
}
template<typename T,typename T1>
void read(T &x, T1 &y){
 cin>>x>>y;
}
template<typename T,typename T1, typename T2>
void read(T &x, T1 &y, T2 &z){
 cin>>x>>y>>z;
}
template<typename T,typename T1, typename T2, typename T3>
void read(T &x, T1 &y, T2 &z , T3 &a){
 cin>>x>>y>>z>>a;
}
template<typename T>
void reada(T oneD,ll n){
 for(ll i=0;i<n;i++)
  cin>>oneD[i];
}
template <typename T>
void readv(vector< T > &oneD,ll n){
 forn(i,n){
  ll x;
  read(x);
  oneD.push_back(x);
 }
}
ll gcd(ll a, ll b){
 if(a==0)
  return b;
 else
  return gcd(b%a,a);
}

ll gcdExt(ll a,ll b, ll &x, ll &y){
 if(a==0){
  x=0;
  y=1;
  return b;
 }
 ll x1,y1;
 ll gcd=gcdExt(b%a,a,x1,y1);
 x=y1-(b/a)*x1;
 y=x1;
 return gcd;
}

ll pwr(ll a, ll b){
 ll res=1;
 while(b>0){
  if(b&1)
   res=res*a;
  a*=a;
  b>>=1;
 }
 return res;
}

ll pwrm(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;
}

vector<bool>sieve(1000000,true);
void Sieve(){
 sieve[0]=false;
 sieve[1]=false;
 for(ll i=2;i*i<=1000000;i++){
  if(sieve[i]==true){
   for(ll j=i*i;j<1000000;j+=i)
    sieve[j]=false;
  }
 }
}

vll sieve_spf(1000001);
void Sieve_spf(){
 ll n=1000001;
 
 forn(i,n)
  sieve[i]=i;
 
 sieve[0]=-1;
 sieve[1]=-1;
 
 forab(i,2,n,2)
  sieve[i]=2;
 
 forab(i,3,n,2)
  if(sieve[i]==i)
   forab(j,i*i,n,i)
    if(sieve[j]==j)
     sieve[j]=i;
}


int main(){
 ll v,n,sum=0;
 read(v,n);
 ll a[n];
 reada(a,n);
 forn(i,n)
  sum+=a[i];
 if(sum>v)
  cout<<"-1\n";
 else
  cout<<(v-sum)<<"\n";
 return 0;
}

Measured memory_bytes: 10988
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,a[maxn],f[maxn];
long long k;
inline bool cmp(int x,int y)
{
	return x>y;
}
inline void chkmin(long long &x,long long y)
{
	if(x>y)
		x=y;
}
inline bool chk(long long x)
{
	long long sum=0;
	for(register int i=1;i<=n;i++)
		if(1ll*a[i]*f[i]>x)
		{
			long long res=(1ll*a[i]*f[i]-x)/f[i];
			long long s=1ll*a[i]*f[i]-f[i]*res;
			if(s>x)
				res++;
			sum+=res;
			if(sum>k)
				return 0;
		}
	return 1;
}
int main()
{
	scanf("%d%lld",&n,&k);
	for(register int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(register int i=1;i<=n;i++)
		scanf("%d",&f[i]);
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp);
	long long l=0,r=1e12,ans=1e12;
	while(l<=r)
	{
		long long mid=(l+r)>>1;
		if(chk(mid))
		{
			r=mid-1;
			chkmin(ans,mid);
		}
		else
			l=mid+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    rep(i, s.length()) {
        int x = s[i] - 'A';
        x = (x + n) % 26;
        printf("%c", 'A'+x);
    }
    printf("\n");
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, n, k, a[300000];
  scanf("%d%d", &n, &k);
  for(i = 0; i < n; i++)scanf("%d", &a[i]);
  printf("%d", (n - 2) / (k - 1) + 1);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
ll f[N];
int n, m;
int main() {
    memset(f, 0x3f, sizeof(f));
    f[0] = 0;
    scanf("%d%d", &n, &m);
    for (int i = 1, w, v; i <= n; i++) {
        scanf("%d%d", &w, &v);
        for (int j = N - 1; j >= v; j--) f[j] = min(f[j], f[j - v] + w);
    }
    int add = N - 1;
    while (f[add] > m) add--;
    printf("%d\n", add);
    return 0;
}

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

int main(){
	int n, m, x;
	cin >> n >> m >> x;
	int c[n], a[n][m], b[m], cost=0, min=2147483647;
	for(int i=0; i<m; ++i){
		b[i] = 0;
	}
	for(int i=0; i<n; ++i){
		cin >> c[i];
		for(int j=0; j<m; ++j){
			cin >> a[i][j];
		}
	}
	for(int i=1; i<=(1<<n)-1; ++i){
		for(int j=0; j<n; ++j){
			//cout << i << ", " << j << ": " << (i & (1<<j)) << endl;
			if(i & (1<<j)){
				cost += c[j];
				for(int k=0; k<m; ++k){
					b[k] += a[j][k];
				}
			}
		}
		//cout << cost << " ";
		bool flag = true;
		for(int j=0; j<m; ++j){
			if(b[j] < x){
				flag = false;
			}
		}
		if(cost < min && flag){
			min = cost;
		}
		cost=0;
		for(int j=0; j<m; ++j){
			b[j] = 0;
		}
	}
	if(min != 2147483647){
		cout << min << endl;
	}
	else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int i=0,N=IN(),r=0,w=0;char *stones=(char*)malloc(sizeof(char)*(N+1));stones[N]=0;
  if(stones==NULL||!scanf("%s",stones)){exit(EXIT_FAILURE);}
  while(N--){if(stones[N]=='R')r++;}while(r--){if(stones[i++]=='W')w++;}
  free(stones);return printf("%d\n",w),0;
}

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

using ll = long long int;

const ll MOD = (ll)(1e9 + 7);

ll n, m;

ll ans = 0;

ll cal_step(ll target) {
  ll last = 1;
  for (ll i = 1; i <= target; ++i) {
    last *= i;
    last %= MOD;
  }
  return last;
}

int main(void){
  // Here your code !
  scanf("%lld %lld", &n, &m);

  if (n == m) {
    ans = (((cal_step(n) * cal_step(m)) % MOD) * 2) % MOD;
  }
  else if (abs(n - m) == 1) {
    ans = (cal_step(n) * cal_step(m)) % MOD;
  }
  else {
    ans = 0;
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main(){
    int A, B, M;
    int ans = 1000000;
    int x, y, c;
    int a_min = 100000;
    int b_min = 100000;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    for (int i=0; i<A; i++){
        cin >> a[i];
        a_min = min(a[i], a_min);
    }
    for (int i=0; i<B; i++){
        cin >> b[i];
        b_min = min(b[i], b_min);
    }
    for (int i=0; i<M; i++){
        cin >> x >> y >> c;
        ans = min(ans, a[x-1]+b[y-1]-c);
    }
    ans = min(ans, a_min+b_min);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  string s;cin>>s;
  ll n=s.size();
  vector<ll>v(4,0);
  rep(i,0,n){
    if(s[i]=='N')v[0]++;
    else if(s[i]=='W')v[1]++;
    else if(s[i]=='S')v[2]++;
    else if(s[i]=='E')v[3]++;
  }

  if(((v[0]!=0&&v[2]!=0)&&(v[1]!=0&&v[3]!=0))||((v[0]!=0&&v[2]!=0)&&(v[1]==0&&v[3]==0))||((v[0]==0&&v[2]==0)&&(v[1]!=0&&v[3]!=0)))out("Yes");
  else out("No");



  return 0;
}


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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

vector<vector<ll> > dp(401, vector<ll>(401, -1LL));
vector<int> v(401);
vector<ll> pre(401, 0LL);

ll ans(int l, int r) {
    if (l == r)
        return 0;
    else if (dp[l][r] != -1LL)
        return dp[l][r];

    ll a = LLONG_MAX;
    // merge (l, i-1) and (i, r);
    for (int i = l + 1; i <= r; i++) {
        ll cost = 0;

        cost += ans(l, i - 1);
        cost += ans(i, r);

        a = min(a, cost);
    }
    a += pre[r] - pre[l - 1];
    dp[l][r] = a;
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        pre[i] += (ll)v[i] + pre[i - 1];
    }
    cout << ans(1, n);
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int s_to_i(string s){
	int res = 0;
	for(int i=0 ; i < s.size() ; i++ ){
		res = res * 10 + (s[i] - '0');
	}
	return res;
}

string i_to_s(int n){
	string s;
	do{
		s.push_back( n % 10 + '0');
		n /= 10;
	}while( n );
	reverse( s.begin() , s.end() );
	return s;
}

int main(){
	string a[21];
	int L;
	while( cin >> a[0] >> L ){
		if( a[0] == "0" && L == 0 ) break;
		int i = 0;
		// h[a[i]] := j;
		map<int,int> h;

		while( true ){
			if( h.count( s_to_i(a[i]) ) ){
				int j = h[ s_to_i(a[i]) ];
				cout << j << " " << s_to_i(a[i]) << " " << (i - j) << endl;
				break;
			}else{
				h[ s_to_i(a[i]) ] = i;
				
				string s = a[i];
				while( s.size() < L ) s = "0" + s;
				sort( s.begin() , s.end() );
				int small = s_to_i(s);
				reverse( s.begin() , s.end() );
				int large = s_to_i(s);
				int next = large - small;
				a[i+1] = i_to_s(next);
				i++;
			}
		}
	}
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a; cin>>n;
	set<int> st;
	for (int i=0; i<n; i++) {
		cin>>a; st.insert(a);
	}
	if(st.size()==n) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 9600
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

ll n,k;
vector<ll>a;
vector<ll>f;

bool binary_j(ll mid){
  ll sum=0;
  ll z=0;
  for(ll i=0;i<n;i++){
    sum+=max(z,a[i]-mid/f[i]);
  }
  if(sum>k) return false;
  else return true;
}

ll binary_search(ll left,ll right){
  ll mid;
  while(left<right){
    mid = (left+right)/2;
    if(binary_j(mid)){
      right = mid;
    }
    else{
      left = mid+1;
    }
  }
  return left;
}

int main(){
  ll ans=0;
  cin>>n>>k;
  a.assign(n,0);
  f.assign(n,0);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  for(ll i=0;i<n;i++){
    cin>>f[i];
  }
  sort(a.begin(),a.end());
  sort(f.begin(),f.end());
  reverse(f.begin(),f.end());
  ans=binary_search(0,2*(1e+12));
  cout<<ans<<endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n, a, b, c, x;
    cin >> n >> a >> b >> c >> x;
    if (n == 0) return;

    vi32 y(n); cin >> y;
    int ans = 0;
    int idx = 0;
    while (true) {
      if (ans > 10000) break;
      if (y[idx] == x) idx++;
      if (idx == n) break;
      ans++;
      x = (a * x + b) % c;
    }
    if (ans > 10000) {
      cout << -1 << '\n';
    } else {
      cout << ans << '\n';
    }
  }
}



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

long long K,X;

int main() {
    cin >> K >> X;
    if ((K * 500) >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

public class Main {
    int n;
    int[][] h;
    boolean[][] r, l;
    Scanner sc;
    static int INF = 1<<28;

    Main() {
        sc = new Scanner(System.in);
    }

    public static void main(String[] args) {
        new Main().run();
    }

    boolean init() {
        n = sc.nextInt();
        if (n == 0) return false;
        h = new int[n][n];
        r = new boolean[n][n];
        l = new boolean[n][n];
        for (int i = 0; i < n; i++) 
            for (int j = 0; j < n; j++) 
                h[i][j] = sc.nextInt();
        return true;
    }

    void run() {
        while (init()) {
            // each row
            for (int i = 0; i < n; i++) {
                int min_h = INF;
                for (int j = 0; j < n; j++) 
                    if (min_h > h[i][j]) min_h = h[i][j];
                for (int j = 0; j < n; j++) 
                    if (h[i][j] == min_h) r[i][j] = true;
            }

            // each column
            for (int j = 0; j < n; j++) {
                int max_h = 0;
                for (int i = 0; i < n; i++) 
                    if (max_h < h[i][j]) max_h = h[i][j];
                for (int i = 0; i < n; i++) 
                    if (h[i][j] == max_h) l[i][j] = true;
            }

            boolean found = false;
find_target:
            for (int i = 0; i < n; i++) 
                for (int j = 0; j < n; j++) 
                    if (r[i][j] && l[i][j]) {
                        found = true;
                        System.out.println(h[i][j]);
                        break find_target;
                    }
            if (!found) System.out.println("0");
        }
    }
}

Measured memory_bytes: 12000
N = int(input())
A = list(map(int, input().split()))
cnt = i = 0
while i < len(A):
    if i == len(A)-1:
        cnt += 1
        break
        
    if A[i] == A[i+1]:
        i += 1
        continue
        
    elif A[i] < A[i+1]:
        j = 0
        while i+j+1 < len(A) and A[i+j] <= A[i+j+1]:
            j += 1
        i += j + 1
        cnt += 1
        continue
    
    elif A[i] > A[i+1]:
        j = 0
        while i+j+1 < len(A) and A[i+j] >= A[i+j+1]:
            j += 1
        i += j + 1
        cnt += 1
print(cnt)

Measured memory_bytes: 14480
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return int(gcd(b, c))

def lcm(a, b):
    return int(a * b / gcd(a,b))

A, B, C, D = list(map(int, input().split(" ")))

l = lcm(C, D)

A = A-1
x = (B-A)
y = (B//C - A//C)
z = (B//D - A//D)
a = (B//l - A//l)
print(x+a - (y+z))

Measured memory_bytes: 3064
# AOJ Volume4 0411
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0411

N, L = list(map(int, input().split()))
c = []
for _ in range(0, N):
    p, d = list(map(int, input().split()))
    c += [(p, d)]
c.sort()
masu = [p for p, d in c]
dir  = [d for p, d in c]

result = 0

score = 0
for j in range(0, N):
    if dir[j] == 0:
        score += masu[j] - j - 1
    elif dir[j] == 1:
        score -= masu[j] - j - 1
    masu[j] = j + 1
result = score

for i in range(N - 1, -1, -1):
    if dir[i] == 1:
        score += L - (N - i) - masu[i] + 1
    elif dir[i] == 0:
        score -= L - (N - i) - masu[i] + 1
    masu[i] = L - (N - i) + 1
    
    result = max(result, score)
print(result)



Measured memory_bytes: 20608
#include <stdio.h>

int main(void)
{
  int h, w, i, ii, a;
  
  scanf("%d%d", &h, &w);
  
  for(a = 0; a < 1; a--) {
    if((h != 0)&&(w != 0)) {
	for(i = 0; i < h; i++) {
	    if((i == 0)||(i+1 == h)) {
	      for(ii = 0; ii < w; ii++) {
		    printf("#");
	      }
	      printf("\n");
	    } else {
	      for(ii = 0; ii < w; ii++) {
		if((ii == 0)||(ii+1 == w)) {
		  printf("#");
		} else {
		  printf(".");
		}
	      }
	      printf("\n");
	    }
        }
	printf("\n");
	scanf("%d%d", &h, &w);
    } else {
      break;
    }
  }
}

Measured memory_bytes: 572
#include<stdio.h>
int main()
{
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if(A+B>C+D)
	{
		printf("Left");
	}
	else if (A+B==C+D){
			printf("Balanced");
			
	}
	else {
			printf("Right");
	}
	
}

Measured memory_bytes: 1732
/**
 * Created by hiramekun at 17:05 on 2019-10-16.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll w, h, n;
    cin >> w >> h >> n;
    ll xma = w, xmi = 0, yma = h, ymi = 0;
    rep(i, n) {
        ll x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                xmi = max(x, xmi);
                break;
            case 2:
                xma = min(x, xma);
                break;
            case 3:
                ymi = max(y, ymi);
                break;
            case 4:
                yma = min(y, yma);
                break;
        }
    }
    if (xma - xmi < 0 || yma - ymi < 0) {
        cout << 0 << '\n';
    } else {
        cout << max(0LL, (xma - xmi) * (yma - ymi)) << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
a=gets.to_i
b=gets.to_i
c=gets.to_i
x=gets.to_i

ans=0
0.upto(a) do |i|
    0.upto(b) do |j|
        0.upto(c) do |k|
            if 500*i+100*j+50*k == x
                ans+=1
            end
        end
    end
end
puts ans


Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
using namespace std;
int a[10];
bool dfs(int cur,int l,int r){
	if(cur==10){
		return true;
	}
	return (a[cur]>l && dfs(cur+1,a[cur],r)) || (a[cur]>r && dfs(cur+1,l,a[cur]));
}
int main(){
	ios::sync_with_stdio(false);
	int T;
	cin>>T;
	while(T--){
		for(int i=0;i<10;i++)
			cin>>a[i];
		puts(dfs(0,0,0)?"YES":"NO");
	}
	return 0;
}

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

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

    if ( n > 0 && n <= 9 )
    {
        cout << n << endl;
    }
    else if ( n >= 10 && n <= 99 )
    {
        cout << "9" << endl;
    }
    else if ( n >= 100 && n <= 999 )
    {
        cout << 9+n-100+1 << endl;
    }
    else if ( n >= 1000 && n <= 9999 )
    {
        cout << 9+900 << endl;
    }
    else if ( n >= 10000 && n <= 99999 )
    {
        cout << 9+900+n-10000+1 << endl;
    }
    else
    {
        cout << 9+900+90000 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int MAX=10000;
vector<int>G[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],flag[MAX];
int N,timer;
void dfs(int u){
    prenum[u]=lowest[u]=timer++;
    flag[u]=true;
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        if(!flag[v]){
            parent[v]=u;
            dfs(v);
            lowest[u]=min(lowest[u],lowest[v]);
        }
        
    }
    //int minBackEdge=1000000;
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        if(parent[u]!=v && parent[v]!=u)
            lowest[u]=min(lowest[u],prenum[v]);
    }
    
}
void art_points(){
    timer=1;
    dfs(0);
    set<int>s;
    int head=-1,count=0;
    for(int i=0;i<N;i++)
    {
        if(parent[i]==-1){
            head=i;
            continue;
        }
        int p=parent[i];
        if(p==head){
            count++;
            continue;
        }
        if(prenum[p]<=lowest[i])
            s.insert(p);
    }
    if(count>=2)s.insert(head);
    for(set<int>::iterator it=s.begin();it!=s.end();it++)
        cout<<(*it)<<endl;
}
int main()
{
    int E,s,t;
    cin>>N>>E;
    for(int i=0;i<N;i++){
        prenum[i]=0;
        parent[i]=-1;
        flag[i]=false;
    }
    for(int i=0;i<E;i++){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_points();
    //dfs(0);
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define p_b push_back
#define e_b emplace_back
#define m_p make_pair
#define m_t make_tuple

using namespace std;

int main() {
	int n, x, t,u;
	cin >> n >> x >> t;

	if (n % x == 0) {
		u = n / x;
	}
	else {
		u = n / x + 1;
	}

	cout << t * u << endl;
	return 0;
}

Measured memory_bytes: 3624
function Main(input) {
  input = input.split("\n");
  S= input[0].split("");
  var ans=0;
  for(i=0;i<S.length;i++){
    if(S[i]=="2"){
      ans++;
    }
  }

  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r,c,k;
    cin >> r >> c >> k;
    vector<vector<int>> v(r+1,vector<int>(c+1,0));
    for(int i=0;i<k;i++)
    {
        int a,b,w;
        cin >> a >> b >> w;
        v[a][b]=w;
    }
    vector<array<ll,4>> now(c+1,{0,0,0,0});
    for(int o=1;o<=r;o++)
    {
        vector<array<ll,4>> nxt(c+1,{0,0,0,0});
        for(int i=1;i<=c;i++)
        {
            nxt[i][0]=max(max({now[i][0],now[i][1],now[i][2],now[i][3]}),nxt[i-1][0]);
            for(int j=3;j>=1;j--) nxt[i][j]=max(nxt[i-1][j],max(nxt[i-1][j-1],nxt[i][j-1])+v[o][i]);
        }
        now=nxt;
    }
    ll res=0;
    for(int j=0;j<=3;j++) res=max(res,now[c][j]);
    cout << res << "\n";
    return 0;
}


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

int main() {
  int N,M,c;
  cin>>N>>M;
  vector<int> city(N);
  
  for(int i;i<2*M;i++){
    cin>>c;
    city.at(c-1)++;
  }
  
  for(int i;i<N;i++){
    cout<<city.at(i)<<endl;
  } 
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <functional>
inline int recfunc(int n,int c){
  c++;
  if(n>=10)return recfunc(n/10,c);
  else{return c;}
}
int main(){
  int a,b;
  using std::cin;
  while(cin>>a>>b){
    if(cin.eof())break;
    int c = a + b;
    using std::cout;
    using std::endl;
    cout<<recfunc(c,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
void ABC50(void);
void ABC52(void);
void ABC53(void);
void ABC54(void);
void ABC55(void);
void ABC56(void);
void ABC57(void);
void ABC58(void);
void ABC59(void);

int main(void){
    ABC59();
    return 0;
}

void ABC59(void){
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    s1[0]=s1[0]-('a'-'A');
    s2[0]=s2[0]-('a'-'A');
    s3[0]=s3[0]-('a'-'A');
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 2010
int a[N];
int n;
vector<int> g[N];
bool used[N];

vector<int> dfs(int u){
	used[u] = true;
	vector<int> res(1, u);
	vector<vector<int>> r;
	priority_queue<P> q;
	for(auto v: g[u]){
		if(used[v]) continue;
		vector<int> x = dfs(v);
		reverse(all(x));
		r.push_back(x);
		q.push(P(x.back(), r.size()-1));
	}
	while(!q.empty()){
		P p = q.top(); q.pop();
		res.push_back(p.fst);
		r[p.snd].pop_back();
		if(!r[p.snd].empty()) q.push(P(r[p.snd].back(), p.snd));
	}
	return res;
}

int main(){
	cin>>n;
	rep(i, n) cin>>a[i];
	sort(a, a+n);
	rep(i, n) rep(j, n){
		if(i==j) continue;
		if(__gcd(a[i], a[j])>1){
			g[i].push_back(j);
		}
	}
	rep(i, n){
		g[n].push_back(i);
		//g[i].push_back(n);
	}
	vector<int> res = dfs(n);
	rep(i, n) cout<<a[res[i+1]]<<" "; cout<<endl;
	return 0;
}


Measured memory_bytes: 16128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
const double PI = 3.14159265359;

int main()
{
    int N, H; cin >> N >> H;
    vector<int> as(N), bs(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> as[i] >> bs[i];
    }
    int maxA = *max_element(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    int ans = 0;
    while (H > 0)
    {
        if (bs.empty() || bs.back() < maxA)
        {
            ans += (H + maxA - 1) / maxA;
            break;
        }
        else
        {
            H -= bs.back();
            bs.pop_back();
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4032
import itertools
n=int(input())
m=0;a=0;r=0;c=0;h=0
for i in range(n):
    s=input()
    if s[0]=="M":
        m+=1
    elif s[0]=="A":
        a+=1
    elif s[0]=="R":
        r+=1
    elif s[0]=="C":
        c+=1
    elif s[0]=="H":
        h+=1

l=itertools.combinations([m,a,r,c,h],3)
c=0
for i in l:
    k=1
    for i2 in i:
        k*=i2
    c+=k
print(c)


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

int main(void)
{
	int N;
	cin >> N;

	if ((N / 100) == 7)
	{
		cout << "Yes" << endl;
	}
	else if (((N % 100) / 10) == 7)
	{
		cout << "Yes" << endl;
	}
	else if ((N % 10) == 7)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int t = in(); t; t--) {
		int n = in() - 1, k = in() - 1, p = in(), r = 0;
		vector<int> v;
		while (n--) {
			int c = in(), d = c - p;
			r += d;
			v.push_back(d);
			p = c;
		}
		int m = min((int) v.size(), k);
		nth_element(v.begin(), v.begin() + m, v.end(), [](int a, int b) {return a > b;});
		for_each(v.begin(), v.begin() + m, [&r](int i){r -= i;});
		outl(r);
	}
}


Measured memory_bytes: 3012