akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
	vector<int> a(5);
	rep(i,5){
		cin >> a[i];
	}
	rep(i,5){
		if(a[i] == 0){
			cout << i+1 << endl;
			return 0;
		}
	}
    return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

const int N=200005;

struct E{
	int to,next;
}mem[N<<1];
int n,num,x,y,m,flag,s1,s2,s0,cnt;
ll ans;
int head[N],c[N];
bool vis[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void dfs(int k,int col){
	int j,u;
	vis[k]=1; c[k]=col; cnt++;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (vis[u]){
			if (c[u]!=(col^1)) flag=1;
			continue;
		}
		dfs(u,col^1);
	}
}

int main(){
	int i;
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	ans=0;
	for (i=1;i<=n;i++)
		if (!vis[i]){
			flag=0; cnt=0;
			dfs(i,0);
			if (cnt==1) s0++;
			else if (flag) s1++;
			else s2++;
		}
	ans=1ll*s0*s0+1ll*s1*s1+2ll*s2*s2;
	ans+=2ll*s0*(n-s0);
	if (s1) ans+=2ll*s1*s2;
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    int h[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];

    int dp[n];
    for (int i = 0; i < n; i++)
        dp[i] = INT_MAX;

    dp[0] = 0;

    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i - j < 0)
                break;
            dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
        }
    }

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



Measured memory_bytes: 1024
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$h = (int)$input[0];
$w = (int)$input[1];

if ($h === 1 || $w === 1) {
	echo 1;
	exit();
}

