akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int  maxn = 1e5 + 5;
string s;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> s;
    int cnt_ones = 0, cnt_zeros = 0;
    for(int i = 0; i < (int)s.size(); i ++){
        if(s[i] == '0'){
            cnt_ones ++;
        }
        else{
            cnt_zeros ++;
        }
    }
    int tmp = abs(cnt_zeros - cnt_ones);
    cout << (int)s.size() - tmp << endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
w = list(map(int, input().split()))

l = [0 for i in range(n+1)]
r = [0 for i in range(n+1)]

for i in range(1, n+1):
  l[i] = w[i-1] + l[i-1]
  r[-(i+1)] = w[-i] + r[-i]

ans = 1e+12
for i in range(n+1):
  ans = min(ans, abs(l[i]-r[i]))
print(ans)
            

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n << endl;
    return 0;
  } else {
    cout << n * 2 << endl;
    return 0;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		// input
		int price = scan.nextInt();

		// check
		for(int i = 1; i <= 50000; i++) {
			if(Math.floor(i * 1.08) == price) {
				System.out.println(i);
				break;
			}
			if(Math.floor(i * 1.08) > price) {
				System.out.println(":(");
				break;
			}
		}

	}
}


Measured memory_bytes: 23764
n = int (input())
a = list(list(map(int,input().split())) for hoge in range(2))
candy = 0
for i in range(n):
         if sum(a[0][:i+1])+sum(a[1][i:]) > candy:
                  candy = sum(a[0][:i+1])+sum(a[1][i:])
print(candy)


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

using namespace std;
using ll = long long;
#define int ll

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N, P, C0, C1;

void init()
{
	cin >> N;
	cin >> P;
	rep(i, N) {
		int a;
		cin >> a;
		if (a % 2) C1++;
		else C0++;
	}
}

void solve()
{
	if (C1) {
		ll res = 1;
		rep(i, N-1) {
			res *= 2;
		}
		cout << res << endl;
		return;
	}
	if (P) {
		cout << 0 << endl;
		return;
	}
	ll res = 1;
	rep(i, N) {
		res *= 2;
	}
	cout << res << endl;
}


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

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

    int ans = 0;
    for (int a = 1; a < n; a++) {
        for (int b = 1; a * b < n; b++) {
            ans++;
        }
    }

    cout << ans;
}

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

int main() {
    string S;
    cin >> S;
    int Snum = stoi(S);
    string res;
    int judge = 0;
    
    int t1 = Snum/1000;
    int t2 = (Snum-t1*1000)/100;
    int t3 = (Snum-t1*1000-t2*100)/10;
    int t4 = Snum-t1*1000-t2*100-t3*10;
    int ue = t1*10 + t2;
    int sita = t3*10 + t4;

    if(ue> 0 && ue<13) {
        if(sita > 0 && sita < 13) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if(sita > 0 && sita < 13) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }

    return 0;

}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

string c[2] = {"RY", "GB"};
int32 H, W, d;

int main(void){
	cin >> H >> W >> d;
	vector<string> v(H, "");
	REP(i, H){
		REP(j, W){
			int32 x = (i+j+1000)/(d)%2, y = ((i-j+1000)/(d))%2;
			cout << c[x][y];
			v[x] += c[x][y];
		}
		cout << endl;
	}

}

Measured memory_bytes: 1024
program bt;

var n,i,t:integer;
    a:array[1..1000] of integer;

begin
   readln(n);
   for i:=1 to n-1 do
    read(a[i]);
   readln(a[n]);
   t:=0;
   for i:=1 to n do
    if (i mod 2=1) and (a[i] mod 2=1) then t:=t+1;
   write(t);
   readln;
end.

Measured memory_bytes: 1384
h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0  # 何通りあるか
for row in range(1 << h):  # h行の選び方は2のh乗通り
    for col in range(1 << w):  # w行の選び方は2のw乗通り
        cnt = 0  # 黒いマスの数
        for i in range(h):
            for j in range(w):
                if row >> i & 1:
                    # h行目を選ぶ場合、該当行は黒ではないのでスキップ
                    continue
                if col >> j & 1:
                    # i列目を選ぶ場合、該当列は黒ではないのでスキップ
                    continue
                if c[i][j] == "#":
                    # 黒の数を数える
                    cnt += 1
        ans += cnt == k  # 黒の数がk個残る選び方が何通りあるか数える
        # if cnt == k:
        #     # 黒の数がk個残る選び方が何通りあるか数える
        #     ans += 1
