akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<vector<long long>> A(N, vector<long long>(N));
    for (int i=0; i<N; i++)
        for (int j=0; j<N; j++)
            cin>>A[i][j];

    vector<pair<long long, pair<int, int>>> B;
    for (int i=0; i<N; i++)
        for (int j=0; j<i; j++)
            B.push_back(make_pair(A[i][j], make_pair(i, j)));
    sort(B.begin(), B.end());

    long long oo = 0x100000000LL;
    vector<vector<long long>> E(N, vector<long long>(N, oo));
    vector<vector<long long>> D(N, vector<long long>(N, oo));
    for (int i=0; i<N; i++)
        E[i][i] = D[i][i] = 0LL;
    for (auto b: B)
    {
        long long d = b.first;
        int x = b.second.first;
        int y = b.second.second;
        if (D[x][y] < d)
        {
            cout<<-1<<endl;
            return 0;
        }
        if (D[x][y] > d)
        {
            E[x][y] = E[y][x] = d;
            D[x][y] = D[y][x] = d;
            for (int i=0; i<N; i++)
            for (int j=0; j<N; j++)
                D[i][j] = min(D[i][j], D[i][x]+d+D[y][j]),
                D[i][j] = min(D[i][j], D[i][y]+d+D[x][j]);
        }
    }
    long long ans = 0;
    for (int i=0; i<N; i++)
    for (int j=0; j<i; j++)
        if (E[i][j] < oo)
            ans += E[i][j];
    cout<<ans<<endl;
}


