akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
double arr[MAXN];
double dp[MAXN][MAXN][2];
bool vis[MAXN][MAXN][2];
double memo(int i, int n, bool flag){
    if(i < 0) return n == 0;
    if(n < 0) return 0;
    if(vis[i][n][flag]) return dp[i][n][flag];
    vis[i][n][flag] = true;
    double res = 0;
    if(flag){
        res = (memo(i - 1, n - 1, 0) + memo(i - 1, n - 1, 1)) * arr[i];
        return dp[i][n][flag] = res;
    }
    else{
        res = (memo(i - 1, n, 0) + memo(i - 1, n, 1)) * (1 - arr[i]);
        return dp[i][n][flag] = res;
    }
}
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    double ans = 0;
    for(int i = (n + 1) / 2; i <= n; i++){
        ans += memo(n - 1, i, 0) + memo(n - 1, i, 1);
    }
    cout << fixed << setprecision(12) << ans / 2 << '\n';
}

Measured memory_bytes: 158592
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int l = in.nextInt();
        double oneLine = l/(double)3.0;
        DecimalFormat df = new DecimalFormat("0.0000000");
        System.out.println(df.format(oneLine*oneLine*oneLine));
    }
}


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

int main(){
    vector<int> A(3);
    for(int i=0;i<3;++i)cin>>A[i];
    sort(A.begin(),A.end());
    if(A[0]==A[1]&&A[1]!=A[2])puts("Yes");
    else if(A[0]!=A[1]&&A[1]==A[2])puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
X= int(input())
if 399<X and X<600:
    print(8)
if 599<X and X<800:
    print(7)
if 799<X and X<1000:
    print(6)
if 999<X and X<1200:
    print(5)
if 1199<X and X<1400:
    print(4)
if 1399<X and X<1600:
    print(3)
if 1599<X and X<1800:
    print(2)
if 1799<X and X<2000:
    print(1) 

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

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

    if(x%y==0){
        cout << -1 << endl;
        return 0;
    }
    int z=x;
    while(z<y*x){
        if(z%y!=0){
            cout<<z << endl;
            return 0;
        }
        z+=x;

    }

    cout << -1 << endl;
    return 0;


    



}


Measured memory_bytes: 3552
#include<stdio.h>
int main() {
	int N, a[1000],ans=0,i,baf;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	baf = a[0];
	for (i = 1; i < N; i++) {
		if (a[i] == baf) {
			ans++;
			baf = 10000;
		}
		else {
			baf = a[i];
		}
	}

	printf("%d\n", ans);
}

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

const int MAXN = 300000;
int cum[MAXN];

void sieve() {
    for (int i = 0; i < MAXN; i++) cum[i] = 1;
    for (int i = 2; i < MAXN; i++) {
        if (cum[i]) {
            for (int j = 2 * i; j < MAXN; j += i) {
                cum[j] = 0;
            }
        }
    }
}

int main() {
    sieve();
    for (int i = 1; i < MAXN; i++) {
        cum[i] += cum[i - 1];
    }
    int n;
    while (cin >> n, n) {
        cout << cum[2 * n] - cum[n] << endl;
    }
}


Measured memory_bytes: 4220
#include <stdio.h>

int main(){
	int time, h, m, s;
	scanf("%d", &time);
	for(h = 0; h <= 25; h++){
		if(time-h*3600 >= 0){
			continue;
		}
		else{
			time = time-(h-1)*3600;
			break;
		}
	}
	for(m = 0; m <= 61; m++){
		if(time-m*60 >= 0){
			continue;
		}
		else{
			time = time-(m-1)*60;
			break;
		}
	}
	s = time;
	printf("%d:%d:%d\n", h-1, m-1, s);
	return 0; 
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  map<string,int> m;
  int N,M;
  string s,t;

  cin >> N;
  rep(i,N) {
    cin >> s;
    m[s]++;
  }

  cin >> M;
  rep(i,M) {
    cin >> t;
    m[t]--;
  }

  int res = 0;
  for(auto x : m) {
    res = max(res, x.second);
  }

  cout << res << endl;

  return 0;
}


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

