akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const int mod = 1000000007;

vector<int> dp;
vector<int> to[100000];

int dfs(int n) {
    if (dp[n] != -1) return dp[n];
    int res = 0;
    for (auto i : to[n]) {
        res = max(res, dfs(i) + 1);
    }
    return dp[n] = res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        to[x].push_back(y);
    }

    dp.resize(n);
    rep(i, n) dp[i] = -1;

    int ans = 0;
    rep(i, n) {
        ans = max(ans, dfs(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11000
#include<stdio.h>

void change(int n[])
{
  int i,j,temp;
  for(i=0;i<3;i++){
    for(j=0;j<2;j++){
      if(n[j]>n[j+1]){
        temp=n[j];
        n[j]=n[j+1];
        n[j+1]=temp;
      }
    }
  }
}

  
    
int main(void)
{
  int n[3];
  int i;
  for(i=0;i<3;i++)
    scanf("%d",&n[i]);
  
  change(n);
  
  if(n[0]==5 && n[1]==5 && n[2]==7)
    puts("YES");
  else
    puts("NO");
  
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007




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

	int n;
	int c[3];
	c[0] = c[1] = c[2] = -1;

	long long ans = 1;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;

		int cnt = 0;
		rep(i, 3)if (c[i] + 1 == a)cnt++;

		if (cnt == 0) {
			ans = 0;
			break;
		}
		ans *= cnt;
		ans %= MOD;
		rep(i, 3)if (c[i] + 1 == a) {
			c[i]++;
			break;
		}
	}


	cout << ans << endl;

	return 0;
}

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

ll n,sum[1000],t[1000];
string p,s[10000];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i]>>t[i];
		sum[i]=t[i]+sum[i-1];
	}
	cin>>p;
	for(int i=1;i<=n;i++)
	{
		if(p==s[i])
		{
			cout<<sum[n]-sum[i]<<'\n';
			break;
		}
	}
}

Measured memory_bytes: 384
par = [0]*101
rank = [0]*101
def init_union_find(V):
    for i in xrange(V):
        par[i] = i
        rank[i] = 0
        
def find(x):
    if par[x] == x: return x
    else:
        par[x] = find(par[x])
        return par[x]
    
def unite(x,y):
    x = find(x)
    y = find(y)
    if (x == y): return
    
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if(rank[x] == rank[y]): rank[x] += 1

def same(x,y):
    return find(x) == find(y)
    
# Entry point
while 1:
    n,m = map(int,raw_input().split())
    if n == 0: break
    edge = [map(int,raw_input().split()) for i in xrange(m)]
    edge = sorted(edge, key = lambda x: x[2])
    
    init_union_find(n)
    ans = 0
    for i in xrange(m):
        e = edge[i]
        if not same(e[0],e[1]):
            unite(e[0],e[1])
            ans += e[2]
    print ans
    
    
    

Measured memory_bytes: 4288
S=input()

i=0
flag=0
while i<len(S) and len(S)%2==0:
    if S[i] == 'h' and S[i+1] == 'i':
        i=i+2
    else:
        flag=1
        i=len(S)

if flag==0 and len(S)%2==0:
    print('Yes')
else:
    print('No')

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

int solve(){
  int n;  cin >> n;
  vector<vector<int>> c(10, vector<int>(10));
  for(int i=1; i<=n; i++){
    string sn = to_string(i);
    c[sn.front()-'0'][sn.back()-'0']++;
  }
  int ans = 0;
  for(int i=1; i<10; i++) for(int j=1; j<10; j++){
    ans += c[i][j]*c[j][i];
  }
  cout << ans << endl;
  return 0;
}

int main(){
  solve();
  return 0;
}


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


int main (void){
  int n=0;
  int *arr;
  int *sub;
  
  int i;
  
  if(scanf("%d",&n) == 1){
    arr = (int *)calloc(n,sizeof(int));
    sub = (int *)calloc(n,sizeof(int));
    if (arr != NULL && sub != NULL){
      for(i=1; i<n; i++){
	scanf("%d",&arr[i]);
      }
      for(i=0; i<n; i++){
	sub[arr[i]-1] += 1;
      }
      for(i=0; i<n; i++){
	printf("%d\n",sub[i]);
    }}
  }


  return 0;
  
}


