akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
long long int iremono[100001], koware[100001];
long long int iremono2[100001], check[100001],xpo[10000001],ypo[10000001],hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;
pair<long long int, long long int>pairs[101],pointkaku[10000000];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char re;
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
bool qw = false, er = false, ty = false,ui=false;
int main() {
	cin >> a>>b;
	if (a<b) {
		cout << 0 << endl;
}
	else {
		cout << 10 << endl;
	}

}


Measured memory_bytes: 2304
N = int(input())
X = [int(i) for i in input().split(" ")]
XP2 = [i**2 for i in X]
sum_x = sum(X)
sum_xp2 = sum(XP2)

Min = 10000000000

for p in range(1,max(X)+1):
    M = sum_xp2 - 2*p*sum_x + (p**2)*N
    if  M < Min:
        Min = M
print(Min)

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

namespace Contests
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var inputs = Console.ReadLine().Split(' ').Select((x) => int.Parse(x));
            var colors = new int[8];
            int over = 0;
            int variant = 0;
            foreach (var x in inputs)
            {
                var ix = x / 400;
                if (ix > 7) over++;
                else
                {
                    if (colors[ix] == 0) variant++;
                    colors[ix]++;
                }
            }
            Console.WriteLine("{0} {1}", Math.Max(1, variant), variant + over);
        }
    }
}


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

