akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int N, K;
int a[105];
bool f[100005];

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}

int main() {
	N = Rd(), K = Rd();
	for(int i = 1; i <= N; ++i)
		a[i] = Rd();
	int nex;
	for(int i = 0; i <= K; ++i) {
		if(!f[i]) {
			for(int j = 1; j <= N; ++j) {
				nex = i + a[j];
				if(nex <= K) f[nex] = true;
			}
		}
	}
	puts(f[K] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,P;
    cin >> N >> P;
    int ans = 0;
    ans = N*3+P;
    
    cout << ans/2 << endl;
}

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

#define range 100005
#define mod 1000000007
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;


int a[500];

int dp[500][500];

int summi[500][500];

int titu[500];

void dfrec(int l,int r)
{
	if(l>r)
		return;
	if(r-l==1)
		return;
	for(int i=l;i<r;i++)
	{
		if(dp[l][i]==eps)
		  dfrec(l,i);
		if(dp[i+1][r]==eps)
		  dfrec(i+1,r);
		//cout<<"l = "<<l<<"i = "<<i<<"r = "<<r<<endl;
		dp[l][r] = min(dp[l][r],dp[l][i] + dp[i+1][r] + summi[l][i] + summi[i+1][r]);
		//cout<<"dp[i][l] + dp[i+1][r] + summi[i][l] + summi[i+1][r] = "<<dp[i][l] + dp[i+1][r] + summi[i][l] + summi[i+1][r]<<endl;
		//cout<<dp[l][r]<<endl;
	}
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			dp[i][j] = eps;
	for(int i=1;i<n;i++)
		dp[i][i+1] = a[i] + a[i+1];
	for(int i=1;i<=n;i++)
		dp[i][i] = 0;
	for(int i=1;i<=n;i++)
		titu[i]+=(titu[i-1] + a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			summi[i][j] = titu[j] - titu[i-1];
	dfrec(1,n);
	/*for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cout<<"dp["<<i<<"]["<<j<<"] = "<<dp[i][j]<<"  ";
		cout<<endl;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cout<<"summi["<<i<<"]["<<j<<"] = "<<summi[i][j]<<"  ";
		cout<<endl;
	}*/
	cout<<dp[1][n];
	return 0;
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1+a2+a3 >=22) cout << "bust";
  else cout << "win";

}

Measured memory_bytes: 256
x, y = map(int, input().split())

ans = 0

if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000

if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

if x == 1 and y == 1:
    ans += 400000

print(ans)


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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define RFOR(i, a, b) for (int (i) = (b) - 1; (i) >= (a); (i)--)

#define SORT(v, n) sort(v, v + n)
#define VSORT(v) sort(v.begin(), v.end())
#define REVERSE(v, n) reverse(v, v + n)
#define SIZE(v) (sizeof(v) / sizeof(v[0]))
#define ALLCOUNT(v, n, x) count(v, v + n, x)

#define PUT(x)  cout << #x << ": " << x << endl
#define ll long long

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

using namespace std;

int main(){
    int count = 0;
    int n, t; cin >> n >> t;
    long minnum = 2000000000, mincou = 0, maxnum = 0, maxcou = 0, maxdif = 1;
    bool f = false;
    for(int i = 0; i < n; i++) {
        f = false;
        int a = 0;
        cin >> a;
        if(a < minnum) {
            minnum = a;
            mincou = 1;
            maxnum = 0;
            maxcou = 0;
            f = true;
        }
        if(a < minnum) mincou++;
        if(a > maxnum) {
            maxnum = a;
            maxcou = 1;
            f = true;
        }
        if(a > maxnum) maxcou++;
        if(maxnum - minnum > maxdif) {
            maxdif = maxnum - minnum;
            count = 0;
        }
        if(maxnum - minnum == maxdif && f) {
            count += max(mincou, maxcou);
            // cout << maxnum << " " << minnum << endl;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
class Jobs
   attr_accessor :time, :dead
end

s = gets.to_i
jobs = []

for i in 0..s-1 do
  job= Jobs.new
  m = gets.chomp.split(" ")
  job.time = m[0].to_i
  job.dead = m[1].to_i
  jobs.push(job)
end

jobs.sort! do |a, b|
  (a.dead <=> b.dead) ||
    (a.time <=> a.time)
end
endtime =  jobs.map { |a| a.time.to_i }
deadtime = jobs.map { |b| b.dead.to_i }

sumtime = 0
res = "Yes"
for j in 0..s-1 do
  sumtime = sumtime + endtime[j] 
  if sumtime.to_i > deadtime[j].to_i
    res = "No"
  end
end
puts res

Measured memory_bytes: 21980
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < (N); X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ceilint(A, B) ((A) + (B - 1)) / (B)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

int main(){

    int n,k;
    cin >> n >> k;

    vector<int> a;

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.pback(tmp);
    }

    //k=1としたときの転倒数

    ll basic = 0;

    rep(i,n - 1){
        for(int j = i + 1; j < n; j++){
            if(a[i]>a[j]) basic = (basic + 1) % MODN;
        }
    }

    sort(ALL(a));
    ll combi = 0;

    rep(i,n - 1){
        for(int j = i + 1; j < n; j++){
            if(a[i] < a[j]) combi = (combi + 1) % MODN;
        }
    }

    ll modk = (k % MODN);
    ll ans = (basic * modk) % MODN;
    

    //ll tmp1 = (combi * (combi - 1) / 2) % MODN;
    ll tmp2 = (modk * (modk - 1) / 2) % MODN;
    combi = (combi * tmp2) % MODN;

    ans = (ans + combi) % MODN;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N ,M,L= map(int,input().split())
if N+M+L > 21:
    print("bust")
else:
    print("win")

Measured memory_bytes: 67052
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	value, _ := strconv.Atoi(sc.Text())
	return value
}
func calc_preI(I int, K int) int {
	tmp := math.Log2(float64((K + I - 1) / I))
	if tmp-float64(int(tmp)) > 0 {
		return int(tmp + 1)
	} else {
		return int(tmp)
	}
}
func main() {
	sc.Split(bufio.ScanWords)
	N := scanInt()
	K := scanInt()
	answer := 0.0
	for i := 0; i < N; i++ {
		answer += math.Pow(0.5, float64(calc_preI(i+1, K))) / float64(N)
	}
	fmt.Printf("%1.10f", answer)
}

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

int main(void){
    string w, t;
    int count = 0;
    cin >> w;

    while(1){
        cin >> t;
        if(t == "END_OF_TEXT") break;
        for(int i = 0; i < t.size(); i++){
            if(isupper(t[i])) t[i] = t[i] + 'a' - 'A'; 
        }
        if(t == w) count++;
    }   
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n,a[100005],f=1,d[100005],s=0;
	memset(d,0,sizeof(d));
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int k;
	for(k=1;k<n;k++)
	{
		if(a[k]!=a[k-1])break;
	}
	if(k==n)s++;
	for(int i=1,j;i<n;i++)
	{
		if(a[i]>a[i-1]){
			s++;
			for(j=i;j<n;j++)
				if(a[j]<a[j-1])break;
			i=j;
			//printf("** %d\n",j);
			if(j+1==n)s++;
		}
		else if(a[i]<a[i-1]){
			s++;
			for(j=i;j<n;j++)
				if(a[j]>a[j-1])break;
			i=j;
			//printf("*** %d\n",j);
			if(j+1==n)s++;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
  int n;
  bool ok = false;
  int ans;
  cin >> n;
  rep(i,10){
    rep(j,10){
      int a = 100*n+10*i+j;
      if(a%108==0){
        ans = a/108;
        ok = true;
      }
      if(ok) break;
    }
    if(ok) break;
  }
  if(ans == 0) cout << ":(" <<endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
all = [[] for _ in range(N)]
for i in range(N):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        all[i].append([x, y])

max_val = 0
for i in range(2 ** N):
    check = True
    for j in range(N):
        if i >> j & 1 == 1:
            for x, y in all[j]:
                if i >> (x-1) & 1 != y:
                    check = False
                    break
    if check == True:
        max_val = max(max_val, bin(i)[2:].count('1'))
print(max_val)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



signed main(){
  int a, b, c;
  scanf("%lld%lld%lld",&a, &b, &c);
  int d = min(b, c);
  int ans = d*2;
  b -= d;c -= d;
  
  d = min(a, c);
  ans += d;c -= d;
  if(c)ans++;
  printf("%lld\n", ans+b);
  return 0;
}






Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(c<=a+b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<double> exp(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        exp[i] = double(1 + p[i]) / 2.0;
    }
    for (int i = 1; i < n; ++i) {
        exp[i] += exp[i - 1];
    }
    double ret = exp[k - 1];
    for (int i = k; i < n; ++i) {
        chmax(ret, exp[i] - exp[i - k]);
    }
    cout << fixed << setprecision(10) << ret << "\n";
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();
		int e = 0;
		int o = 0;
		for(int i = 0; i < N; i++) {
			if(A[i] % 2 == 0) {
				e++;
			}else {
				o++;
			}
		}
		if(o % 2 == 1) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}

	}
}

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

typedef long long ll;

int main()
{
    ll x;
    cin >> x;
    ll quo = x/11;
    ll spare = x%11;
    ll add;
    if(x <= 6){
        cout << 1 << endl;
    }else{
        if(spare == 0){
            add = 0;
        }else if(spare <= 6){
            add = 1;
        }else{
            add = 2;
        }
        cout << 2*quo + add << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for l in itertools.combinations(L, 3):
        l = list(l)
        l.sort()
        if l[0]!=l[1] and l[1]!=l[2] and l[2]!=l[0]:
            if l[2] < l[0]+l[1]:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68236
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
typedef pair <int,int> ii;
int n,m;
vector <int> adj[100002];
int vis[100002][3];
queue <ii> q;
void bfs(int s, int c) {
    q.push(ii(s,0));
    vis[s][0]=0;
    while (!q.empty()) {
        ii u=q.front();
        q.pop();
        for (int i:adj[u.x]) {
            if (!vis[i][(u.y+1)%3]) {
                q.push(ii(i,(u.y+1)%3));
                vis[i][(u.y+1)%3]=vis[u.x][u.y]+1;
            }
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int s,t;
    cin >> n >> m;
    for (int i=0; i<m;i++) {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
    }
    cin >> s >> t;
    bfs(s,0);
    if (vis[t][0]) cout << vis[t][0]/3;
        else cout << -1;
}


Measured memory_bytes: 11372
class Node():
    def __init__(self, parent = -1, left = -1, right = -1):
        self.parent = parent
        self.left = left
        self.right = right

def postorder(ns, i, post):
    if ns[i].left != -1:
        postorder(ns, ns[i].left, post)
    if ns[i].right != -1:
        postorder(ns, ns[i].right, post)
    post.append(str(i + 1))

def poio_node(ns, po, io):
    p = po[0]
    i = io.index(p)
    if i != 0:
        ns[p].left = po[1]
        ns[po[1]].parent = p
        poio_node(ns, po[1:i + 1], io[:i])
    if i != len(io) -1:
        ns[p].right = po[i + 1]
        ns[po[1 + i]].parent = p
        poio_node(ns, po[i + 1:], io[i + 1:])

def min1(n):
    return n - 1
    
n = int(input())
po = list(map(int, input().split()))
io = list(map(int, input().split()))
po = list(map(min1, po))
io = list(map(min1, io))
ns = [Node() for i in range(n)]

poio_node(ns, po, io)

post = []
postorder(ns, po[0], post)
print(" ".join(post))


Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{
    double a, b, h, m;
    double kaku1, kaku2, kaku, r;
        cin >> a >> b >> h >> m;
        
    kaku1 =(double)(60*h+m) / 360;
    kaku2 = (double)m / 30;
    
    kaku = abs(kaku1-kaku2);

    
    
        r = a * a + b * b - 2 * a * b * cos( kaku * MATHPI );
        r = sqrt(r);
 
 
        cout << fixed << setprecision(18) << r << endl;
}

Measured memory_bytes: 4220
#include <cstdio>
#include <cmath>

double theta = M_PI/3.0;

void koch(double *left, double *right, int m){
	if (m==0){
		std::printf("%f %f\n", left[0], left[1]);
	}
	else{
		double s[2], u[2], t[2];

		s[0] = (2*left[0] + right[0])/3.0;
		s[1] = (2*left[1] + right[1])/3.0;


		t[0] = (left[0] + 2*right[0])/3.0;
		t[1] = (left[1] + 2*right[1])/3.0;
		
		u[0] = std::cos(theta)*(t[0]-s[0]) - std::sin(theta)*(t[1]-s[1]) + s[0];
		u[1] = std::sin(theta)*(t[0]-s[0]) + std::cos(theta)*(t[1]-s[1]) + s[1];

		koch(left, s, m-1);
		koch(s, u, m-1);
		koch(u, t, m-1);
		koch(t, right, m-1);
	}
}

int main(){
	int n, i;
	double left[2], right[2];
	left[0]=0.;
	left[1]=0.;

	right[0]=100.0;
	right[1]=0.0;

	std::scanf("%d", &n);
	
	koch(left, right, n);
	std::printf("%f %f\n", right[0], right[1]);
	return 0;
}

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

int main() {
	int a, b;
	char op;

	while (1) {	
		cin >> a >> op >> b;
		if (op == '?')break;

		switch (op) {
		case'+':cout << a + b << endl;
			break;
		case'-':cout << a - b << endl;
			break;
		case'*':cout << a * b << endl;
			break;
		case'/':cout << a / b << endl;
			break;
		}
		}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)
#define mod 1000000007

int main()
{
    int s;
    cin >> s;
    vector<ll> ans(s+1, 1);
    ans[1] = 0;
    ans[2] = 0;
    reps(i, 6, s+1){
        reps(j, 3, i+1-3){
            ans[i] = (ans[i] + ans[j]) % mod;
        }
    }
    cout << ans[s] << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int X[201010],H[201010];
ll buf[201010];

int main() {
    int N,D,A;
    cin>>N>>D>>A;
    rep(i,N) cin>>X[i]>>H[i];

    D*=2;
    vector<pair<int,int>> xh;
    rep(i,N) xh.push_back({X[i],H[i]});
    sort(all(xh));

    ll ans=0;
    int R=0;
    rep(L,N){
        if(L) buf[L]+=buf[L-1];

        int x=xh[L].first;
        int h=xh[L].second;

        if(buf[L]<h){
            R=max(R,L+1);
            while(R<N && xh[R].first-x<=D) R++;
            ll d=h-buf[L];
            ll cnt=(d+A-1)/A;
            buf[L]+=cnt*A;
            buf[R]-=cnt*A;
            ans+=cnt;
        }
    }

    cout<<ans<<endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N;
	int t[105], v[105]={}, s[105]={};

	cin >> N;
	rep(i,N) cin >> t[i];
	rep(i,N) cin >> v[i];
	rep(i,N) s[i+1] = s[i] + t[i];

	int vt[500008]={}, cur=0, pos=0;
	rep(i,s[N]){
		if( s[pos+1] <= i ) pos++;
		if( v[pos] > cur ){
			vt[i*2+1] = cur*2 + 1;
			cur++;
		}else{
			chmin(cur, v[pos]);
			vt[i*2+1] = cur*2;
		}
		vt[i*2+2] = cur*2;
	}
	cur = 0;
	chmin(vt[s[N]*2], 0);
	rrep(i,s[N]){
		if( s[pos] > i ) pos--;
		if( v[pos] > cur ){
			chmin(vt[i*2+1], cur*2 + 1);
			cur++;
		}else{
			chmin(cur, v[pos]);
			chmin(vt[i*2+1], cur*2);
		}
		chmin(vt[i*2], cur*2);
	}
	//rep(i,s[N]*2+5) cout << i << ": " << vt[i] << endl;

	double ans=0;
	rep(i,s[N]*2) ans += (double)(vt[i] + vt[i+1]) / 8.0;

	printf("%.9f\n", ans);

	return 0;
}

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

using ll = long long int;
using vi = vector<int>;
using vii = vector<vi>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
  ll n;
  scanf("%lld", &n);
  ll ans = 2 * (n / 11);
  n %= 11;
  if(n > 0){
    ans++;
    if(n > 6) ans++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - αlphabet
 * 英大文字か英小文字のいずれか 1 文字 α が入力されます。
 * α が英大文字なら A、英小文字なら a と出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        String a = sc.next();

        System.out.println( Character.isUpperCase( a.charAt( 0 ) ) ? "A" : "a" );

        sc.close();
    }
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
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)) //最小値

int main(){
    string S;
    cin>>S;
    REP(i,3){
        if(S[i]=='1') cout<<9;
        else cout<<1;
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	
	unsigned long long int A,B,C,sum, mem;
	
	cin>>A>>B>>C;
	for(int i=1;;i++){
		sum+=A;
		if (i == 1){
			mem = A%B;
		}
		if(C==sum%B){
			//cout<<i <<endl;
			cout<<"YES"<<endl;
			break;
		}
	    if(mem==sum%B && i != 1){
	    	//cout<<i <<endl;
			 cout<<"NO"<<endl;
			 break;
		}
	}
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
   
  int main() {
    int a;
    cin >> a;
    int s, r;
    s = a/100;
    r = a%100;
    s+=r/10;
    r = r%10;
    
    cout << s+r << endl;
    return 0;
  }


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

MOD = 10 ** 9 + 7

m = 4 ** (n-1) % MOD

c.sort(reverse=True)

ans = 0
for i in range(n):
    ans = (ans + c[i] * (i+2) * m) % MOD

print(ans)

Measured memory_bytes: 27108
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int prime[1000100];


void primek(void) {
	prime[0] = 1;
	prime[1] = 1;
	for (int i = 2; i < 10000; i++) {
		int j = 2;
		while (i * j <= 100000) {
			prime[i*j] = 1;
			j++;
		}
	}
}

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

	primek();
	int N; cin >> N;


	int output[N];

	vector<int> p;
	rep(i, 1000000) {
		if (!prime[i]) p.push_back(i);
	}
	int i = 0;
	int K = N;
	while (N--) {
		while (p[i] % 10 != 3) i++;
		output[K - N - 1] = p[i];
		i++;
	}

	rep(i, K - 1) cout << output[i] << " ";
	cout << output[K - 1] << endl;



    return 0;
}


Measured memory_bytes: 6384
long B[3<<17],a,r,I;h[2<<17],i,j;s(i){for(r=0;i;i-=i&-i)r=fmax(r,B[i]);}main(n){for(scanf("%d",&n);i<n;)scanf("%d",h+i++);for(;~scanf("%d",&a);)for(s(I=h[j++]);I<3<<17;I+=I&-I)B[I]=fmax(B[I],a+r);printf("%ld",r,s(n));}

Measured memory_bytes: 3840
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	ll a; cin >> a;
	string s; cin >> s;
	int k = s[0] - '0';
	k = k * 10 + s[2] - '0';
	k = k * 10 + s[3] - '0';
	cout << a * k / 100 << endl;
	return 0;
}

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

int main(){
    string s;
    int l;
    cin >> s;
    l=s.size();
    int k=0;
    rep(i,l/2){
        if (s[i]!=s[l-i-1]){
            ++k;
        }
    }
    cout << k << 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 = int64_t;
using pint = pair<int, int>;

int main()
{
    int a;
    cin>>a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main(){
  double r;
  cin >> r;
  // cout << 2*M_PI*r << " " << M_PI*r*r << endl;
  printf("%lf %lf\n",M_PI*r*r,2*M_PI*r);

return 0;

}

Measured memory_bytes: 1236
g = {
    1 => 0,
    2 => 2,
    3 => 0,
    4 => 1,
    5 => 0,
    6 => 1,
    7 => 0,
    8 => 0,
    9 => 1,
    10 => 0,
    11 => 1,
    12 => 0,
}

x, y = gets.split.map(&:to_i)
puts g[x] == g[y] ? 'Yes' : 'No'

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

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

    int n;
    cin >> n;

    map<int, bool> mp;
    REP(i, n){
        int a;
        cin >> a;
        if(mp[a]) mp[a] = false;
        else mp[a] = true;
    }

    int ans = 0;
    for(auto x : mp){
        if(x.second) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
s = input()
flag = True
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            pass
        else:
            flag = False
            break
    elif i%2 == 1:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
            pass
        else:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

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

int main(){
  int n;
  cin>>n;
  vector<int> num(n);
  for(int &x:num){
	cin>>x;
  }
  sort(num.begin(),num.end());
  int sum=0;
  for(int i=0;i<n-1;i++){
    sum+=num.at(i+1)-num.at(i);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	int N;
	string ST;
	S(N);
	cin >> ST;
	int r = 0, g = 0, b = 0;
	R(i, N) {
		if (ST[i] == 'R') r++;
		else if (ST[i] == 'G') g++;
		else b++;
	}
	ll all = (ll)r * g * b;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			if (ST[i] != ST[j]) {
				if (j + (j - i) <= N - 1) {
					if (ST[j + (j - i)] != ST[i] && ST[j + (j - i)] != ST[j]) all--;
				}
			}
		}
	}
	PL(all);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	vector<ll> x(m), dif(m - 1);
	for (int i = 0; i < m; ++i) { cin >> x[i]; }
	sort(x.begin(), x.end());
	for (int i = 0; i < m - 1; ++i) { dif[i] = x[i + 1] - x[i]; }
	sort(dif.begin(), dif.end());
	ll ans = 0;
	ll t   = m - n;
	for (int i = 0; i < t; ++i) { ans += dif[i]; }
	dump(ans);
}

Measured memory_bytes: 1792
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main(){
	int n;
	ll c;  cin >> n >> c;
	int mm = 1;
	while(mm < n+1) mm*=2;
	vector<ll> da(mm+1, 1100000);
	rip(i,n,0) cin >> da[i+1];
	vector<int> BIT(mm+1, 1);
	vector<ll> dp(mm+1, LLONG_MAX/2);
	dp[1] = 0;
	auto power = [](ll x){return x*x;};
	auto score = [&](int x, int y){return dp[y] + power(da[x]-da[y]);};
	auto update = [&](int x) {
		int now  = 0, look = mm;
		while(look){
			look /= 2;
			// cout << now << endl;
			int tmp = now + look;
			if(score(tmp, BIT[tmp]) >= score(tmp, x)){
				BIT[tmp] = x;
			}
			else now += look;
		}
	};
	auto minu = [&](int x){
		ll ret = LLONG_MAX/2;
		int tmp = x;
		while(tmp > 0){
			chmin(ret, score(x, BIT[tmp]));
			tmp -= tmp & -tmp;
		}
		return ret;
	};
	rip(i,n+1,2){
		dp[i] = minu(i) + c;
		update(i);
		// vdeb(dp);
		// vdeb(BIT);

	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 5376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		if(b == 1) {
			System.out.println(0);
			return;
		}
		if(b <= a) {
			System.out.println(1);
			return;
		}
		
		b = b - a;
		a = a - 1;
		if(b % a == 0) {
			System.out.println(b/a + 1);
		}else {
			System.out.println(b/a + 2);
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21076
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

  UnionFind tree(n);

  vector<vector<int>> info(n);
  int a,b;
  rep1(i, m){
    cin >> a >> b;
    //zero base
    tree.unite(a-1, b-1);
  }

  vector<int> result(n);
  rep1(i, n){
    result[i] = tree.root(i);
  }
  

  sort(result.begin(), result.end());
  int max = 0;
  for(int l = 0; l < n;){
    int r = 1;
    for(; r + l < n && result[l] == result[l+r]; r++){};
    if(max < r){
      max = r;
    }
    l += r;
    r = 0;
  }
  cout << max;
    
  
  
}

Measured memory_bytes: 34340
#include<bits/stdc++.h>
using namespace std;
int main()
{
   // ifstream cin("input.in");
   // ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long N,M,X,Y;
    bool S1[200009]={0},S2[200009]={0};
    cin>>N>>M;
    while(M--)
    {
        cin>>X>>Y;
        if(X==1 && Y==N)
        {
            cout<<"POSSIBLE\n";
            return 0;
        }
        if(X==N && Y==1)
        {
            cout<<"POSSIBLE\n";
            return 0;
        }
        if(X==1)
            S1[Y]=1;
        if(Y==1)
            S1[X]=1;
        if(X==N)
            S2[Y]=1;
        if(Y==N)
            S2[X]=1;
    }
    for(long i=1;i<=200000;i++)
            if(S1[i] && S2[i])
            {
                cout<<"POSSIBLE\n";
                return 0;
            }
    cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 640
use std::io::stdin;
use std::io::BufRead;

fn enough(hs: &[usize], a: usize, b: usize, count: usize) -> bool{
    let mut attack = 0;
    // 最大ダメージはb * count + a * a_i
    // ただし Sum(a_i) <= count
    // min a_i = (hs[i] - b * count) / (a - b) (+ 1 割り切れなかったら)
    for &h in hs{
        if h < b * count{
            continue;
        }
        else{
            attack += (h - b * count) / (a - b);
            if (h - b * count) % (a - b) != 0{
                attack += 1;
            }
        }
    }
    attack <= count
}

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let n;
    let a;
    let b;
    {
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        let mut it = buf.split(' ').map(|s| s.trim().parse::<usize>().unwrap());
        n = it.next().unwrap();
        a = it.next().unwrap();
        b = it.next().unwrap();
    }

    let hs = {
        let mut hs = Vec::with_capacity(n);
        for line in stdin.lines(){
            hs.push(line.unwrap().parse::<usize>().unwrap());
        }
        hs
    };
    let mut left = 0;
    let mut right = std::usize::MAX / 2;

    while left < right{
        let mid = (left + right) / 2;
        if enough(&hs, a, b, mid){
            right = mid;
        }
        else{
            left = mid + 1;
        }
    }
    println!("{}",left);
}


Measured memory_bytes: 4476
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int N_MAX = 100000;

int N, C, K;
int T[N_MAX];

void solve() {
  sort(T, T + N);
  int ans = 0;
  for(int i = 0; i < N;) {
    int s = T[i];
    int n = 0;
    while (i < N && T[i] <= s + K && n < C) {
      i++; n++;
    }
    ans++;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d%d", &N, &C, &K);
  REP(i, N) scanf("%d", T + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 512
/*
y = x*xの0 <= x <= 600の積分
ただし横幅dが600の約数の長方形の和で考えるため、精度は低い
*/

#include <iostream>
using namespace std;

int main(void) {
    int d;
    int square;
    
    while(cin >> d) {
        square = 0;
        for(int i = 0; i < 600; i += d) {
            square += (i * i) * d;
        }
        cout << square << endl;
    }
}


Measured memory_bytes: 2992
fun main(args: Array<String>) {
    val (k, s) = readLine()!!.split(" ").map { it.toInt() }

    var ans = 0
    for (x in 0..k) {
        for (y in 0..k) {
            if (s - x - y in 0..k) {
                ans++
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 35992
S = input()
od = [0, 0]
ev = [0, 0]
for i, s in enumerate(S):
    if i % 2 == 0:
        if s == '0':
            ev[0] += 1
        else:
            ev[1] += 1        
    else:
        if s == '0':
            od[0] += 1
        else:
            od[1] += 1
print(min(od[0]+ev[1], od[1]+ev[0]))

Measured memory_bytes: 3188
H, W, K = list(map(int, input().split()))
c = []
for _ in range(H):
    c.append( input() )
count = 0
for h_pattern in range( 2**H ):
    for w_pattern in range( 2**W ):
        black_count = 0
        for h in range(H):
            for w in range(W):
                if (h_pattern>>h)&1 and (w_pattern>>w)&1 and c[h][w]=='#':
                    black_count+=1
        if black_count==K:
            count += 1
print(count)


Measured memory_bytes: 9092
N = int(input())
d = [int(input()) for _ in range(N)]
d_s = sorted(d, reverse=True)

ans = 0
flag = 0
temp = 0
for x in d_s:
    if flag != 0:
        if x < temp:
            ans += 1
        else:
            pass
    else:
        flag = 1
        ans += 1
    temp = x    
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	    // 引数で標準入力System.inを指定する
	    Scanner scanner = new Scanner(System.in);
		try {

		    // 1行目を取得(a)
			String[] line1Array = scanner.nextLine().split(" ");
			int num = Integer.parseInt(line1Array[0]);

			String[] line2Array = scanner.nextLine().split(" ");
			int[] blockArray = new int[line2Array.length];

			for (int i = 0; i < line2Array.length; i++) {
				blockArray[i] = Integer.parseInt(line2Array[i]);
			}

			int answer = 0;

			for (int i = 0; i < blockArray.length; i++) {
				if ((blockArray[i] % 2 == 1) && ((i + 1) %2 == 1)) {
					answer++;
				}
			}

			System.out.printf("%d", answer);

		} finally {
		    // Scannerクラスのインスタンスをクローズ
		    scanner.close();
		}
	}
}

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

vector<pair<int, int> > firstHalf;
vector<pair<int, int> > secondHalf;

pair<int, int> removeBrackets(string s)
{
	stack<char> brackets;
	for(int i = 0; s[i]; i++)
	{
		if(brackets.empty())
		{
			brackets.push(s[i]);
			continue;
		}
		
		if(s[i] == '(')
			brackets.push(s[i]);
			
		else
		{
			if(brackets.top() == '(')
				brackets.pop();
				
			else
				brackets.push(s[i]);
		}
	}
	
	int Ai = 0, Bi = 0;
	while(!brackets.empty())
	{
		if(brackets.top() == ')')
			Ai++;
			
		else
			Bi++;
			
		brackets.pop();
	}
	
	return make_pair(Ai, Bi);
}

bool cmp(pair<int, int> p1, pair<int, int> p2)
{
	return p1.second > p2.second;
}

int main()
{
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i++)
	{
		string s;
		cin >> s;
		
		pair<int, int> removed = removeBrackets(s);
		
		//If open brackets win, sort based on increasing number of close brackets.
		if(removed.second >= removed.first)
			firstHalf.push_back(removed);
		
		//Else, sort based on decreasing number of open brackets.
		else
			secondHalf.push_back(removed);
	}
	
	sort(firstHalf.begin(), firstHalf.end());
	sort(secondHalf.begin(), secondHalf.end(), cmp);
	
	int sum = 0;
	
	string bracketSeq = "";
	for(int i = 0; i < (int)(firstHalf.size()); i++)
	{
		sum -= firstHalf[i].first;
		if(sum < 0)
		{
			printf("No");
			return 0;
		}
		
		sum += firstHalf[i].second;
	}

	for(int i = 0; i < (int)(secondHalf.size()); i++)
	{
		sum -= secondHalf[i].first;
		if(sum < 0)
		{
			printf("No");
			return 0;
		}
		
		sum += secondHalf[i].second;
	}

	if(sum == 0)
		printf("Yes");
		
	else
		printf("No");
}

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

int main() {
    int N,D;
    int count =1;
    cin >> N>>D;
    while(N-(2*D+1)>0){
        N -= 2*D+1;
        count ++;
    }
    cout << count <<endl;
}


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

int main() {

    while(true){
    
        // 1. input end check.
        long long e;
        cin >> e;
        
        // 2. exit check.
        if(e == 0) break;
        
        // 3. calculate the minimum value.
        long long m = 1e6;
        // long long yMax = (long long) pow(e, 1.0 / 2);
        // long long zMax = (long long) pow(e, 1.0 / 3);
        long long yMax = 1000, zMax = 1000;
        for(long long z = 0; z < zMax + 1; z++){
            for(long long y = 0; y < yMax + 1; y++){
                long long x = e - y * y - z * z * z;
                if(x >= 0) m = min(m, x + y + z);
            }
        }
        
        // 4. output answer.
        cout << m << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleTest
{
    class Program
    {
        static int Combination(int num)
        {
            if (num <= 1) return 0;
            return (num) * (num - 1) / 2;
        }
        static void Main(string[] args)
        {
            int[] p = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var result = Combination(p[0]) + Combination(p[1]);
            Console.WriteLine(result.ToString());
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)



int main(){
    int n,b; cin >> n;
    int A[n];
    rep(i,n){
        cin >> A[i];
        A[i] -= (i+1);
    }
    sort(A,A+n);
    long long ans = 0;
    b = A[n/2];
    rep(i,n){
        ans += abs(A[i] - b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024