akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    string s;
    std::cin >> s;
    ll now = s.length();
    while(true){
        if(now<=4){
            std::cout << "NO" << std::endl;
            return 0;
        }else if(now == 5){
            if( s.substr(now-5,5) == "dream" || s.substr(now-5,5) == "erase"){
                std::cout << "YES" << std::endl;
                return 0;
            }else{
                std::cout << "NO" << std::endl;
                return 0;
            }
        }else if(now == 6){
            if( s.substr(now-5,5) == "dream" || s.substr(now-5,5) == "erase"){
                now-=5;
                continue;
            }else if( s.substr(now-6,6) == "eraser" ){
                std::cout << "YES" << std::endl;
                return 0;
            }else{
                std::cout << "NO" << std::endl;
                return 0;
            }
        }else if(now == 7){
            if( s.substr(now-5,5) == "dream" || s.substr(now-5,5) == "erase"){
                now-=5;
                continue;
            }else if( s.substr(now-6,6) == "eraser" ){
                now-=6;
                continue;
            }else if( s.substr(now-7,7) == "dreamer" ){
                std::cout << "YES" << std::endl;
                return 0;
            }else{
                std::cout << "NO" << std::endl;
                return 0;
            }
        }else{
            if( s.substr(now-5,5) == "dream" || s.substr(now-5,5) == "erase"){
                now-=5;
                continue;
            }else if( s.substr(now-6,6) == "eraser" ){
                now-=6;
                continue;
            }else if( s.substr(now-7,7) == "dreamer" ){
                now-=7;
                continue;
            }else{
                std::cout << "NO" << std::endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 512
import itertools
from collections import deque
from sys import stdin
input = stdin.readline


def main():
  H, W = list(map(int, input().split()))

  M = [input()[:-1] for _ in range(H)]

  def bfs(start):
    dist = [[float('inf')]*W for _ in range(H)]
    dist[start[0]][start[1]] = 0

    is_visited = [[0]*W for _ in range(H)]
    q = deque([start])
    max_ = 0

    while len(q):
      now_h, now_w = q.popleft()
      if M[now_h][now_w] == '#':
        return
      is_visited[now_h][now_w] = 1
      for next_h, next_w in ((now_h+1, now_w),
                             (now_h-1, now_w),
                             (now_h, now_w-1),
                             (now_h, now_w+1)):

        if not(0 <= next_h < H) or not(0 <= next_w < W) or \
           (dist[next_h][next_w] != float('inf')) or \
           M[next_h][next_w] == '#':
           # is_visited[next_h][next_w] or \
          continue

        dist[next_h][next_w] = dist[now_h][now_w] + 1
        max_ = max(max_, dist[next_h][next_w])
        q.append((next_h, next_w))
    return max_

  max_ = 0
  for h in range(H):
    for w in range(W):
      if M[h][w] == '.':
        max_ = max(bfs((h, w)), max_)

  print(max_)


if(__name__ == '__main__'):
  main()


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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input

  int i;    // subscript

  int comp; // comparison
  int num_count, rem_count;



  /* Input, Array_Proclamation */
  cin >> N;
  vector<int> A(N);


  for(i=0; i<N; i++)
  {
    cin >> A.at(i);
  }


  /* Initialize */
  num_count = 1;
  rem_count = 0;



  /* Calculation */
  sort( all(A) );

  for(i=0; i<N-1; i++)
  {

    comp = A.at(i);
    if( comp == A.at(i+1) )
    {
      num_count++;
    }
    else if( comp < A.at(i+1) )
    {
      if(num_count %2 != 0)
      {
        rem_count++;
      }
      num_count = 1;
    }
    
  }
  
  if(num_count %2 != 0)
  {
    rem_count++;
  }

  /* Output */
  cout << rem_count << endl;


  return 0;

}


/* entity */
//  - none -




Measured memory_bytes: 640
import sys
input = sys.stdin.readline

n = int(input())
h = [int(x) for x in input().split()]

dp = [float('inf')] * (n + 1)

dp[1] = 0
dp[2] = abs(h[1] - h[0])

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

print(dp[-1])


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

int main() {
    long long X, a = 0, b = 0, c = 0, happy = 0;
    cin >> X;

    a = X / 500;
    b = X % 500 / 5;  
    happy = a * 1000 + b * 5;

    cout << happy << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int mod = 1000000007;
    int n, m;
    cin>>n>>m;
    int arr[n][m];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            char ch;
            cin>>ch;
            if(ch == '.')
            {
                arr[i][j] = -1;
            }
            else if(ch=='#')
            {
                arr[i][j] = 0;
            }
        }
    }
    arr[n-1][m-1] = 1;
    for(int i = n-1; i>=0; i--)
    {
        for(int j=m-1; j>=0; j--)
        {
            if(arr[i][j]==0)
                continue;
            if(i==n-1 && j==m-1)
                continue;
            else if(i==n-1)
            {
                arr[i][j] = arr[i][j+1];
            }
            else if(j==m-1)
            {
                arr[i][j] = arr[i+1][j];
            }
            else
            {
                arr[i][j] = arr[i+1][j] + arr[i][j+1];
            }
            arr[i][j] = arr[i][j]%mod;
        }
    }
    cout<<arr[0][0];

    return 0;
}


















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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int lo=0,hi=1e9;
	while(hi-lo>1){
		int mi=(lo+hi)/2;

		lint cnt;
		if(mi==0){
			cnt=INF;
		}
		else{
			cnt=0;
			rep(i,n) cnt+=(a[i]+mi-1)/mi-1;
		}

		if(cnt<=k) hi=mi;
		else       lo=mi;
	}
	printf("%d\n",hi);

	return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
