akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  cin >> s;
  reverse(all(s));
  int u=0;
  ll ans=0;
  rep(i,s.size()){
    int a=s[i]-'0';
    a+=u;
    if (a==10){
      if (i==s.size()-1) ans++;
      u=1;
      continue;
    }
    if (a==5){
      if (i!=s.size()-1){
        if (s[i+1]-'0'>=5) {
          u=1;
          ans+=10-a;
          if (i==s.size()-1) ans++;
        }
        else {
          ans+=a;
          u=0;
        }
      }
      else {
        ans+=a;
        u=0;
      }
    }
    if (a>5){
      u=1;
      ans+=10-a;
      if (i==s.size()-1) ans++;
    }
    if (a<5) {
      ans+=a;
      u=0;
    }
    // cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1412
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll k,n,m,ans=0;
	cin>>k>>n>>m;
	if(k<n||n+2>=m)
	{
		cout<<k+1<<endl;
		return 0;
	}
	ans+=n;
	k-=n-1;
//	cout<<ans<<' '<<k<<endl;
	ans+=k%2;
	ans+=k/2*(m-n);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N, x;
  cin >> N;

  // ここにプログラムを追記
  for (int i = 0; i < 10; i++) {
    int a = 10;
    for (int y = i; y > 0; y--) {
      a *= 10;
    }
    x += N % a / (a / 10);
  }
  
  if (N % x == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;
int N;
int K;
long long H[200000];

int main()
{
  int i;
  long long sum;

  cin >> N >> K;
//  vector<long long> H(N);
  for (i=0; i<N; i++) {
    cin >> H[i];
  }
//  sort(H.begin(), H.end());
  sort(H, H+N);

  if (K>=N) {
    printf("0\n");
    return 0;
  }
  for (i=0, sum=0; i<N-K; i++) {
    sum += H[i];
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 1792
package main

import "fmt"

func abs(x int64) int64 {
    if x > 0 {
        return x
    }
    return -x
}

func main() {
    var n int
    fmt.Scan(&n)
    a := make([]int64, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    var ans int64 = 0
    var min_a int64 = 1000000007
    var min_i int
    for i, v := range a {
        v = abs(v)
        if min_a > v {
            min_i = i
            min_a = v
        }
    }
    for i := 0; i < min_i; i++ {
        if a[i] < 0 {
            a[i] *= -1
            a[i + 1] *= -1
        }
    }
    for i := n - 1; i > min_i; i-- {
        if a[i] < 0 {
            a[i] *= -1
            a[i - 1] *= -1
        }
    }
    for _, v := range a {
        ans += v
    }
    fmt.Println(ans)
}


Measured memory_bytes: 6656
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M,K=get_i
flag=false
(N+1).times do|x|
    (M+1).times do|y|
        if x*(M-y)+y*(N-x)==K
            flag=true
            break
        end
    end
end
puts yn_judge(flag)
 

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int V[N];
  for (int i = 0; i < N; i++) cin >> V[i];

  int L[N];
  L[0] = V[0];
  for (int i = 1; i < N; i++) L[i] = __gcd(L[i - 1], V[i]);

  int R[N];
  R[N - 1] = V[N - 1];
  for (int i = N - 2; i >= 0; i--) R[i] = __gcd(R[i + 1], V[i]);

  int ans = R[1];
  for (int i = 1; i < N - 1; i++) ans = max(ans, __gcd(L[i - 1], R[i + 1]));

  cout << max(ans, L[N - 2]) << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - v.begin();
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PI 3.14159265358979323846
using namespace std;

int N;
int A[3];
vector<int> l;

int saiki(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return INF;
        return abs(a - A[0]) + abs(b - A[1]) + abs(c - A[2]);
    }
    int res = saiki(i + 1, a, b, c);
    res = min(res, saiki(i + 1, a + l[i], b, c) + (a ? 10 : 0));
    res = min(res, saiki(i + 1, a, b + l[i], c) + (b ? 10 : 0));
    res = min(res, saiki(i + 1, a, b, c + l[i]) + (c ? 10 : 0));

    return res;
}

signed main() {
    cin >> N >> A[0] >> A[1] >> A[2];
    l.resize(N);
    REP(i, N) { cin >> l[i]; }
    //  sort(ALL(l));

    cout << saiki(0, 0, 0, 0) << endl;

    // int cnt[3];
    // REP(j, 3) {
    //     if (l[0] < A[j]) {
    //         cnt[j] = -1;
    //         continue;
    //     }
    //     REP(i, N) {
    //         if (l[i] >= A[j]) {
    //             break;
    //         }
    //         cnt[j]++;
    //     }
    // }

    // int sa[3];
    // REP(i, 3) {
    //     if (cnt[i] != N || cnt[i] == -1) {
    //         if (A[i] - l[cnt[i]] >= A[i] - l[cnt[i - 1]]) {
    //             sa[i] = A[i] - l[cnt[i]];
    //         } else {
    //             sa[i] = A[i] - l[cnt[i - 1]];
    //             cnt[i]--;
    //         }
    //     }
    // }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAXN=100001;
int n,a[MAXN],b[MAXN],c[MAXN],f[MAXN][4];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=1;i<=n;i++){
        f[i][1]=max(f[i-1][2],f[i-1][3])+a[i];
        f[i][2]=max(f[i-1][1],f[i-1][3])+b[i];
        f[i][3]=max(f[i-1][1],f[i-1][2])+c[i];
    }
    cout<<max(f[n][1],max(f[n][2],f[n][3]));
    return 0;
}

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

int main(){
    char field[3][3];
    while(cin >> field[0], field[0][0] != '0'){
        char win = ' ';
        for(int i=1; i < 3; i++){
            cin >> field[i];
        }

        if(field[0][0] == field[1][1] && field[1][1] == field[2][2] && field[0][0] != '+')win = field[0][0];

        if(field[2][0] == field[1][1] && field[1][1] == field[0][2] && field[2][0] != '+')win = field[2][0];

        for(int i=0; i < 3; i++){
            if(field[i][0] == field[i][1] && field[i][1] == field[i][2] && field[i][0] != '+')win = field[i][0];
            if(field[0][i] == field[1][i] && field[1][i] == field[2][i] && field[0][i] != '+')win = field[0][i];

        }
        if(win == ' ') cout << "NA" << endl;
        else cout << win << endl;
    }
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
const int N = 102;
int n, a[3][N], sum[3][N];
int main () {
	ios_base::sync_with_stdio (false);
	cin.tie (0);
	cout.tie (0);
	//freopen ("Problem_A_Contest_381560_Vjudge.inp", "r", stdin);
	//freopen ("Problem_A_Contest_381560_Vjudge.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			sum[i][j] = max(sum[i - 1][j], sum[i][j - 1]) + a[i][j];
		}
	}
	cout << sum[2][n];
	return 0;
}


Measured memory_bytes: 3628
n = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(n - 1):
    if i+1 == P[i]:
        ans += 1
        P[i],P[i+1] = P[i+1],P[i]
if P[n-1] == n:
    ans += 1
print(ans)


Measured memory_bytes: 14004
#include <stdio.h>

int main(void) {
	int A, B, K;
	int count, i;
	if (scanf("%d%d%d", &A, &B, &K) != 3) return 1;
	count = 0;
	for (i = A; i > 0; i--) {
		if (A % i == 0 && B % i == 0) {
			count++;
			if (count >= K) {
				printf("%d\n", i);
				return 0;
			}
		}
	}
	puts("ERROR!!!!!");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a;
  a=100*N/108;
  if(a*108/100==N){
  cout<<a<<endl;
  }
  else if((a+1)*108/100==N){
    cout<<a+1<<endl;
  }
  else{
  cout<<":("<<endl;
  }
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
using namespace std;

int main(){
    int n,b,f,r,v;
    int room[4][3][10] = {0};
    
    cin >> n;
    
    rep(i,0,n){
        cin >> b >> f >> r >> v;
        room[b-1][f-1][r-1] += v;
    }
    
    
    rep(i,0,4){
        rep(j,0,3){
            rep(k,0,10){
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if(i != 3){
            cout << "####################" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>

int n;

int judge(unsigned long long x){
	int ret = 0;
	for(int i = 0; i < n; ++i){
		ret ^= x & 1;
		x >>= 1;
	}
	return ret;
}

void ans(int n, unsigned long long a, unsigned long long b, unsigned long long fix){
	if(n == 1){
		printf("%llu %llu ", a, b);
	}else{
		for(int i = 0; i < 32; ++i){
			if(((a >> i) & 1) != ((b >> i) & 1)){
				fix |= 1llu << i;
				for(int j = 0; j < 32; ++j){
					if(i != j && !((fix >> j) & 1)){
						ans(n - 1, a, a ^ (1llu << j), fix);
						ans(n - 1, a ^ (1llu << i) ^ (1llu << j), b, fix);
						return;
					}
				}
			}
		}
	}
}

int main(){
	unsigned long long a, b;
	scanf("%d%llu%llu", &n, &a, &b);
	if(judge(a ^ b)){
		puts("YES");
		ans(n, a, b, 0);
		putchar('\n');
	}else{
		puts("NO");
	}
}


Measured memory_bytes: 896
import sys
sys.setrecursionlimit(10**6)

V, E = list(map(int, input().split()))
G = [[] for i in range(V)]

for i in range(E):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)

class LowLink:
    def main(G, V):
        LowLink.G = G
        LowLink.used = [False] * V
        LowLink.ord = [0] * V
        LowLink.low = [0] * V
        LowLink.aps = []
        LowLink.bridges = []
        n = 0
        
        for i in range(V):
            if not LowLink.used[i]: n = LowLink.dfs(i, n, -1)
            
        LowLink.aps.sort()
        LowLink.bridges.sort()
        
    def dfs(v, n, par):
        LowLink.used[v] = True
        LowLink.ord[v] = n+1
        n += 1
        LowLink.low[v] = LowLink.ord[v]
        
        is_aps = False
        chi = 0
        
        for u in LowLink.G[v]:
            if not LowLink.used[u]:
                chi += 1
                n = LowLink.dfs(u, n, v)
                LowLink.low[v] = min(LowLink.low[v], LowLink.low[u])
                if par != -1 and LowLink.ord[v] <= LowLink.low[u]: is_aps = True
                if LowLink.ord[v] < LowLink.low[u]: LowLink.bridges.append((min(v, u), max(v, u)))
                
            elif u != par:
                LowLink.low[v] = min(LowLink.low[v], LowLink.ord[u])
                
        if par == -1 and chi >= 2: is_aps = True
        if is_aps: LowLink.aps.append(v)

        return n

LowLink.main(G, V)      

for v in LowLink.aps:
    print(v)
       


Measured memory_bytes: 19476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x7fffffff;
#define mp(a,b) make_pair(a,b)
const int N=111;
int n;
int d[N][2];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&d[i][0],&d[i][1]);
	}
	bool ans=false;
	for(int i=0;i<n-2;i++){
		bool cur=true;
		for(int j=i;j<i+3;j++){
			if(d[j][0]!=d[j][1]){
				cur=false;
			}
		}
		if(cur)ans=true;
	}	
	if(ans)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3680
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

typedef pair <long long, long long> Fun;

const int maxN = 1 << 18, maxL = 33;

bool cmp(Fun& f, Fun& g)
{
	return f.ft * (g.sd + 1) > g.ft * (f.sd + 1);
}

long long dp[maxN][maxL];

void solve()
{
	int n;
	long long t;
	scanf ("%d%lld", &n, &t);
	vector <Fun> T;
	vector <long long> bonus;
	while (n--)
	{
		long long a, b;
		scanf ("%lld%lld", &a, &b);
		a == 0 ? bonus.pb(b+1) : T.pb({a, b});
	}
	
	sort(ALL(T), cmp);
	n = T.size();
	FOR(i, 1, maxL)
		dp[0][i] = t+1;
	FOR(i, 1, n+1)
	{
		long long a, b; tie(a,b) = T[i-1];
		FOR(j, 1, maxL)
		{
			dp[i][j] = dp[i-1][j];
			long long x = dp[i-1][j-1] + 1;
			dp[i][j] = min(dp[i][j], dp[i-1][j-1] + 1 + a*x+b);
		}
	}
	
	sort(ALL(bonus));
	FOR(i, 1, bonus.size())
		bonus[i] += bonus[i-1];
		
	int res = 0;
	FOR(i, 0, maxL) if (dp[n][i] <= t)
	{
		int prop = upper_bound(ALL(bonus), t-dp[n][i]) - bonus.begin();
		res = max(res, i + prop);
	}	
	printf("%d\n", res);
} 

 
int main()
{
    int t;
    t=1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}


Measured memory_bytes: 56684
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
S = input()
ans1 = 0
ans2 = 0
for i, s in enumerate(S):
    if i%2:
        ans1 += s == "0"
        ans2 += s != "0"
    else:
        ans1 += s != "0"
        ans2 += s == "0"
print(min(ans1, ans2))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            long X = in.nextLong();
            long Y = in.nextLong();

            int count = 0;
            for (; X <= Y;) {
                X <<= 1;
                count++;
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 27068
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) container.begin(), container.end()
using namespace std;
const int INF = 1e9;

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

  int able = (n % 2 == 0) ? (n / 2) : ((n+1) / 2);
  if (able >= k) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int h,w;
    while(scanf("%d %d",&h,&w) && (h != 0 || w != 0)){
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2600
N = int(input())
A = list(map(int,input().split()))+[0]
kane = 1000
kabu = 0

baibai = [] 
#1は買い時、-1は売り時、0は無視
for i in range(N):
    sa = A[i+1] -A[i]
    if sa == 0:
        baibai.append(0)
    elif sa != abs(sa):
        baibai.append(-1)
    else:
        baibai.append(1)

#最後の売り時
if 1 in baibai:
    uri = N - (baibai[::-1].index(1))
else:
    uri = -1

#baibai通りに売買(最後の売り時で打ち切り)
for j in range(N):
    if j == uri:
        kane += A[j] * kabu
        print(kane)
        exit()
    elif baibai[j] > 0:
        kabu += (kane//A[j])
        kane -= A[j] * (kane//A[j])
    elif baibai[j] < 0:
        kane += A[j] * kabu
        kabu = 0

print(kane)

Measured memory_bytes: 61828
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll N,K;
    cin>>N>>K;
    vl a(N);
    vl sum(N+1,0);
    vl b(N*N,0);
    REP(i,N) cin>>a[i];
    REP(i,N){
        sum[i+1]=sum[i]+a[i];
    }
    ll idx=0;
    REP(l,N){
        REP2(r,l+1,N+1){
            b[idx]=sum[r]-sum[l];
            idx++;
        }
    }

    vector<bool> ok(N*N,true);
    ll ans=0;
    REPD2(i,58,-1){
        ll mask=1LL<<i;
        ll cnt=0;
        REP(j,idx){
            if(!ok[j]) continue;
            if(mask&b[j]) cnt++;
        }

        if(cnt>=K){
            ans+=pow(2,i);
            REP(j,idx){
                if(!ok[j]) continue;
                if(!(mask&b[j])) ok[j]=false;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11088
a, b = (int(i) for i in input().split()) 

list=[]
 
for i in range(a):
    list.append(int(input()))

new_list = sorted(list)

sabun = None

for i in range(len(new_list)):

    bbb = new_list[i+b-1] - new_list[i]

    if sabun == None:
        sabun = bbb
        continue

    if sabun > bbb:
        sabun = bbb

    if i+b == len(new_list):
        break
    
print(sabun)

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

void solve(long long n, vector<long long> a){
	bool rev = false;
	deque<long long> d;
	REP(i,n){
		if(!rev){
			d.push_back(a[i]);
		}else{
			d.push_front(a[i]);
		}
		rev = !rev;
	}
	if(rev){
		reverse(ALL(d));
	}
	REP(i,n){
		cout<<d[i]<<" ";
	}
	cout<<endl;
}

int main(){	
	long long n;
	scanf("%lld",&n);
	vector<long long> a(n-1+1);
	for(int i = 0 ; i <= n-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(n, a);
	return 0;
}


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

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;

    ll ans = n/(a+b)*a + min(n%(a+b), a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int r = sc.nextInt();

        if (r%2 == 0)
            System.out.println("0.5");
        else
            System.out.println ( ( (r/2)+1 )/(float)r );
    }
}


Measured memory_bytes: 35956
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

alias lread = () => readln.chomp.to!long;
alias aryread = () => readln.split.to!(long[]);

void main()
{
    auto ab = aryread();
    (((ab[0] * ab[1]) % 2 == 0) ? "No" : "Yes").writeln;
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A <= 5)
    {
        cout << 0 << endl;
    }
    else if (A <= 12)
    {
        cout << B / 2 << endl;
    }
    else
    {
        cout << B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FF first.first
#define FS first.second
#define S  second
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>PP;
PP p[100001];
int main(void){
	int n,m;
	int i;
	int cnt;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>p[i].FF>>p[i].FS;
		p[i].S=i;
	}
	sort(p+1,p+m+1);
	cnt=1;
	for(i=1;i<=m;i++){
		if(p[i].FF!=p[i-1].FF&&i>1)	cnt=1;
		p[i].FS=cnt;
		cnt++;
	}
	for(i=1;i<=m;i++){
		swap(p[i].FF,p[i].S);
	}
	sort(p+1,p+m+1);
	for(i=1;i<=m;i++){
		printf("%06d",p[i].S);
		printf("%06d\n",p[i].FS);
	}
	return 0;
}


Measured memory_bytes: 2688
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  int p[h][w];
  int count = 0;
  int d[h][w];
  string s;
  for(int i=0;i<h;i++){
    cin >> s;
    for(int j=0;j<w;j++){
      d[i][j] = -1;
      if(s[j] == '.'){
        count += 1;
        p[i][j] = 1;
      }
      else{
        p[i][j] = 0;
      }
    }
  }
  queue<pair<int,int> > q;
  q.push(make_pair(0,0));
  d[0][0] = 0;
  while(!q.empty()){
    pair<int,int> now;
    now = q.front();
    q.pop();
    int x,y;
    x = now.first;
    y = now.second;
    if(-1 < x-1){
      if(d[x-1][y] == -1 && p[x-1][y] == 1){
        d[x-1][y] = d[x][y]+1;
        q.push(make_pair(x-1,y));
      }
    }
    if(-1 < y-1){
      if(d[x][y-1] == -1 && p[x][y-1] == 1){
        d[x][y-1] = d[x][y]+1;
        q.push(make_pair(x,y-1));
      }
    }
    if(x+1 < h){
      if(d[x+1][y] == -1 && p[x+1][y] == 1){
        d[x+1][y] = d[x][y]+1;
        q.push(make_pair(x+1,y));
      }
    }
    if(y+1 < w){
      if(d[x][y+1] == -1 && p[x][y+1] == 1){
        d[x][y+1] = d[x][y]+1;
        q.push(make_pair(x,y+1));
      }
    }
  }
  if(d[h-1][w-1] == -1) cout << -1 << endl;
  else cout << count - d[h-1][w-1]-1 << endl;


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	ll N,cnt=1,ans=0;
	vector<ll> A(100010);
	cin >> N;
	REP(i,N) cin >> A[i];
	sort(A.begin(), A.end());
  	reverse(A.begin(), A.end());
	REP(i,N-1){
      	if(A[i]!=0){
			if(A[i]==A[i+1]) cnt++;
			else{
				if(cnt%2!=0) ans++;
				cnt=1;
			}
        }else break;
	}
	if(cnt%2!=0) ans++;
	cout << ans << endl;
	
	return 0;
}

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

#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200) cout << "red" << endl;
	else cout << s << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
import time
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    S = 0
    X = 0
    r = 0
    for l in range(N):
        while r != N and S + A[r] == X ^ A[r]:
            S += A[r]
            X ^= A[r]
            r += 1
        ans += r - l
        S -= A[l]
        X ^= A[l]

    return ans


def main():
    N = read_int()
    A = read_int_n()

    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27124
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    w = input()
    c = Counter(w)

    def judge():
        for key, val in c.items():
            if val % 2 == 1:
                return False

        return True

    if judge():
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

bitset<4000010> bit;
ll A[2000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;

	ll asum = 0;
	bit[0] = 1;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		asum += A[i];
		bit |= bit << A[i];
	}

	ll ans = asum;
	for(int i = asum; i >= (asum + 1) / 2; i--){
		if(bit[i]) ans = i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        String a = sc.next();
        String s = sc.next();
        String c = sc.next();
        
        char d = s.charAt(0);
        
        System.out.println("A" + d + "C");
    }
}

Measured memory_bytes: 20688
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n,q;
  cin >> n >> q;
  vector<bool> check(n);
  vector<int> wronger(n);


  int correct = 0,wrong = 0;
  while(q--)
  {
    int p;
    cin >> p;
    p--;
    string s;
    cin >> s;

    if(check[p]) continue;

    if(s == "AC") 
    {
      check[p] = true;
      correct++;
    }
    else
    {
      wronger[p]++;
    }
  }

  for(int i=0;i<n;i++) if(check[i]) wrong += wronger[i];
  cout << correct << " " << wrong << endl; 
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

#define max 100000

int parent(int i){
  i/=2;
  return i;
}
int left(int i){
  i*=2;
  return i;
}
int right(int i){
  i=2*i+1;
  return i;
}

int main(){
  int h, i, a[max+1];
  scanf("%d",&h);
  for(i=1 ; i<=h ; i++){
    scanf("%d",&a[i]);
  }
  for(i=1 ; i<=h ; i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(parent(i)>=1)printf("parent key = %d, ",a[parent(i)]);
    if(left(i)<=h)printf("left key = %d, ",a[left(i)]);
    if(right(i)<=h)printf("right key = %d, ",a[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int M1,D1,M2,D2;
    cin>>M1>>D1>>M2>>D2;
    if(M1!=M2) cout<<1<<endl;
    else cout<<0<<endl;
}

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

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


alpha = 'abcdefghijklmnopqrstuvwxyz'
s = input()
print(alpha[alpha.index(s)+1])


Measured memory_bytes: 38384
#include <iostream>
#include <unordered_set>
#include <algorithm>

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

using namespace std;

int n;
unordered_set<string> s;

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	rep(i, n){
		string c, d;
		cin >> c >> d;
		if(c == "insert"){
			s.insert(d);
		}
		else{
			cout << (s.find(d) != s.end() ? "yes" : "no") << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 28932
#include "iostream"

using namespace std;

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

	int tmp = 0;
	int ans = 0;
	for (int i = 1; i < 10; i++) {
		for (int k = 0; k < 10; k++) {
			for (int l = 0; l < 10; l++) {
				tmp = i * 10000 + k * 1000 + l * 100 + k * 10 + i;
				if (tmp >= a && tmp <= b) ans++;
			}
		}
	}

	cout << ans << endl;
}

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

int main(){
    int K,ans = 0,r,a,b,c,d,tmp;
    cin>>K;
    for(int i=1;i<=K;i++){
        for (int j=1;j<=K;j++){
            a = i;
            b = j;
            if(a<b){
              tmp = a;
              a = b;
              b = tmp;
            }
            r = a%b;
            while(r!=0){
              a = b;
              b = r;
              r = a % b;
            }
            for(int k=1;k<=K;k++){
                d = b;
                c = k;
                if(c<d){
                  tmp = c;
                  c = d;
                  d = tmp;
                }
                r = c%d;
                while(r!=0){
                  c = d;
                  d = r;
                  r = c % d;
                }
                ans += d;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<iostream>

int main(void){
    int l, r;
    std::cin >> l >> r;
    if(r >= 2019 + l){
        r = 2019 + l;
    }
    int min = 2018;
    for(int i = l; i <= r; i++){
        for(int j = i+1; j <= r; j++){
            int cur = (i % 2019) * (j % 2019);
            cur %= 2019;
            min = std::min(cur, min);
        }
    }
    std::cout << min << std::endl;

    return 0;
}

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

int a[5000];
int n,k,q;

int main(){
	scanf("%d%d%d",&n,&k,&q);
	rep(i,n)scanf("%d",&a[i]);
	int Min=INT_MAX;
	rep(i,n){
		vector<vector<int>>v{{}};
		rep(j,n){
			if(a[j]>=a[i]){
				v.back().push_back(a[j]);
			}
			else{
				v.push_back({});
			}
		}
		vector<int>a;
		for(auto&u:v){
			sort(u.begin(),u.end(),greater<>());
			while(u.size()>=k){
				a.push_back(u.back());
				u.pop_back();
			}
		}
		sort(a.begin(),a.end());
		if(a.size()>=q)Min=min(Min,a[q-1]-a[0]);
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt k;
	std::cin >> k;
	lnt x=7;
	rep(i,1000005) {
		if(x%k==0) {
			print(i+1);
			return 0;
		}
		x*=10;
		x+=7;
		x%=k;
	}
	print(-1);
}


Measured memory_bytes: 3608
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 210000;

ll a[N];
ll b[N];

int n;

ll get(int x) {
	x %= n;
	if (x < 0)
		x += n;
	return b[x];
}

void no() {
	cout << -1 << "\n";
	exit(0);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i)
		if (a[i] > b[i])
			no();
	set<pair<ll, int>> ss;
	for (int i = 0; i < n; ++i)
		if (a[i] != b[i])
			ss.emplace(b[i], i);
	ll ans = 0;
	while (!ss.empty()) {
		int x = ss.rbegin()->second;
		ss.erase({b[x], x});
		ll g = get(x - 1) + get(x + 1);
		ll cnt = (b[x] - a[x]) / g;
		if (cnt == 0)
			no();
		ans += cnt;
		b[x] -= cnt * g;
		if (b[x] != a[x]) {
			ss.emplace(b[x], x);
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

using pt = complex<ld>;
const int N = 60;
int n, k;
ld x[N], y[N], c[N];

vector<pt> cxc(pt c1, ld r1, pt c2, ld r2) {
  ld dq = norm(c1-c2), rq=r1*r1-r2*r2;
  pt c = (c1+c2)+(c2-c1)*rq/dq; c*=.5;
  ld dt=2*dq*(r1*r1+r2*r2)-dq*dq-rq*rq;
  if (dt < -EPS) return {};
  if (dt < EPS) return {c};
  dt=sqrt(dt)/2/dq;
  pt d = (c2-c1)*pt(0,1)*dt;
  return {c+d, c-d};
}

bool poss(ld t) {
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      auto pts = cxc({x[i], y[i]}, t/c[i], {x[j], y[j]}, t/c[j]);
      for (pt p : pts) {
        int cnt = 0;
        for (int l = 0; l < n; ++l) {
          pt o = {x[l], y[l]};
          ld d = abs(o-p);
          if (d - EPS < t/c[l]) {
            cnt++;
            if (cnt >= k) return true;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    pt p(x[i], y[i]);
    int cnt = 0;
    for (int l = 0; l < n; ++l) {
      pt o = {x[l], y[l]};
      ld d = abs(o-p);
      if (d - EPS < t/c[l]) {
        cnt++;
        if (cnt >= k) return true;
      }
    }
  }
  return false;
}

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> c[i];
  }
  ld lo = 0, hi = 1e10;
  while (abs(hi - lo) > EPS) {
    ld mid = (lo+hi)/2;
    if (poss(mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << hi << nl;

  return 0;
}



Measured memory_bytes: 640
#include<iostream>

int main(){
	int A, B, C, D;
	int sum = 0;
	std::cin >> A >> B >> C >> D;

	if(A < B){
		sum += A;
	}else{
		sum += B;
	}

	if(C < D){
		sum += C;
	}else{
		sum += D;
	}

	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n,x,t;  cin >> n >> x >> t;
    if(n <= x)  cout << t << endl;
    else if(n%x == 0)   cout << t*(n/x) << endl;
    else        cout << t*(n/x+1)   << endl;
}


Measured memory_bytes: 3632
n = gets.chomp.to_i
a = []
n.times do |i|
    a[i] = gets.chomp
end
a.sort!
max_s = []
max = 0
cnt = 0
max_cnt = 0
if a.uniq.size == a.size 
    puts a
    exit
end
for i in 0..(n-1)
    if a[i] == a[i+1]
        cnt += 1
    else  
        if cnt > max
            max_s = max_s.clear
            max_cnt = 0
            max_s[max_cnt] = a[i]
            max = cnt
        elsif cnt == max && max != 0
            max_cnt += 1
            max_s[max_cnt] = a[i]
        end
        cnt = 0
    end
end
puts max_s

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

int main(void)
{
    string S;
    string T;

    cin >> S >> T;

    int count = 0;

    for (int i=0; i < S.length(); i++){
        if(S[i] != T[i]) count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 3920
#include<cstdio>

using namespace std;

int a[105];

int main()
{
	int n,d,x;
	int ans=0;
	scanf("%d%d%d",&n,&d,&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		ans+=1+((d-1)/a[i]);
	}
	printf("%d",ans+x);
	return 0;
}

Measured memory_bytes: 128
import math
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

count = 0
for i in range(n - 1):
    for j in range(i+1, n):
        dis = 0
        for k in range(d):
            dis += (x[i][k] - x[j][k]) ** 2
        dis = math.sqrt(dis)
        if dis.is_integer():
            count += 1

print(count)


Measured memory_bytes: 3064
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n = sc.read();
    let mut a: Vec<usize> = sc.read_vec(n);
    a.sort();
    let mut used = vec![false; n];
    let mut ans = 0;
    for i in (0..31).rev() {
        let pow = 1 << i;
        let mut head = 0;
        let mut tail = n - 1;
        while head < tail {
            while head < tail && used[head] {
                head += 1;
            }
            while head < tail && (used[tail] || pow < a[head] + a[tail]) {
                tail -= 1;
            }
            if a[head] + a[tail] == pow && head < tail {
                used[head] = true;
                used[tail] = true;
                ans += 1;
            }
            head += 1;
        }
    }

    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

int main()
{
	int cnt = 0;
	vector<int> v(3);

	cin >> v[0] >> v[1] >> v[2];

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

	while (v[0] != v[2]) {
		if (v[2] > v[1]) {
			++v[1];
			++v[0];
		} else if (v[2] == v[1]) {
			v[0] += 2;
		}
		sort(v.begin(), v.end());
		++cnt;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

enum Direction {R, L, U, D};

bool input(int b[])
{
	char dummy;
	for (int i=0; i<5; i++) {
		if ( !(cin >> b[i]) ) return false;
		if (i<4) cin >> dummy;
	}
	return true;
}

void sort5(int a[])
{
	for (int i=0; i<5; i++) {
		for (int j=4; j>i; j--) {
			if (a[j-1] > a[j]) {
				int tmp = a[j];	a[j] = a[j-1]; a[j-1] = tmp;
			}
		}
	}
}

int main()
{
	int hand[5];
	while ( input(hand) ) {
		sort5(hand);
		if ( hand[0] == hand[3] || hand[1] == hand[4] ) {
			cout << "four card";
		} else if ( (hand[0] == hand[2] && hand[3] == hand[4]) || (hand[0] == hand[1] && hand[2] == hand[4]) ) {
			cout << "full house";
		} else if ( hand[0] + 1 == hand[1] && hand[1] + 1 == hand[2] && hand[2] + 1 == hand[3] && hand[3] + 1 == hand[4] ) {
			cout << "straight";
		} else if ( hand[0] == 1 && hand[1] == 10 && hand[2] == 11 && hand[3] == 12 && hand[4] == 13 ) {
			cout << "straight";
		} else if ( hand[0] == hand[2] || hand[1] == hand[3] || hand[2] == hand[4] ) {
			cout << "three card";
		} else if ( hand[0] == hand[1] && hand[2] == hand[3] || hand[0] == hand[1] && hand[3] == hand[4] || hand[1] == hand[2] && hand[3] == hand[4] ) {
			cout << "two pair";
		} else if ( hand[0] == hand[1] || hand[1] == hand[2] || hand[2] == hand[3] || hand[3] == hand[4]) {
			cout << "one pair";
		} else cout << "null";
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3080
#include <math.h>
#include <stdio.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int main() {
	long long n, k, min;
	scanf("%lld%lld", &n, &k);
	printf("%lld\n", MIN(MIN(llabs(n - n / k * k), llabs(n - (n / k - 1) * k)),
						 llabs(n - (n / k + 1) * k)));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(void) {

  string s1, s2, s3;

  cin >> s1 >> s2 >> s3;

  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;

  return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];

  int max = *max_element(l.begin(), l.end());
  int sum_others = accumulate(l.begin(), l.end(), 0) - max;
  cout << (max < sum_others ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));

  vector<int> ba(n, 0);  // 各 b[i] について自分より真に小さい a が何個あるか
  vector<int> bc(n, 0);  // 各 b[i] について自分より真に大きい c が何個あるか

  rep(i, n) {
    auto itr = lower_bound(ALL(a), b[i]);
    if (itr == a.begin()) continue;
    int idx = itr - a.begin();
    ba[i] = idx;
  }

  rep(i, n) {
    auto itr = upper_bound(ALL(c), b[i]);
    if (itr == c.end()) break;
    int idx = itr - c.begin();
    bc[i] = n - idx;
  }

  ll ans = 0;

  rep(i, n) {
    ans += ll(ba[i]) * ll(bc[i]);
  }

  cout << ans << endl;

  return 0;
}


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

int main(void){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int N;
    cin >> N;
    int arr[N];
    float sum = 0;
    for(int i = 0; i < N; i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sum /= N;
    sum = round(sum);
    int stam = 0;
    for(int i = 0; i < N; i++){
        stam += (sum-arr[i])*(sum-arr[i]);
    }
    cout << stam;
    return 0;
}

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

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	int A[100100];
	cin >> N;
	int count = 0;
	ll sum = 0;
	int key = INF;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] < 0)count++;
		sum += abs(A[i]);
		key = min(key, abs(A[i]));
	}
	if (count % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - 2 * key << endl;
	}
	return 0;
}



Measured memory_bytes: 640