print(ans)


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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N,M,K;
ll ans = -1;

cin >> N >> M >> K;

vector<ll> A(N);
vector<ll> B(M);

for(ll i = 0;i < N;++i) cin >> A[i];
for(ll j = 0;j < M;++j) cin >> B[j];

vector<ll> sumA(N+1,0);
vector<ll> sumB(M+1,0);

for(ll i = 0;i < N;++i) sumA[i+1] = sumA[i] + A[i];
for(ll i = 0;i < M;++i) sumB[i+1] = sumB[i] + B[i];

for(ll i = 0;i <= N;++i){

ll t = K - sumA[i];

if(t < 0) break;
  
  ll left = 0;
  ll right = M+1;
  ll mid = 0;

  while(right - left > 1){

    mid = (left + right)/2;

    if(sumB[mid] <= t) left = mid;
    else right = mid;

  }

  ll res = i + left;

  ans = max(ans,res);

}



cout << ans << endl;

return 0;

}   


Measured memory_bytes: 9596
n, k = map(int, input().split(" "))
 
nums=[]
for i in range(0, n):
    a, b = map(int, input().split(" "))
    nums.append([a, b])

nums.sort(key=lambda x:x[0])
#print(nums)
sum = 0
for i in range(0, n):
    sum +=nums[i][1]
    if sum >= k:
        print(nums[i][0])
        break




Measured memory_bytes: 21248
X, Y = map(int, input().split())
a = 0
output = 'No'
if Y%2 != 0:
    pass
else:
    while X >= 0:
        b = X*2 + a*4
        if b == Y:
            output = 'Yes'
        X -= 1
        a += 1
print(output)

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


long long N, Q, A[100000], X[100000];
vector<int>border;
long long a_sum[100001], a_skip_sum[100001];

int main(){
  cin >> N >> Q;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    a_sum[i+1] = a_sum[i] + A[i];
    a_skip_sum[i+1] = a_skip_sum[i] + (((N - i) % 2)? A[i]: 0);
  }
  for(int q = 0; q < Q; q++){
    cin >> X[q];
  }
  border.push_back(-2e9);
  for(int i = 1; i <= (N - 1)/2; i++){
    border.push_back(-A[N-1-i] - A[N-1-2*i] - 1);
  }
  for(int q = 0; q < Q; q++){
    int split = lower_bound(border.begin(), border.end(), -2 * X[q]) - border.begin();
    long long t_sum = 0;
    t_sum += a_sum[N] - a_sum[N - split];
    t_sum += a_skip_sum[N - 2 * split];
    /*
    int a_sum = 0;
    for(int i = 0; i < split; i++){
      t_sum += A[N - 1 - i];
      a_sum += A[N - 1 - split - i];
    }
    for(int i = N - 2 * split - 1; i >= 0; i--){
      if((N - i) % 2){
	t_sum += A[i];
      }else{
	a_sum += A[i];
      }
    }
    */
    cout << t_sum << endl;
    //cout << lower_bound(border.begin(), border.end(), -2 * X[q]) - border.begin() << endl;
  }
}


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