Measured memory_bytes: 3232
import sys
input=sys.stdin.readline
class UnionFind:
  def __init__(self, num):
    self.rank = [0]*num
    self.par = [i for i in range(num)] #基準(par = parentのpar)
    self.n   = num
    self.size = [1]*num

#親を探す
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x]) #自分じゃなきゃ親を探す
      return self.par[x]

#集合を結合する(結合する前に親のポインタを取得する)
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.rank[x] < self.rank[y]: #ランクの高い方に基準を合わせる
      x,y=y,x
    if self.rank[x] == self.rank[y]:
      self.rank[x] += 1
    self.par[y] = x
    self.size[x] += self.size[y]
    self.size[y] = 0

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def all_find(self):
    for n in range(len(self.par)):
      self.find(n)


n,m=map(int,input().split())
uf=UnionFind(n)
ans=0
ab=[]
for i in range(m):
  a,b=map(int,input().split())
  ab.append([a,b])
for i in range(m):
  uf=UnionFind(n)
  flag=False
  for j in range(m):
    a,b=ab[j]
    if i==j:
      continue
    uf.union(a-1,b-1)
  for j in range(n):
    for k in range(j,n):
      if not uf.same(j,k):
        flag=True
  if flag:
    ans+=1

print(ans)

Measured memory_bytes: 3064
n, q = map(int, input().split())

par = [i for i in range(n + 1)]

def find(x):
    if x == par[x]:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    par[x] = y

def same(x, y):
    return find(x) == find(y)

for i in range(q):
    a, b = map(int, input().split())
    unite(a, b)

for i in range(n):
    find(i+1)

par.pop(0)

al = set(par)
print(len(al) - 1)


Measured memory_bytes: 18372
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] L = new int[K];
        int[] R = new int[K];
        for (int i = 0; i < K; i++) {
            L[i] = scan.nextInt();
            R[i] = scan.nextInt();
        }
        long mod = 998244353;
        long[] dp = new long[N+1];
        dp[1] = 1;
        dp[2] = -1;
        for (int i = 1; i <= N; i++) {
            if (1 < i) {
                dp[i] += dp[i - 1];
                dp[i] %= mod;
            }
            for (int j = 0; j < K; j++) {
                if (N < i + L[j]) {
                    continue;
                }
                dp[i + L[j]] += dp[i];
                dp[i + L[j]] %= mod;
                if (i + R[j] + 1 <= N) {
                    dp[i + R[j] + 1] -= dp[i];
                    dp[i + R[j] + 1] %= mod;
                    if (dp[i + R[j] + 1] < 0) {
                        dp[i + R[j] + 1] += mod;
                    }
                }
            }
        }
        System.out.println(dp[N]);
    }
}


Measured memory_bytes: 38292
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
set<string> s;
string tmp;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	while(n--){
		cin>>tmp;
		s.insert(tmp);
	}
	cout<<s.size()<<endl;
	return 0;
}