$even = (int)ceil($w / 2);
$odd = (int)floor($w / 2);
$sum = (int)ceil($h/2) * $even + (int)floor($h/2) * $odd;
echo $sum;

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
double x[1005],y[1005];
double dis(int i,int j){
    return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
double r(int i,int j,int k){
    vector<double> t(3);
    t[0]=dis(i,j),t[1]=dis(j,k),t[2]=dis(k,i);
    sort(ALL(t));
    double c=(t[0]*t[0]+t[1]*t[1]-t[2]*t[2])/2/t[0]/t[1];
    if(c>0){
        return t[2]/2/sqrt(1-c*c);
    }
    else{
        return t[2]/2;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    REP(i,n){
        cin >> x[i] >> y[i];
    }
    if(n==2){
        cout << fixed << setprecision(10) << dis(0,1)/2.0 << endl;
        return 0;
    }
    double ans=0;
    REP(i,n){
        FOR(j,i+1,n){
            FOR(k,j+1,n){
                chmax(ans,r(i,j,k));
            }
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;

int main() {
 int N,M,ac=0,wa=0;
  cin>>N>>M;
  vector<int> A(M);
  vector<string>B(M);
  unordered_map<int,int> map;
    for(int i=0; i<M; i++){
      cin>>A[i]>>B[i];
     // if(!map.count(A[i])){
     	 if(B[i]=="AC"){
           if(!map.count(A[i])){map[A[i]]=0;ac++;}
           if(map[A[i]]!=0){wa+=map[A[i]]; map[A[i]]=0; ac++;}}
         else if(!map.count(A[i])) map[A[i]]=1;
         else if(map[A[i]]!=0)map[A[i]]++;
    }
  cout<<ac<<" "<<wa<<endl;
}


Measured memory_bytes: 10276
N, W = list(map(int, input().split()))
w=[0]*N
v=[0]*N
for i in range(N):
    w[i], v[i]=list(map(int, input().split()))
# print(w)
# print(v)

# やることは一緒だけど, WがくそでかいのでこのままだとTLE
# なので発想を変えて, 保存する状態量を変更するのがポイント
# dp[i][j]:i番目までの品物から, "価値が"（ちょうど）jになるように詰めた時の最小の重さ
# 価値は高々100*10**3だから間に合うハズ

V=sum(v)
dp=[[float("inf") for j in range(V+1)] for i in range(N)]
dp[0][0]=0
dp[0][v[0]]=w[0]
# print(dp)

for i in range(1,N):
    for j in range(V+1):
        if j >= v[i]:
            dp[i][j]=min(dp[i-1][j], dp[i-1][j-(v[i])]+w[i])
        else:
            dp[i][j]=dp[i-1][j]
    # print(dp[i])

ans=V
while dp[N-1][ans]>W:
    ans-=1
print(ans)

Measured memory_bytes: 260832
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define forloop for(int i = 0; i < n; i++)
#define ll long long

int main(){
	int a, b; cin >> a >> b;
	(a > 2 * b) ? cout << a - 2 * b : cout << 0;

	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Math;

class P{
  static void Main(){
    int n,k;
    string[] s = Console.ReadLine().Split();
    n = int.Parse(s[0]);
    k = int.Parse(s[1]);
    double ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i >= k) {
			ans += 1.0;
			continue;
		}
		int j = 1;
		long i2 = i;
		for (;; j++) {
			i2 *= 2;
			if (i2 >= k) {
				ans += 1 / Pow(2.0,(double)j);
				break;
			}
		}
	}
    Console.WriteLine(ans / n);
  }
}

Measured memory_bytes: 11092
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');
            int a = int.Parse(x[0]);
            int b = int.Parse(x[1]);
            int c = int.Parse(x[2]);
            int d = b/a;

            if (d >= c)
            {
                Console.WriteLine(c);
            }
            else
            {
                Console.WriteLine(d);
            }
        }
    }
}


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

signed main() {
	ll n; cin >> n;
	ll ans = 0;
	vector<ll> p(n);
	rep(i, n) cin >> p[i];
	for(ll i = 1; i < n - 1; i++){
		vector<ll> x(3);
		x = {p[i -1],p[i],p[i + 1]};
		sort(x.begin(),x.end());
		if(x[1] == p[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
using namespace std;
// double dp[3000][3000];
double poss(double p[],int n){
    double dp[n+1][n+1];
    memset(dp,0.0,sizeof(dp));
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            dp[i][j] = p[i-1]*(dp[i-1][j-1]) +  (1.0-p[i-1])*dp[i-1][j];
        }
    }
    double sm = 0.0;
    for(int i=(n+1)/2;i<=n;i++)
        sm+=dp[n][i];
    return sm;
}
// double poss(double p[],int n,int heads,int tot){
//     if(n<=0){
//         return heads>=tot-heads;
//     }
//     if(dp[n][heads])
//         return dp[n][heads];
    
//     return (dp[n][heads] = p[n-1]*poss(p,n-1,heads+1,tot) + (1-p[n-1])*poss(p,n-1,heads,tot));
// }
int main(){
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    cout<<fixed<<setprecision(10);
    cout<<poss(p,n)<<endl;
}

Measured memory_bytes: 74100
'use strict'

const main = INPUT => {
  let input = INPUT.split('\n')
  const N = Number(input[0].split(' ')[0])
  const K = Number(input[0].split(' ')[1])
  const h = input
    .slice(1, N + 1)
    .map(n => Number(n))
    .sort((a, b) => a - b)

  let ans = Number.MAX_SAFE_INTEGER
  for (let i = 0; i <= h.length - K; i++) {
    let tmp = h[i + K - 1] - h[i]
    if (tmp < ans) {
      ans = tmp
    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 28752
from collections import deque
n,m,k=map(int,input().split())
fl=[set() for _ in range(n+1)]
bl=[set() for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  fl[a].add(b)
  fl[b].add(a)
for i in range(k):
  c,d=map(int,input().split())
  bl[c].add(d)
  bl[d].add(c)
stack = deque()
ans = [0]*(n+1)
visited = [0]*(n+1)
for i in range(1, n+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in fl[n]:
            if visited[j] == 0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    for i in link:
        ans[i] = len(link) - len(link & fl[i]) - len(link & bl[i]) -1
print(*ans[1:])

Measured memory_bytes: 80704
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if (x == 1) {
            System.out.println(1);
            return;
        }
        int max = 1;
        for (int i = 2; i <= x; i++) {
            for (int j = 2; (int)Math.pow(i, j) <= x; j++) {
                max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35888
import math
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
n = int(input())
while n:
    if is_prime(n):
        print(n)
        break
    n += 1


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s=="SUN")cout << 7 <<endl;
    if(s=="MON")cout << 6 <<endl;
    if(s=="TUE")cout << 5 <<endl;
    if(s=="WED")cout << 4 <<endl;
    if(s=="THU")cout << 3 <<endl;
    if(s=="FRI")cout << 2 <<endl;
    if(s=="SAT")cout << 1 <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define LATTE 100000

int dp[2][2001][3001];

int main(){
    int N,M,S;
    while(cin>>N>>M>>S, N||M||S){
        for(int i=1;i<=M;i++)for(int j=1;j<=S;j++) dp[0][i][j]=dp[1][i][j]=0;
        for(int i=1;i<=M;i++){
            dp[1][i][i]=1;
        }
        for(int i=1;i<N*N;i++){
            for(int j=1;j<=M;j++){
                for(int k=1;k<=S;k++){
                    //printf("%d,%d,%d\n",i,j,k);
                    if(k+j+1<=S && j+1<=M){
                        dp[(i+1)&1][j+1][k+j+1] +=
                            dp[i&1][j][k]+dp[(i+1)&1][j][k+j];
                        dp[(i+1)&1][j+1][k+j+1]%=LATTE;
                    }
                    dp[i&1][j][k]=0;
                    /*for(int l=j+1;l<=50;l++){
                        dp[i+1][l][k+l] += dp[i][j][k];
                        dp[i+1][l][k+l]%=LATTE;
                    }*/
                }
            }
        }
        int ans=0;
        for(int i=1;i<=M;i++){
            ans += dp[(N*N)&1][i][S];
        }
        printf("%d\n",ans%LATTE);
    }
    return 0;
}

Measured memory_bytes: 48036
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define LOCAL  1
#define UPLOAD 2
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

//#define int long log

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  string s = input<string>();

  string ret = "Yes";
  for(int i=0;i<s.length();i++){
    if(i % 2 != 0 && s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
      ret = "No";
    }
    if(i % 2 == 0 && s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
      ret = "No";
    }
  }

  output(ret);

  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

template<ull mod,ull phi_mod=mod-1>
class basic_mod_int{
    private:
        using mod_int=basic_mod_int<mod,phi_mod>;
        ull num;
        static ull pow_mod(ull x,ull y){x%=mod;return(y==0?1:y%2==0?pow_mod(x*x%mod,y/2):x*pow_mod(x,y-1))%mod;}
    public:
        basic_mod_int()=default;
        basic_mod_int(ull num):num(num%mod){}
        explicit operator ull()             const{return num;}
        bool    operator==(const mod_int&mi)const{return num==mi.num;}
        bool    operator!=(const mod_int&mi)const{return !operator==(mi);}
        mod_int operator~ ()                const{return pow_mod(num,phi_mod-1);}
        mod_int operator+ (const mod_int&mi)const{return num+mi.num;}
        mod_int operator- (const mod_int&mi)const{return num-mi.num+mod;}
        mod_int operator* (const mod_int&mi)const{return num*mi.num;}
        mod_int operator/ (const mod_int&mi)const{return num*(~mi).num;}
        mod_int&operator= (const mod_int&mi)     {num=mi.num;       return*this;}
        mod_int&operator+=(const mod_int&mi)     {num=operator+(mi);return*this;}
        mod_int&operator-=(const mod_int&mi)     {num=operator-(mi);return*this;}
        mod_int&operator*=(const mod_int&mi)     {num=operator*(mi);return*this;}
        mod_int&operator/=(const mod_int&mi)     {num=operator/(mi);return*this;}
};
template<ull mod,ull phi_mod=mod-1>
class combination_modulo:public basic_mod_int<mod,phi_mod>{
    private:
        using mod_int=basic_mod_int<mod,phi_mod>;
        vector<mod_int>factorial_mod;
    public:
        combination_modulo(ull max_n):factorial_mod(max_n+1)
        {
            factorial_mod[0]=1;
            for(ll i=1;i<=max_n;++i)factorial_mod[i]=factorial_mod[i-1]*i;
        }
        mod_int operator()(ull n,ull r)
        {
            return n<r?0:factorial_mod[n]/(factorial_mod[r]*factorial_mod[n-r]);
        }
};

int main()
{
    ll n=in();
    vector<ll>a(n+1);for(auto&i:a)i=in();

    ll d=accumulate(a.begin(),a.end(),0LL)-n*(n+1)/2;
    ll d1_idx=find(a.begin(),a.end(),d)-a.begin();
    ll d2_idx=a.rend()-find(a.rbegin(),a.rend(),d)-1;

    auto cm=combination_modulo<1000000007>(n+1);
    for(ll i=1;i<=n+1;++i)cout<<(ull)(cm(n+1,i)-cm(n+1-(d2_idx-d1_idx+1),i-1))<<endl;
}


Measured memory_bytes: 2816
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, ma, k;
int a[100000];
signed main() {
	cin >> k >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ma = max(ma, a[i]);
	}
	cout << max(ma - 1 - (k - ma), 0ll) << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  bool ans=true;
  ll n;
  cin>>n;
  vector<ll> a;
  for(ll i=0;i<n;i++){
    ll ai;
    cin>>ai;
    a.push_back(ai);
  }
  sort(a.begin(),a.end());
  for(ll i=1;i<n;i++){
    if(a[i-1]==a[i]){
      ans=false;
      break;
    }
  }if(ans){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    lint n, k;
    cin >> n >> k;
    vector<pll> s(n);
    repeat (i, n) cin >> s[i].fst >> s[i].snd;
    
    sort(s.begin(), s.end(), [](pll a, pll b) -> bool {
        if (a.fst != b.fst) return a.fst < b.fst;
        else return a.snd > b.snd;
    });
    
    vector<pll> v;
    v.push_back(make_pair(s[0].snd, 1));
    repeat_from (i, 1, n) {
        if (s[i].fst != s[i-1].fst) {
            v.push_back(make_pair(s[i].snd, 1));
        }
        else {
            v.push_back(make_pair(s[i].snd, 0));
        }
    }
    
    sort(v.begin(), v.end(), [](pll a, pll b) -> bool {
        if (a.fst == b.fst) return a.snd > b.snd;
        else return a.fst > b.fst;
    });
    
    //repeat (i, n) pdump(v[i]);
    
    lint ans = 0;
    lint A = 0, B = 0;
    priority_queue<lint, vector<lint>, greater<lint>> pq;
    repeat (i, k) {
        A += v[i].fst;
        B += v[i].snd;
        if (v[i].snd == 0) pq.push(v[i].fst);
    }
    ans = A + B * B;
    //el; dump(A); dump(B); dump(ans); el;
    
    auto showpq = [](priority_queue<lint, vector<lint>, greater<lint>> pq) -> void {
        cout << "show pq = ";
        while (!pq.empty()) {
            cout << pq.top() << " ";
            pq.pop();
        }
        cout << endl;
    };
    
    repeat_from_to (i, k, n-1) {
        if (v[i].snd == 0) continue;
        ++B;
        if (pq.empty()) break;
        //showpq(pq);
        A -= pq.top();
        pq.pop();
        A += v[i].fst;
        ans = max(ans, A + B * B);
        //dump(i); dump(A); dump(B); dump(ans); el;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 4208
import java.lang.Math.*


fun main(args: Array<String>) {
    val (n, k) = readIntList().subList(0, 2)
    val v = readLongList()

    var ans = 0L

    var right = 0
    var left = 0

    fun calc() {
        var canRemoveCount = k - (right + left)
        val list = v.copy().toMutableList()
        val merged = list.subList(0, right).apply {
            addAll(list.subList(list.size - left, list.size))
            sort()
        }
        ans = max(ans, merged.filter {
            if (it < 0 && canRemoveCount > 0) {
                canRemoveCount--
                return@filter false
            } else {
                return@filter true
            }
        }.sum())

    }

    while (right + left <= min(k, n)) {
        while (right + left <= min(k, n)) {
            calc()
            left++
        }
        right++
        left = 0
    }

    println(ans)
}


fun readList() = readLine()!!.split(' ')
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)

fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readString() = readLine()!!

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

Measured memory_bytes: 42408
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int N;
	cin>>N;
	
	vector<long long> T(N),A(N);
	
	for(int i=0;i<N;i++)cin>>T[i]>>A[i];
	
	long long t = 1,a = 1;
	
	for(int i=0;i<N;i++){
		long long X = (t+T[i]-1)/T[i];
		long long Y = (a+A[i]-1)/A[i];
		long long n = max(X,Y);
		
		t=T[i]*n;
		a=A[i]*n;
		
	}
	
	cout<<t+a<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int M, N;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll INF = 1e9+7;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> d(n);
    for(int i = 0; i < m; i++)
    {
        int s, t;
        cin >> s >> t;
        s--;t--;
        d[s].push_back(t);
    }

    vector<double> dp(n);
    dp[n-1] = 0;
    for(int i = n-2; i >= 0; i--)
    {
        int size = d[i].size();
        double sum = 0;
        for(int cand : d[i])
        {
            sum += dp[cand] + 1;
        }
        dp[i] = sum / size;
    }
    vector<double> tdp(n);
    tdp[n-1] = 0;
    double ans = dp[0];
    for(int i = n-2; i >= 0; i--)
    {
        for(int j = n-2; j >= 0; j--)
        {
            double sum = 0;
            if(d[j].size() == 1)
            {
                tdp[j] = tdp[d[j][0]]+1;
            }
            else
            {
                double ma = 0;
                for(int cand : d[j])
                {
                    sum += tdp[cand]+1;
                    if(tdp[cand]+1 > ma) ma = tdp[cand]+1;
                }
                if(i == j)
                {
                    sum -= ma;
                    tdp[j] = sum / (d[j].size()-1);
                }
                else
                {
                    tdp[j] = sum / d[j].size();
                }
            }
        }
        ans = min(ans, tdp[0]);
    }
    printf("%.10f", ans);;
}


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

int main() {
	int a,b,c;
	cin >>a>>b>>c;
	if(a<=b && b<=c && a<=c){
		cout<< a << " " << b << " " << c <<endl;
	}
	else if(a<=c && c<=b && a<=b){
		cout<< a << " " << c << " " << b <<endl;
	}
	else if(b<=a && a<=c && b<=c){
		cout<< b << " " << a << " " << c <<endl;
	}
	else if(b<=c && c<=a && b<=a){
		cout<< b << " " << c << " " << a <<endl;
	}
	else if(c<=a && a<=b && c<=b){
		cout<< c << " " << a << " " << b <<endl;
	}
	else if(c<=b && b<=a && c<=a){
		cout<< c << " " << b << " " << a <<endl;
	}
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const int INF = INT_MAX / 2;
const int MOD = 998244353;
const ll e18 = 1e18;

int memo[1<<26];

int g(int N, ll x);

int f(string s) {
	int N = s.length();
	vector<vector<ll>> a(N + 1, vector<ll>(N + 1));
	rep(l, N + 1) for (int r = l + 1; r <= N; r++)
		a[l][r] = a[l][r - 1]<<1 | (s[r - 1] - '0');
	vector<int> dp(N + 1);
	dp[0] = 1;
	rep(i, N) {
		if (s[i] == '0') dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
		if (s[i] == '1') dp[i + 1] = (dp[i + 1] + dp[i] * 2LL) % MOD;
		for (int d = 1; i + d * 2 <= N; d++) {
			ll x = a[i][i + d];
			for (int j = i + d * 2; j <= N; j += d) {
				x &= a[j - d][j];
				dp[j] = (dp[j] + (ll)dp[i] * g(d, x)) % MOD;
			}
		}
	}
	return dp[N];
}

int g(int N, ll x) {
	x |= 1LL<<N;
	if (N <= 25 && memo[x] >= 0) return memo[x];
	string s(N, '0');
	rep(i, N) if (x>>i & 1) s[N - 1 - i] = '1';
	int ans = f(s);
	if (N <= 25) memo[x] = ans;
	return ans;
}

int main() {
	rep(x, 1<<26) memo[x] = -1;
	string s; cin >> s;
	cout << f(s) << endl;
}


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

int k,tot,a[19];
long long ans;
long long pw10[19] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};

void dfs(int l,int x,int c)
{
	a[c] = x;
	if(c==l)
	{
		tot++;
		if(tot==k)for(int i = 1;i<=l;i++)ans += a[i]*pw10[l-i];
		return;
	}
	if(x)dfs(l,x-1,c+1);
	dfs(l,x,c+1);
	if(x!=9)dfs(l,x+1,c+1);
}

int main()
{
	cin >> k;
	for(int i = 1;i<=9;i++)dfs(1,i,1);
	for(int i = 1;i<=9;i++)dfs(2,i,1);
	for(int i = 1;i<=9;i++)dfs(3,i,1);
	for(int i = 1;i<=9;i++)dfs(4,i,1);
	for(int i = 1;i<=9;i++)dfs(5,i,1);
	for(int i = 1;i<=9;i++)dfs(6,i,1);
	for(int i = 1;i<=9;i++)dfs(7,i,1);
	for(int i = 1;i<=9;i++)dfs(8,i,1);
	for(int i = 1;i<=9;i++)dfs(9,i,1);
	for(int i = 1;i<=9;i++)dfs(10,i,1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a = 0;
    int b = 0;
    int c = 0;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if( (a < b) && (b < c) ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1008
//
// Darsein AC : O(5^4)
// implement : 5 min
// debug     : 0 min
//

#include<iostream>
using namespace std;

bool rec(int la, int ra, int lb, int rb){
  if(la>=5 && ra>=5)return 0;
  if(lb>=5 && rb>=5)return 1;

  bool f = true;
  if(la<5 && lb<5)f &= rec(lb+la,rb,la,ra);
  if(la<5 && rb<5)f &= rec(lb,rb+la,la,ra);
  if(ra<5 && lb<5)f &= rec(lb+ra,rb,la,ra);
  if(ra<5 && rb<5)f &= rec(lb,rb+ra,la,ra);

  return !f;
}

int main(){
  int la, ra, lb, rb;
  cin >> la >> ra >> lb >> rb;
  
  cout << (rec(la,ra,lb,rb)?"ISONO":"NAKAJIMA") << endl;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
#define ll long long
int main(){
	ll n, m, k, ans = 2147483647;
	scanf("%lld %lld %lld", &n, &m, &k);
	string s[n];
	for (ll i = 0; i < n; i++) cin >> s[i];
	for (ll mask = 0; mask < (1 << (n - 1)); mask++){
		ll p[n], c = 0;
		p[0] = 0;
		for (ll i = 0, j = 1; i < n - 1; i++, j <<= 1){
			if ((mask & j) != 0) c++;
			p[i + 1] = c;
		}
		ll cuts = c;
		vector<ll> v;
		for (ll i = 0; i <= c; i++) v.emplace_back(0);
		bool bad = false;
		for (ll i = 0; i < m; i++){
			for (ll j = 0; j < n; j++){
				if (s[j][i] == '1') v[p[j]]++;
			}
			bool ono = false;
			for (ll j = 0; j < v.size(); j++){
				ono = (ono || (v[j] > k));
			}
			if (ono){
				cuts++;
				fill(v.begin(), v.end(), 0);
				for (ll j = 0; j < n; j++){
					if (s[j][i] == '1') v[p[j]]++;
				}
				bool onoono = false;
				for (ll j = 0; j < v.size(); j++){
					onoono = (onoono || (v[j] > k));
				}
				if (onoono){
					bad = true;
					break;
				}
			}
		}
		if (bad) continue;
		ans = min(ans, cuts);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AIZU {
	class Program {
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			int[] Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }

		static void Main(string[] args) {
			var numeric = @"\d+";
			string input;
			int Res = 0;
			while (true) {
				input = Console.ReadLine();
				if (input==null) break;
				var mc = Regex.Matches(input, numeric);
				foreach (Match m in mc) 
					Res+=int.Parse(m.Value);
			}
			print(Res);
		}
		
	}
}

Measured memory_bytes: 10876
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			String n = in.nextString();

			long sum1 = 0;
			for (int i = 0; i < n.length(); i++) {
				sum1 += Long.parseLong(n.substring(i, i+1));
			}

			long sum2 = 0;
			for (int i = 0; i < n.length(); i++) {
				if (i == 0) {
					sum2 += Long.parseLong(n.substring(i, i+1))-1;
				} else {
					sum2 += 9;
				}
			}

			out.println(Math.max(sum1, sum2));

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val A = nl()
    val B = nl()
    val C = nl()
    var K = nl()
    val a = min(A, K)
    K -= a
    val b = min(B, K)
    K -= b
    val c = min(C, K)
    out.println(a - c)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

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

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

const int MOD = 1e+9 + 7;

template <typename T>
T pow_mod( T n, T p, T m )
{
    if( p == 0 ) return 1;
    if( p%2 == 1 ) return pow_mod(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}


int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;

    int M = s.size();

    // dp[i][j]: i 回の操作で j (1-index) 文字の文字列を作る場合の数
    vector<vector<long long>> dp(N+1, vector<long long>(N+1));
    dp[0][0] = 1;
    REP(i, N){
        dp[i+1][0] = (dp[i][0] + dp[i][1]) % MOD;
        FOR(j, 1, N){
            dp[i+1][j] = (2*dp[i][j-1] + dp[i][j+1]) % MOD;
        }
        dp[i+1][N] = (2*dp[i][N-1]) % MOD;
    }

    cout << (dp[N][M]*pow_mod<long long>(2, (long long) M*(MOD-2), MOD)) % MOD << endl;

    return 0;
}

Measured memory_bytes: 195840
char*a,*b;main(m,i){for(;~scanf("%as%as",&a,&b);printf("%d\n",m)){int C[2][4001]={m=i=0},j,t;for(;a[i];i++)for(j=0;t=b[j++];t>m?m=t:0)t=C[~i&1][j]=a[i]-t?0:C[i&1][j-1]+1;}}

Measured memory_bytes: 544
#include<stdio.h>
#include<stdlib.h>

#define MAX 100

int m, cnt, G[MAX];

void insertionSort(int *A, int n, int g){
  int i, j, v;
  
  for(i = g; i < n; i++){
    v = A[i];
    j = i - g;
    while((j >= 0) && (A[j] > v)){
      A[j + g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int *A, int n){
  int i;
  G[0] = 1;

  //        3    9     27     81
  // G = {1   4    13     40}     x121
  i = 0;
  while((++i) <= MAX){
    if(G[i - 1] > n){
      m = i - 1;
      break;
    }
    else{
      G[i] = G[i - 1] * 3 + 1;
    }
  }

  // 40 13 4 1 (reverse)
  for(i = m - 1; i >= 0; i--){
    insertionSort(A, n, G[i]);
  }
}


int main(){
  int i,n,*A;

  scanf("%d",&n);
  A = malloc(sizeof(int) *n);

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

  shellSort(A, n);
  
  printf("%d\n",m);
  for(i = m - 1; i > 0; i--)
    printf("%d ",G[i]);
  printf("%d\n%d\n",G[i],cnt);
  for(i = 0; i < n; i++)
    printf("%d\n",A[i]);
  
  free(A);
  
  return 0;
}




Measured memory_bytes: 5476
#include<stdio.h>
int main(void){
	int a, b, c, n;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b){
		n = a;
		a = b;
		b = n;
	};
	if(b > c){
		n = b;
		b = c;
		c = n;
	};
	if(a > b){
		n = a;
		a = b;
		b = n;
	};
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2064
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

res=0

for i in range(len(a)):
    res+=b[a[i]-1]
    if i>0 and a[i]-a[i-1] == 1 : res+= c[a[i]-1-1]
        
print(res)
       

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mst(a, b)   memset((a), (b), sizeof(a))
#define gc() gutchar()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pr;
typedef long long ll;
const double eps = 1e-5;
const int inf = 0x3f3f3f3f;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()
{
	int h, a, cs;
	cin >> h >> a;
	cs = (h + a - 1) / a;
	cout << cs;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

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

func ScanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = ScanText()
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	var a = ScanTextSlice(3)
	if a[0][len(a[0])-1] == a[1][0] && a[1][len(a[1])-1] == a[2][0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


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

bool path_aruka(vector<int> path, vector<pair<int, int>> edges){
  vector<int> path_ret(path.size());
  copy(path.begin(), path.end(), path_ret.begin());
  path_ret.insert(path_ret.begin(), 1);
  /*
  for(int i = 0; i < path_ret.size(); i++)
      cout << path_ret.at(i);
  */

  for(int i = 0; i < path_ret.size() - 1; i++){
    for(int j = 0; j < edges.size(); j++){
      if((path_ret.at(i) == edges.at(j).first && path_ret.at(i+1) == edges.at(j).second)||
         (path_ret.at(i) == edges.at(j).second && path_ret.at(i+1) == edges.at(j).first))
        if(i == path_ret.size() - 2)
         return true;
      	else
          break;
      if(j == edges.size() - 1)
        return false;
    }
  }
}



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

  vector<pair<int, int>> edges(m);
  for (int i = 0; i < m; i++){
    cin >> edges.at(i).first >> edges.at(i).second;
  }

  //2~nの頂点リストを生成
  vector<int> vertexes(n-1);
  iota(vertexes.begin(), vertexes.end(), 2);

  //(始点を除く)頂点の全組み合わせをループ
  
  int cnt = 0;
  do{
    if(path_aruka(vertexes, edges))
      cnt++;
    //cout << endl;
  }while(next_permutation(vertexes.begin(), vertexes.end()));

  cout << cnt << endl; 
  
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 3");
            WillReturn.Add("dxx");
            WillReturn.Add("axx");
            WillReturn.Add("cxx");
            //axxcxxdxx
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        var SList = new List<string>();
        foreach (string EachStr in InputList.Skip(1)) {
            SList.Add(EachStr);
        }

        var sb = new System.Text.StringBuilder();
        SList.Sort();
        SList.ForEach(X => sb.Append(X));
        Console.WriteLine(sb.ToString());
    }
}


Measured memory_bytes: 3288
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int back;
    if (N % 1000 == 0) {
      back = 0;
    }else {
      back = 1000 - (N % 1000);
    }
    System.out.println(back);
  }
}

Measured memory_bytes: 35680
#include<iostream>
using namespace std;
int s(int q[],int len){
    int cont=0;
    for(int i=0;i<len;i++)
        for(int j=len-1;j>i;j--)
            if(q[j]<q[j-1]){
                swap(q[j],q[j-1]);
                cont++;
            }
    return cont;
}

int main(){
    int n,q[100];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>q[i];
    int cont = s(q,n);
    for(int i=0;i<n;i++)
        if(i==0) cout<<q[i];
        else cout<<' '<<q[i];
    cout<<endl<<cont<<endl;
    return 0;
}


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

namespace mxfl{
  const int N=2.1e5, M=2e6;
  typedef int str;
  const str inf=1e9;
  
  struct E{
    int to; str fl; int nex;
  }e[M];
  int n, hea[N], cne, cur[N], st, en, d[N];
  void init(int n_=N-1){
    n=n_; cne=1;
    memset(hea,0,sizeof (int)*(n+1));
  }
  void adde(int u,int v,str w,str bw=0){
    e[++cne]=(E){v,w,hea[u]}; hea[u]=cne;
    e[++cne]=(E){u,bw,hea[v]}; hea[v]=cne;
  }
  bool bfs(){
    memset(d,33,sizeof d); d[st]=0;
    queue<int>q; q.push(st);
    for (int x,y,z;!q.empty();){
      x=q.front(); q.pop(); if (x==en) return 1;
      for (int i=hea[x];i;i=e[i].nex){
        if (!e[i].fl) continue;
        y=e[i].to; z=d[x]+1;
        if (z<d[y]) d[y]=z, q.push(y);
      }
    }
    return 0;
  }
  str dfs(int x,str F){
    if (x==en||!F) return F;
    str las=F;
    for (int &i=cur[x];i;i=e[i].nex){
      int y=e[i].to;
      if (!e[i].fl||d[y]!=d[x]+1) continue;
      str t=dfs(y,min(las,e[i].fl));
      las-=t; e[i].fl-=t; e[i^1].fl+=t;
      if (!las) break;
    }
    return F-las;
  }
  str realmain(int st_,int en_){
    st=st_; en=en_;
    str ans=0;
    for (;bfs();){
      memcpy(cur,hea,sizeof (int)*(n+1));
      ans+=dfs(st,inf);
    }
    return ans;
  }
}

int n, a[101000], a2[101000], b[101000], b2[101000], tot, S, T;

void gao(int *a,int *a2){
	for (int i=1;i<=n;++i) cin>>a[i], ++a[i];
	for (int i=1;i<=n;++i){
		if (a2[i]) continue;
		++tot;
		for (int p=i;!a2[p];p=a[p]) a2[p]=tot;
	}
}

int main(){
	cin>>n;
	gao(a,a2);
	gao(b,b2);
	mxfl::init(); S=++tot; T=++tot;
	int ans=n;
	for (int i=1;i<=n;++i){
		if (a[i]==i&&b[i]==i){
			--ans;
		}else if (a[i]==i){
			mxfl::adde(b2[i],T,1);
		}else if (b[i]==i){
			mxfl::adde(S,a2[i],1);
		}else{
			mxfl::adde(b2[i],a2[i],1,(a[i]==b[i]));
		}
	}
	cout<<ans-mxfl::realmain(S,T)<<endl;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  Cins(int, n, h);

  int ans = 1;
  for (int i = 1; i < n; ++i) {
    bool ok = true;
    for (int j = 0; j < i; ++j)
      if (h[i] < h[j]) ok = false;
    if (ok) ans++;
  }
  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
mod=1000000007
n=int(input())
#n,k=map(int,input().split())
a=[int(i) for i in input().split()]
t=[0]*(n+1)
for i in range(n):
    t[i]=t[i-1]+a[i]
ans=chk=0
#print(t)
for i in range(n-1):
#    print(-(i+1))
    x=-1*(i+1)
#    print(x)
#    print(a[x],t[x-2])
    ans+=a[x]*t[x-2]
    ans%=mod
print(ans)

Measured memory_bytes: 94188
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <map>
#include <math.h>

using namespace std;

typedef signed long long ll;

int main(void)
{
    long long count = 0;
    int N = 0;
    cin >> N;

    vector<long> A(N, 0);
    vector<long> B(N, 0);
    vector<long> C(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    sort(B.begin(), B.end());
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    sort(C.begin(), C.end());

    long long ab = 0;
    long long bc = 0;
    for (int j = 0; j < N; j++)
    {
        auto it_A = lower_bound(A.begin(), A.end(), B[j]);
        ab = distance(A.begin(), it_A);
        auto it_C = upper_bound(C.begin(), C.end(), B[j]);
        bc = N - distance(C.begin(), it_C);

        count = count + (ab * bc);
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 2560
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(60):
    ichi=0
    for j in range(n):
        if (a[j]>>i)&1:
            ichi+=1
    zero=n-ichi
    s=ichi*zero*pow(2,i,mod)%mod# xorをしたあとi桁目が1になる組み合わせの個数 x 2**i
    ans+=s
    ans%=mod
print(ans)


Measured memory_bytes: 122936
#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 dp[3][3][3];//dokokara dokomade kyori

int main() {
  int m,n;
  cin >> m >> n;
  if(m==n) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define mx 1500000
#define mod 1000000007
#define pii pair<int,int>
typedef long long ll;
using namespace std;
void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main()
{
    fastio();
    int i,j,t,n,k,l,x,y;
    //cin>>t;
    //while(t--){
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    ll s=0,ans=mx;
    for(j=-100;j<=100;j++){
       for(i=0;i<n;i++){
        s+=((a[i]-j)*(a[i]-j));
       }
       ans=min(ans,s);
       s=0;
    }
    cout<<ans<<endl;
     //}
 return 0;
}


Measured memory_bytes: 3628