const ll INF = 1e9;
int dp[110][110];
string s[110];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main(){
    int H,W; cin >> H >> W;
    rep(i,H){
        string ad; cin >> ad;
        s[i+1] = '0' + ad + '0';
    }
    rep(i,110){
        rep(j,110){
            dp[i][j] = INF;
        }
    }
    if(s[1][1] == '.') dp[1][1] = 0;
    else dp[1][1] = 1;

    for(int x=1;x<=H;x++){
        for(int y=1;y<=W;y++){        
            dp[x][y] = min(dp[x][y], dp[x-1][y] + (s[x][y]!=s[x-1][y]) );
            dp[x][y] = min(dp[x][y], dp[x][y-1] + (s[x][y]!=s[x][y-1]) );
        }
    }
    if(dp[H][W]) dp[H][W]++;
    cout << dp[H][W]/2 << endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    cout << n*(n-1)/2 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
bool solve(int n){
	while(n){
		if(n%10==7){
			return true;
		}
		n=n/10;
	}
	return false;
}
int main(){
	int n;
	cin>>n;
	if(solve(n)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;



int main()
{
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;

  string res = "NG";
  FOR(i,a,b+1){
    if(i%k==0){
      res = "OK";
      break;
    }
  }

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3632
def main():
    N, K = (int(i) for i in input().split())
    c0 = 0
    c1 = 0
    for num in range(1, N+1):
        if num % K == 0:
            c0 += 1
        elif K % 2 == 0 and num % K == K//2:
            c1 += 1
    print(pow(c0, 3) + pow(c1, 3))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
#include<stdio.h>
int sum (int n,int score[]);
int main ()
{
    int n,res;
    scanf("%d",&n);
    int score[n],i;
    getchar();
    for (i=0;i<n;i++)
    {
        scanf("%d",&score[i]);
    }
    res = sum(n,score);
    printf("%d",res);
    return 0;
}
int sum (int n,int score[])
{
    int sum = 0,a=1,i=0;
    for (a=1;a<=n-1;a++)
    {
        for (i=0;i<n-a;i++)
            {
                sum+=score[i]*score[i+a];
            }
    }
    return sum;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int x;
char y[101];

int main(){
	scanf("%d",&x);
	scanf("%s",&y);
	int len = strlen(y);
	if(len<=x){
		printf("%s\n",y);
		return 0;
	}
	else{
		for(int i=x; i<len; i++){
			y[i]='\0';
		}
		for(int i=x; i<x+3; i++){
			y[i]='.';
		}
		printf("%s\n",y);
		return 0;
	}
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int n,ans=0,maxn=0;
string s;
int main() {
	cin>>n>>s;
	for(int i=0;i<n;i++) {
		if(s[i]=='I') ans++;
		if(s[i]=='D') ans--;
		if(maxn<ans) maxn=ans;
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int acc[10][30001];
int main() {
	int n;
	string s;
	cin >> n >> s;
	int temp[10];
	int temp2[10];
	rep(i,10) {
		temp[i] = n;
		temp2[i] = -1;
	}
	rep(i,n) {
		rep(j,10) {
			if((s[i] - '0') == j) {
				if(temp[j] == n) temp[j] = i;
				temp2[j] = i;
				acc[j][i] = 1;
				if(i != 0) acc[j][i] += acc[j][i-1];
			}
			else {
				acc[j][i] = 0;
				if(i != 0) acc[j][i] += acc[j][i-1];
			}
		}
	}
	ll ans = 0;
	rep(i,10) {
		rep(j,10) {
			//cout << i << " " << j << " first appeared i " << temp[i] << " last appeared j " << temp2[j] << " ";
			if(temp[i] <= temp2[j]) {
				int temp3 = n;
				for(int k=temp[i]+1; k<n; k++) {
					int t = s[k] - '0';
					if(t == j && temp3 == n) temp3 = k;
				}
				rep(q,10) {
					//cout << endl;
					//cout << q << "last appeared q " << temp2[q] << " first appeared j after i " << temp3; 
					if(temp2[q] > temp3) ans++;
				}
			}
			//cout << endl;
		}
	}
	cout << ans << endl;


  return 0;
}


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

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

    int N, p;
    int P[50], Q[50];

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> p;
        Q[i] = P[i] = p;
    }
    sort(Q, Q + N);

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] != Q[i]) {
            cnt++;
        }
    }
    if (cnt <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// Problem : E - Yutori
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int N, K, C;

string s;
long long dp[200005];
long long mx[200005];
bool good[200005];

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> K >> C >> s;
	for(int i = 1; i<=N; i++){
		if(s[i-1] == 'o'){
			dp[i] = 1;
			if(i >= C+1){
				dp[i] = mx[i-C-1] + 1;
			}
		}
		mx[i] = max(mx[i-1], dp[i]);
	}
	if(mx[N] == K){
		int n = N;
		while(n > 0){
			while(n > 0 && s[n-1] == 'x'){
				n--;	
			}
			if(n > 0){
				good[n] = 1;
			}
			n -= C+1;
		}
		bool b = 0;
		for(int i = N; i; i--){
			if(mx[i] != mx[i+1]){
				b = 0;
			}
			if(good[i]){
				b = 1;
			}
			good[i] = b;
		}
		int crnt = 1, cnt = 0, x = 0;
		for(int i = 1; i<=N; i++){
			if(dp[i] && dp[i] == crnt && good[i]){
				cnt++;
				x = i;
			}
			else if(dp[i] && dp[i] != crnt && good[i]){
				if(cnt == 1){
					cout << x << "\n";
				}
				crnt = dp[i];
				cnt = 1;
				x = i;
			}
		}
		if(cnt == 1){
			cout << x << "\n";
		}
	}
}

Measured memory_bytes: 5140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}

int main()
{
    int a, b;
    top = 0;
    char s[100];

    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-') {
        b = pop();
        a = pop();
        push(a - b);
        }
        else if (s[0] == '*') {
        a = pop();
        b = pop();
        push(a * b);
       }
       else {
        push(atoi(s));
       }
    }

    printf("%d\n", pop());
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100000][3];
ll getTheMaximum(ll day,ll activity,ll a[][3]){
    // cout<<day<<endl;
    if(dp[day][activity]!=0){
        return dp[day][activity];
    }
    //base case
    if(day==0){
        dp[day][activity]=a[day][activity];
        return dp[day][activity];
    }
    
        //when i choose activity 1;
        //activities;
    dp[day][activity]=0;
    for(ll k=0;k<=2;k++){
        if(k!=activity){
            dp[day][activity]=max(dp[day][activity],getTheMaximum(day-1,k,a)+a[day][activity]);
        }
    }
    
    return dp[day][activity];
}
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n][3];
	for(ll i=0;i<n;i++)
	    cin>>a[i][0]>>a[i][1]>>a[i][2];
	ll maxi=INT_MIN;
	for(ll i=0;i<3;i++){
	    maxi=max(maxi,getTheMaximum(n-1,i,a));
	}
	cout<<maxi;
	return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>