Measured memory_bytes: 19200
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <exception>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int INFI = 1<<28;
const long long int INFL = 1LL<<60;
const double INFD = 1e+300;
const float INFF = 1e+100;
const double EPS = 1e-8;
//> ^ < v
//int dx[] = {1,0,-1,0};
//int dy[] = {0,-1,0,1};
//struct P {
//    int v, cost;
//    P () {}
//    P (int i, int c) : id(i), cost(c) {}
//    bool operator < (const P &p) const { return cost > p.cost; }
//};
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M), C(M);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<tuple<int,int>> ps;
    for (int i = 0; i < M; i++) {
        cin >> B[i] >> C[i];
        ps.push_back(make_tuple(C[i], B[i]));
    }
    map<int,int> m;
    for (int i = 0; i < N; i++) {
        m[A[i]]++;
    }
    for (auto it: m) {
        ps.push_back(make_tuple(it.first, it.second));
    }
    sort(ps.begin(), ps.end());
    reverse(ps.begin(), ps.end());
    LL ans = 0;
    for (int i = 0; N > 0 && i < ps.size(); i++) {
        LL v = get<0>(ps[i]);
        int num = get<1>(ps[i]);
        //cout << v << " " << num << endl;
        ans += v * min(N, num);
        N -= num;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8180
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////
#define int long long

const int N = 1e5 + 5;

int fre[N];

void solve(){

	int n;
	cin>>n;
	int a[n];
	int sum = 0;
	for(int i = 0; i < n ; ++i){

		int x;
		cin>>x;
		fre[x]++;
		sum += x;
	}

	int q;
	cin>>q;
	while(q--){

		int x , y;
		cin>>x>>y;

		sum -= fre[x]*x;
		sum += fre[x]*y;

		fre[y] += fre[x];
		fre[x] = 0;

		cout<<sum<<endl;
	}
}

signed main(){

	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}

Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define rep(i,n) for(int i = 0 ; i < n ;i++)
int main(){
    int n ;cin >> n ;ll X[n] , Y[n] , H[n] ;
    rep(i,n) cin >> X[i] >> Y[i] >> H[i] ;
    int ans_H = 0 ,ans_Y = 0 ;
    ll ans_X = 0 ;
    ll ch ;  
    rep(x,101){
        rep(y,101){
            rep(i,n) if( H[i] != 0 ) ch =(ll) H[i] + abs(x - X[i]) + abs(y - Y[i]) ;
            int count = 0 ;
            rep(i,n) if( H[i] == max(ch - abs(x - X[i]) - abs(y - Y[i]),(ll)0) )count++ ;
            if( count == n ){
                    ans_H = ch ;
                    ans_X = x  ;
                    ans_Y = y  ;
            }
        }
    }
    cout << ans_X << " " << ans_Y << " " << ans_H << endl;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll N, M;

int main() {
    cin >> N;
    int x = 0;
    REP(i, N) {
        int a;
        cin >> a;
        x = x xor a;
    }
    if (x) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int a,b;cin>>a>>b;
    if(a*b%2==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := ReadString()
	m := make(map[byte]bool)
	for _, c := range []byte(S) {
		m[c] = true
	}
	for c := byte('a'); c <= 'z'; c++ {
		if !m[c] {
			fmt.Printf("%c\n", c)
			return
		}
	}
	fmt.Println("None")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int palin(int n){
  int p[5];
  p[0] = n/10000;
  p[1] = (n-p[0]*10000)/1000;
  p[2] = (n-p[0]*10000-p[1]*1000)/100;
  p[3] = (n-p[0]*10000-p[1]*1000-p[2]*100)/10;
  p[4] = n%10;
  if(p[0] == p[4] && p[1] == p[3]){
    return 1;
  }
  else{
    return 0;
  }
}

int main(){
  int a,b;
  cin >> a >> b;
  int count = 0;
  int i;
  for(i=a;i<b+1;i++){
    if(palin(i)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define max(a, b) (a < b ? b : a) 
#define min(a, b) ((a > b) ? b : a) 
#define mod 1e9 + 7 
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++) 
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--) 
#define INF 1000000000000000003 
typedef long long int ll; 
typedef vector<int> vi; 
typedef vector<long long int> vl; 
typedef pair<int, int> pi; 
#define F first 
#define S second 
#define pb push_back 
#define POB pop_back 
#define MP make_pair 
 
int main()

{
ll n;
cin>>n;
vector<string>s;
vl a(4,0);
string x;
FOR(i,n)
{cin>>x;
s.pb(x);
}
FOR(i,n)
{if(s[i]=="AC")
a[0]++;
else if(s[i]=="WA")
a[1]++;
else if(s[i]=="TLE")
a[2]++;
else if(s[i]=="RE")
a[3]++;
}
cout<<"AC x "<<a[0]<<endl;
cout<<"WA x "<<a[1]<<endl;
cout<<"TLE x "<<a[2]<<endl;
cout<<"RE x "<<a[3]<<endl;
return 0;
}
  


Measured memory_bytes: 7452
#include <stdio.h>

int main() {
	int n;
	int b[99]={};
	int ans=0;
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		scanf("%d", &b[i]);
	}
	ans = b[0];
	for (int i = 0; i < n - 1; i++) {
		if(b[i]<b[i+1])
			ans+=b[i];
		else
			ans+=b[i+1];
	}
	ans += b[n-2];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
//Author: ZindagiMeBasAishHiChahiye
//WA/TLE
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ll          long long
#define N 1000005
// ll po(ll a,ll b,ll m){
// 	a%=m;
// 	if(b==0) return 1;
// 	if(b%2) return (a*(po((a*a)%m,b/2,m)%m)%m)%m;
// 	return po((a*a)%m,b/2,m)%m;
// }

// bool check(ll a,ll b,ll n){
// 	if(a<0||b<0) return false;
// 	if(a>=n||b>=n) return false;
// 	return true;
// }

void solve(){
	ll n,x,t;
	cin>>n>>x>>t;
	ll an=ceil(n/(x*1.0))*t;
	cout<<an;
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1,z=1;
	// cin>>TESTS;
	while(TESTS--){
		// time
		// cout<<"Case #"<<z<<": ";
		// z++;
		solve();
		time

	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=2*(1e5)+10,ST=1<<20,TOP=20,inf=2e9;
int seg[TOP+1][N],d[N],tor[ST],tol[ST],a[N];
int n,m,v,lg,all;
bool in(int st,int x){return st>>x-1&1;}
int St(int x){return 1<<x-1;}
void get_seg(){
    for (int i=1;i<=lg;++i){
        seg[i][0]=0;
        for (int j=1;j<=n;++j){
            if (j==1||d[j-1]>v>>i-1) ++seg[i][0];
            seg[i][seg[i][0]]=j;
        }
    }
}
bool firstcheck(){
    if (seg[1][0]<=lg) return true;
    for (int i=1;i<=n;++i) printf("Impossible\n");
    return false;
}
int expand_right(int which,int x){
    int l=1,r=seg[which][0],mid,ret=r;
    while (l<=r){
        mid=l+r>>1;
        if (seg[which][mid]>x) ret=mid,r=mid-1;
        else l=mid+1;
    }
    return seg[which][ret];
}
int expand_left(int which,int x){
    int l=1,r=seg[which][0],mid,ret=l;
    while (l<=r){
        mid=l+r>>1;
        if (seg[which][mid]<x) ret=mid,l=mid+1;
        else r=mid-1;
    }
    return seg[which][ret]+1;
}
void dp(){
    all=1<<lg;
    for (int st=0;st<all;++st) tor[st]=0,tol[st]=n+1;
    for (int st=0;st<all;st+=2){
        for (int i=2;i<=lg;++i){
            if (in(st,i)) continue;
            tor[st|St(i)]=max(tor[st|St(i)],expand_right(i,tor[st]));
            tol[st|St(i)]=min(tol[st|St(i)],expand_left(i,tol[st]-1));
        }
    }
}
void get_ans(){
    int L,R;
    bool ok;
    for (int i=1;i<=seg[1][0];++i){
        L=i==1?1:seg[1][i-1]+1; R=seg[1][i];
        ok=false;
        for (int st=0;st<all&&!ok;st+=2)
            if (L-1<=tor[st]&&tol[(all-1)-st-1]<=R+1) ok=true;
        for (int j=L;j<=R;++j) printf(ok?"Possible\n":"Impossible\n");
    }
}

int main(){
    scanf("%d%d",&n,&v);
    for (int i=1;i<=n;++i) scanf("%d",a+i);
    d[n]=inf;
    for (int i=1;i<n;++i) d[i]=a[i+1]-a[i];
    lg=0;
    while ((v>>lg)>0) ++lg;
    ++lg;
    get_seg();
    if (!firstcheck()) return 0;
    dp();
    get_ans();
}

Measured memory_bytes: 27776
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    int X, N;
    cin >> X >> N;
    vector<int> freq(102, 0);
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        freq[a]++;
    }
    int mindiff = 2000;
    int mindiffnum = 0;
    
    for(int i=0; i<=101; i++) {
        if(freq[i]>0) continue;
        //find diff
        int diff = abs(i-X);
        if(diff<mindiff) {
            mindiff = diff;
            mindiffnum = i;
        }
    }
    cout << mindiffnum << "\n";
    
    return 0;
}


Measured memory_bytes: 3592
h, w = map(int, input().split())
answer = 0

if h%3==0 or w%3 ==0:
    print(answer)
else:
    min1 = h*w
    min2 = h*w
    boxs = [0,0,h*w]
    for i in range(0,w):
        if h%2==0:
            boxs[0] += int(h//2)
            boxs[1] += int(h//2)
            boxs[2] -= h
            min1 = min(max(boxs)-min(boxs),min1)
        if h%2 ==1:
            boxs[0] += int(h//2)+1
            boxs[1] += int(h//2)
            boxs[2] -= h
            min1 = min(max(boxs)-min(boxs),min1)
    boxs = [0,0,h*w]      
    for i in range(0,h):
        if w%2==0:
            boxs[0] += int(w//2)
            boxs[1] += int(w//2)
            boxs[2] -= w
            min2 = min(max(boxs)-min(boxs),min2)
        if w%2 ==1:
            boxs[0] += int(w//2)+1
            boxs[1] += int(w//2)
            boxs[2] -= w
            min2 = min(max(boxs)-min(boxs),min2)
    print(min(min1,min2,h,w))

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//16:35~
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	string S;cin>>S;
	cout<<(S[0]=='S'?"Cloudy":(S[0]=='C'?"Rainy":"Sunny"))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MOD=1000000007;

int n;
int a[30][30];
ll dp[30][1<<21]; // man, woman

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%d",&a[i][j]);
	dp[0][0]=1;
	for(int i=1;i<=n;i++) for(int j=0;j<(1<<n);j++)
	{
		if(__builtin_popcount(j)!=i) continue;
		for(int k=0;k<n;k++)
		{
			if(!(j&(1<<k))) continue;
			if(!a[i][k+1]) continue;
			dp[i][j]=(dp[i][j]+dp[i-1][j^(1<<k)])%MOD;
		}
	}
	printf("%lld\n",dp[n][(1<<n)-1]);
	return 0;
}



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

class Program
{
    static void Main(string[] args)
    {
        int[] I = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();
        int A = I[0];
        int B = I[1];
        Console.WriteLine(Lcm(A, B));
    }

    static long Gcd(long a, long b)
    {
        return a > b ? (a % b == 0 ? b : Gcd(a % b, b)) : Gcd(b, a);
    }

    static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <utility>
#include <fstream>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

//const double PI = acos(-1);



int main() {
    int a, b;
    cin >> a >> b;
    int ans = a + b;
    ans = max(ans, a + a  - 1);
    ans = max(ans, b + b  - 1);
    cout << ans;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
 
#define ALL(x) x.begin(), x.end()
using namespace std;
 
int point[100005];
 
int main(void){
    int n, m;
    cin >> n >> m;
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        point[x]++;
        point[y]++;
    }
    for(int i=0; i<n; i++){
        if(point[i] % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;

void solve(int n) {
    int ans = 0;
    string t; cin >> t;
    for(int i=0; i<n-1; i++) {
        string s; cin >> s;
        if(t[0]!=s[0] and t[1]==s[1]) ans++;
        t = s;
    }
    cout << ans << "\n";
}

int main() {
    int n;
    while(cin>>n && n) solve(n);
    return 0;
}

Measured memory_bytes: 3160
using System;
using System.Linq;
using System.Collections.Generic;

public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine().Trim());
    List<int> B = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToList();    
    
    List<int> A = new List<int>();
    A.Add(B[0]);
    for(var i = 0; i < B.Count() - 1; i++) {
      A.Add(Math.Min(B[i], B[i + 1]));
    }
    A.Add(B[B.Count - 1]);
    Console.WriteLine(A.Sum());
  }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;
 
 
 
int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
 
    vector<long> a(n), b(n);
    vector<pair<long, long> > c(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld%ld", &a[i], &b[i]);
        c[i]=make_pair(a[i]+b[i], i);
    }
    sort(c.rbegin(), c.rend());
 
    ll sum=0;
    for(i=0; i<n; i++) {
        if(i%2==0) sum += a[c[i].second];
        else sum -= b[c[i].second];
    }
 
    printf("%lld\n", sum);
 
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    bool flag=false;
    for(int i=0;i<n;i++){
        char c;
        cin>>c;
        if(c=='Y')flag=true;
    }
    if(flag)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
    return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        bool gemsOnField[21][21] = {};
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            gemsOnField[y][x] = true;
        }
        int cx = 10, cy = 10, m;
        cin >> m;
        for (int i = 0; i < m; i++) {
            char d;
            int l;
            cin.ignore();
            cin >> d >> l;
            switch (d) {
            case 'N':
                for (int j = 0; j < l; j++) {
                    gemsOnField[++cy][cx] = false;
                }
                break;
            case 'E':
                for (int j = 0; j < l; j++) {
                    gemsOnField[cy][++cx] = false;
                }
                break;
            case 'S':
                for (int j = 0; j < l; j++) {
                    gemsOnField[--cy][cx] = false;
                }
                break;
            case 'W':
                for (int j = 0; j < l; j++) {
                    gemsOnField[cy][--cx] = false;
                }
                break;
            }
        }
        bool isAllGemsRecovered = true;
        for (int y = 0; y < 21; y++) {
            for (int x = 0; x < 21; x++) {
                if (gemsOnField[y][x]) {
                    isAllGemsRecovered = false;
                }
            }
        }
        if (isAllGemsRecovered) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 0
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll 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;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N, P; cin >> N >> P;
	vector<ll> A(N); rep(i, N) cin >> A[i];

	ll cnt_e = 0;
	rep(i, N) if (A[i] % 2 == 0)cnt_e++;

	if (cnt_e == N) {
		if (P == 0) cout << setprecision(40) << pow(2, N) << endl;
		else cout << 0 << endl;
		return 0;
	}
	else {
		cout <<setprecision(40) <<  pow(2, N - 1) << endl;
	}
}

Measured memory_bytes: 8064
#include<set>
#include<map>
#include<cmath>
#include<deque>
#include<stack>
#include<ctime>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define PI acos(-1)
#define MAXN 200000
#define INF 0x3f3f3f3f
int main(){
	double a=read(),b=read(),x=read();
	double s=x/a;
	if(s<=a*b/2)
		printf("%.8lf\n",90-atan(2*s/b/b)*180/PI);
	else
		printf("%.8lf\n",90-atan(a*a/2/(a*b-s))*180/PI);
	return 0;
}

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

namespace ABC138E
{
    class Program
    {
        static void Main(string[] args)
        {
           // Console.WriteLine(search(new List<long> {1, 3, 5, 7, 9}, 15));
           
            string s = CIN.String();
            string t = CIN.String();
            
            HashSet<char> ssub = new HashSet<char>();
            // 文字charに対して、Indexの位置を保存しておく 二分探索で取得する
            Dictionary<char, List<int>> map = new Dictionary<char, List<int>>();

            for (char c = 'a'; c <= 'z'; c++)
            {
                map.Add(c, new List<int>());
            }
            
            for (int i = 0; i < s.Length; i++)
            {
                ssub.Add(s[i]);
                map[s[i]].Add(i);
            }

            for (int i = 0; i < t.Length; i++)
            {
                if (!ssub.Contains(t[i]))
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            int curIndex = -1;
            long ans = 0;
            for (int i = 0; i < t.Length; i++)
            {
                char curChar = t[i];
                var list = map[curChar];
                var min = search(list, curIndex + 1);
                
                if (min == list.Count)
                {
                    ans += s.Length - curIndex - 1;
                    curIndex = -1;
                    i--;
                    //Console.WriteLine(curChar + " " + min + " :" + ans);
                    continue;
                }
                
                ans += list[min] - curIndex;
                curIndex = list[min];
                //Console.WriteLine(curChar + " " + min + " " + list[min] + " :" + ans);
            }
            Console.WriteLine(ans);
        }

        static int search(List<int> list, long min)
        {
            int lb = -1;
            int ub = list.Count;

            while (ub - lb > 1)
            {
                int mid = (lb + ub) / 2;
                if (list[mid] >= min)
                {
                    ub = mid;
                }
                else
                {
                    lb = mid;
                }
            }
            return ub;
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 15328
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "begin", long, "end");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, r;
    scan(n, r);
    if(n < 10)
        writeln(r + 100 * (10 - n));
    else
        writeln(r);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int x = Integer.parseInt(stdin.readLine());

        int a = x / 100;
        int b = x % 100;

        int c = 0;
        for (int i = 5; i >= 1; i--) {
            c += b / i;
            b %= i;
        }

        if (c <= a) {
            stdout.println(1);
        } else {
            stdout.println(0);
        }
    }


    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b){
    if(a < b){
        swap(a, b);
    }
    T r;
    while(r=a%b){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    string s;
    cin>>s;
    ll n;
    cin>>n;
    if(n==1)
      cout<<s[0]<<endl;
    else if(s[0]!='1')
      cout<<s[0]<<endl;
    else
    {
      int i=0;
      
        while(s[i]=='1')
        {
          i++;
        }
      if(i>=n)
        cout<<s[n-1]<<endl;
      else if(i==s.length())
      {
        cout<<s[n-1]<<endl;
      }
      else
      {
        cout<<s[i]<<endl;
      }
      
    
  }  
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int p, q, r;
    cin >> p >> q >> r;

    vector<int> res(3);
    res[0] = p + q;
    res[1] = q + r;
    res[2] = p + r;

    int min = 300;
    for (int i = 0; i < res.size(); i++) {
        if (res[i] < min) {
            min = res[i];
        }
    }

    cout << min;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int k, q; cin >> k >> q;
  vector<int> d(k); REP(i, k) cin >> d[i];
  while (q--) {
    int n, x, m; cin >> n >> x >> m;
    vector<int> D(k);
    REP(i, k) {
      D[i] = d[i] % m;
      if (D[i] == 0) D[i] = m;
    }
    ll last = x;
    REP(i, k) {
      int cnt = (n - 1) / k + ((n - 1) % k > i);
      last += 1LL * D[i] * cnt;
    }
    cout << n - 1 - (last / m - x / m) << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		System.out.println(k*(long)Math.pow(k-1,n-1));
	}

}

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

//i < j
int distance(int i, int j, int &X, int &Y){
  int a = j - i;
  int b, c, d;
  b = abs(i - X);
  c = abs(i - Y);
  b = min(b,c);
  c = abs(j - X);
  d = abs(j - Y);
  c = min(c,d);
  d = b + c + 1;
  return min(a,d);
  
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  map<int, int> cnt;
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= N; j++){
      int d = distance(i,j,X,Y);
      if(cnt.count(d)){
        cnt.at(d)++;
      }else{
        cnt[d] = 1;
      }
    }
  }
  for(int i = 1; i <= N - 1; i++){
    if(cnt.count(i)){
      cout << cnt.at(i) <<endl;
    }else{
      cout << 0 << endl;
    }
  }
}



Measured memory_bytes: 384
from bisect import *
N,M,Q=map(int,input().split())
LR=[list(map(int,input().split())) for i in range(M)]
PQ=[list(map(int,input().split())) for i in range(Q)]
data=[[] for i in range(N+1)]
for l,r in LR:
    data[l].append(r)
for i in range(1,N):
    data[i].sort()

data2=[[0] for i in range(N+1)]
for i in range(1,N+1):
    for c in range(1,N+1):
        data2[i].append(bisect_right(data[i],c))
#print(data2)
for p,q in PQ:
    count=0
    for i in range(p,q+1):
        count+=data2[i][q]
    print(count)


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

int gcd(int a, int b, int c){
  int m, i;
  
  m = min(min(a, b), c);
  for(i = m; i > 1; i--){
    if(a % i == 0 && b % i == 0 && c % i == 0){
      return i;
    }
  }
  return 1;
}

int main() {
  int n, i, j, k;
  int ans = 0;
  
  cin >> n;
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      for(k = 1; k <= n; k++){
        ans += gcd(i, j, k);
      }
    }
  }
  cout << ans << endl;  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll s=1,ans=0;
  while(a[n-1]!=0){
    ll cntz=0;
    ll cnto=0;
    rep(i,n){
      if(a[i]%2==0){
        cntz++;
      }
      else{
        cnto++;
      }
      a[i] /=2;
    }
    ans=(ans+(s*cntz)%MOD*cnto)%MOD;
    s=2*s%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560