int main() {
  int n; cin >> n;
  vector<vector<int>> alpha(n, vector<int>(26));
  for (int i = 0; i < n; i++) {
    string S; cin >> S;
    for (int j = 0; j < S.size(); j++)
      alpha[i][S[j] - 'a']++;
  }

  string ans;
  for (int i = 0; i < 26; i++) {
    int min_alpha = 51;
    for (int j = 0; j < n; j++)
      min_alpha = min(alpha[j][i], min_alpha);

    if (min_alpha)
      for (int j = 0; j < min_alpha; j++)
        ans += 'a' + i;
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
	int N, T, E, x[101];
	cin >> N >> T >> E;
	for(int i=0 ; i < N ; i++ ){
		cin >> x[i];
	}
	for(int t=T ; t <= T+E ; t++ ){
		for(int i=0 ; i < N ; i++ ){
			if( t % x[i] == 0 ){
				cout << i+1 << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 0
def main():
    MOD = 998244353
    n, k = map(int, input().split())
    L, R = [], []
    for _ in range(k):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    dp = [0] * (n + 1)
    s = [0] * (n + 1)
    dp[1] = 1
    s[1] = 1
    for i in range(2, n + 1):
        for j in range(k):
            l = max(1, i - R[j])
            r = i - L[j]
            if r < 1: continue
            dp[i] += s[r] - s[l - 1]
            dp[i] %= MOD
        s[i] = s[i - 1] + dp[i]
        s[i] %= MOD
    print(dp[n])


if __name__ == "__main__":
    main()


Measured memory_bytes: 24400
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String input = sc.nextLine();
		char[] ipt = input.toCharArray();
		char[]one = {'S' , 'S' , 'W' , 'W'};
		char[]two = {'S' , 'W' , 'S' , 'W'};
		char[]ans = new char[N+1];
		for(int i = 0 ; i<4; i++) {
			ans[0] = one[i];
			ans[1] = two[i];
			ans = getAnswer(ans, ipt);
			if(ans[ans.length-1] == ans[0]) {
				if(ans[0] == 'S') {
					if(ipt[0] == 'o') {
						if(ans[1]!=ans[ans.length-2])continue;
					}
					else {
						if(ans[1]==ans[ans.length-2])continue;
					}
				}
				else {
					if(ipt[0] == 'o') {
						if(ans[1] == ans[ans.length-2])continue;
					}
					else {
						if(ans[1] != ans[ans.length-2])continue;
					}
				}
				for(int j = 0 ; j<ans.length-1; j++) {
					System.out.print(ans[j]);
				//	if((j-1)%211 == 0)System.out.println();
				}
				System.out.println();
			//	System.out.println(ans[0]+""+ans[1]);
				return;
			}
		}
		System.out.println(-1);
	}
	
	static char[] getAnswer(char[] ans, char[] ipt) {
		for(int i = 1; i<ipt.length; i++) {
			if(ipt[i] == 'o') {
				if(ans[i] == 'S') {
					if(ans[i-1] == 'S') {
						ans[i+1]='S';
					}
					else {
						ans[i+1]='W';
					}
				}
				else {
					if(ans[i-1] == 'S') {
						ans[i+1]='W';
					}
					else {
						ans[i+1]='S';
					}
				}
			}
			else {
				if(ans[i] == 'S') {
					if(ans[i-1] == 'S') {
						ans[i+1]='W';
					}
					else {
						ans[i+1]='S';
					}
				}
				else {
					if(ans[i-1] =='S') {
						ans[i+1]='S';
					}
					else {
						ans[i+1]='W';
					}
				}
			}
		}
		return ans;
	}
}


Measured memory_bytes: 33504
import sys
import numba
from numba import njit, i8
input = sys.stdin.readline

@njit(i8(i8, i8, i8, i8), cache=True)
def floor_sum(n, m, a, b):
    ans = 0
    if a >= m:
        ans += (n-1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ans += b * (b // m)
        b %= m
    
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans

def main():
    t = int(input())
    for i in range(t):
        n, m, a, b = map(int, input().split())
        res = floor_sum(n, m, a, b)
        print(res)

    
if __name__ == "__main__":
    main()

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

#define up(i,j,k) for (int i = (j); i <= (k); i++)
#define down(i,j,k) for (int i = (j); i >= (k); i--)
#define DEBUG printf("Passing [%s] in LINE %d\n", __FUNCTION__, __LINE__)

#define lb long double
#define ll long long
#define ull unsigned long long

#define mp std::make_pair
#define pb push_back

#define all(x) (x).begin(), (x).end()
#define mem(a) memset((a), 0, sizeof(a))
#define File(x)                       \
    freopen("" #x ".in", "r", stdin); \
    freopen("" #x ".out", "w", stdout);

#define int long long

inline int read() {
    int data = 0, w = 1; char ch = 0;
    while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
    if (ch == '-') w = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); }
    return data * w;
}

inline void print (int v) {
    if (v < 0) { putchar('-'); v = -v; }
    if (v > 9) print(v / 10);
    putchar(v % 10 + '0');
}

std::multiset <std::string> s;

signed main () {
    int x, y, z;
    x = read(); y = read(); z = read();
    up (i, 1, x) s.insert("a");
    up (i, 1, y) s.insert("b");
    up (i, 1, z) s.insert("c");
    while (s.size() ^ 1) {
        auto l = *s.begin(), r = *s.rbegin();
        s.erase(s.lower_bound(l));
        s.erase(s.lower_bound(r));
        s.insert(l + r);
    }
    std::cout << *s.begin();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,i,j,count=0,flag,temp;
  scanf("%d",&N);
  int A[N];

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

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

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

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

  return 0;
}
	

  



Measured memory_bytes: 2144
use proconio::input;
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

fn main() {
    input! {
        n: usize,
        v: [i32; n]
    }

    let ans = {
        let mut ans = 0;
        for i in 0..n {
            for j in i+1..n {
                for k in j+1..n {
                    if v[i] != v[j] && v[j] != v[k] && v[k] != v[i] && v[i]+v[j] > v[k] && v[j]+v[k] > v[i] && v[k]+v[i] > v[j] {
                        ans += 1;
                    }
                } 
            }
        }
        ans
    };

    println!("{}",ans)
}


Measured memory_bytes: 2168
#include <stdio.h>
int main(void){
    int N, K, X, Y;
    
    scanf("%d %d %d %d", &N, &K, &X, &Y);
    
    if(N <= K){
        printf("%d\n", X * N);
    }else if(N > K){
        printf("%d\n", (N - K) * Y + (K * X));
    }
    
}


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

using namespace std;
typedef long long ll;

double a,b,x;

double deg(double g){
    return g * 180 / M_PI;
}

int main(){
    cin >> a >> b >> x;
    if(a*a*b/2 >= x){
        cout << fixed << setprecision(15) << 90.0 - deg(atan(2 * x / a/b/b)) << endl;
    }else{
        cout << fixed << setprecision(15) << deg(atan(2*(a*a*b-x)/a/a/a)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = float('inf')
for k in range(0, 2 * max(X, Y) + 1, 2):
    i = max(X - k // 2, 0)
    j = max(Y - k // 2, 0)
    ans = min(ans, A * i + B * j + C * k)

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#define maxn 200010
using namespace std;
int a[maxn],b[maxn],sum;
int main(){
	int n,m,k,i,j,ans;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=m;i++)scanf("%d",&b[i]);
	i=j=1;
	while(i<=n&&sum+a[i]<=k)sum+=a[i],i++;
	while(j<=m&&sum+b[j]<=k)sum+=b[j],j++;
	i--,j--;
	ans=i+j;
	while(i){
		sum-=a[i],i--;
		j++;
		while(j<=m&&sum+b[j]<=k)sum+=b[j],j++;
		j--;
		ans=max(ans,i+j);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4784
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
        return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
        return readInts()[0];
}
auto readLongs() {
        return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
        return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto n = readLong();
    foreach(i; iota(n)) {
        long a, b;
        readlnTo(a, b);
        if(a < b) {
            writeln(iota(a, b+1).map!(to!string).join(" "));
        } else {
            if(a < 6) {
                writeln(iota(b, a+1).retro.map!(to!string).join(" "));
            } else {
                if(b < 6) {
                    writeln((iota(a, 10).array ~ iota(b, 6).retro.array).map!(to!string).join(" "));
                } else {
                    writeln((iota(a, 10).array ~ iota(0L, 6).retro.array ~ iota(1, b+1).array).map!(to!string).join(" "));
                }
            }
        }
    }
}

Measured memory_bytes: 2540
import random

D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]

plus=0
minus=0
data=[[1 for i in range(D)] for j in range(26)]
ans=[0]*D
for i in range(D):
    val=-float("inf")
    type=-1
    for j in range(1,27):
        test=s[i][j-1]
        testminus=sum(c[k]*(data[k][i-1]+1) for k in range(26))
        testminus-=c[j-1]*(data[j-1][i-1]+1)
        if test-testminus>val:
            val=test-testminus
            type=j
    t=type
    ans[i]=t
    plus+=s[i][t-1]
    if i!=0:
        for j in range(26):
            data[j][i]=data[j][i-1]+1
    data[t-1][i]=0
    minus+=sum(c[j]*data[j][i] for j in range(26))

eval=plus-minus
count=2000000
check=[]
while count:
    d=random.randint(2,D)
    q=random.randint(1,26)
    if ans[d-1]==q:
        continue
    if c[ans[d-1]-1]*data[ans[d-1]-1][d-2]>c[q-1]*data[q-1][d-2] or s[d-1][q-1]>s[d-1][ans[d-1]-1]:
        testplus=plus+s[d-1][q-1]-s[d-1][ans[d-1]-1]
        testminus=minus
        pre=ans[d-1]
        #print("pre",pre)

        day=0
        for j in range(d-1,D):
            if data[q-1][j]!=0:
                if j==d-1:
                    testminus+=day*c[q-1]-data[q-1][d-1]*c[q-1]
                else:
                    testminus+=(day+1-data[q-1][j])*c[q-1]
                    day+=1
            else:
                break

        day=0
        for j in range(d-1,D):
            if j==d-1:
                if j==0:
                    day=1
                    testminus+=c[pre-1]*day
                else:
                    day=1+data[pre-1][j-1]
                    testminus+=c[pre-1]*day
            elif data[pre-1][j]!=0:
                testminus+=(day+1-data[pre-1][j])*c[pre-1]
                day+=1
            else:
                break

        if testplus-testminus>eval:
            eval=testplus-testminus
            plus=testplus
            minus=testminus
            ans[d-1]=q
            for j in range(d-1,D):
                if data[q-1][j]!=0:
                    if j==d-1:
                        data[q-1][d-1]=0
                    else:
                        data[q-1][j]=data[q-1][j-1]+1
                else:
                    break

            for j in range(d-1,D):
                if j==d-1:
                    if j==0:
                        data[pre-1][j]=1
                    else:
                        data[pre-1][j]=1+data[pre-1][j-1]
                elif data[pre-1][j]!=0:
                    data[pre-1][j]=data[pre-1][j-1]+1
                else:
                    break
    else:
        continue

    count-=1
#print(eval)
for i in range(D):
    print(ans[i])


Measured memory_bytes: 90236
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();

    long n = N / K;
    long count = n * n * n;
    if (K % 2 == 0) {
      int r = K / 2;
      n = (N + r) / K;
      count += n * n * n;
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main() {
	int a, b;
	char c;
	int x;
	double y;
	x = 0;
	y = 0;
	int z = 0;
	double i = 0;
	while (cin >> a >> c >> b){
		x += a*b;
		y += b;
		z += b;
		i++;
	}
	cout << x << endl;
	y /= i;
	z /= i;
	if (y - z >= 0.5) {
		z += 1;
	}
	cout << z <<endl;
}

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

using ll = int_fast64_t;
using pll = pair<ll,ll>;
#define rep(i,n) for(int i=0;i<(n);++i)

signed main(){

  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  for(auto&ai:a)cin>>ai;
  sort(rbegin(a),rend(a));

  auto count_hs = [&](ll v){
    ll res = 0;
    rep(i,n){
      auto itr = upper_bound(begin(a),end(a),v-a[i],greater<>());
      int j = itr-begin(a);
      res += j;
    }
    return res;
  };
  ll lef=0,req=1e10;
  while(req-lef>1){
    ll mid = lef+req>>1;
    (count_hs(mid)>m?lef:req) = mid;
  }

  vector<ll> sum(n+1);
  rep(i,n)sum[i+1]=sum[i]+a[i];

  ll ans = lef*(m-count_hs(req));
  rep(i,n){
    auto itr = upper_bound(begin(a),end(a),req-a[i],greater<>());
    ll j = itr-begin(a);
    ans += a[i]*j;
    ans += sum[j];
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 4824
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 20:56:20 2020

@author: Kanaru Sato
"""

n = int(input())
amari = n%10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if amari in hon:
    print("hon")
elif amari in pon:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61604
n = int(input())
b = list(map(int, input().split()))
if n == 2:
    print(b[0] * 2)
else:
    res = [0] * n
    res[0] = b[0]
    for i in range(n-2):
        if b[i] < b[i+1]:
            res[i+1] = b[i]
        else:
            res[i+1] = b[i+1]
    if b[-2] < b[-1]:
        res.append(b[-1])
    else:
        res.append(b[-1])
    print(sum(res))


Measured memory_bytes: 3064
n, m, x = gets.split.map(&:to_i)
books = []
sum = 10000000
flg = false
n.times do
  books << gets.split.map(&:to_i)
end
(2**n).times do |pattern|
  csum = 0
  xsum = Array.new(m, 0)
  n.times do |i|
    next if 1<<i & pattern == 0

    b = books[i]
    (1..m).each do |idx|
      xsum[idx-1] += b[idx]
    end
    csum += b[0]
  end
  if xsum.all?{ _1 >= x }
    flg = true
    sum = [sum, csum].min
  end
end
puts flg ? sum : -1

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

using namespace std;

int main() {
	int n;
	int a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		cout << a[i];
		if (i != 0) {
			cout << ' ';
		}
	}
	cout << endl;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int n,b;
  cin >> n;
  vector<int> a(n),c(n);
  int p=0;
  for (int i=0; i < n; i++){
    cin >> a[i];
  }
  for (int i=0; i < n; i++){
    cin >> b;
    p = p + b;
  }
  for (int i=0; i < n-1; i++){
    cin >> c[i];
  }
  for (int i=0; i < n-1; i++){
    if (a[i+1] - a[i] == 1){
      p = p + c[a[i]-1];
    }
  }
  cout << p << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int imu,orshi,i,j,k,l;
  scanf("%d",&imu);
  i = imu%10;
  imu = imu/10;
  j = imu%10;
  imu = imu/10;
  k = imu%10;
  imu = imu/10;
  l = imu%10;
  if(i==j || j==k || k==l) printf("Bad\n");
  else printf("Good\n");
  return 0;
}


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

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

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

  int n; cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }

  int ans = mp.size();
  int tmp = 0;
  // 最後の要素が偶数個か
  bool flag;
  for(auto e : mp) {
    flag  = false;
    int t = e.second-tmp;
    // if(t == 0) ans--;
    if(t%2 == 0){
      tmp = 1;
      flag = true;
      continue;
    }
    tmp = 0;
  }

  cout << max(1, ans-(flag ? 1 : 0)) << '\n';
  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ll long long
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 2e5+100;
const int mod = 1e9+7;
const int inf = 1e9;
const int sigma = 30;
int n, m, k, t = 1;

int dp[ms][5];
int ele[ms][3];

void solve(){
  cin>>n;
  for(int i =0; i<n; i++){
    cin>>ele[i][0]>>ele[i][1]>>ele[i][2];
    dp[i][0] = dp[i][1] = dp[i][2] = 0;
  }
  dp[0][0] = ele[0][0];
  dp[0][1] = ele[0][1];
  dp[0][2] = ele[0][2];
  for(int i = 1; i<n; i++){
    dp[i][0] = ele[i][0] + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = ele[i][1] + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = ele[i][2] + max(dp[i-1][1], dp[i-1][0]);
  }
  cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

Measured memory_bytes: 5632
use std::io::stdin;
use std::time::SystemTime;

fn main() {
    let nm: Vec<usize> = read().split(" ").map(|n| n.parse().unwrap()).collect();
    let mut vec: Vec<(usize, usize)> = vec![];
    for _ in 0..nm[0] {
        let ab: Vec<usize> = read().split(" ").map(|n| n.parse().unwrap()).collect();
        vec.push((ab[0], ab[1]));
    }
    vec.sort_by(|a, b| a.0.cmp(&b.0));
    
    let mut yen = 0;
    let mut count = 0;
    for v in vec {
        if count == nm[1] {
            break;
        }
        
        let t = nm[1] - count;
        if v.1 <= t {
            count = count + v.1;
            yen = yen + v.0 * v.1;
        } else {
            count = count + t;
            yen = yen + v.0 * t;
        }
    }
    println!("{}", yen);
}

fn read() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int h,w;
int main()
{
	cin>>h>>w;
	string s[1005];
	for(int i=0;i<h;i++)
		cin>>s[i];
	int d[1005][1005];
	queue <pair <int,int> > que ;
	for(int i=0;i<1005;i++)
		memset(d[i],-1,sizeof(d[i]));
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(s[i][j]=='#')
			{
				d[i][j]=0;
				que.push(make_pair(i,j));
			}
		}
	}
	while(!que.empty())
	{
		pair <int,int> p=que.front();
		que.pop();
		int x=p.first,y=p.second;
		for(int k=0;k<4;k++)
		{
			int vx=x+dx[k],vy=y+dy[k];
			if(vx<0 || vx>=h || vy<0 || vy>=w || d[vx][vy]!=-1)
				continue;
			d[vx][vy]=d[x][y]+1;
			que.push(make_pair(vx,vy));
		}
	}
	int ans=0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			ans=max(ans,d[i][j]);
		}
	}
	cout<<ans<<"\n";
 	return 0;
}


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

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    long long left = 0;
    for (int i = 0; i < N; i++) {
        left += A.at(i);
        sum -= A.at(i);
        if (left >= sum) {
            long long a = sum + 2 * A.at(i) - left;
            cout << min(a, left - sum) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4836
/*
** Author: MAC45
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt","wt",stdout);
    ll X, A, B;
    cin >> X;
    for (ll i = -1000; i < 1000; i++)
    {
        for (ll j = -1000; j < 1000; j++)
        {
            if (pow(i, 5) - pow(j, 5) == X)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4036
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    # > なお、ピザの組み替えにより、必要な量を超えたピザが発生しても構いません。
    val_min = 5001 * (X+Y)
    for z in range(0, 2*max(X, Y)+1, 2):
        x = max(0, X - z//2)
        y = max(0, Y - z//2) 
        val_min_cond = A*x + B*y + C*z
        #print(x,y,z,val_min_cond)
        val_min = val_min_cond if val_min_cond < val_min else val_min
    print(val_min)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()


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


int main(){
    ll n;cin>>n;
    ll p,q[200010];
    rep(i,0,n){
        cin>>p;
        p--;
        q[p]=i;
    }
    ll CN=0,cn=1;
    rep(i,0,n-1){
        if(q[i]<q[i+1])cn++;
        else {
            CN=max(CN,cn);
            cn=1;
        }
    }
    CN=max(CN,cn);
    cout<<n-CN<<endl;
    

}







Measured memory_bytes: 1920
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

typedef long long LL;

int Ans = 233;
LL N;

int F(LL x)
{
	int ret = 0;
	while (x) ++ret,x /= 10LL;
	return ret;
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> N; int Sqrt = sqrt(N);
	for (LL i = 1; i <= Sqrt; i++)
	{
		if (N % i != 0) continue;
		Ans = min(Ans,max(F(i),F(N / i)));
	}
	cout << Ans << endl;
	return 0;
}

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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int N,M,X,Y; cin >> N >> M >> X >> Y;
    REP(i,N){
        int x; cin >> x;
        X = max(X,x);
    }
    REP(i,M){
        int y; cin >> y;
        Y = min(Y,y);
    }

    if(X<Y) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 3584
program main
  implicit none
  integer(8) :: m = 10 ** 9 + 7
  integer(8) :: n, k, i, g, res
  integer(8), allocatable :: s(:), t(:)
  read *, n, k
  allocate (s(k), t(k))
  do i = 1, k
    t(i) = get_t(i)
  end do
  s(:) = t(:)
  do g = k, 1, -1
    do i = 2, k / g
      s(g) = s(g) - s(i * g)
      s(g) = modulo(s(g), m)
    end do
  end do
  res = 0
  do g = 1, k
    res = res + g * s(g)
    res = modulo(res, m)
  end do
  print "(i0)", res

  contains

  integer(8) function get_t(f)
    integer(8), intent(in) :: f
    integer(8) :: ng
    ng = k / f
    get_t = pow(ng, n)
  end function get_t

  function pow(n, p) result(res)
    integer(8), intent(in) :: n, p
    integer(8) :: res, i, imax, buf(0:63)
    imax = bit_size(p) - leadz(p) - 1
    buf(0) = modulo(n, m)
    do i = 1, imax
      buf(i) = modulo(buf(i - 1) ** 2, m)
    end do
    res = 1
    do i = 0, imax
      if (btest(p, i)) then
        res = res * buf(i)
        res = modulo(res, m)
      end if
    end do
  end function pow
end program main


Measured memory_bytes: 4272
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
#define float long double
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    
       int n;
       cin>>n;
       vector<float> a(n);
       c(a,n);
       vector<vector<float>>dp(n+1,vector<float>(n+1,0.00));
       dp[1][1]=a[0];
       dp[1][0]=1-a[0];
       for(int i=2;i<=n;i++)
       {
           for(int j=0;j<=i;j++)
            {
                if(j==0){
                    dp[i][j]=(1.00-a[i-1])*dp[i-1][j];
                    continue;
                }
                if(j==i){
                    dp[i][j]=dp[i-1][j-1]*a[i-1];
                    continue;
                }
                dp[i][j]+=(a[i-1]*dp[i-1][j-1]);
                dp[i][j]+=(dp[i-1][j]*(1.00-a[i-1]));
            }

       }       
       float ans=0.00;
       for(int i=n/2+1;i<=n;i++)
       ans+=dp[n][i];
       cout<<setprecision(10)<<ans<<lc;
    
    return 0;
}

Measured memory_bytes: 144220
//                             .
//                            .:.
//                            :|:
//                           .:|:.
//                           ::|::
//            :.             ::|::             .:
//            :|:.          .::|::.          .:|:
//            ::|:.         :::|:::         .:|:;
//            `::|:.        :::|:::        .:|::'
//             ::|::.       :::|:::       .::|:;
//             `::|::.      :::|:::      .::|::'
//              :::|::.     :::|:::     .::|::;
//              `:::|::.    :::|:::    .::|::;'
//     `::.      `:::|::.   :::|:::   .::|::;'     .:;'
//      `:::..    `;::|::.  :::|:::  .::|:::    ::::;
//        `:::::.    ':|::. :::|::: .::|:'   ,::::;'
//          `:::::.    ':|:::::|:::::|:'   :::::;'
//            `:::::.:::::|::::|::::|::::.,:::;'
//               ':::::::::|:::|:::|:::::::;:'
//                  ':::::::|::|::|:::::::''
//                       `::::::::::;'
//                      .:;'' ::: ``::.
//                           :':':
//                             ;                             

//             ,d                                                  
//             88                                                  
// ,adPPYba, MM88MMM ,adPPYba,  8b,dPPYba,   ,adPPYba, 8b,dPPYba,  
// I8[    ""   88   a8"     "8a 88P'   `"8a a8P_____88 88P'   "Y8  
//  `"Y8ba,    88   8b       d8 88       88 8PP""""""" 88          
// aa    ]8I   88,  "8a,   ,a8" 88       88 "8b,   ,aa 88          
// `"YbbdP"'   "Y888 `"YbbdP"'  88       88  `"Ybbd8"' 88  

// ++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ 
// ++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ 

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define deb(x) cerr << ">> " << #x << " : " << x << "\n" // never forget to comment out
#define endl '\n'
#define RAGE ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

const ll inf = 1e18 + 42;

const ll MAX = 1e9;

void solve()
{
	ll r;
	cin >> r;
	ld ans = 2 * PI * r;
	cout << ans << endl;
}	

int main()
{
	RAGE
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	ll t;
	//cin >> t;
	//while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
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);
  rep(i,N){
    cin >> a.at(i);
  }
  vector<int> b(N);
  rep(i,N){
    b.at(i) = a.at(i);
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());

  int key = 1;
  rep(i,N){
    if(a.at(i)!=b.at(i)){
      key = 0;
    }
  }
  if(key==1){
    cout<<1000<<endl;
  }
  else{

  long long money = 1000;
  long long kabu = 0;
  int kabuka = 100;
  int i = 0;
  auto l = unique(a.begin(),a.end());
  a.erase(l,a.end());
  N = a.size();
  while(a.at(i)>=a.at(i+1)&&i+1<N){
    i += 1;
  }
  if(i+1==N){
    cout<<1000<<endl;
  }
  else{
    kabuka = a.at(i);
    kabu = money / kabuka + kabu;
    money = money - kabu * kabuka;
    
    //cout<<i+1<<"日目に株価："<<kabuka<<"で"<<kabu<<"個買って"<<money<<"になった"<<endl;
    //底値にいったi日目に買ってスタート
    rep(j,N-i-2){
      int k = i + j + 1;
      if(a.at(k-1)<=a.at(k)&&a.at(k)>a.at(k+1)){
        kabuka = a.at(k);
        money = money + kabuka*kabu;
        //cout<<k+1<<"日目に株価："<<kabuka<<"で"<<kabu<<"個うって"<<money<<"になった"<<endl;
        kabu = 0;
      }
      else if(a.at(k-1)>=a.at(k)&&a.at(k)<a.at(k+1)){
        kabuka = a.at(k);
        kabu = money / kabuka + kabu;
        money = money - kabuka * kabu;
        //cout<<k+1<<"日目に株価："<<kabuka<<"で"<<kabu<<"個買って"<<money<<"になった"<<endl;
      }
      else{
        if(money<200&&a.at(k)<=money){
          kabuka = a.at(k);
          kabu = kabu + money / kabuka;
          money = money - kabuka * kabu;
        }
      }
    }
    if(a.at(N-2)<=a.at(N-1)){
      kabuka = a.at(N-1);
      money = money + kabu * kabuka;
      //cout<<"最終日に株価："<<kabuka<<"で"<<kabu<<"個うって"<<money<<"になった"<<endl;
      kabu = 0;
    }

    if(kabu>0){
      //cout<<"株が"<<kabu<<"個残っている"<<endl;
      int h = 0;
      while(a.at(N-1-h)<a.at(N-2-h)){
        h += 1;
      }
      kabuka = a.at(N-2-h);
      money = money + kabu * kabuka;
      
      //cout<<N-h-1<<"日目に株価："<<kabuka<<"で"<<kabu<<"個うって"<<money<<"になった"<<endl;
    }

    cout<<money<<endl;
  }
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    if((N-1)*(N-2)/2 < K){
        cout << -1 << endl;
        return 0;
    }
    else{
        int rem = (N-1)*(N-2)/2 - K;
        cout << N-1 + rem << endl;;
        REP(i,N-1){
            cout << 1 << " " << i+2 << endl;
        }
        if(rem == 0){
            return 0;
        }
        for(int i = 2; i <= N; i++){
            for(int j = i+1; j<= N; j++){
                cout << i << " " << j << endl;
                rem--;
                if(rem == 0){
                    return 0;
                }
            }
        }
    }

}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}



unsigned long long t[1000];
unsigned long long a[1000];


int main(void){
    int n;
    scanf("%d", &n);
    unsigned long long tcmn, acmn, cmn;
    for (int i = 0; i < n; i++){
        scanf("%llu %llu", &t[i], &a[i]);
    }
    for (int i = 1; i < n; i++){
        if (t[i] < t[i-1] || a[i] < a[i-1]){
            if (t[i-1]%t[i] == 0){
                tcmn = t[i-1]/t[i];
            }else{
                tcmn = t[i-1]/t[i]+1;
            }
            if (a[i-1]%a[i] == 0){
                acmn = a[i-1]/a[i];
            }else{
                acmn = a[i-1]/a[i]+1;
            }
        cmn = acmn>tcmn?acmn:tcmn;
        t[i] = cmn*t[i];
        a[i] = cmn*a[i];
        }
    }
    printf("%llu\n", a[n-1]+t[n-1]);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	String T = sc.next();
    	sc.close();
    	StringBuilder sb = new StringBuilder(S);
    	int len_T = T.length();
    	for(int i = sb.length(); i >= len_T; i--){
    		int cnt = 0;
    		for(int j = len_T; j > 0; j--){
    			int K = i-cnt;
    			if(sb.substring(K-1, K).equals(T.substring(j-1, j)) || sb.substring(K-1, K).equals("?")){
    				cnt++;
    				continue;
    			}else{
    				cnt = 0;
    				break;
    			}
    		}
			if(cnt >= len_T){
				sb.replace(i-len_T, i, T);
				String str = sb.toString();
				str = str.replaceAll(Pattern.quote("?"), "a");
				System.out.println(str);
				System.exit(0);
			}
    	}
    	System.out.println("UNRESTORABLE");
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N; cin >> N;
  int A = 0;
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    if (s == "A") {
      A++;
    } else {
      if (A==0) {
        cout << "NO" << endl;
        return 0;
      } else {
        A--;
      }
    }
  }
  if (A > 0) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}



Measured memory_bytes: 3164
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    s = S()
    print(s + ["es", "s"][s[-1] != "s"])
    return


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


Measured memory_bytes: 81212
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val x = sc.nextInt()

    val t = 2 * ((a * a * b).toDouble() - x.toDouble()) / (a * a).toDouble()
    if (t <= b) {
        val d = Math.atan(t / a.toDouble()) * 180 / Math.PI
        println(d)
    } else {
        val s = (2 * x.toDouble()) / a / b
        val d = (Math.PI / 2 - Math.atan(s / b.toDouble())) * 180 / Math.PI
        println(d)
    }
}


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

#define what_is(x) cerr << #x << " is " << x << endl;

const ll LMAX = (1LL<<61);
const int IMAX = (1<<29);
const int BIG = 104206970;
const int PRIME = 104206969;

const int N = 100001;
const int MOD = 1e9+7;
const int MAXN = 1e9;

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// cout.precision(9); cout << fixed;
	int n, k, s; cin >> n >> k >> s;
	int i = 0;
	for (; i < k; i++)
		cout << s << (i+1 == n ? '\n' : ' ');
	for (; i < n; i++)
		cout << (s == MAXN ? 1 : MAXN) << (i+1 == n ? '\n' : ' ');

	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    int a,b,c,d,e,f;
    int i1,i2,i3,i4,tot,sug;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;
    b*=100;
    tot=a;
    sug=0;
    for(i1=0;i1<=100;i1++)for(i2=0;i2<=100;i2++)for(i3=0;i3<=100;i3++)for(i4=0;i4<=100;i4++){
        int totwat=i1*a+i2*b;
        int totsug=i3*c+i4*d;
        if(totwat+totsug<=f){
            if(totsug*100<=totwat*e){
                if(sug*(totsug+totwat)<=tot*totsug){
                    sug=totsug;
                    tot=totwat+totsug;
                }
            }
        }
    }
    cout<<tot<<" "<<sug<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int num = 1;
    for(int i = 0; i < n; i++){
        if (a[i] == num){
            num++;
        }
    }
    if (num==1){
        puts("-1");
        return 0;
    }
    printf("%d\n", n - num + 1);
}

Measured memory_bytes: 896
#include<stdio.h>
int main(void)
{
	int h1,h2,k1,k2,a,b,c,d,g,m;
	scanf("%d%d%d%d%d%d%d%d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
	g=h1*a+h2*b+h1/10*c+h2/20*d;
	m=k1*a+k2*b+k1/10*c+k2/20*d;
	if(g<m)
	{
		printf("kenjiro\n");
	}
	else if(m<g)
	{
		printf("hiroshi\n");
	}
	else
	{
		printf("even\n");
	}
	return 0;
}

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

#define mp make_pair
#define repn(i, n) for(int i = 1; i < n; ++i)
#define rep(i, n) for(int i = 0; i < n; ++i)


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

    pair<pair<string, int>, int> v[n];
    rep(i, n){
        string s; int p;
        cin >> s >> p;

        v[i] = mp(mp(s, -p), i+1);
    }

    sort(v, v+n);

    rep(i, n){
        cout << v[i].second << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[])
{
  uint32_t n;
  uint32_t a, x;

  std::cin >> n;
  std::cin >> a;
  for (uint32_t i=1; i<n; ++i) {
    std::cin >> x;
    a ^= x;
  }

  if (a == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


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

int main() {
 string S;
 cin >> S;
 int n = S.size() / 2;
 for(int i=0; i<n; i++) {
   if(S[i] != S[n+1+i]) { 
    cout << "No" << endl; 
    return 0;
   }
 }
 int nn = n / 2;
 for(int i=0; i<nn; i++) {
   if(S[i] != S[n-1-i]) {
     cout << "No" << endl;
     return 0;
   }
 }
 cout << "Yes" << endl;
}

Measured memory_bytes: 3608
from sys import exit
from collections import Counter
mod = 998244353
n = int(input())
D = list(map(int, input().split()))
m = max(D)
C = Counter(D)
ans = 1
if C.get(0):
    if C[0] != 1 or D[0] != 0:
        print(0)
        exit()
else:
    print(0)
    exit()
for i in range(0, m):
    if C.get(i + 1):
        ans *= (C[i] ** C[i + 1]) % mod
        ans %= mod
    else:
        print(0)
        exit()

print(ans)

Measured memory_bytes: 24312
import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
	private static BufferedReader br = null;
	
	public static void main(String[] args) {
		String[] strs = read(3);
		int n = Integer.parseInt(strs[0]);
		String[] vs = strs[1].split(" ");
		String[] cs = strs[2].split(" ");

		int max = 0;
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(vs[i]) - Integer.parseInt(cs[i]);
			if (a > 0) {
				max += a;
			}
		}

		System.out.println(max);
	}
	
	private static String[] read(int len) {
		List<String> strList = new ArrayList<>();
		
		try {
			if (br == null) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			
			for (int i = 0; i < len; i++) {
				strList.add(br.readLine());
			}
		} catch (IOException e) {
		}
		
		return strList.toArray(new String[0]);
	}
	
	private static void close() {
		try {
			if (br != null) {
				br.close();
			}
		} catch (IOException e) {
		}
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
  int i, j, n;
  cin >> n;
  long long a[n], sum=0, b[n];
  for(i=0; i<n; i++){
    cin >> a[i];
    sum+=a[i];
  }
    for(i=0; i<n; i++)
      if(i%2==1) sum-=2*a[i];
    b[0]=sum;
    cout << b[0];
    for(i=1; i<n; i++){
      b[i]=a[i-1]*2-b[i-1];
      cout << " " << b[i];
    }
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<algorithm>

typedef long long ll;
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
def main():
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    
    total = 0
    for x in range(1, N + 1):
        if x <= K:
            total += X
        else:
            total += Y

    print(total)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	int g = 0, mx = 0, mi = 1e9;
	VI A;
	for(int i = 0; i < N; i++) {
		int a;
		scanf("%d", &a);
		A.PB(a);
		g = __gcd(g, a);
		mx = max(mx, a);
		mi = min(mi, a);
	}
	sort(ALL(A));
	for(int i = 1; i < N; i++)
		mi = min(mi, A[i] - A[i - 1]);
	if(K < mi || K > mx || K % g != 0)
		puts("IMPOSSIBLE");
	else
		puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 892