int main(){
  int n,i,j,k,l,count,check,mark,turn,seq[16],sub[16],pre[16];

  count=0;
  mark=0;
  check=0;
  turn=0;
    k=0;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    else
      {
	turn=0;
	for(i=0;i<n;i++)scanf("%d",&seq[i]);
	while(1){
	  count=0;
	  check=0;
	
	for(i=0;i<n;i++){
	  count=0;
	  for(j=0;j<n;j++){
	    if(seq[i]==seq[j])count++;
	  }
	  sub[i]=count;
	}
	for(i=0;i<n;i++){
	  if(seq[i]==sub[i])check++;}
	if(check==n)break;
	else{
	  turn++;
	  for(i=0;i<n;i++){
	    seq[i]=sub[i];
	    sub[i]=0;
	  }
	}
	}
	printf("%d\n",turn);
	for(i=0;i<n;i++){
	  if(i==0)printf("%d",seq[i]);
	  else{
	    printf(" %d",seq[i]);}
	}
	printf("\n");
      }
  }



  return 0;
}

Measured memory_bytes: 604
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        m: usize,
        p: [(i32, i32, i32); n],
        e: [(usize1, usize1); m],
    }
    let mut g = vec![vec![]; n];
    for (s, t) in e {
        g[t].push(s);
    }
    let mut ans = vec![0; n];
    for k in 0..8 {
        let mut v = vec![];
        for (i, &(x, y, z)) in p.iter().enumerate() {
            let mut d = 0;
            d += if k & 1 == 1 {x} else {-x};
            d += if k & 2 == 2 {y} else {-y};
            d += if k & 4 == 4 {z} else {-z};
            v.push((d, i));
        }
        v.sort();
        let inf = 1_000_000_000;
        let mut dp = vec![inf; n];
        for (d, v) in v {
            if dp[v] < inf {
                continue;
            }
            let mut s = vec![];
            dp[v] = d;
            s.push(v);
            while let Some(v) = s.pop() {
                for &u in &g[v] {
                    if dp[u] > d {
                        dp[u] = d;
                        s.push(u);
                    }
                }
            }
        }
        for i in 0..n {
            let (x, y, z) = p[i];
            let mut d = 0;
            d += if k & 1 == 1 {x} else {-x};
            d += if k & 2 == 2 {y} else {-y};
            d += if k & 4 == 4 {z} else {-z};
            let v = d - dp[i];
            if ans[i] < v {
                ans[i] = v;
            }
        }
    }
    for v in ans {
        writeln!(out, "{}", v).unwrap();
    }
}