//#include "puzzle.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)
#pragma warning (disable:4244)
#pragma warning (disable:4996)

using namespace std;
typedef long long int lint;


//***** Main Program *****

int main() {
	int n;
	cin >> n;
	deque<int> dq;
	Loop(i, n) {
		char cmd[20];
		int x;
		scanf("%s", cmd);
		if (cmd[0] == 'i') {
			scanf("%d", &x);
			dq.push_front(x);
		}
		else if (cmd[0] == 'd'&&cmd[6] == '\0') {
			scanf("%d", &x);
			Loop(i, dq.size()){
				if (dq[i] == x) {
					dq.erase(dq.begin() + i);
					break;
				}
			}
		}
		else if (cmd[6] == 'F') dq.pop_front();
		else if (cmd[6] == 'L') dq.pop_back();
		else return -1;
	}
	while (dq.size() > 1) {
		printf("%d ", dq.front());
		dq.pop_front();
	}
	if (dq.size() > 0) cout << dq.front() << endl;
	return 0;
}

Measured memory_bytes: 7080
def pre_combi1(n, p):
    fact = [1]*(n+1)  # fact[n] = (n! mod p)
    factinv = [1]*(n+1)  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0]*(n+1)  # factinv 計算用
    inv[1] = 1
    # 前処理
    for i in range(2, n + 1):
        fact[i]= fact[i-1] * i % p
        inv[i]= -inv[p % i] * (p // i) % p
        factinv[i]= factinv[i-1] * inv[i] % p
    return fact, factinv

def combi1(n, r, p, fact, factinv):
    """
    k<n<10**7でpが素数のときのnCr % pを求める
    """
    # 本処理
    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p=998244353
fact,finv=pre_combi1(2*10**5+1,p)
n,m,k=map(int,input().split())
ans=0
dup=[0] * n
dup[0] = 1
for j in range(1,n):
  dup[j]=dup[j-1]*(m-1) % p
for i in range(k+1):
  ans += m*combi1(n-1,i,p,fact,finv)*dup[n-i-1]
  ans %= p
print(ans)

Measured memory_bytes: 32440
#include <stdio.h>
#include <math.h>

#define MAX 999999

int main(void) {
    int sieve[MAX+1]={0},count,i,j,num;
    sieve[1]=1;
    for (i=2; i<=sqrt(MAX); i++) {
        if (sieve[i]==0) {
            for (j=2*i; j<=MAX; j+=i) sieve[j]=1;
        }
    }
    while (scanf("%d",&num)!=EOF) {
        count=0;
        for (i=2; i<=num; i++) {
            if (sieve[i]==0) count++;
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 4508
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(map(str, ans[:K])))


Measured memory_bytes: 207948
n,m,k=map(int,input().split())
ll=[]
tot=0
for i in range(n):
    s=input().split()[0]
    tot+=s.count('#')
    ll.append(s)
x=2**n
y=2**m
#print(x,y)
cou=0

for i in range(x):
    bx=bin(i)[2:]
    bx='0'*(n-len(bx))+bx
    row=[]
    for ii in range(n):
        if(bx[ii]=='0'):
            row.append(ii)
    for j in range(y):
        column=[]
        by=bin(j)[2:]
        by='0'*(m-len(by))+by
        for jj in range(m):
            if(by[jj]=='0'):
                column.append(jj)
        su=0
        #print(row,column,bx,by)
        for ii in row:
            for jj in range(m):
                if(ll[ii][jj]=='#'):
                    su+=1
        #ss=su
        for jj in column:
            for ii in range(n):
                if(ll[ii][jj]=='#'):
                    su+=1
        #print(column,su-ss)
        #print(su)
        for ii in row:
            for jj in column:
                if(ll[ii][jj]=='#'):
                    su-=1
        #print(row,column,su)
        if(tot-su==k):
            #print(row,column,su)
            cou+=1
print(cou)
            

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

namespace ConsoleApp20 {
    class Program {
        static void Main(string[] args) {
            int[] s = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int N = s[0];
            int Y = s[1];

            int y = Y / 1000;

            int ansi = -1;
            int ansj = -1;
            int ansk = -1;

            for (int j = 0; j <= (y - N) / 4; j++) {
                for (int k = 0; k <= Math.Min(N - j, (y - N - 4 * j) / 9); k++) {
                    if (4 * j + 9 * k == y - N) {
                        //これでペアを発見！
                        ansj = j;
                        ansk = k;
                        ansi = N - (j + k);

                        goto end;   
                    }
                }
            }

            end:;

            Console.WriteLine(ansk + " " + ansj + " " + ansi);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int N, M;
  cin >> N;
  cin >> M;
  if (N == M) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 256
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long

int main()
{
    fastt;

    ll n, m, k, i, j, x, l, r, md, y, s=0, h, f=0, an = 0;
    cin>>n>>k;
    ll a[n];
    for(i=0; i<n; i++){
        cin>>a[i];
        if(s<a[i])s=a[i];
    }
    l = 1;
    r = s;
    while(l<=r){
        f=0;
        md = (l+r)/2;
        s=0;
        for(i=0; i<n; i++){
            if(a[i]>md){
                x=a[i]/md;
                if(md*x==a[i])s+=x-1;
                else s+=x;
            }
            if(s>k){
                f=1;
                break;
            }
        }
        if(f==0){
            an = md;
            r=md-1;
        }
        else{
            l=md+1;
        }
    }
    cout<<an<<endl;
    return 0;
}






Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
typedef  long long                  ll;
typedef  unsigned long long        llu;
typedef  long double               ldo;
#define  mod                 1000000007
#define  pi              3.141592653589
#define  sz(c)             (ll)c.size()
#define  fr                       first 
#define  sc                      second
#define  pb                   push_back
#define  mp                   make_pair
#define  all(v)   (v).begin(),(v).end()
#define  rep(i,a,n) for(ll i=a;i<n;i++)
#define  endl                      '\n'
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef  vector <ll>               vll;
typedef  vector <string>           vss;
typedef  vector <pair <ll,ll>>    vpll; 
typedef  vector <vector <ll>>     vvll;
typedef  set <ll>                  sll;

class Solution{
  public:
 // vll v;

  //Solution():v(10, false){v[2]=6;}
  void SolutionFunc(){
    double n;cin>>n;
    cout<<2*n*pi;
    
    
  }
};

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif */
  IOS;

  Solution obj;
  ll T=1;
  //cin>>T;
  rep(i,0,T){
    //cout<<"Case #"<<i+1<<": ";
    obj.SolutionFunc();
  }  
  return(0);
} 



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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return true; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
    if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void  solve()
{
    
    ll n,k;
    cin>>n>>k;
    cout<<(500*n>=k?"Yes":"No");

    

}

int main()
{
 
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>

using namespace std;

const int MAX_D = 11;
int m,c,n,ans;
vector<int> req;
vector<int> D[MAX_D];

void input(){
  vector<int> tmp[n];
  int sum = 0;
  
  for(int i = 0; i < n; i++){
    int num;
    cin >> num;
    sum += num;
    for(int j = 0; j < num; j++){
      int in;
      cin >> in;
      tmp[i].push_back(in);
    }
  }
  
  int pos = 0;
  while(sum){
    for(int i = 0; i < n; i++)
      if(tmp[i].size() > pos){
	req.push_back(tmp[i][pos]);
	sum--;
      }
    pos++;
  }
  
  D[m] = req;
}

void init(){
  req.clear();
  for(int i = 0; i < MAX_D; i++)
    D[i].clear();
  ans = 0;
}

int find(int num){
  
  vector<int>::iterator ite;
  
  for(int i = 0; i <= m; i++)
    for(ite = D[i].begin(); ite < D[i].end(); ite++)
      if(*ite == num){
	D[i].erase(ite);
	return i+1;
      }
}

int ret(int num){
  int cost = 0;
  
  if(D[0].size() < c){
    D[0].push_back(num);
    return 1;
  }else{
    int minpos = m;
    for(int i = 0; i < m; i++)
      if(D[i].size() < c){
	minpos = i;
	break;
      }
    
    //from counter to minpos+1
    cost += minpos+1;
    
    int tmppos = m;
    for(int i = 0; i < m; i++)
      if(i == minpos){
	if(D[i].size()+1 < c){
	  tmppos = i;
	  break;
	}
      }else if(D[i].size() < c){
	tmppos = i;
	break;
      }
    //from 1 to (tmppos+1)
    cost+=tmppos+2;
    
    D[tmppos].push_back(D[0][0]);
    D[0].erase(D[0].begin());
    
    
    D[0].push_back(num);
    
    //from (minpos+1) to 1
    cost += minpos+2;
  }
  return cost;
}
void solve(){
  
  for(int i = 0; i < req.size(); i++){
    int fpos = find(req[i]);
    int rcos = ret(req[i]);
    ans += fpos+rcos;
  }
  cout << ans << endl;
}

int main(){
  
  while(cin >> m >> c >> n && m+c+n){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1352
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf, pi, cos
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

a, b, h, m = [int(i) for i in input().split()]

tmp = 0
res = 0

theta = 2 * pi * (h / 12.0 + m / 720.0 - m / 60.0)
res = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theta))

print(res)


Measured memory_bytes: 30160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        public static void Main()
        {

            List<int> sss = new List<int>();
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            for (int b = 0; b < a[0]; b++)
            {
                var c= Console.ReadLine().Split().Select(int.Parse).ToArray();
                for(int d = 0; d < a[1]; d++)
                {
                    sss.Add(c[d]);
                }
            }

            for (int e = 0; e < a[0]; e++)
            {
                int g = 0;
                for(int f = 0; f < a[1]; f++)
                {
                    Console.Write(sss[e*a[1]+f]+" ");
                    g += sss[e * a[1] + f];
                }
                Console.WriteLine(g);
            }
            int i = 0;
            for(int h = 0; h < a[1]; h++)
            {
                int j = 0;
                for (int m = 0; m < a[0]*a[1]; m+=a[1])
                {
                    j += sss[m + h];
                }
                Console.Write(j+" ");
                i += j;
            }
            Console.WriteLine(i);

            }

        }
    }

Measured memory_bytes: 9808
import math
N = int(input())
ST = [[int(i) for i in input().split()] for j in range(N-1)]
for i in range(N-1):
    t = ST[i][1] + ST[i][0]
    for j in range(i+1,N-1):
        t = max(t, ST[j][1])
        k = math.ceil((t-ST[j][1])/ST[j][2])
        t = k * ST[j][2] + ST[j][1] + ST[j][0]
    else:
        print(t)
print(0)


Measured memory_bytes: 3188
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	K := sc.nextInt()
	count := 0
	queue := &Queue{}
	bfs := func(n int) bool {
		last := n % 10
		for i := max(last-1, 0); i <= min(last+1, 9); i++ {
			count++
			next := n*10 + i
			if count == K {
				fmt.Fprintln(wtr, next)
				return true
			}
			queue.push(Node{next})
		}
		return false
	}
	for i := 1; i < 10; i++ {
		count++
		if count == K {
			fmt.Fprintln(wtr, i)
			return
		}
		queue.push(Node{i})
	}
	for !queue.isEmpty() {
		if bfs(queue.pop().num) {
			return
		}
	}
}

type Node struct {
	num int
}

type Queue struct {
	arr []Node
}

func (q *Queue) push(v Node) {
	q.arr = append(q.arr, v)
}

func (q *Queue) pop() Node {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *Queue) isEmpty() bool {
	return len(q.arr) == 0
}


Measured memory_bytes: 4864
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C&lang=jp
*/
#include<iostream>
using namespace std;

int v[1001],w[1001];
int n,k;
int dp[101][10001];
/*
ナップサック
iは品物の番号、jはその時の重さ
*/
void knapsack(){
  for(int i=0;i<n;i++){
    for(int j=0;j<=k;j++){
      if(w[i]>j) {
        dp[i+1][j]=dp[i][j];
      }else{
        dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      }
    }
  }
}
int main(){
  cin>>n>>k;
  for(int i=0;i<k;i++){
    cin>>v[i]>>w[i];
  }
  knapsack();
  cout<<dp[n][k]<<"\n";
}



Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,A[100000+10]={};
  cin >> N;
  rep(i,N){
    int a;
    cin >> a;
    A[a-1]++;
    A[a]++;
    A[a+1]++;
  }
  int ans=-1;
  rep(i,100000+10){
    chmax(ans,A[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())  
r, s, p = map(int, input().split())  
read_data = input()

res = 0
log = []
for i in range(len(read_data)):
    # k = 2
    if len(log) < k:
        if read_data[i] == 'r':
            res+=p
        if read_data[i] == 's':
            res+=r
        if read_data[i] == 'p':
            res+=s

        log.append(read_data[i])

    else:
        tmp = log.pop(0)
        if tmp != read_data[i]:
            if read_data[i] == 'r':
                res+=p
            if read_data[i] == 's':
                res+=r
            if read_data[i] == 'p':
                res+=s
            log.append(read_data[i])
        else:
            log.append('-')
    
    
print(res)

Measured memory_bytes: 9772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能

struct Unionfind{
    vector<int> data;
    Unionfind(int size): data(size, -1) {}
    bool unite(int x, int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if( data[y] < data[x] ) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x!=y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return (data[x] < 0)? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

int main(){
    int n,m; cin >> n >> m;
    int p[n];
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    Unionfind uni(n);
    rep(i,m){
        int x,y; cin >> x >> y;
        x--; y--;
        uni.unite(x,y);
    }
    int ans=0;
    rep(i,n){
        if(uni.same(i,p[i])) ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
typedef struct {
	int p;
	double t;
}Record;
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
void bubbleSort(Record[],int);
int main() {
	int i,n=3;
	Record d[8], dd[6];
	while (n) {
		for (i = 0; i < 8; i++) {
			fscanf(stdin, "%d%lf", &d[i].p, &d[i].t);
		}
		bubbleSort(d,8);
		fprintf(stdout, "%d %.2lf\n", d[0].p, d[0].t);
		fprintf(stdout, "%d %.2lf\n", d[1].p, d[1].t);
		dd[2 * n - 1].p = d[2].p, dd[2 * n - 1].t = d[2].t;
		dd[2 * n - 2].p = d[3].p, dd[2 * n - 2].t = d[3].t;
		n--;
	}
	bubbleSort(dd,6);
	fprintf(stdout, "%d %.2lf\n", dd[0].p, dd[0].t);
	fprintf(stdout, "%d %.2lf\n", dd[1].p, dd[1].t);
	return 0;
}

void bubbleSort(Record d[], int n) {
	int i, j;
	Record temp;
	for (i = 0; i < n - 1; i++)
		for (j = i + 1; j < n; j++)
			if (d[i].t > d[j].t)
				temp = d[i], d[i] = d[j], d[j] = temp;
}

Measured memory_bytes: 656
#include<iostream>
#include<string>
#define value( x ) cout<< "value of "<< #x << " is "<< x<<endl;
long long max( long long x, long long y) {if(x>y) return x;else return y;}
using namespace std;
const long long mod = 1000000007;
int main()
{
	
    long long n;
    cin>>n;
    string a,b;
    cin>>a>>b;
   int ppos=-1, pppos=-1, ptype=0,pptype=0;
   long long answare=0;
    for(int i=0;i<n;i++)
    {
    	if(a[i]!=b[i]){
    		if(ptype==1) answare=(answare*2)%mod;
    		else if(ptype==2) answare=(answare*3)%mod;
    		else answare=6;
    		ptype=2;
    		i++;}
    	else
    	{
    		if(ptype==2) answare=(answare%mod);
    		else if(ptype==1) answare=(answare*2)%mod;
    		else answare=3;
    		ptype=1;
    	}//value(answare);
    }
    	cout<<answare;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int x; cin >> x;
    if(x < 1200) {
        p("ABC");
    }else {
        p("ARC");
    }
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;


int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}
int main(){
    int D;
    cin >> D;
   if(D==25)cout << "Christmas" << endl;
   else if(D==24)cout << "Christmas Eve" << endl;
   else if(D==23)cout << "Christmas Eve Eve" << endl;
   else cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%s %s",$a,$b);
fscanf(STDIN,"%s %s",$c,$d);
fscanf(STDIN,"%s %s",$e,$f);
$moji=$a.$b.$c.$d.$e.$f;
$count=0;
//echo($moji);
if(substr_count($moji,"1")==2)$count++;
if(substr_count($moji,"2")==2)$count++;
if(substr_count($moji,"3")==2)$count++;
if(substr_count($moji,"4")==2)$count++;
if($count==2){
echo("YES");
}else{
echo("NO");
}
?>

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

int main() {
    string s; cin>>s;
    int n = s.size()-1;

    long long ans = 0;
    long long tmp = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
      tmp = s.at(0)-'0';
      for(int i=0;i<n;i++){
        if(bit & 1<<i){
          ans += tmp;
          tmp = 0;
        }
        tmp = tmp*10+(s.at(i+1)-'0');
      }
      ans += tmp;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n=int(input())
s=[None]*n
nA=0
nB=0
nAB=0
ans=0
for i in range(n):
    ss = input()
    ans+= ss.count("AB")
    if ss[0]=="B" and ss[-1]=="A":
        nAB+=1
    elif ss[0]=="B":
        nB+=1
    elif ss[-1]=="A":
        nA+=1
    s[i]=ss

if nAB==0:
    ans+=min(nA,nB)
elif nA==0 and nB==0:
    ans+=nAB-1
elif nA==0:
    ans+=nAB
elif nB==0:
    ans+=nAB
else:
    ans+=nAB+1 + min(nA,nB)-1
print(ans)

Measured memory_bytes: 44648
//file_name:ABC96_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    int a[5][110];
    int count[5] = {};

    srep(i,2,55556){
        int flag = 0;
        srep(j,2,min(i,250)){
            if(i%j == 0){
                flag = 1;
                break;
            }
        }
        if(flag==0&&count[i%5]<100){
            a[i%5][count[i%5]] = i;
            count[i%5]++;
        }
    }

    //cout << "OK1";

    rep(i,5){
        if(count[i%5]>=n){
            rep(j,n){
                cout << a[i%5][j] << ' ';
            }
            cout << endl;
            break;
        }
    }

    return 0;
}



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


public class Main {
	private	static			BufferedReader	br    = null;
	private	static			int				min   = 0;
	private	static	final	int[][]			table = {
		{ 1500, 2244 },	// 重みが1.50
		{ 1000, 1520 },	// 重みが1.52
		{ 1200, 1870 },	// 重みが1.56
		{  500,  850 },	// 重みが1.70
		{  300,  550 },	// 重みが1.83
		{  200,  380 },	// 重みが1.00
	};

	static {
		br  = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	sum = 0;

		while ((sum = strIn()) != 0) {
			min = 0;
			price(0, 0, sum);
			System.out.println(min);
		}
	}

	private static void price(int bit, int cost, int sum) {
		int	div  = 0;
		int	rest = 0;
		int	tmp1 = 0;

		for(int n1 = 0; n1 < table.length; n1++) {
			if ((bit & 1 << n1) != 0) {
				// ここはもう計算したからスキップ
				continue;
			}

			div = (sum / table[n1][0]);
			for (int n2 = div; n2 > 0; n2--) {
				rest = (sum % table[n1][0]) + (div - n2) * table[n1][0];
	
				if (rest == 0) {
					min = (min != 0) ? Math.min(min, cost + table[n1][1] * div) : (cost + table[n1][1] * div);
				} else {
					tmp1 = n2 * table[n1][1];
					bit += 1 << n1;
					price(bit, cost+tmp1, rest);
					bit -= 1 << n1;
				}
			}
		}
	}

	private static int strIn() {
		int		sum   = 0;
		String	strIn = null;

		if ((strIn = parseStdin()) != null) {
			sum = Integer.parseInt(strIn);
		}
		
		return sum;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 19580
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
 
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main(){
    int n;
    cin >> n;
    vector<vector<int>> x(n), y(n);
    int ans = 0;
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a) {
            int x_, y_;
            cin >> x_ >> y_;
            x[i].push_back(x_);
            y[i].push_back(y_);
        } 
    }
    //cout << x[0].size() << " ";
    queue<int> q;
    rep(bit, 1<<n){
        int cnt=0;
        int cnt_1=0;
        int res = 1;
        vector<int> t_f(n,-1);
        //rep(j,n) cout << t_f[j] << " ";
        rep(i, n){
            if(bit>>i&1){
                q.push(i);
                for(int t=0; t < x[i].size(); t++){
                    //cout << x[i][t] << " ";
                    if(t_f[x[i][t]-1]==0) {
                        if(y[i][t]==1) t_f[x[i][t]-1]=2;
                        }
                    else if(t_f[x[i][t]-1]==-1){
                        t_f[x[i][t]-1]=y[i][t];
                    }
                    else if(t_f[x[i][t]-1]==1){
                        if(y[i][t]==0) t_f[x[i][t]-1]=2;
                    }
                    else continue;
                }
            }
        }
        while(!q.empty()){
            int test = q.front();
            cnt++;
            if(t_f[test]==0) {
                res=0;
                q.pop();
            }
            else if(t_f[test]==1){
                t_f[test]=-1;
                q.pop();
            }
            else{
                q.pop();
            }
        }
        rep(j,n) if((t_f[j]==1)||(t_f[j]==2)) res=0;
        //if((res==1)&&(cnt==cnt_1)) ans=max(ans, cnt);
        if(res==1) ans=max(ans, cnt);
    }

    cout << ans;
    
    return 0;
}



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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define mod 1000000007
const ll N = 1e5;

ll fact[N], inv[N];

ll modPow (ll a, ll b){
    if(b == 0)
        return 1;
    ll ret = modPow(a, b / 2);
    ret = ((ret % mod) * (ret %mod))%mod;
    if(b % 2)
        ret = (ret * (a % mod))%mod;
    return ret;
}

ll pre(ll N){
    fact[0] = inv[0] = 1;
    for (ll i=1; i<=N; ++i){
        fact[i]= (i * fact[i-1]) % mod;
        inv[i]= modPow(fact[i], mod -2);
    }
}

ll nCr (ll n, ll r){
    return (((fact[n] * inv[n-r]) % mod ) * inv[r]) % mod ;
}

int main() {
	Omar45
    ll N, M, C1=0, C2=0, ans=0;
    cin >> N >> M;
	pre(max(N,M)+5);
    if (N>1)
        C1 = nCr(N,2);
    if (M>1)
        C2 = nCr(M,2);
    ans = C1+C2;
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll; // ll  is 64bit same as double

int main() {
	
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N;

	cin >> N;
		
	int a[N];
	
	for(int i =0; i< N; i++){
		cin >> a[i];
	}
	
	int mx = INT_MIN;
	for(int i =0; i< N; i++){
		mx = max(mx, a[i]);
	}
	
	vector<int> vis(mx+1, 0);
	vector<bool> b(mx+1, false);
	
	int answer = 0;	
	
	for(int i = 0; i<N; i++) {
		if(b[a[i]]) {
			vis[a[i]]++;
			continue;
		}
		b[a[i]] = true;
		for(int j = 2*a[i]; j<mx+1; j+=a[i]) {
			vis[j]++;
		}
	}
	
	
	for(int i =0; i<N; i++) {
		if(vis[a[i]]==0) answer++;
	}
	
	cout << answer << "\n";
	
	return 0;
}

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

vector<int> z_function (string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}



int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long n;
	cin >> n;
	string s;
	cin >> s;
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		vector<int> z = z_function(s);
		for (int i = 1; i < s.size(); i++) {
            ans = max(ans, min(i, z[i]));
		}
		s = s.substr(1);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,d,w,t,h,i,j,k,l,m,n,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> n >> x >> t;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));
	ans = (n + x - 1)/x * t;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, x, t; cin >> n >> x >> t;
    int ans = (n+x-1)/x * t;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#ABC 115 B
n = int(input())
price_list = []
for i in range(n):
    price = int(input())
    price_list.append(price)
max_price = max(price_list)
price_list.remove(max_price)
price_list.append(max_price/2)
print(int(sum(price_list)))

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int N, Q;
    cin >> N >> Q;
    int Si, Ti, Xi, Di;
    vector<array<int, 3>> stx(N);
    for(int i=0;i<N;i++){
        cin >> Si >> Ti >> Xi;
        auto l = Si-Xi;
        auto r = Ti-Xi;
        if(l<0) l=0;
        stx[i] = array<int, 3>{l, r, Xi};
    }
    sort(stx.begin(), stx.end(), [](array<int, 3>& a, array<int, 3>& b){return a[2] < b[2];});
    set<int> D;
    map<int, int> res;
    for(int i=0;i<Q;i++){
        cin >> Di;
        D.insert(Di);
    }

    for(auto v : stx){
        auto itrl = D.lower_bound(v[0]);
        auto itrr = D.upper_bound(v[1]-1);
        for(auto itr = itrl; itr != itrr; ++itr){
            res[*itr] = v[2];
        }
        D.erase(itrl, itrr);
    }
    for(auto v : D){
        res[v] = -1;
    }
    for(auto m : res){
        cout << m.second << endl;
    }

    return 0;
}

Measured memory_bytes: 21888
#include<iostream>
#include<string>
#include<vector>
#include<numeric>

using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> A1(N), A2(N);
  for(int i=0; i<N; ++i){
    cin >> A1[i];
  }
  for(int i=0; i<N; ++i){
    cin >> A2[i];
  }

  int sum1, sum2, max_sum;
  max_sum = 0;
  for(int i=0; i<N; ++i){
    sum1= accumulate(A1.begin(), A1.begin()+i+1, 0);;
    sum2= accumulate(A2.begin()+i, A2.end(), 0);;
    if(max_sum < (sum1+sum2)){
      max_sum = sum1+sum2;
    }
  }
  cout << max_sum << endl;
  return 0;
}


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

abv3200 = 0 # count for above 3200
colors = set([])
for ai in a:
    if ai//400 >= 8:
        abv3200 += 1
    else:
        colors.add(ai//400)
    
min_colors = len(colors) if len(colors)>0 else 1
max_colors = len(colors) + abv3200
print(min_colors, max_colors)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

struct Shogen {
  int x, y;
};

void solve(void)
{
  int N; cin >> N;
  vector<vector<Shogen>> A(N);
  for (int i = 0; i < N; ++i) {
    int sz; cin >> sz;
    for (int _ = 0; _ < sz; ++_) {
      int x, y; cin >> x >> y;
      --x;
      A[i].push_back({x, y});
    }
  }

  int ans{};
  int itr = 1 << N;
  while (itr) {
    int res{};
    for (int i = 0; i < N; ++i) {
      if (itr >> i & 0x01) {
        ++res;
        for (const auto& p : A[i]) {
          auto isPass = ((itr >> p.x) & 0x01) == p.y;
          if (!isPass) {
            goto err;
          }
        }
      }
    }

    chmax(ans, res);
err:
    --itr;
  }
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main(){
	lli n,w;
	cin>>n>>w;
	lli wei[n+1],val[n+1];
	lli sum_val=0;
	for(lli i=1;i<=n;i++){
		cin>>wei[i]>>val[i];
		sum_val+=val[i];
	}
	wei[0]=0;
	val[0]=0;
	lli dp[n+1][sum_val+1];
	for(lli i=0;i<=n;i++){
		for(lli j=0;j<=sum_val;j++){
			dp[i][j]=INT_MAX;
		}
	}
	for(int i=0;i<=n;i++)
	dp[i][0]=0;
	dp[1][val[1]]=wei[1];
	for(lli i=2;i<=n;i++){
		for(lli j=0;j<=sum_val;j++){
			if(j-val[i]>=0 && dp[i-1][j-val[i]]!=INT_MAX)
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i]]+wei[i]);
			else
			dp[i][j]=dp[i-1][j];
			//cout<<dp[i][j]<<" ";
		}
		//cout<<"\n";
	}
	lli ans=0;
	for(lli i=0;i<=sum_val;i++){
		if(dp[n][i]<=w)
		ans=i;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=400;
int a[maxn+5],b[maxn+5];
int n,m;
int pw[maxn+5][maxn+5];
int dp[maxn+5][maxn+5];
int sum[maxn+5][maxn+5];
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int j=1;j<=n;j++) scanf("%d",&b[j]);
    for (int i=1;i<=400;i++) {
        pw[i][0]=1;
        for (int j=1;j<=m;j++) pw[i][j]=1LL*pw[i][j-1]*i%mod;
    }
    for (int i=1;i<=400;i++)
        for (int j=0;j<=m;j++) sum[i][j]=(sum[i-1][j]+pw[i][j])%mod;
    dp[0][0]=1;
    for (int i=1;i<=n;i++)
        for (int j=0;j<=m;j++)
        for (int k=0;k<=j;k++)
        dp[i][j]=(dp[i][j]+1LL*dp[i-1][j-k]*(sum[b[i]][k]-sum[a[i]-1][k]+mod)%mod)%mod;
    printf("%d\n",dp[n][m]);
    return 0;
}



Measured memory_bytes: 2176