Measured memory_bytes: 3068
#include<stdio.h>
int main(void)
{
  int n, i=0;
  scanf("%d", &n);
  double a, b, ans;
  ans = 0;
  char s[4];
  do{
    scanf("%lf %s", &a, s);
    if(s[0]=='B'){
      a *= 380000.0;
    }
    ans += a;
    a = 0;
    i++;
  }while(i<n);
  printf("%lf\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>
#include <random>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14


using namespace std;

// 素数判定 O(sqrt(x))
bool is_prime(int x) {
    if (x == 2) {
        return true;
    }
    if (x < 2 || x % 2 == 0) {
        return false;
    }

    for (int i = 3; i * i <= x; i += 2) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    int ans = 0;
    FOR(i, 0, N) {
        int n;
        cin >> n;
        ans += is_prime(n);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s1, s2;
    bool jdg=false;
    getline(cin, s1);
    getline(cin, s2);

    for(int i=0; i < (int)s1.length(); i++){
        if((int)s1.length() >= i + (int)s2.length() + 1){
            if(s1.substr(i, (int)s2.length()) == s2){
                jdg = true;
                exit;
            }
        }else{
            int cnt1 = (int)s1.length() - i; // 初回比較文字数
            int cnt2 = (int)s2.length() - cnt1;  // 2回目の比較文字数

            if(s1.substr(i, cnt1) == s2.substr(0, cnt1) && s1.substr(0, cnt2) == s2.substr(cnt1 , cnt2)){
                jdg = true;
                exit;
            }
        }
    }
    
    if(jdg == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3216
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, m = LI()
lst = [[] for _ in range(n)]

for i in range(m):
    p, y = LI()
    lst[p-1].append([y, i])

for i in lst:
    i.sort()

ans = []
for i in range(n):
    for idx, [j, k] in enumerate(lst[i]):
        s = "0" * 6 + str(i+1)
        s = s[-6:]
        t = "0" * 6 + str(idx+1)
        t = t[-6:]
        ans.append([k, s+t])
ans.sort()
for i, j in ans:
    print(j)

Measured memory_bytes: 114460
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll d;cin>>d;
  ll c[26];
  for(ll i=0;i<26;i++){
    cin>>c[i];
  }
  ll s[d][26];
  for(ll i=0;i<d;i++){
    for(ll j=0;j<26;j++){
      cin>> s[i][j];
    }
  }
  ll t[d];
  for(ll i=0;i<d;i++){
    cin>>t[i];
    t[i]--;
  }
  ll ans=0;
  ll last[26];fill(last,last+26,0);
  for(ll i=0;i<d;i++){
    ans+=s[i][t[i]];
    last[t[i]]=i+1;
    for(ll j=0;j<26;j++){
      ans-=c[j]*(i-last[j]+1);
    }
    cout << ans<<endl;
  }
  
}

Measured memory_bytes: 3696
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>

int main() {
    int iStudent;
    int iSum;
    int iCount;
    int iScore[1010];
    double dAve;
    double dDispersion;
    double dSum2;

    while (1) {
        scanf("%d", &iStudent);
        if (iStudent == 0) break;

        iSum = 0;
        for (iCount = 0; iCount < iStudent; iCount++) {
            scanf("%d", &iScore[iCount]);
            iSum += iScore[iCount];
        }
        dAve = (double)iSum / iStudent;
        dSum2 = 0;
        for (iCount = 0; iCount < iStudent; iCount++) {
            dSum2 += (iScore[iCount] - dAve) * (iScore[iCount] - dAve);
        }
        dDispersion = dSum2 / iStudent;
        printf("%.8lf\n", sqrt(dDispersion));
    }

    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool isSame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};


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

	ll n,m,k;
	cin >> n >> m >> k;
	vector<ll> a(m), b(m);

	UnionFind friends(n);
	vector<vector<ll>> fri(n, vector<ll>(0));
	vector<vector<ll>> block(n, vector<ll>(0));

	rep(i, m)
	{
		cin >> a[i] >> b[i];
		friends.merge(a[i]-1, b[i]-1);
		fri[a[i] - 1].push_back(b[i] - 1);
		fri[b[i] - 1].push_back(a[i] - 1);
	}

	vector<ll> c(k), d(k);
	rep(i, k)
	{
		cin >> c[i] >> d[i];
		block[c[i] - 1].push_back(d[i] - 1);
		block[d[i] - 1].push_back(c[i] - 1);
	}

	vector<ll> ans(n,0);

	rep(i, n)
	{
		ans[i] = friends.size(i)-1;
		ans[i] -= fri[i].size();
		rep(j, block[i].size())
		{
			if (friends.isSame(block[i][j], i))
				ans[i]--;
		}
	}

	rep(i, n-1)
	{
		cout << ans[i] << " ";
	}
	cout << ans[n - 1] << endl;


	return 0;
}

Measured memory_bytes: 18420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int n;
	while(cin >> n, n) {
		int f[101][101] = {};
		FOR(i, 1, n+1) {
			int m; cin >> m;
			FOR(j, 1, m+1)
				cin >> f[i][j];
		}
		int k; cin >> k;
		int l[k], cnt, ans = 0;
		REP(i, k)
			cin >> l[i];
		FOR(i, 1, n+1) {
			cnt = 0;
			FOR(j, 1, n+1) {
				REP(idx, k) if(f[i][j] == l[idx])
					cnt++; 
				if(cnt == k) {
					if(!ans) ans = i;
					else ans = -1;
					break;
				}
			}
		}
		if(ans == 0) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

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


int main(){
	int dp[17][17];
	bool matatabi[16][16][2];
	int t;
	cin>>t;
	while(t--){
		memset(dp,0,sizeof(dp));
		memset(matatabi,false,sizeof(matatabi));
		int gx,gy,p;
		cin>>gx>>gy>>p;
		while(p--){
			int x1,y1,x2,y2;
			cin>>x1>>y1>>x2>>y2;
			matatabi[min(y1,y2)][min(x1,x2)][x1==x2]=true;
		}
		dp[0][0]=1;
		for(int i=0;i<=gy;i++){
			for(int j=0;j<=gx;j++){
				if(!matatabi[i][j][1])dp[i+1][j]+=dp[i][j];
				if(!matatabi[i][j][0])dp[i][j+1]+=dp[i][j];
			}
		}
		if(dp[gy][gx])cout<<dp[gy][gx]<<endl;
		else cout<<"Miserable Hokusai!"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
	int H,W;
	while(true)
	{
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) 
		{
			break;
		} 
		for(int i = 0; i < W; i++) 
		{
			printf("#");
		}
		printf("\n");
		for(int i = 1; i < H-1; i++)
		{
			printf("#");
			for(int j = 1; j < W-1; j++) 
			{
			    printf(".");
			}
			printf("#\n");
		}

		if(H > 1)
		{
			for(int i = 0; i < W; i++)
			{
			      printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2524
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    map <string,int> cnt;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        cnt[s]++;
    }
    cout<<"AC x "<<cnt["AC"]<<'\n';
    cout<<"WA x "<<cnt["WA"]<<'\n';
    cout<<"TLE x "<<cnt["TLE"]<<'\n';
    cout<<"RE x "<<cnt["RE"]<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15576
object Main extends App{

  val n = io.StdIn.readLine().toInt
  
  for (i <- 1 to n) {
    val sideAry = io.StdIn.readLine().split(' ').map { _.toInt }.sorted
    val a = sideAry(0) * sideAry(0)
    val b = sideAry(1) * sideAry(1)
    val c = sideAry(2) * sideAry(2)

    if (c == (a + b))
      println("YES")
    else
      println("NO")
  }
}

Measured memory_bytes: 45028
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
int N, answer;
pair<int, int> r[105], b[105];
bool r_[105];
int main(){
 cin >> N;
 for(int i = 0; i < N; i++)cin >> r[i].F >> r[i].S ;sort(r, r+N);
 for(int i = 0; i < N; i++)cin >> b[i].F >> b[i].S ;sort(b, b+N);

 for(int i = 0; i < N; i++){
  int k = -1;	
	for(int j = 0; j < N && r[j].F < b[i].F; j++){
	 if(!r_[j] && r[j].S < b[i].S){
		if(k < 0)k = j; 
		else if(r[k].S < r[j].S)k = j;
	 } 
	} 
	if(k >= 0){ answer++;r_[k] = true;}
 }
 cout << answer << endl;
 return 0; 
};


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

struct Team {
	int id;
	int uni;
	int solved;
	int penalty;
	bool selected;

	bool operator<(const Team& another) const {
		if(solved != another.solved) {
			return (solved > another.solved);
		}
		if (penalty != another.penalty) {
			return (penalty < another.penalty);
		}
		return id < another.id;
	}
};

int selectedCounts[1001];

int main() {
	int n;
	while(true) {
		cin >> n;
		if (n == 0) {
			break;
		}

		vector<Team> teams(n);
		for (int i = 0; i < n; i++) {
			cin >> teams[i].id >> teams[i].uni >> teams[i].solved >> teams[i].penalty;
			teams[i].selected = false;
		}

		for (int i = 0; i < 1001; i++) {
			selectedCounts[i] = 0;
		}

		sort(teams.begin(), teams.end());

		int entireSelectedCount = 0;

		for (int i = 0; i < n; i++) {
			if(entireSelectedCount < 10 && selectedCounts[teams[i].uni] < 3
					|| entireSelectedCount < 20 && selectedCounts[teams[i].uni] < 2
					|| entireSelectedCount < 26 && selectedCounts[teams[i].uni] < 1) {
				selectedCounts[teams[i].uni]++;
				entireSelectedCount++;
				cout << teams[i].id << endl;
			}
		}

	}
	return 0;
}

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

Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N, M, P;
  while(cin >>N >>M >>P && N){
    int sum = 0, h = 0;
    REP(i, N){
      int tmp; cin >>tmp;
      sum += (tmp * 100);
      if(i + 1 == M) h = tmp;
    }
    P = 100 - P;
    sum = sum * P / 100;
    cout <<(h == 0 ? 0 : sum / h) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	scanf("%2d%2d",&n,&m);
    if((n<=0||n>12)&&(m<=0||m>12)){
        cout<<"NA";
        return 0;
    }
    if(n>0&&n<=12&&m>0&&m<=12){
        cout<<"AMBIGUOUS";
        return 0;
    }
    if(n<=12&&n>0){
        cout<<"MMYY";
        return 0;
    }
    if(m<=12&&m>0){
        cout<<"YYMM";
        return 0;
    }
    return 0;
}
//.........


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
//ゲート１　１から３　ゲート２　２から４　１がゲート２が×　４はゲート１が×
void _main() {
	int A,P;
	cin >> A >> P;
	int ans = (A * 3 + P) / 2;
	cout << ans << endl;

}

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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 4;

map<int, int> M;
int n, m, d;

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

	scanf("%d", &m);
	for(int i = 0; i < m; ++i) {
		scanf("%d", &d);
		if(!M[d]) {
			return 0 * puts("NO");
		}

		--M[d];
	}

	puts("YES");
	return 0;
}


Measured memory_bytes: 9600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = numeric_limits<ll>::max();

int main(){
    int N, M;
    vector<int> A(M);
    cin >> N >> M;
    REP(i, 0, M) cin >> A[i];

    int sum = 0;
    REP(i, 0, M){
        sum += A[i];
    }
    
    if (sum>N){
        cout << -1 << endl;
    } else{
        cout << N - sum << endl;
    }

    return 0;
}


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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
// #define int long long
// --------------------------------------------------------------------------------

void test_case(int tc)
{
	int n,x,t;cin>>n>>x>>t;
	cout<<(n/x)*t+(bool)(n%x)*t;
}

int32_t main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int tc=1;
    //cin>>tc;
    for(int i=1;i<=tc;++i)test_case(tc);
}

Measured memory_bytes: 3648
#include  <cmath>
#include  <fstream>
#include  <iostream>
#include  <sstream>
#include <algorithm>
#include <stdlib.h>
#include <string>
using namespace std;

int main(void)
{
    int a, b;
    cin >> a >> b;
    string str = "";
    int min, max;
    if(a<b)
    {
        min = a;
        max = b;
    }
    else
    {
        min = b;
        max = a;
    }

    for(int i=0; i<max; i++)
    {
        str = str + to_string(min);
    }
    cout << str << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e9+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;

ll n, mod = 1000000007;
const ll MAX = 1e7 + 1;
vector<ll> v(MAX);

#define MAX_W 6000
int dp[4000][8000];

int main()
{
    int N, T;
    int w, v;
    
    cin >> N >> T;
    vector<pair<ll, ll> > pairs(N);
    
    int max_w = 0;
    rep(i, N){
        cin >> w >> v;
        pairs[i] = make_pair(w, v);
        max_w = max(max_w, w);
    }

    sort(pairs.begin(), pairs.end(), greater<pair<ll, ll> >()); 
    
    ll ww = T - 1 + max_w;
    
    int best = 0;
    for (int i = N - 1; i >= 0; i--){
        for (int j = 0; j <= T - 1/*ww*/; j++){
            w = pairs[i].first; 
            v = pairs[i].second; 
            best = max(best, v + dp[i + 1][j]);
            if (j < w){
                dp[i][j] = dp[i + 1][j];
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w] + v);
            }
        }
    }
    cout << best;
    return 0;

    //int best = 0;
    for (int t = ww; t >= T - 1; t--){
        //for (int i = 0; i < N - 1; i++){
        best = max(best,  dp[N - 1][t]);
        for (int i = N - 2; i >= 0; i--){
            w = pairs[i].first; 
            v = pairs[i].second; 
            //fprintf(stderr, "dp[%d][%d] = %d, w[i] = %d\n", i, t, dp[i][t], w[i]);
            if (t - w >= 0 && dp[i][t] == dp[i + 1][t - w] + v){
                if  (t - w <= T - 1){
                    best = max(best,  dp[i][t]);
                }
                //break;
            }
        }
    }
    cout << best;
    return 0;
}
    
#if 0
#include<bits/stdc++.h>
using namespace std;
int dp[3003][6003],n,t;
pair<int,int>a[3003];
int main(){
	cin>>n>>t;
	for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
	sort(a,a+n);
	dp[0][0]=0;
    dp[0][a[0].first]=a[0].second;
	for(int i=1;i<n;i++)
	{
	    int v = a[i].first;
	    int w = a[i].second;
		for (int j = 0; j < t; j++)
	        dp[i][j+v] = dp[i-1][j] + w;
		for(int j=0;j<6003;j++)
	        dp[i][j] = max(dp[i][j], dp[i-1][j]);
	}
	int ans=0;
	for(int i=0;i<6003;i++)ans=max(ans,dp[n-1][i]);
	cout<<ans;
}
#endif


Measured memory_bytes: 171648
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

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


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        var count0 = 0;
        var count1 = 0;
        for(int i = 0; i < s.Length; i++)
        {
            if (i % 2 == 0 && s[i] == '0')
                count1++;
            else if (i % 2 != 0 && s[i] == '0')
                count0++;
        }
        if (count1 + count0 == 0 && s.Length % 2 != 0)
            Console.WriteLine((s.Length - 1) / 2);
        else if (count0 > count1)
        {
            if (s.Length % 2 == 0)
                Console.WriteLine(s.Length / 2 - count0 + count1);
            else
                Console.WriteLine((s.Length - 1) / 2 - count0 + count1);
        }
        else
        {
            if (s.Length % 2 == 0)
                Console.WriteLine(s.Length / 2 - count1 + count0);
            else
                Console.WriteLine((s.Length + 1) / 2 - count1 + count0);
        }





        Console.Out.Flush();
    }
}

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

int main()
{
    char a;
    cin >> a;
    if(a=='A')
        cout << "T";
    else if(a=='T')
        cout << "A";
    else if(a=='C')
        cout << "G";
    else
        cout << "C";
    return 0;
}


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

using namespace std;

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *node) {
  if (node == NIL) return;
  inorder(node->left);
  printf(" %d", node->key);
  inorder(node->right);
}
void preorder(Node *node) {
  if (node == NIL) return;
  printf(" %d", node->key);
  preorder(node->left);
  preorder(node->right);
}

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

  for (int i = 0; i < n; i++) {
    string s; int key;
    cin >> s;
    if (s == "insert") {
      cin >> key;
      insert(key);
    } else if (s == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26672
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

int main(){
	init();
	ll x,a,b;cin>>x>>a>>b;
	if(abs(a-x)<abs(b-x)){
		cout<<"A"<<endl;
	}else cout<<"B"<<endl;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>G(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].pb(b);
		G[b].pb(a);
	}

	vector<int>dist(n, -1);
	queue<int>que;
	dist[0] = 0;
	que.push(0);

	while (!que.empty()) {
		int v = que.front();
		que.pop();
		for (int nv : G[v]) {
			if (dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}
	if (dist[n - 1] == 1 || dist[n - 1] == 2)print("POSSIBLE");
	else print("IMPOSSIBLE");
}

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

p1 = (int(n[0]) + int(n[1]) * 1j)
p2 = (int(n[2]) + int(n[3]) * 1j)

p3 = (p2 - p1) * 1j + p2
p4 = p3 + (p1 - p2)

print(int(p3.real), int(p3.imag), int(p4.real), int(p4.imag))

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

int main(){

  int n;

  while(cin >> n){

    int i,j,k,l;
    int ans = 0;

    for(i = 0; i < 10 ; i++){
      for(j = 0; j < 10 ; j++){
	for(k = 0 ; k < 10 ; k++){
	  for(l = 0; l < 10 ; l++){
	    if(i + j + k + l == n)
	      ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main() {
	int a, b;
	int east=1,south=0; //east東　south西
	
	cin >> a >> b;
	int i = 1;
	int j = 2;
	bool flag = true;
	while (flag) {
		south += i;
		east += j;
		//cout << south << " " << east << "\n";
		for (int k = 1; k <south ; k++) {
			if (south - k == a && east - k == b) {
				cout << k;
				flag = false;
			}
		}
		i++; j++;
	}
	return 0;
}

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

int main() {
  int n,m,ans=0;
  cin>>n>>m;
  if(m==0){
    ans = pow(10,n-1);
    if(n==1) ans=0;
    cout<<ans;
    return 0;
  }
  vector<pair<int,int>> a(m);
  for(int i=0; i<m; i++) {
    int s,c; cin>>s>>c;
    a[i]=make_pair(s,c);
  }
  sort(a.begin(),a.end());
  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){
      if(i != j && a[i].first==a[j].first && a[i].second != a[j].second) {
        cout<<-1;
        return 0;
      }
    }
  }
  if(n==3 && a[0].first!=1) ans = 100;
  if(n==2 && a[0].first!=1) ans = 10;
  for(int i=1; i<m+1; i++){
    if(a[i-1].first != a[i].first){
      int temp = pow(10,n-a[i-1].first);
      ans += a[i-1].second * temp;
    }
    if(i==m) {
      int temp = pow(10,n-a[i].first);
      ans += a[i].second * temp;
    }
  }
  int c = log10(ans)+1;
  if (n != 1 && c != n) {
    cout<<-1;
    return 0;
  }
  cout<<ans;
}

Measured memory_bytes: 512
#include <stdio.h>

int A[2000], n;

bool is_combinated(int i, int m){
  if(m == 0) return true;
  else if(m < 0  || i >= n) return false;
  bool res = is_combinated(i+1, m) || is_combinated(i+1, m-A[i]);
  return res;
}

int main(void){
  int q, m;
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);

  for(int i=0; i<q; i++){
    scanf("%d", &m);
    if(is_combinated(0, m)){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2668
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k=0,a[200]={0};
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i=i+2){
		if(a[i]%2!=0) k++;
	}
	cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
/*
using ll = long long;
using P = pair<int, int>;
*/
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; }

const int INF = 1e9;
int dp[50001];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    rep(i,m) cin >> c[i];
    rep(j,n+1) dp[j] = INF;
    dp[0] = 0;
    rep(i,m){
        rep(j,n+1){
            if(j-c[i] < 0) continue;
            chmin(dp[j], dp[j-c[i]] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3400
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
   int t;
   ll a, b, pro;
   ll sq, res = 0;
   cin>>t;
   while (t--) {
      scanf("%lld%lld", &a, &b);
      pro = a * b;
      sq = sqrt(pro);
      res = sq * 2;
       if(sq * sq == pro)
          res = res-2;
       else if((pro - 1) / sq == sq)
           res--;
       if(!(a == b))
           res--;
 		printf("%lld\n", res);
   }
}


Measured memory_bytes: 888
import sys

def main():
    input = sys.stdin.readline
    mod = pow(10,9)+7
    
    n = int(input())
    key1 = dict()
    key2 = dict()
    
    a_0 = 0
    b_0 = 0
    ab_0 = 0
    
    for i in range(n):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            ab_0 += 1
            continue
        if a == 0:
            a_0 += 1
            continue
        if b == 0:
            b_0 += 1
            continue
        k1, k2 = abs(a), abs(b)
        if k2 < k1:
            k1, k2 = k2, k1
        while k2%k1:
            k2, k1 = k1, k2%k1
        a //= k1
        b //= k1
        if a*b > 0:
            k = (abs(a), abs(b))
            if k in key1:
                key1[k] += 1
            else:
                key1[k] = 1
        else:
            k = (abs(b), abs(a))
            if k in key2:
                key2[k] += 1
            else:
                key2[k] = 1
    
    
    left = n-a_0-b_0-ab_0
    key = [(a_0, b_0)]
    for k, v in key1.items():
        if k in key2:
            v2 = key2[k]
            key.append((v, v2))
            left -= v+v2
    
    ans = pow(2, left, mod)
    for a, b in key:
        ans *= pow(2, a, mod)+pow(2, b, mod)-1
        ans %= mod
    ans += mod-1
    ans += ab_0
    ans %= mod
    
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 44524
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	d := getInts(N)

	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			ans += d[i] * d[j]
		}
	}
	out(ans)
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (n + 1) / 2;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
 
var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
 
function main(){
  var n = next();
  var ans = n * (n+1) * (n+2) / 6;
  for(var i = 1; i < n; i++){
    var u = next(), v = next();
    if(u > v){var temp = u; u = v; v = temp;}
    ans -= u * (n-v+1);
  }
  return ans;
}

Measured memory_bytes: 61488
#include <stdio.h>
#include <vector>
#include <iostream>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int N;
	cin >> N;
	vector<int> A(N+1);
	vector<int> B(N+1);
	long ans=0;
	vector<int> X(N+1);

	rep(i, N+1) cin >> A.at(i);
	rep(i, N) cin >> B.at(i);
	B.at(N) = 0;
	X.at(0) = 0;

	rep(i, N+1){
		//rep (k, N+1) printf("X: %d ", X.at(k));
		//printf("\n");
		ans += min(A.at(i), X.at(i) + B.at(i));
		if (i < N) {
			int Tem = max(B.at(i) + X.at(i) - A.at(i) , 0);	
			X.at(i+1) = min(Tem, B.at(i));
		} 
		else break;
		
	}
	//printf("M\n");
	//rep(i, N+1) printf("%d ", M.at(i));
	//printf("\n");
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

ll prim(vector<vector<pll>> &g, vvl &b) {
  ll total = 0;
  vector<bool> used(g.size(), false);
  priority_queue<pll, vector<pll>, greater<pll>> que;
  que.emplace(0, 0);
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    if (used[p.second]) continue;
    used[p.second] = true;
    total += p.first;
    for (auto &e : g[p.second]) {
      que.emplace(e.second, e.first);
    }
  }
  return total;
}

int main() {
  //
  ll n;
  cin >> n;
  vvl a(n, vl(n));
  vvl b(n, vl(n, 0));
  vector<vector<pll>> g(n);
  rep(i, n) {
    rep(j, n) {
      cin >> a[i][j];
      if (i != j) {
        g[i].emplace_back(j, a[i][j]);
      }
    }
  }
  rep(k, n) {
    rep(i, n) {
      rep(j, n) {
        if (a[i][j] > a[i][k] + a[k][j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  ll total = 0;
  rep(i, n - 1) {
    REP(j, i + 1, n) {
      ll mincost = INF;
      rep(k, n) {
        if (k != i && k != j) {
          mincost = min(mincost, a[i][k] + a[k][j]);
        }
      }
      if (mincost > a[i][j]) {
        total += a[i][j];
      }
    }
  }
  cout << total << endl;
  return 0;
}


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

const int mod = 1004535809;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int fastpow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
std::mt19937 rd(time(0) + (size_t) new char);
const int MAXN = 250010;
struct func {
	int a, b;
	func() { a = b = 0; }
	func(int x, int y) { a = x, b = y; }
	friend func operator + (func x, func y){ // x(y())
		return func(mul(x.a, y.a), ((LL) x.a * y.b + x.b) % mod);
	}
	int operator () (int x) {
		return ((LL) x * a + b) % mod;
	}
} pre[2][MAXN];
int to[256];
func fs[2][4];
int n;
char buf[MAXN];
typedef std::pair<int, int> pi;
std::map<pi, int> S;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> buf + 1;
	to['+'] = 0, to['-'] = 1, to['<'] = 2, to['>'] = 3;
	const int x1 = rd() % (mod - 1) + 1, inv1 = fastpow(x1, mod - 2);
	const int x2 = rd() % (mod - 1) + 1, inv2 = fastpow(x2, mod - 2);
	fs[0][0] = func(1, 1), fs[1][0] = func(1, 1);
	fs[0][1] = func(1, mod - 1), fs[1][1] = func(1, mod - 1);
	fs[0][2] = func(x1, 0), fs[1][2] = func(x2, 0);
	fs[0][3] = func(inv1, 0), fs[1][3] = func(inv2, 0);
	pre[0][0] = pre[1][0] = func(1, 0);
	for (int i = 1; i <= n; ++i) {
		int tar = to[buf[i]];
		pre[0][i] = pre[0][i - 1] + fs[0][tar];
		pre[1][i] = pre[1][i - 1] + fs[1][tar];
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		++S[pi((pre[0][i - 1] + pre[0][n])(0), (pre[1][i - 1] + pre[1][n])(0))];
		ans += S[pi(pre[0][i](0), pre[1][i](0))];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 35712
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		long K = long.Parse(str[1]);
		long[]A = new long[N];
		long[]B = new long[N];
		string[] str2 = Console.ReadLine().Split();
		string[] str3 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
			B[i] = long.Parse(str3[i]);
		}
		Array.Sort(A,(x,y)=>y.CompareTo(x));
		Array.Sort(B,(x,y)=>x.CompareTo(y));
		long min = 0;
		long max = 9999999999999;
		while(min<max){
			long m = (min+max)/2;
			long s = 0;
			for(var i=0;i<N;i++){
				long t = m/B[i];
				if(A[i]>t){
					s += A[i]-t;
				}
			}
			if(s>K){
				min = m+1;
			} else {
				max = m;
			}
		}
		Console.WriteLine(min);
	}
}

Measured memory_bytes: 47592
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	e := make([]float64, n)
	var max float64
	var sum float64
	for i := 0; i < n; i++ {
		var p float64
		fmt.Scan(&p)
		e[i] = (float64(1) + p) / float64(2)
		if i < k - 1 {
			sum += e[i]
		} else if i == k - 1 {
			sum += e[i]
			max = sum
		} else if i > k - 1 {
			dif := -e[i-k] + e[i]
			sum += dif
			if max < sum {
				max = sum
			}
		}
	}
	fmt.Println(max)
}


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

bool ipn(int n){//cout<<n<<endl;
  if(n == 2 || n == 3) return true;
  if(n <= 4 || n%2 == 0 || n%3 == 0) return false;
  for(int i = 6; (i-1)*(i-1) <= n; i+=6)
    if(n%(i-1) == 0 || n%(i+1) == 0) return false;
  return true;
}

int main(){
  int n, mi, ma;
  while(cin>>n, n){
    for(int i = n;;i++)
      if(ipn(i)){ma=i;break;}
    for(int i = n;;i--)
      if(ipn(i)){mi=i;break;}
    cout<<ma-n + n - mi<<endl;
  }

  return 0;
}


Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

bool ok(string s){
    int p = 0;
    int e = s.size()-1;
    while(p<e){
        if(s[p]!=s[e]) return false;
        p++;
        e--;
    }
    return true;
}


int main() {
    int a,b;cin>>a>>b;
    int ans=0;
    repsg(i,a,b+1){
        string s = to_string(i);
        if(ok(s))ans++;
    }
    cout<<ans<<endl;
    return 0;
}







Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,f=1;
    cin >> n;
    while(n>0){
        int d = n%10;
        n /= 10;
        if(d==7){
            cout << "Yes" << endl;
            f = 0;
            break;
            
        }
    }
    if(f) cout << "No" << endl;

    return 0;
}


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

int main(){
    int a[4], b[4];
    int cnt[4];
    cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
    for(int i = 0; i < 3; i++){
        cin >> a[i] >> b[i];
        if(a[i] == 1) cnt[0]++;
        else if(a[i] == 2) cnt[1]++;
        else if(a[i] == 3) cnt[2]++;
        else if(a[i] == 4) cnt[3]++;
        if(b[i] == 1) cnt[0]++;
        else if(b[i] == 2) cnt[1]++;
        else if(b[i] == 3) cnt[2]++;
        else if(b[i] == 4) cnt[3]++;
    }
    if(cnt[0] == 1 && cnt[1] == 2 && cnt[2] == 2 && cnt[3] == 1) cout << "YES" << endl;
    else if(cnt[0] == 2 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 1) cout << "YES" << endl;
    else if(cnt[0] == 1 && cnt[1] == 2 && cnt[2] == 1 && cnt[3] == 2) cout << "YES" << endl;
    else if(cnt[0] == 2 && cnt[1] == 1 && cnt[2] == 1 && cnt[3] == 2) cout << "YES" << endl;
    else if(cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 2) cout << "YES" << endl;
    else if(cnt[0] == 2 && cnt[1] == 2 && cnt[2] == 1 && cnt[3] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll nax=1e6+5, inf=1e18;

const ld PI = 3.141592653589793, eps = 1e-8;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
long double angle(long double h,long double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    long double hour_angle = 0.5 * (h * 60 + m);  
    long double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    long double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
    angle=angle*PI/180;
    return angle;  
}  
void solve(){
	ld a, b, c, d;
	cin>>a>>b>>c>>d;
	cout<<fixed<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos(angle(c,d)));
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 4188
#include<stdio.h>
int main(void)
{
	float a;
	while(scanf("%f",&a)!=EOF) {
		if(a<=48.00) {
			printf("light fly\n");
		}
		else if(a<=51.00) {
			printf("fly\n");
		}
		else if(a<=54.00) {
			printf("bantam\n");
		}
		else if(a<=57.00) {
			printf("feather\n");
		}
		else if(a<=60.00) {
			printf("light\n");
		}
		else if(a<=64.00) {
	        printf("light welter\n");
		}
		else if(a<=69.00) {
			printf("welter\n");
		}
		else if(a<=75.00) {
			printf("light middle\n");
		}
		else if(a<=81.00) {
			printf("middle\n");
		}
		else if(a<=91.00) {
			printf("light heavy\n");
		}
		else {
			printf("heavy\n");
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
   int a,b,c,x;
   cin>>a>>b>>c>>x;
   int cnt=0;
 
    for(int i=0;i<=a;i++)
   {
       for(int j=0;j<=b;j++)
       {
           for(int m=0 ;m<=c ;m++)
           {
           if(x==( 500*i + 100*j + 50*m )) cnt++;
           }
       }
   }
   cout<<cnt;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n,x=0;
	cin >> n;
	for (int i=1;i<=n;i++) {
		x+=i;
	}
	cout << x;
}



Measured memory_bytes: 256