fn main() {
    run();
}



Measured memory_bytes: 39764
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




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

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

signed main(){
  int n;string s,t;cin>>n>>s>>t;
  string ans;
  rep(i,n){
    ans += s[i];ans += t[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c >> d;
    intl x = c - a;
    intl y = d - b;
    cout << c - y << " " << d + x << " ";
    cout << a - y << " " << b + x;
    return 0;
}

Measured memory_bytes: 256
import bisect
import itertools
N, M, K = [int(_) for _ in input().split()]
A = list(itertools.accumulate([0] + [int(_) for _ in input().split()]))
B = list(itertools.accumulate([0] + [int(_) for _ in input().split()]))
ans = 0
for i, a in enumerate(A):
    if a > K:
        break
    ans = max(ans, i + bisect.bisect(B, K - a) - 1)
print(ans)


Measured memory_bytes: 128396
use proconio::{fastout, input};

use std::cmp::max;

#[fastout]
fn main() {
    input! {
        mut n: i64, m: usize,
        a: [i64; m]
    }
    for x in a.iter() {
        n -= x;
    }
    println!("{}", max(n, -1));
}


Measured memory_bytes: 2236
#include <stdio.h>
int main(void)
{
	int a, b, x=0, y=0, z=0;
	scanf("%d %d", &a, &b);
	x = a+b;
	y = a-b;
	z = a*b;
	if(x>y && x>z)
		printf("%d\n", x);
	else if(y>x && y>z)
		printf("%d\n", y);
	else if(z>x && z>y)
		printf("%d\n", z);
	else
		printf("%d\n", x);	
}

Measured memory_bytes: 128
n = int(input())
s = [input() for _ in range(n)]

import collections
cnt = collections.Counter(s)
dict = sorted(cnt)

max_vote = max(cnt.values())
ans = []
for a,b in cnt.items():
  if max_vote == b:
    ans.append(a)
ans = sorted(ans)
print('\n'.join(ans))

Measured memory_bytes: 39244
class Sushi(object):
    def __init__(self, sushi_type, delicious):
        self.t = sushi_type
        self.d = delicious


def main() -> None:
    n, k = map(int, input().split())
    menu = [[int(x) for x in input().split()] for _ in range(n)]
    selected = []
    unselected = []
    cnt = 0
    p_satisfied = 0
    selected_type = set()

    menu.sort(key=lambda x: x[1], reverse=True)

    for i in range(n):
        sushi = Sushi(menu[i][0], menu[i][1])
        if sushi.t not in selected_type and cnt < k:
            selected_type.add(sushi.t)
            cnt += 1
            selected += [menu[i]]
        else:
            unselected += [menu[i]]

    unselected.sort(key=lambda x: x[1])

    while cnt < k and len(unselected) > 0:
        p_satisfied += unselected[-1][1]
        unselected.pop()
        cnt += 1

    while True:
        t_cnt = len(selected)
        if len(selected) == 0 or len(unselected) == 0:
            break
        if t_cnt ** 2 + selected[-1][1] > (t_cnt - 1) ** 2 + unselected[-1][1]:
            break
        p_satisfied += unselected[-1][1]
        unselected.pop()
        selected.pop()

    for v in selected:
        p_satisfied += v[1]

    print(p_satisfied + len(selected) ** 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73048
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=(1e5+5)*2;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif

	clock_t startTime=clock();

	ll n;
	cin>>n;
	
	ll ar[n];
	ll maxi=-mod;
	rep(i,0,n)
	{
		cin>>ar[i];
		maxi=max(maxi,ar[i]);
	}

	ll vis[maxi+10];
	memset(vis,0,sizeof vis);


	for(ll i=0;i<n;i++)
	{
		for(ll j=ar[i];j<=maxi;j+=ar[i])
		{
			vis[j]+=1;
		}
	}

	ll c=0;

	rep(i,0,n)
	{
		if(vis[ar[i]]<=1)
			c++;
	}
	cout<<c<<endl;


	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 13156
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
//#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;x=x*x%mod; y>>=1;} return res; }
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

int t,n,m,k;
map<string,int> a;
string s;
int main(){
    scanf("%d",&n);
    rep(i,1,n){
        cin>>s;
        a[s]++;
    }
    printf("%d\n",a.size());













    return 0;
}


Measured memory_bytes: 19372
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 50005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

string a;

int main(){
    cin>>a;
    if(a[0] == '9' || a[1] == '9')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		Integer[] Ints = new Integer[10];
		for (int i=0; i<10; i++) {
			Ints[i] = sc.nextInt();
		}
		Arrays.sort(Ints,Comparator.reverseOrder());
		for (int i=0; i<3; i++) {
			System.out.println(Ints[i]);
		}
	}
}


Measured memory_bytes: 26308
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 1e6+2;

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m, t, mod=1e9+7;

    cin >> n;

    if (n==1)
        cout<<0<<endl;
    else
    {
        ll ans=1;

        ans=(power(10,n,mod)-((2*power(9,n,mod))%mod)+power(8,n,mod)+mod)%mod;
        cout<<(ans+mod)%mod<<endl;
    }


    return 0;
}

Measured memory_bytes: 3544
from itertools import product

INF = 10**10
n,m,x = map(int,input().split())
C = [0]*n
A = [[0]*m for _ in range(n)]
for i in range(n):
  T = list(map(int,input().split()))  
  C[i] = T[0]
  A[i] = T[1:]
 
prd = product([1,0],repeat = n)

ans = INF
for pr in prd:
  tmp = [0]*m
  cost = 0
  for i in range(n):
    if pr[i]:
      cost += C[i]
      for j in range(m):
        tmp[j] += A[i][j]
  if all([t>=x for t in tmp]):
    ans = min(cost,ans)
  
if ans == INF:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=2e5+5;
const int maxm=5e2+5;
const int maxq=55;
const int INF=0x3f3f3f3f;
ll a[maxn];
int n;
ll check(ll b)
{
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=abs(a[i]-(b+i));
    }
    return sum;
}
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        ll l=-2e9;ll r=2e9;
        ll ans=0;
        while(l<=r)
        {
//            cout<<l<<" "<<r<<endl;
            ll mid1=l+(r-l)/3;
            ll mid2=r-(r-l)/3;
            ll ans1=check(mid1);ll ans2=check(mid2);
            if(ans1<=ans2)
            {
                ans=ans1;
                r=mid2-1;
            }
            else
            {
                ans=ans2;
                l=mid1+1;
            }
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 1792
let cnt = ref 0

let merge a l m r =
  let ni = m - l in
  let ai = Array.make (ni + 1) max_int in
  for i = 0 to ni - 1 do
    ai.(i) <- a.(l + i)
  done;
  let aj = Array.make (r - m + 1) max_int in
  for i = 0 to r - m - 1 do
    aj.(i) <- a.(m + i)
  done;
  let i = ref 0 in
  let j = ref 0 in
  for k = l to r - 1 do
    if ai.(!i) <= aj.(!j) then begin
      a.(k) <- ai.(!i);
      incr i;
    end else begin
      a.(k) <- aj.(!j);
      cnt := !cnt + (ni - !i);
      incr j;
    end
  done

let rec merge_sort a l r =
  if (l + 1) >= r then () else
  let m = (l + r) / 2 in
  merge_sort a l m;
  merge_sort a m r;
  merge a l m r

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 11412
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	char S[100010];
	int N = 0;
	while ((S[N] = getchar_unlocked()) >= 'a') N++;

	int n[100001][26];
	rep(i, 26) n[N - 1][i] = -1;
	for (int i = N - 1; i >= 0; i--) {
		n[N - 1][S[i] - 'a'] = i;
	}
	for (int i = N - 1; i >= 1; i--) {
		memcpy(n[i - 1], n[i], sizeof(n[i]));
		n[i - 1][S[i] - 'a'] = i;
	}

	int OK = 1;
	ll kotae = 0;
	int k = N - 1;
	char T;
	while ((T = getchar_unlocked() - 'a') >= 0) {
		int k2 = n[k][T];
		if (k2 == -1) {
			OK = 0;
			break;
		}

		if (k2 > k) kotae += k2 - k;
		else kotae += k2 - k + N;
		k = k2;
	}

	if (OK) printf("%lld", kotae);
	else printf("-1");

	Would you please return 0;
}

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