int main() {
 
  int n,k,q;
  cin >>n>>k>>q ;
  vector<int> a(q);
  vector<int> b(n);
  for (int i = 0; i <q ; i++) {
    cin>>a.at(i);
    b.at(a.at(i)-1)++;
  }
  for (int i = 0; i <n ; i++) {
    if(q-b.at(i)<k){
    cout << "Yes" << endl;
    }else{
    cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int N,num[100];
  int i,j=0,flag,res,count=0;

  scanf("%d",&N);
  
  
  for(i=0;i<N;++i){
    scanf("%d",&num[i]);
  }

  while(j!=N){
    flag=1;

    while(flag){
    flag=0;

  for(i=N-1;i>0;--i){
    if(num[i]<num[i-1]){
      res=num[i];
      num[i]=num[i-1];
      num[i-1]=res;
      ++count;
      flag=1;
    }
  }
    }
  ++j;
  }

  for(i=0;i<N;i++){
    printf("%d",num[i]);
    if(i!=N-1) printf(" ");
    else printf("\n");
  }

  printf("%d\n",count);

  return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int N;
  int ans = 0;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  REP(i,N) {
    cin >> A[i];
  }
  REP(i,N) {
    cin >> B[i];
    ans += B[i];
  }
  REP(i,N) {
    cin >> C[i];
  }
  FOR(i, 1, N) {
    if (A[i] == A[i - 1] + 1) {
      ans += C[A[i - 1] - 1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
def main():
  n = int(input())
  l = list(map(int,input().split()))
  sum=l[0]
  max=l[0]
  for i in range(1,n):
    sum+=l[i]
    if l[i]>max:
      max=l[i]
  sum-=max
  if sum>max:
    print("Yes")
  else:
    print("No")
main()

Measured memory_bytes: 9112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			x -= tmp;
			min = Math.min(min, tmp);
		}
		int ans = n + x / min;
		System.out.println(ans);
	}

}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,h,hmax,i,ans=1;
  cin >> n >> hmax;
  for (i=1;i<n;i++){
    cin >> h;
    if (h>=hmax){
      ans++;
      hmax=h;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

	string s; cin >> s;

	vector<int>c(256, 0); // ???????????????????????°

	rep(i, 0, s.size())c[s[i]]++;

	vector<int>sum(1010, 0);// ???????????°????????°

	int odd(0);
	rep(i, 0, 256){
		if (c[i] & 1)odd++;
	}
	cout << odd/2 << endl;


	return 0;
}

Measured memory_bytes: 3148
S = list(input())
n_game = len(S)
n_rest_game = 15 - n_game
n_win = 0
n_lose = 0

for s in S:
    if s == 'o':
        n_win += 1
    else:
        n_lose += 1
if 8 - n_win <= n_rest_game:
    print('YES')
else:
    print('NO')

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

int main()
{
  string abc;
  cin >> abc;

  vector<char> v(3, 'n');

  v[0] = abc[0];
  v[1] = abc[1];
  v[2] = abc[2];

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

  if (v[0] == 'a' && v[1] == 'b' && v[2] == 'c')
    cout << "Yes" << endl;
  else
    cout << "No" << endl; 


}


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

int main() {
    long N;
    cin>>N;
    vector<long> L(N);
    
    long sum=0;
    for(int i=0;i<N;i++){
        cin>>L.at(i);
        sum+=L.at(i);
    }
    
    for(int i=0;i<N;i++){
        if(2*L.at(i)>=sum){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


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

		// 入力を受け取る
		int num = scan.nextInt();
		for(int i = 0; i < num; i++) {
			sum += 1.0 / scan.nextDouble();
		}

		System.out.println(1.0 / sum);

	}
}


Measured memory_bytes: 23124
a = []
while True:
    d = list(map(int,input().split()))
    if d == [0,0]:
        break
    a.append(d)

for H,W in a:
    print('#'*W)
    for i in range(0,H-2):
        print('#'+'.'*(W-2)+'#')
    print('#'*W)
    print('')

Measured memory_bytes: 7636
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 220000;
typedef long long ll;
int n,m,k;
double a[M];
int main(){
    cin>>n>>k;
    int t;
    a[0]=0;
    double ans=0;
    fo(i,1,n) {
        cin>>t;
        double sum=(t+1)*t/2;
        sum/=t;
        a[i] = a[i-1]+sum;
        if(i>=k) {
            ans=max(ans,a[i]-a[i-k]);
        }
    }
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 1792
//This sourcecode is under GPLv3
//http://yeguanghao.xyz
#include <bits/stdc++.h>
#define rep(name,start,end,step) for(int name=start;name<=end;name+=step)
using namespace std;
#define Pn(x) printf("%d\n",x)
#define Ps(x) printf("%d ",x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define PROB
inline void R(int &x) {
	x=0; int f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
void Redirect() {
	freopen(PROB".in","r",stdin);
#ifndef YGHDEBUG
	freopen(PROB".out","w",stdout);
#endif
}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
char s[105];
string ans[105][105];
int dp[105][105];
int n;
int main() {
	R(n);
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		dp[i][i]=1;
		ans[i][i]="()";
	}
	for(int l=1;l<=n;++l) {
		for(int i=1;i<=n-l;++i) {
			int j=i+l;
			dp[i][j]=INT_MAX;
			if(s[i]=='('&&s[j]==')') {
				if(dp[i][j]>dp[i+1][j-1]) {
					dp[i][j]=dp[i+1][j-1];
					ans[i][j]="("+ans[i+1][j-1]+")";
				} else if(dp[i][j]==dp[i+1][j-1]) {
					ans[i][j]=min(ans[i][j],"("+ans[i+1][j-1]+")");				
				}
			}
			if(s[i]=='('&&s[j]!=')') {
				if(dp[i][j]>(dp[i+1][j]+1)) {
					dp[i][j]=dp[i+1][j]+1;
					ans[i][j]="("+ans[i+1][j]+")";
				} else if(dp[i][j]==(dp[i+1][j]+1)) {
					ans[i][j]=min(ans[i][j],"("+ans[i+1][j]+")");
				}
				
			}
			if(s[i]!='('&&s[j]==')') {
				if(dp[i][j]>(dp[i][j-1]+1)) {
					dp[i][j]=dp[i][j-1]+1;
					ans[i][j]="("+ans[i][j-1]+")";
				} else if(dp[i][j]==(dp[i][j-1]+1)) {
					ans[i][j]=min(ans[i][j],"("+ans[i][j-1]+")");
				}
			}
			for(int k=i;k<j;++k) {
				if(dp[i][j]>(dp[i][k]+dp[k+1][j])) {
					dp[i][j]=dp[i][k]+dp[k+1][j];
					ans[i][j]=ans[i][k]+ans[k+1][j];
				} else if(dp[i][j]==(dp[i][k]+dp[k+1][j])) {
					ans[i][j]=min(ans[i][j],ans[i][k]+ans[k+1][j]);
				}
				
			}
		}
	}
	cout<<ans[1][n]<<endl;
}



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

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a + b > c + d ? "Left" : (a + b == c + d ? "Balanced" : "Right")) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef set<int>::iterator ssii;

#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)

const int maxn = 5000 + 10;
int n, m;
int f[maxn];


int main() {
    //freopen("input.txt", "r", stdin);
    scanf("%d%d", &n, &m);

    f[0] = 1;
    _for(i, 1, n) {
        int k = min(i, n - i + 1);
        _for(j, k, n) (f[j] +=f[j-k]) %= m;
    }

    ll ans = 0;
    _for(k, 0, n) {
        ans += 1ll * (n-k) * f[k] % m;
        ans %= m;
    }
    cout << ans << endl;
}

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

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

void main()
{
    long n, m, k;
    scan(n, m, k);
    auto folows = new long[][](n, 0);
    auto blocks = new long[][](n, 0);
    foreach (i; iota(m))
    {
        long a, b;
        scan(a, b);
        folows[a - 1] ~= b - 1;
        folows[b - 1] ~= a - 1;
    }
    foreach (j; iota(k))
    {
        long c, d;
        scan(c, d);
        blocks[c - 1] ~= d - 1;
        blocks[d - 1] ~= c - 1;
    }
    // 連結成分を数える
    // メモリ足りるのか怪しい
    auto seen = new bool[](n);
    auto connect = new long[](n);
    foreach (i; iota(n))
    {
        if (seen[i])
            continue;

        // 探索済みの頂点を連想配列に記憶、最後にブロックの個数を数えて引く
        bool[long] elements;
        // BFS
        {
            auto q = DList!long(i);
            while (!q.empty())
            {
                auto p = q.front();
                seen[p] = true;
                elements[p] = true;
                q.removeFront();
                foreach (e; folows[p])
                {
                    if (!seen[e])
                    {
                        q.insertBack(e);
                        seen[e] = true;
                    }
                }
            }
        }
        auto size = elements.length;
        foreach (key, value; elements)
        {
            connect[key] = size - folows[key].length - 1;
            foreach (e; blocks[key])
            {
                if (e in elements)
                    connect[key]--;
            }
        }
    }
    foreach (e; connect)
        writef("%s ", e);
    writeln();
}

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


Measured memory_bytes: 31228
n, m = map(int, input().split())
a = [int(x) for x in input().split() ]

while m > 0 and a[0] > 0:
    a.sort(reverse=True)
    tmp = a[0] // 2
    for i in range(n):
        if a[i] > tmp and m > 0:
            a[i] //= 2
            m -= 1
        else:
            break

print(sum(a))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int a,b;
	cin>>a>>b;
	cout<<max(max(a+a-1,b+b-1),a+b);
	re 0;
}

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

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

    vector<int> a(n);
    vector<pair<int, int>> b(n);// (a[i], i)
    for(int i=0; i<n; i++){
        cin >> a[i];
        b[i] = make_pair(a[i],i);// 0-indexed (be careful)
    }
    sort(b.begin(),b.end());

    vector<pair<int, int>> ans;

    // mise en place
    if(b[0].first < 0 && b[n-1].first > 0){// make it "all non-negative" or "all non-positive"
        if(abs(b[n-1].first) >= abs(b[0].first)){
            for(int i=0; i<n; i++){
                a[i] += b[n-1].first;
                ans.push_back({b[n-1].second+1, i+1});
            }
        }
        if(abs(b[n-1].first) <  abs(b[0].first)){
            for(int i=0; i<n; i++){
                a[i] += b[0].first;
                ans.push_back({b[0].second+1, i+1});
            }
        }
    }

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

    // case(1) all non-negative
    if(a[0] >= 0){
        for(int i=1; i<n; i++){
            ans.push_back({i, i+1});// a[i] += a[i-1];
        }
    }
    // case(2) all non-positive
    if(a[0] < 0){
        for(int i=n-2; i>=0; i--){
            ans.push_back({i+2, i+1});//a[i] += a[i+1];
        }
    }

    cout << ans.size() << endl;
    for(auto x : ans){
        cout << x.first << " " 
             << x.second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <sstream>
#include <deque>
#include <cmath>

using namespace std;
using ll = long long;

int main() {

    string s, t;
    cin >> s >> t;

    if (s.length() + 1 == t.length() &&
        s == t.substr(0, s.length()))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 3640
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a = ni()
print(a+a**2+a**3)

Measured memory_bytes: 9172
N=gets.to_i
A=gets.split.map(&:to_i).sort
ok=Array.new(A[-1]+1){true}
A.each do |a|
  next unless ok[a]
  (a+a).step(A[-1], a) do |i|
    ok[i]=false
  end
end
A.each_cons(2) do |a,b|
  ok[a]=false if a==b
end
p A.count{|a|ok[a]}

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

int main(){

int h1, m1, h2, m2, k;
cin >> h1 >> m1 >> h2 >> m2 >> k;
int m1kansan, m2kansan;
m1kansan = h1*60+m1;
m2kansan = h2*60+m2;
cout << m2kansan-m1kansan-k << endl;
}


Measured memory_bytes: 3636
import sys
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[(int(i),int(a)) for i,a in enumerate(input().split())]
    A.sort(key=itemgetter(1))
    s=""
    for a in A:
        s+=str(a[0]+1)+" "
    print(s)
if __name__=='__main__':
    main()

Measured memory_bytes: 23412
## coding: UTF-8

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
lq = [list(map(int, input().split())) for _ in range(Q)]

#print(N, A, Q, lq)


ans = sum(A)
num = [i for i in range(1, 10**5+10)]
#num = [i for i in range(1, 10000)]
d = {k: 0 for k in num}
#print(d)


for i in range(N):
    d[A[i]] += 1
#print(d)


for i in range(Q):
    query = lq[i]
    start = query[0]
    goal = query[1]
    n = d[start]
    ans -= start * n
    ans += goal * n
    d[start] = 0
    d[goal] += n
    print(ans)

Measured memory_bytes: 116284
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
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 ll INF = 1LL << 60;

int main(){
	int h, w;
	cin >> h >> w;
	char a[h+2][w+2];
	for(int i = 0; i <= h+1; ++i){
		for(int j = 0; j <= w+1; ++j){
			if(i == 0 || i == h+1) a[i][j] = '#';
			else if (j == 0 || j == w+1) a[i][j] = '#';
			else cin >> a[i][j];
		}
	}
	for(int i = 0; i <= h+1; ++i){
		for(int j = 0; j <= w+1; ++j){
			cout << a[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long LL;
LL h[50+5][2]; 		//第一个倍数，第二个余数 
int main()
{
	LL sum_b=0;
	LL bushu=0; 
	LL N;
	scanf("%lld",&N);
	for(int i=0;i<N;i++) 
	{
		LL num;
		scanf("%lld",&num);
		h[i][0]=num/N;
		h[i][1]=num%N;
		sum_b+=h[i][0]; 
	} 
	while(sum_b!=0)
	{
		LL sum_a=sum_b;
		bushu+=sum_b;
		sum_b=0; 
		 for(int i=0;i<N;i++)
		{
			h[i][1]=h[i][1]+sum_a-h[i][0];
			h[i][0]=h[i][1]/N;
			h[i][1]=h[i][1]%N;
			sum_b+=h[i][0]; 
		} 
		
	} 
	printf("%lld\n",bushu); 
	return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
int cnt=1;//边的数量
int head[110],cur[110];//head记录每一个点最后一条边的编号，cur记录当前点循环到了哪一条边
int n,deep[110],s,t,start;//s设为不选，t为选，即源点和汇点
//权值为负的点向s连容量为-w的边，权值为正的点向t连容量为w的边
//这里的容量相当于是割掉这条边的代价
ll ans,tmp;
queue<int>q;//定义一个bfs寻找分层图时的队列
struct node
{
    int to,next;//to即每一条边指向的点，next指向对应点的前一条边
    ll w;//每一条边的残量
}num[25000];
void add(int start,int y,ll w)//对于所有有倍数关系的点，小的向大的连inf的边
//ans一开始为所有正权边的权值和
{
    num[++cnt].to=y;
    num[cnt].next=head[start];
    num[cnt].w=w;
    head[start]=cnt;
    num[++cnt].to=start;
    num[cnt].next=head[y];
    num[cnt].w=0;
    head[y]=cnt;
}
int bfs()
{
    memset(deep,0,sizeof(deep));//初始化深度为0
    deep[s]=1;//源点深度为1
    q.push(s);
    while(!q.empty())
    {
        int now=q.front();
        q.pop();
        for(int i=head[now];i;i=num[i].next)
        {
            if(!deep[num[i].to]&&num[i].w)//当前还未分配深度且残量不为零，则分配深度并放入队列
            {
                deep[num[i].to]=deep[now]+1;//计算深度
                q.push(num[i].to);//入队一个节点
            }
        }
    }
    return deep[t];
}
ll dfs(int start,ll minf)//当前节点，当前流量
{
    ll tmp=minf;
    if(start==t)//到达汇点直接返回前面流过来的流量
        return minf;
    for(int &i=cur[start];i&&tmp;i=num[i].next)//当前弧优化，运用指针在修改i的同时，将cur[start]顺便修改
    {
        if(deep[start]+1==deep[num[i].to]&&num[i].w)//满足分层图的性质
        {
            ll t=dfs(num[i].to,min(num[i].w,tmp));//继续找增广路
            tmp-=t;//剩余容量
            num[i].w-=t;//正向边减
            num[i^1].w+=t;//反向边加
        }
    }
    return minf-tmp;//返回最小割
}
void dinic()
{
    while(bfs())
    {
        memcpy(cur,head,sizeof(head));//每一次建立完分层图后都要把cur置为每一个点的第一条边
        while(tmp=dfs(s,inf))
            ans-=tmp;//减去最小割
    }
}

int main()
{
    scanf("%d",&n);
    s=n+1;
    t=s+1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&start);
        if(start>=0)
        {
            add(i,t,start);
            ans+=start;
        }
        else
            add(s,i,-start);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=2*i;j<=n;j+=i)
        {
            add(i,j,inf);
        }
    }
    dinic();
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

/**
 * Created by zzt on 17-1-29.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        int a;
        for (int i = 0; i < n; i++) {
            a = scanner.nextInt();
            map.computeIfPresent(a,(key, oldValue) -> oldValue+1);
            map.computeIfAbsent(a, key -> 1);
        }
        int ret = map.size();
        if (ret % 2 == 0)
            ret--;
        System.out.println(ret);
    }
}

Measured memory_bytes: 53124
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

int main()
{
	lli n;
	cin>>n;
	int arreglo[n-1][2];
	for (int i=0; i<n-1; i++)
	{
		cin>>arreglo[i][0];
	}
	
	for (int i=n-2; i>=0; i--)
	{
		if (i==n-2)
		{
			arreglo[i][1]=arreglo[i][0];
			continue;
		}
		arreglo[i][1]=min(arreglo[i][0], arreglo[i+1][0]);
	}
	lli suma=arreglo[0][0];
	for (int i=0; i<n-1; i++)
	{
		suma+=arreglo[i][1];
	}
	
	cout<<suma<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

double digsum(string k) {
    double ret = 0;
    for (int i = 0; i < int(k.size()); ++i) {
        ret += k[i] - '0';
    }
    return ret;
}

int main() {
    ll k;
    cin >> k;
    set<pair<ll, double>> snuke;
    for (int i = 1; i <= 1000 * 15; ++i) {
        int dig    = i / 1000;
        string num = to_string(i % 1000);
        if (num == "0")
            continue;
        for (int j = 0; j < dig; ++j) {
            num += "9";
        }
        snuke.emplace(stoll(num), stod(num) / digsum(num));
    }
    double curr = 1e16;
    deque<ll> ret;
    for (auto it = snuke.rbegin(); it != snuke.rend(); it = next(it)) {
        if (curr == it->second || chmin(curr, it->second))
            ret.push_front(it->first);
    }
    for (int i = 0; i < k; ++i) {
        cout << ret[i] << "\n";
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str s; cin >> s;
  ll ans = 753;
  for(ll i = 0;i < s.size() -2;i++)
  {
    str a = s.substr(i, 3);
    ll A = stoi(a);
    ans = min(ans, abs(753 - A));
  }
  fin(ans)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
N ,M = (map(int , input().split()))
shop = []
for i in range(N):
    A ,B = (map(int , input().split()))
    shop.append((A ,B))
sorted_shop = sorted(shop,key = lambda x:x[0])
drink = 0
cost = 0
for a in sorted_shop:
    drink += a[1]
    cost += a[0] * a[1]
    if drink >= M:
        break
sabun = drink - M
ans = cost - (sabun * a[0])
print(ans)

Measured memory_bytes: 18908
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
t = [0] * 41
x = 0
res = 0
for i in range(N):
  for j in range(41):
    t[j] += (a[i] & (1 << j)) > 0

tt = [[0] * 2 for _ in range(41)]
for i in range(41):
  tt[i][0] = t[i] * (1 << i)
  tt[i][1] = (N - t[i]) * (1 << i)
for i in range(40, -1, -1):
  if x + (1 << i) > K:
    res += tt[i][0]
    continue
  if tt[i][0] >= tt[i][1]:
    res += tt[i][0]
  else:
    res += tt[i][1]
    x += 1 << i
print(res)

Measured memory_bytes: 63632
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  string s;
  cin >> s;
  string q = "AKIHBR";
  REP(i,s.size()){
    bool f = false;
    REP(j,6){
      if(s[i] == q[j]){
	f = true;
      }
    }
    if(!f){
      cout << "NO" << endl;
      return 0;
    }
  }
  string t = "KIHBR";
  int g = 0,r = 0;
  if(s.size() > 9){
    cout << "NO" << endl;
    return 0;
  }
  REP(i,s.size()){
    if(s[i] == t[g]){
      if((g == 0 && r < 2) || (g == 3 && r < 2) || (g == 4 && r < 2) || (g == 1 && r == 0) || (g == 2 && r == 0)){
	g++;
	r = 0;
      }
      else{
	
	cout << "NO" << endl;
	return 0;
      }
      if(g == 5){
	rep(j,i+1,s.size()){
	  if(s[j] != 'A'){
	    cout << "NO" << endl;
	    return 0;
	  }
	}
      }
    }
    else{
      r++;
    }
  }
  if(g != 5 || (g == 5 && r > 1)){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
  g = 0;
  r = 0;/*
  REP(i,s.size()){
    if(s[i] == t[g]){

    }
    else if(s){
      r++;
    }
    }*/
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted([int(input()) for i in range(N)])

if N % 2 == 0:
    X = [-2] * ((N - 2) // 2) + [-1, 1] + [2] * ((N - 2) // 2)
    ans = sum([a * x for a, x in zip(A, X)])
    print(ans)
else:
    X1 = [-2] * ((N - 2) // 2 + 1) + [1, 1] + [2] * ((N - 2) // 2)
    X2 = [-2] * ((N - 2) // 2) + [-1, -1] + [2] * ((N - 2) // 2 + 1)
    ans1 = sum([a * x for a, x in zip(A, X1)])
    ans2 = sum([a * x for a, x in zip(A, X2)])
    print(max(ans1, ans2))


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

int main(){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int x = min(a,b);
	int y = min(c,d);
	printf("%d\n",x+y);
	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi b(n+1);
    rep1(i, n-1) b[i] = a[i] - a[i-1];
    ll ans = 1000, val = 0;
    //int last = -1;
    rep1(i, n) {
        if (b[i] > 0 && b[i-1] <= 0) {
            val += ans / a[i-1];
            ans %= a[i-1];
        }
        if (b[i] <= 0 && b[i-1] > 0) {
            ans += val * a[i-1];
            val = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

string a, b;

int num;

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

    stringstream ss;
    ss << a << b;

    ss >> num;

    if((int)sqrt(num) * (int)sqrt(num) == num)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int x, x_max = 100000;
  cin >> x;
  bool dp[x+1];
  REP(i, x+1) { dp[i] = false; }
  dp[0] = true;
  REP(i, x+1) {
    for (int j = 100; j <= 105 && i + j <= x; j++) {
      if (dp[i]) dp[i + j] = true;
    }
  }
  if (dp[x])
    cout << "1\n";
  else
    cout << "0\n";
  //DEBUGS(dp);
  return 0;
}


Measured memory_bytes: 384
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

const size_t SIZE = 50 * 50 * 50 + 10;
const ll inf = 5e15;
ll dp[SIZE];

int main() {
    ll N, W;
    cin >> N >> W;
    V<TLL> items(N);
    for(auto &&ele : items) {
        ll v, w, m;
        cin >> v >> w >> m;
        ele = TLL(v, w, m);
    }

    sort(ALL(items),
         [](TLL a, TLL b) {
             ll va, vb, wa, wb;
             tie(va, wa, ignore) = a;
             tie(vb, wb, ignore) = b;
             if(va * wb != vb * wa) return va * wb < vb * wa;
             else return wb < wa;
         });

    fill(dp + 1, dp + SIZE, inf);
    for(auto &&ele : items) {
        ll v, w, m;
        tie(v, w, m) = ele;
        ll use = min<ll>(m, 50);
        get<2>(ele) -= use;
        for(ll i = 1; use; i *= 2) {
            ll cnt = min(i, use);
            use -= cnt;
            for(ll j = SIZE - 1 - cnt * v; 0 <= j; j--) chmin(dp[j + cnt * v], dp[j] + cnt * w);
        }
    }

    reverse(ALL(items));
    ll ans = 0;

    for(ll i = 0; i < SIZE; i++) {
        if(W - dp[i] < 0) continue;
        ll rest_w = W - dp[i];
        ll tmp = i;
        for(auto &&ele : items) {
            ll v, w, m;
            tie(v, w, m) = ele;
            ll cnt = min(m, rest_w / w);
            tmp += cnt * v;
            rest_w -= cnt * w;
        }
        chmax(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}



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

int main(void)
{
    int n, m;
    std::cin >> n >> m;
    std::vector<int> hi(n);
    std::vector<bool> v(n, true);
    for (int i = 0; i < n; i++)
    {
        int h;
        std::cin >> h;
        hi.at(i) = h;
    }
    for (int i = 0; i < m; i++)
    {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;
        if (hi.at(a) > hi.at(b))
        {
            v.at(b) = false;
        }
        else if (hi.at(b) > hi.at(a))
        {
            v.at(a) = false;
        }
        else
        {
            v.at(a) = false;
            v.at(b) = false;
        }
    }
    int result = 0;
    for (const bool &x : v)
    {
        if (x)
            result++;
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 3760
score = ["e" for i in range(50)]
counter = 0
for i in range(50):
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    counter += 1
    if m == -1 or f == -1:
        score[i] = "F"
    elif m + f >= 80:
        score[i] = "A"
    elif m + f >= 65:
        score[i] = "B"
    elif m + f >= 50:
        score[i] = "C"
    elif m + f >= 30:
        if r >= 50:
            score[i] ="C"
        else:
            score[i] = "D"
    else:
        score[i] = "F"
for i in range(counter):
    print (score[i])



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define out(v) cout<<v<<"\n"

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

  int A[N], X[N];
  rep(i, N) {
    cin >> A[i];
    X[i] = 0;
  }
  if (A[0] > 0) {
    out(-1);
    return 0;
  }
  long long ans = 0;
  rep(i, N-1) {
    if (A[i+1] - A[i] > 1) {
      out(-1);
      return 0;
    }
    if (A[i] + 1 != A[i+1])
      ans += A[i];
  }
  ans += A[N-1];
  out(ans);

  return 0;
}


Measured memory_bytes: 1792
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,x,t;cin >> n >> x >> t;
    cout << (n+x-1)/x*t << endl;
    return 0;
}

Measured memory_bytes: 3624
n, m, x = map(int, input().split())
books = list(list(map(int, input().split())) for _ in range(n))

bestcost = 9999999999
for i in range(pow(2,n)):
    ability = [0]*m
    cost = 0
    num = i
    k = n-1
    while k >= 0:
        if num // pow(2,k) == 1:
            cost += books[k][0]
            for j in range(m):
                ability[j] += books[k][j+1]
            num -= pow(2,k)
        k -= 1
    
    for j in range(m):
        if ability[j] < x:
            cost = 9999999999
    bestcost = min(cost, bestcost)
    

if bestcost == 9999999999:
    print(-1)
else:
    print(bestcost)

Measured memory_bytes: 74004
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long x = long.Parse(input[2]);
        
        long ans = 0;
        ans += b/x;
        if(a>x){
        if(a%x == 0){
            ans -= (a/x)-1;
        }else{
            ans -= a/x;
        }
        }
        if(a==0){
            ans++;
        }
        WriteLine(ans);*/
        string[] inp = ReadLine().Split(' ');
        int a = int.Parse(inp[0]);
        for(int i=0;i<a;i++){
            string s = ReadLine();
            WriteLine(s);
            WriteLine(s);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) {//最大公約数
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp; 
    }
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {//最小公倍数
    return a * b / gcd(a, b);
}

int main() {
    ll sum=0;
int n,a,b,c,d;
	scanf("%d",&n);
	for(a=1;a<=n;a++)
		for(b=1;b<=n;b++)
			for(c=1;c<=n;c++)
				d=gcd(a,b),d=gcd(c,d),sum+=d;
	printf("%lld\n",sum);
	return 0;
}




Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double adeg, bdeg, ddeg;
    double pdeg;
    double ans;
    double pi;
    pi = acos(-1.0);
    adeg = 360.0/12.0*h;
    bdeg = 360.0/60.0*m;
    pdeg = 30.0/60.0*m;
    //cout << "a " << adeg << "b " << bdeg << endl;
    ddeg = abs(adeg+pdeg-bdeg)*(pi/180.0);
    /*if(ddeg >= pi ){
        ddeg = abs(ddeg-pi);
    }*/
    ans = sqrt(pow(a,2)+pow(b,2)-2.0*a*b*cos(ddeg));
    //cout << ans << endl;
    printf("%.12f\n",ans);
}




Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin >> n >> m;
    vector<ll> a(n),b(m),c(m);
    priority_queue<pair<int,int>> pq;
    for(int i=0;i<n;i++){
        cin >> a[i];
        pq.push({a[i],1});
    }
    for(int i=0;i<m;i++){
        cin >> b[i] >> c[i];
        pq.push({c[i],b[i]});
    }
    int cnt=0;
    ll sum=0;
    while(cnt<n){
        ll u=pq.top().first,v=pq.top().second;
        pq.pop();
        sum+=u*min(n-cnt,v);
        cnt+=v;
    }
    cout << sum << endl;
}

Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <vector>

std::pair<long, long> getOperands(std::vector<long> &stack) {
  long a = stack.back();
  stack.pop_back();
  long b = stack.back();
  stack.pop_back();
  return std::make_pair(a, b);
}

void add(std::vector<long> &stack) {
  auto p = getOperands(stack);
  stack.push_back(p.first + p.second);
}
void sub(std::vector<long> &stack) {
  auto p = getOperands(stack);
  stack.push_back(p.second - p.first);
}

void mul(std::vector<long> &stack) {
  auto p = getOperands(stack);
  stack.push_back(p.first * p.second);
}

int main() {
  std::string sbuf;
  std::vector<long> stack;
  while (std::cin >> sbuf) {
    if (sbuf == "+") {
      add(stack);
    } else if (sbuf == "-") {
      sub(stack);
    } else if (sbuf == "*") {
      mul(stack);
    } else {
      stack.push_back(std::stol(sbuf));
    }
  }
  std::cout << stack.back() << std::endl;
  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int cnt[999];
int main(){
for (int n=3;n--;cnt[read()]++);
int ans=0;
for (int i=1;i<=100;++i) if (cnt[i]) ++ans;
write(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX =2000007;
const int MOD = 998244353;
//

     signed main(){
         int n,k,s,t;
         cin>>n>>k>>s>>t;
         vector<int> a1(n),a2,b;
         for(int i=0;i<n;i++)cin>>a1[i];
         for(int i=17;i>=0;i--){
             if((s&(1<<i))>(t&(1<<i))){
                 cout<<0<<endl;
                 return 0;
             }
             if((s&(1<<i))<(t&(1<<i))){
                 b.push_back(i);
                 continue;
             }
             a2.clear();
             for(auto&& j:a1)if((j&(1<<i))==(s&(1<<i)))a2.push_back(((j>>(i+1))<<i)+(j%(1<<i)));
             swap(a2,a1);
         }
         int ans=0;
        int dp[a1.size()+1][k+1];
        for(int i=0;i<=a1.size();i++){
            dp[i][0]=1;
            for(int j=1;j<=k;j++)dp[i][j]=(dp[i][j-1]*(i+1-j))/j;
        }
        for(int i=0;i<=a1.size();i++)for(int j=1;j<=k;j++)dp[i][j]+=dp[i][j-1];
       
        for(int i=0;i<(1<<b.size());i++){
              int k2=1;
            for(int j=0;j<b.size();j++){
                if(i&(1<<j))k2*=(-1);
            }
           
            map<int,int>mp;
            for(auto&& j:a1)mp[j&i]++;
            for(auto&& j:mp)ans+=k2*(dp[j.second][min(k,j.second)]-1);
           
        }
        cout<<ans<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 3616
open Printf
open Scanf

let is_prime n =
  let rec loop i =
    if i * i > n then true
    else if n mod i = 0 then false
    else loop (i + 1) in
  if n = 1 then false else loop 2

let solve n =
  let rec loop i =
    if is_prime i then i
    else loop (i + 1) in
  loop n

let () =
  scanf "%d " solve |> printf "%d\n"


Measured memory_bytes: 384