#define P(s) cout<<s<<endl
#define P2(b,y,f) P(((b)?y:f))
#define REP(i,b,e) for(int i=b;i<e;++i)
#define LOOP(n) while(n--)
#define ALL(con) con.begin(), con.end()
#define In(type, x) type x; cin>>x
#define InVec(type, x, n) vector<type> x(n); REP(i,0,n) cin>>x[i]

int main() {
    In(int, n);
    InVec(int, l, n * 2);
    sort(ALL(l));
    int sum = 0;
    REP(i,0,n) {
        sum += l[i * 2];
    }
    
    P(sum);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=100000;i++)
	{
		if(floor((double)i*0.08)==a&&floor((double)i*0.1)==b)
		{
			cout<<i<<"\n";
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int n; cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; ++i)cin >> p[i];
	int ans = 0;
	for (int i = 1; i < n - 1; ++i) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
			ans++;
		}
		else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

# define C continue;
# define R return

#define int long long
# define D double
# define I insert
# define ld long double
# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) v.begin() , v.end()
# define allcomp(v) v.begin() , v.end() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type, vector<type>, greater<type>>

#define mii map<int, int>
#define mll map<ll, ll>
#define mci map<char, int>
#define msi map<string, int>
#define mis map<int, string>
#define mib map<int, bool>
#define mcb map<char,bool>

#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>
#define umci unordered_map<char, int>
#define umsi unordered_map<string, int>
#define umis unordered_map<int, string>

#define init(arr,val) memset(arr,val,sizeof(arr))
#define REP(i,a,b) for(int i=a; i<b; i++)
#define distance(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define nl "\n"
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = { -2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const int mod = 1e9 + 7 ;
#define test int t; cin>>t;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
void a_b_c()
{
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{
 int n,x,t,ans=0;
 cin>>n>>x>>t;
 while(n>0)
 {
     ans+=t;
     n-=x;
 }
 cout<<ans;

}
int32_t main()
{	fast
    int t=1;
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    //int t;  cin>>t;
    for(int i=1; i<=t; i++) solve();

}



Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 1;
		Integer[] d = new Integer[n];


		for(int i=0; i<n; i++){
			d[i] = sc.nextInt();
		}

		Arrays.sort(d, Comparator.reverseOrder());

		for(int i=1; i<n; i++){
			if(d[i-1]>d[i]){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	/*(^(^(^(^(^o^)^)^)^)^) &#9602;&#9605;&#9607;&#9608;&#9619;&#9618;&#9617;('ω')&#9617;&#9618;&#9619;&#9608;&#9607;&#9605;&#9602; */
	double a,b,c,d,e;
	while(1){
	scanf("%lf%lf%lf",&a,&b,&c);
	if(a==0 && b==0 && c==0) break;
if(a<b){
	int w=a;
	a=b;
	b=w;
}
if(a<c){
	int w=a;
	a=c;
	c=w;
}
if(b<c){
	int w=b;
	b=c;
	c=w;
}
double u=sqrt(b*b+c*c);
int i,n;
scanf("%d",&n);
for(i=0;i<n;i++){
int se;
scanf("%d",&se);
if(se*2>u) printf("OK\n");
else printf("NA\n");
}
}
	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    ll r=0,g=0,b=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='R')r++;
    	else if(s[i]=='G')g++;
    	else b++;
    }
    ll ans=r*g*b;
    for(int i=0;i<n;i++){
    	for(int j=i+2;j<n;j+=2){
    		r=g=b=0;
    		if(s[i]=='R')r++;
    	    else if(s[i]=='G')g++;
    	    else b++;
    	    if(s[j]=='R')r++;
    	    else if(s[j]=='G')g++;
    	    else b++;
    	    if(s[(i+j)/2]=='R')r++;
    	    else if(s[(i+j)/2]=='G')g++;
    	    else b++;
    	    ans-=r*g*b;
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

int check(string &s, int p){
	int a = p/1000, b = (p/100)%10, c = (p/10)%10, d = p%10;
	stack<int> sta;
	
	for(int i = s.size()-1; i >= 0; i--){
		if(s[i] == 'a') sta.push(a);
		else if(s[i] == 'b') sta.push(b);
		else if(s[i] == 'c') sta.push(c);
		else if(s[i] == 'd') sta.push(d);
		else if(s[i] == '^'){
			int e = sta.top(); sta.pop();
			int f = sta.top(); sta.pop();
			sta.push(e^f);
		} else if(s[i] == '+'){
			int e = sta.top(); sta.pop();
			int f = sta.top(); sta.pop();
			sta.push(e|f);
		} else if(s[i] == '*'){
			int e = sta.top(); sta.pop();
			int f = sta.top(); sta.pop();
			sta.push(e&f);
		}
	}
	
	return sta.top();
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	while(true){
		string s;
		int num = 0, con = 0, p;
		cin>>s;
		
		if(s == ".") break;
		
		cin>>p;
		
		num = check(s,p);
		
		for(int i = 0; i < 10000; i++)
			if(num == check(s,i)) con++;
		
		cout<<num<<" "<<con<<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    int A,B,X;
    cin>>A>>B>>X;

    
    if (A>X) {
        cout<<"NO"<<endl;
        return 0;
    }
    if (A+B>=X) {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

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

using namespace std;

int main(void)
{
	int n, maxl = 0, suml = 0;
	cin >> n;
	vector<int> l(n);
	rep(i, n){
		cin >> l[i];
		maxl = max(maxl, l[i]);
		suml += l[i];
	}
	suml -= maxl;
	if (maxl < suml){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
let qq =
  let rec qx x y = 
    let rec qy x y = 
      if y > 9 then qx x 1 else (Printf.printf "%dx%d=%d\n" x y (x * y); qy x (y + 1))
    in
    if x >= 9 then () else qy (x + 1) y
  in
  qx 0 1

let () = qq

Measured memory_bytes: 2160
N, T = map(int, input().split())

d = {}
for _ in range(N):
    Ns = [int(i) for i in input().split()]
    time = Ns[1]
    if time <= T:
        d[Ns[0]] = Ns[1]
if d:
    print(min(d))
else:
    print('TLE')

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n; cin >> n;
    if(n < 1000) cout << "ABC" << ln;
    else cout << "ABD" << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;


 	
 	
int main() {
	
 	int sx,sy,tx,ty;
	
	cin>>sx>>sy>>tx>>ty;
	
	int x=0,y=0;

	while(sy+y<ty){
		cout<<'U';
		y++;
	}

	while(sx+x<tx){
		cout<<'R';
		x++;
	}

	while(y>0){
		cout<<'D';
		y--;
	}

	while(x>0){
		cout<<'L';
		x--;
	}

	cout<<'D';
		while(sx+x<=tx){
		cout<<'R';
		x++;
	}
y=-1;
	while(sy+y<ty){
		cout<<'U';
		y++;
	}
	cout<<'L';
	cout<<'U';
		while(x>0){
		cout<<'L';
		x--;
	}
	while(y>=0){
		cout<<'D';
		y--;
	}
cout<<'R'<<endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool equal(vector<int> a, vector<int> b)
{
    for (int i = 0; i < a.size(); i++)
        if (a[i] != b[i])
            return false;
    return true;
}

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

    int n, fir, sec, pos = 1;
    cin >> n;
    vector<int> p(n), q(n), key(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int j = 0; j < n; j++) cin >> q[j];
    for (int j = 0; j < n; j++) key[j] = j + 1;

    do
    {
        if (equal(p, key)) fir = pos;
        if (equal(q, key)) sec = pos;
        pos++;
    } while (next_permutation(key.begin(), key.end()));

    cout << abs(sec - fir) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

using ll = long long;

int main(){
    string s;
    cin >> s;
    ll w;
    cin >> w;
    for (unsigned int i = 0; i < s.size(); i+=w){
        cout << s.at(i);
    }

  return 0;
}

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

int main(){
    int k, s;
    cin >> k >> s;
    
    int counter=0, z=0;
    for(int x=0; x<=k; ++x){
        for(int y=0; y<=k; ++y){
            z = s - x - y;
            if(0 <= z && z <= k) ++counter;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256