akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {
    bool debug = argc == 2 && (strcmp(argv[1], "debug") == 0);
    int X, Y;
    scanf("%d %d", &X, &Y);

    if (debug) {
        printf("X=%d, Y=%d\n", X, Y);
    }

    int cost = X + Y/2;
    printf("%d\n", cost);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define int long long
using namespace std;

int n;
int c[1000];
int q;
int t[100000], x[100000], d[100000];
int cnt[1000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> c[i];
	
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> t[i] >> x[i] >> d[i]; x[i]--;
	}
	
	for (i = 0; i < q; i++) {
		if (t[i] == 1) { cnt[x[i]] += d[i]; }
		else { cnt[x[i]] -= d[i]; }
		if (cnt[x[i]] > c[x[i]] || cnt[x[i]] < 0) {
			cout << x[i] + 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 5456
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <sstream>

using namespace std;

class c_main
{
private:
    
public:
    c_main();
    void f_input();
};

c_main::c_main()
{

}

void c_main::f_input()
{
    int i, j;
    
    for ( i = 1; i <= 9; ++i ){
        for ( j = 1; j <= 9; ++j ){
            cout << i << "x" <<  j << "=" << i * j << endl;
        }
    }
}

int main(){
    c_main main01;
    main01.f_input();
    
    return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

using P = pair<int,int>;
int main()
{
	int n,m;
	cin >> n>>m;
	vector<P> p(m);
	rep(i,m) cin >> p[i].first >> p[i].second ;
	rep(x,1000){
		int nx = x / 10 ; // 計算用の変数nx これが0になるまでベクターに入れる
		vector<int> d(1,x%10);
		while(nx){
			d.push_back(nx%10) ; 
			nx /= 10 ;
		}
		rSORT(d);
		if( d.size() != n ) continue;
		bool ok = true ; 
		//条件に沿ったものかどうかを今から判定する
		rep(i,m){ 
			//入力で受け取った桁数-1番目の数字が、一致していればok
			if (d[p[i].first-1] != p[i].second ) ok = false ;
		}
		if(ok){
			cout << x << endl ; 
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;


int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;

    vll p(n);

    vector<double> e(n);

    for0(i, n) cin >> p[i];

    for0(i, n){
        e[i] = double(p[i] + 1) / 2.0;
    }

    double result = 0;
    double bef = 0;
    for0(i, k){
        bef += e[i];
    }
    result = bef;

    forx(i, n, k){
        result = max(result, bef = bef - e[i - k] + e[i]);
    }

    cout << setprecision(10) << result;

    return 0;
}


Measured memory_bytes: 3328
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  X = llabs(X);
  ll X_D = X / D;
  if (X_D >= K) {
    cout << X - K * D << endl;
    return 0;
  }
  X = X - X_D * D;
  K = K - X_D;
  ll ans;
  if (K % 2 == 1) {
    ans = llabs(X - D);
  } else {
    ans = X;
  }
  cout << ans << endl;

  return 0;
}

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

int main(){

  int n, ans=0, cnt=0;

  while(cin >> n && n){
    for(int i=1; i<n; i++){
      for(int j=0; j<n-i; j++){
        ans+=i+j;
        if(n==ans){
          cnt++;
        }
      }
      ans = 0;
    }
    cout << cnt << endl;
    cnt = 0;
  }

  return 0;
}

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

int main(){
	long long a,b,c,k,sum = 0;

	cin >> a >> b >> c >> k;

	if (k < a) {
		sum = k;
	}
	else {
		sum = a;
		k = k - a;
		if (k > 0) {
			k = k - b;
			if (k > 0) {
				sum = sum - k;
			}
		}
	}


	cout << sum;
}

Measured memory_bytes: 3632
/* SPDX-License-Identifier: X11
 *
 * Copyright 2020 Elias Yuan <a@jthv.ai>, MIT/X11 License
 *   https://jthv.ai/LICENSE/X11.txt
 *
 * ANU-CPC Complexity Workshop - A: Two Integers
 *   2020-04-13
 */

#include <stdio.h>

int main(void)
{
  unsigned long x,y;
  scanf("%lu %lu",&x,&y);

  if (x < y) {
    printf("%lu\n",x);
    return 0;
  }

  if (x % y == 0) {
    printf("-1\n");
    return 0;
  }

  printf("%lu\n",x);
  return 0;
}

Measured memory_bytes: 128
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
B=0
i=0
while D<=X and i<=N-1:
    D=D+L[i]
    B=B+1
    i=i+1
if i==N and D<=X:
    B=B+1
print(B)

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

int main(){
   int a,b,c,d;
   string ans = "Yes";
   cin >> a >> b >> c >> d;
   if(abs(a-c) <= d);
   else if(abs(a-b) <= d && abs(b-c) <= d);
   else ans = "No";
   cout << ans << endl;
}

Measured memory_bytes: 256
import sys
N = int(input())
H = list(map(int,input().split()))

for i in range(len(H)-1):
  if H[i] - H[i+1] <= 0:
    continue
  elif H[i] - H[i+1] >= 2:
    print("No")
    sys.exit()
  else:
    H[i+1]+=1

print("Yes")

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

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    int cnt = 0;

    while(1){
        if(cnt % 2 == 0){
            C -= B;
        }else{
            A -= D; 
        }

        if(C <= 0 || A<= 0) break;
        cnt++;
    }

    if(C<=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
typedef long long ll;
long long longPow(int n) {
    long long res = 1;
    rep(i, 0, n) { res *= 2; }
    return res;
}
int main() {
    int M, K;
    cin >> M >> K;
    long long max = longPow(M) - 1;
    if(M == 0) {
        if(K == 0) {
            cout << "0 0" << endl;
        } else {
            cout << -1 << endl;
        }
    } else if(M == 1) {

        if(K == 0) {
            cout << "0 1 1 0" << endl;
        } else {
            cout << -1 << endl;
        }
    } else if(max < K) {
        cout << -1 << endl;
    } else {

        rep(i, 0, max + 1) {
            if(i != K) {
                cout << i << " ";
            }
        }
        cout << K << " ";
        rep(i, 0, max + 1) {
            int t = max - i;
            if(t != K) {
                cout << t << " ";
            }
        }
        cout << K << endl;
    }
}


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

#define ll              long long
#define Ull             unsigned long long
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 2;
const ll MOD = 1e9 + 7;


void Solve()
{
	ll n;
	cin >> n;
	ll dp[n][3];
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < 3; j++)
			cin >> dp[i][j];
	}

	for (ll i = 1; i < n; i++)
	{
		for (ll j = 0; j < 3; j++)
		{
			if (j == 0)
				dp[i][j] += max(dp[i - 1][j + 1], dp[i - 1][j + 2]);

			else if (j == 1)
				dp[i][j] += max(dp[i - 1][j + 1], dp[i - 1][j - 1]);

			else
				dp[i][j] += max(dp[i - 1][j - 1], dp[i - 1][j - 2]);


		}
	}

	cout << max3(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]) << "\n";

}


int main()
{

	FastRead;
	int T = 1;
	//cin>>T;
	while (T--)
	{
		Solve();
	}

	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
import java.util.HashMap;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("[\n#]+");
		while (true)
		{
			String str = sc.next();
			if (str.equals("0")) break;
			int rk = Integer.parseInt(str.substring(0, 2), 16);
			int gk = Integer.parseInt(str.substring(2, 4), 16);
			int bk = Integer.parseInt(str.substring(4, 6), 16);
			int d[] = new int[8];
			HashMap<Integer, String> map = new HashMap<Integer, String>();
			d[0] = (0x00 - rk) * (0x00 - rk)
					+ (0x00 - gk) * (0x00 - gk)
					+ (0x00 - bk) * (0x00 - bk);
			map.put(d[0], "black");
			d[1] = (0x00 - rk) * (0x00 - rk)
					+ (0x00 - gk) * (0x00 - gk)
					+ (0xff - bk) * (0xff - bk);
			map.put(d[1], "blue");
			d[2] = (0x00 - rk) * (0x00 - rk)
					+ (0xff - gk) * (0xff - gk)
					+ (0x00 - bk) * (0x00 - bk);
			map.put(d[2], "lime");
			d[3] = (0x00 - rk) * (0x00 - rk)
					+ (0xff - gk) * (0xff - gk)
					+ (0xff - bk) * (0xff - bk);
			map.put(d[3], "aqua");
			d[4] = (0xff - rk) * (0xff - rk)
					+ (0x00 - gk) * (0x00 - gk)
					+ (0x00 - bk) * (0x00 - bk);
			map.put(d[4], "red");
			d[5] = (0xff - rk) * (0xff - rk)
					+ (0x00 - gk) * (0x00 - gk)
					+ (0xff - bk) * (0xff - bk);
			map.put(d[5], "fuchsia");
			d[6] = (0xff - rk) * (0xff - rk)
					+ (0xff - gk) * (0xff - gk)
					+ (0x00 - bk) * (0x00 - bk);
			map.put(d[6], "yellow");
			d[7] = (0xff - rk) * (0xff - rk)
					+ (0xff - gk) * (0xff - gk)
					+ (0xff - bk) * (0xff - bk);
			map.put(d[7], "white");
			Arrays.sort(d);
			System.out.println(map.get(d[0]));
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <math.h>

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

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define rrep(i,n) for(int i=n ; i>=0 ; i--)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;


int main(){
    int n,m ; cin >> n >> m;
    vi a(n);
    vector<pair<int,int>> bc(m);
    ll sum = 0;

    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    //cout << sum << endl;
    rep(i,m){
        cin >> bc[i].second >> bc[i].first;
    }

    Sort(a);
    Sort(bc);
    Reverse(bc);

    int idb = 0;

    rep(i,n){
        if(a[i] >= bc[idb].first) {
            //cout << i << endl;
            break;
        }
        if(bc[idb].second > 0) {
            sum += (bc[idb].first - a[i]);
            bc[idb].second--;
        }
        else{
            if(idb == m-1) break;
            idb++;
            if(a[i] >= bc[idb].first) break;
            if(bc[idb].second > 0) {
                sum += (bc[idb].first - a[i]);
                bc[idb].second--;
            }
        }
    }

    cout << sum << endl;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		long long smaller = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		long long bigger = c.end() - upper_bound(c.begin(), c.end(), b[i]);
		ans += smaller * bigger;
	}
	cout << ans << endl;
		
	return 0;	
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  ll ans = a[n-1];
  for (int i = 0; i < n-2; i++){
    ans += a[n-2-i/2];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e3+10;
const uli mod=1e9+7;
uli f[2][mx];
uli g[mx][mx];
uli cmb[mx][mx];
int main(){
  cmb[0][0]=1;
  for(int i=1;i<mx;i++){
    cmb[i][0]=cmb[i][i]=1;
    for(int j=1;j<i;j++){
      cmb[i][j]=cmb[i-1][j]+cmb[i-1][j-1];
      if(cmb[i][j]>=mod)cmb[i][j]-=mod;
    }
  }
  int N,a,b,c,d;
  scanf("%d %d %d %d %d",&N,&a,&b,&c,&d);
  for(int l=1;l<=N;l++){
    g[0][l]=1;
    for(int n=l;n<=N;n+=l){
      g[n][l]=cmb[n-1][l-1]*g[n-l][l]%mod;
    }
  }
  int rw=0;
  f[rw][0]=1;
  for(int l=a;l<=b;l++){
    rw^=1;
    f[rw][0]=1;
    for(int n=1;n<=N;n++){
      f[rw][n]=f[rw^1][n];
      int from=max(1,c);
      int to=min(n/l,d);
      for(int x=from;x<=to;x++){
        f[rw][n]+=f[rw^1][n-x*l]*g[l*x][l]%mod*cmb[n][l*x]%mod;
        if(f[rw][n]>=mod)f[rw][n]-=mod;
      }
    }
  }
  printf("%lld\n",f[rw][N]);
  return 0;
}


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

int main()
{
	int n, m, l;
	cin >> n >> m >> l;
	vector<vector<long long>> A(n, vector<long long>(m)), B(m, vector<long long>(l)), C(n, vector<long long>(l));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> B[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < l; k++) {
				C[i][k] += A[i][j] * B[j][k];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l - 1; j++) {
			cout << C[i][j] << ' ';
		}
		cout << C[i][l - 1] << endl;
	}
	return 0;
}

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

typedef pair<int, int> P;
typedef pair<P, P> PP;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> field(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
        }
    }

    vector<PP> res;
    for (int i = 0; i < H; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < W; j++) {
                if (j == W - 1) {
                    if (field[i][j] % 2 && i < H - 1) {
                        field[i][j]--;
                        field[i + 1][j]++;
                        res.push_back(PP(P(i, j), P(i + 1, j)));
                    }
                } else {
                    if (field[i][j] % 2) {
                        field[i][j]--;
                        field[i][j + 1]++;
                        res.push_back(PP(P(i, j), P(i, j + 1)));
                    }
                }
            }
        } else {
            for (int j = W - 1; j >= 0; j--) {
                if (j == 0) {
                    if (field[i][j] % 2 && i < H - 1) {
                        field[i][j]--;
                        field[i + 1][j]++;
                        res.push_back(PP(P(i, j), P(i + 1, j)));
                    }
                } else {
                    if (field[i][j] % 2) {
                        field[i][j]--;
                        field[i][j - 1]++;
                        res.push_back(PP(P(i, j), P(i, j - 1)));
                    }
                }
            }
        }
    }

    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) {
        P p1 = res[i].first;
        P p2 = res[i].second;
        cout << p1.first + 1 << " " << p1.second + 1 << " " << p2.first + 1 << " " << p2.second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include<iostream>

int main(void){
    std::string s;
    std::cin >> s;
    for(int i = 1; i < s.size(); i++){
        if(s[i] == s[i-1]){
            std::cout << "Bad" << std::endl;
            return 0;
        }
    }
    std::cout << "Good" << std::endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(long i=k;i<n;++i)
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    string S;
    cin>>S;
    if(S.substr(0,N/2)==S.substr(N/2,N/2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, M;
    i64 K;
    cin >> N >> M >> K;
    Vec<i64> A(N);
    Vec<i64> B(M);
    for (i32 i = 0; i < N; i++) cin >> A[i];
    for (i32 j = 0; j < M; j++) cin >> B[j];
    Vec<i64> S(N + 1, 0);
    Vec<i64> T(M + 1, 0);
    for (i32 i = 1; i <= N; i++) {
        S[i] = S[i - 1] + A[i - 1];
    }
    for (i32 i = 1; i <= M; i++) {
        T[i] = T[i - 1] + B[i - 1];
    }
    i64 max_v = 0;
    i64 j = M;
    for (i64 i = 0; i <= N; i++) {
        i64 sub = K - S[i];
        if (sub < 0) {
            break;
        }
        while (T[j] > sub) j--;
        max_v = max(max_v, i + j);
    }
    cout << max_v << endl;

}


Measured memory_bytes: 9540
int main(void)
{
	int a;			/* ??\?????? */
	int b;			/* ??\?????? */
	int c;			/* ??\?????? */
	int i;			/* ???????????¨?????° */
	int j;			/* ???????????¨?????° */
	int tmp;		/* ????\???¨ */
	int data[3];	/* ??????   */
	
	/* input */
	scanf("%d %d %d", &a, &b, &c);
	data[0] = a;
	data[1] = b;
	data[2] = c;
	
	/* process	*/
	for( i = 0; i < 2; i++){
		for( j = ( i + 1 ); j < 3; j++){
			if( data[i] > data[j] ){
				tmp = data[i];
				data[i] = data[j];
				data[j] = tmp;
			}
		}
	}
	
	/* output */
	printf("%d %d %d\n", data[0], data[1], data[2]);
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    long long a,b,n;cin>>a>>b>>n;
    long long mxf=(n>=b)?b-1:n%b;
    cout<<(mxf*a)/b<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

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

    int K = scanner.nextInt();
    int X = scanner.nextInt();
    int left = Math.max(-1000000, X - K + 1);
    StringBuilder sb = new StringBuilder();
    for (int i = left; i < X + K && i <= 1000000; i++) sb.append(i).append(' ');
    sb.setLength(sb.length() - 1);
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

void returnCharge(int n, int pay[4], int coin[4], int have[4], int ans[6]){
    int payTotal = 0;
    rep(i,4) payTotal+= pay[i] * coin[i];
    int charge = payTotal - n;

    for(int i = 3; i >= 0; i--){
        have[i]+= charge / coin[i]; 
        charge = charge % coin[i];
    }

    int totalHaveCoin = 0,totalPayCoin = 0;
    rep(i,4){
        totalHaveCoin += have[i];
        totalPayCoin += pay[i];
    }
    if( (totalHaveCoin < ans[4]) || (totalHaveCoin == ans[4] && totalPayCoin < ans[5])){
        rep(i,4) ans[i] = pay[i];
        ans[4] = totalHaveCoin;
        ans[5] = totalPayCoin;
    }
}

int main(){
    int n, coin[4] = {10,50,100,500}, have[4] = {-1}, haveCopy[4];
    while(cin >> n, n){
        int pay[4], ans[6];
        rep(i,6) ans[i] = 500000;
        if(have[0] != -1) cout << endl;
        rep(i,4){
            cin >> have[i];
        }
        rep(i,have[0] + 1){
            rep(j,have[1] + 1){
                rep(k,have[2] + 1){
                    rep(l,have[3] + 1){
                        if(i * 10 + j * 50 + k * 100 + l * 500 >= n){
                            pay[0] = i;
                            pay[1] = j;
                            pay[2] = k;
                            pay[3] = l;
                            rep(i,4) haveCopy[i] = have[i] - pay[i];
                            returnCharge(n,pay,coin,haveCopy,ans);
                        }
                    }
                }
            }
        }
        rep(i,4){
            if(ans[i] != 0){
                cout << coin[i] << ' ' << ans[i] << endl;
            }
        }
    }
}

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

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = 998244353;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << t/a*b << endl;

    return 0;
}

Measured memory_bytes: 768
def main():
  N, K = (int(_) for _ in input().split())
  if K%2 == 1:
    print(pow(N // K, 3))
    return
  a = N // K
  b = (N - K//2) // K + 1
  print(pow(a, 3) + pow(b, 3))
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k;
  cin>>k;
  
  queue <long long> qq;
  for(int i=1;i<=9;i++)
  {
   qq.push(i);
  }
  int count =0;
  while(1){
    long long x=qq.front();
    count++;
    qq.pop();
    if(count==k){
      cout<<x<<"\n";
      return 0;
    }
    if(x%10!=0)
      qq.push(x*10+x%10-1);
    qq.push(x*10+x%10);
    if(x%10!=9)
      qq.push(x*10+x%10+1);
  }
  
}
    
    
    
    
    
    
    


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, K = map(int, input().split())
    if N >= 2 * (K - 1) + 1:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61768
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	long long int h;
	cin >> h;
	long long int c = 1;
	long long int res = 0;
	while (h > 0) {
		h /= 2;
		res += c;
		c *= 2;
	}
	cout << res << endl;
}









Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 1000
#define QMAX 150

int LCS(char *, char *);
int max(int, int);

int Z[QMAX];

int main(){

  int i = 0;
  int q = 0;
  char X[N];
  char Y[N];

  scanf("%d",&q);

  for(i = 0; i < q; i++){
    scanf("%s",X);
    scanf("%s",Y);
    printf("%d\n",LCS(X,Y));
  }
  /*
  for(i = 0; i < q; i++){
    printf("%d\n",Z[i]);
  }
  */
  return 0;
  
}

int LCS(char *X, char *Y){

  int i = 0, j = 0;
  int xlen = strlen(X), ylen = strlen(Y),maxc = 0;
  int c[N+1][N+1];

  
  for(i = 0; i <= xlen; i++){//i = 0 or j = 0 -> c[i][j] = 0
    c[0][i] = 0;
  }
  for(i = 0; i <= ylen; i++){
    c[i][0] = 0;
  }

  for(j = 1; j <= ylen; j++){
    
    for(i = 1; i <= xlen; i++){
      if(X[i-1] == Y[j-1]){
	c[i][j] = c[i-1][j-1] +1;
	maxc = max(maxc,c[i][j]);
      }
      else if(X[i-1] != Y[j-1]){
	c[i][j] = max(c[i-1][j],c[i][j-1]);
      }
    }
    
  }
  
  return maxc;
  
}

int max(int a, int b){
  
  if(a > b)return a;
  else return b;
  
}



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

int main() {
	int i, k;
	for (i = 1; i < 10; i++) {
		for (k = 1; k < 10; k++) {
			std::cout << i << "x" << k << "=" << i * k << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <utility>
using namespace std;

template <typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &ai: a) cin >> ai;
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[j] == a[i]) continue;
      for (int k = j + 1; k < n; ++k) {
        if (a[k] == a[i] || a[k] == a[j]) continue;
        if (a[i] + a[j] > a[k]) {
          ++ans;
        }
      }
    }
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3636
#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>;

const ll mod = 1e9;

int main(){
    int n;
    cin >> n;
    vector<int> rate(9);
    int a;
    rep(i,n){
        cin >> a;
        if (a < 3200) rate[a/400]++;
        else rate[8]++;
    }
    int ans = 0;
    rep(i,9){
        if(i == 8){
            if (ans == 0) cout << 1 << ' ' << rate[i] << endl;
            else cout << ans << ' '  << ans + rate[i] << endl;
        }
        else if (rate[i] != 0) ans++;
    }
    return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
S = list(input())
flag = 0
if S[A] == "-":
    pass
else:
    flag = 1
    print("No")
high = S.pop(A)
s = "".join(S)
if flag == 0:
    if s.isdecimal():
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
main(){
  pair<double,int>x[3];
  r(i,3){
    pair<double,int>p[8];
    r(j,8)cin>>p[j].second>>p[j].first;
    sort(p,p+8);
    cout<<p[0].second<<' '<<p[0].first<<endl;
    cout<<p[1].second<<' '<<p[1].first<<endl;
    x[i].second=p[2].second;
    x[i].first=p[2].first;
  }
  sort(x,x+3);
  cout<<x[0].second<<' '<<x[0].first<<endl;
  cout<<x[1].second<<' '<<x[1].first<<endl;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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 int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    ld a,b;
    cin >> a >> b;
    ll ans = a*b;
    cout << ans << endl;

}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
int main(){
  ll n,a[5];
  cin>>n>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
  ll come =n;
  ll ans =4;
  rep(i,5){
  if(come>a[i]){
    come=a[i];
  }
  }
  ans+=(n/come);
  if(n%come)ans++;
  cout<<ans<<endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int h, w;
int f[11][11];

int main() {
    vector<int> res;
    while (cin >> h >> w and h) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> f[i][j];
            }
        }
        int cnt = 0;
        for (int i = 3; i <= h; i++) {
            for (int j = 3; j <= w; j++) {
                for (int k = 0; k <= h - i; k++) {
                    for (int l = 0; l <= w - j; l++) {
                        // cout << k << " " << l << endl;
                        // cout << "H size:" << i << " W size:" << j << endl;
                        int mi = inf;
                        for (int m = 0; m < j; m++) {
                            mi = min(mi, f[k][l + m]);
                            mi = min(mi, f[k + i - 1][l + m]);
                        }
                        for (int m = 0; m < i; m++) {
                            mi = min(mi, f[k + m][l]);
                            mi = min(mi, f[k + m][l + j - 1]);
                        }
                        int ma = -1;
                        int sum = 0;                        
                        for (int m = 1; m < i - 1; m++) {
                            for (int n = 1; n < j - 1; n++) {
                                ma = max(ma, f[k + m][l + n]);
                                sum += mi - f[k + m][l + n];
                            }
                        }
                        // dump(ma);
                        if (mi > ma) {
                            cnt = max(cnt, sum);
                        }
                    }
                }
            }
        }
        res.push_back(cnt);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}


Measured memory_bytes: 3120
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin >> n >> m;
	ll x=n-1;
	ll ans=1;
	if(m==1){
		cout << 0;
		return 0;
	}
	for(ll i=1; i<=1000; i++){
		ans+=x;
		if(ans>=m){
			cout << i;
			return 0;
		}
	}
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,M,p,ac=0,wa[100001]={0},sum=0;
	bool acF[100001]={0};
	string S;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>p>>S;
		if(S=="WA"&&acF[p]==false){wa[p]++;}
		else if(S=="AC"&&acF[p]==false){acF[p]=true;ac++;}
	}
	for(int i=1;i<=N;i++){
		if(acF[i])sum+=wa[i];
	}
	cout<<ac<<" "<<sum;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jun 28 20:59:50 JST 2020
 **/

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

Int D;
std::vector<Int> c;
std::vector<std::vector<Int>> s;
constexpr Int K = 26;

Int calc_score(const std::vector<Int>& a) {
    assert(a.size() == D);
    Int ret = 0;
    Int sum = std::accumulate(c.begin(), c.end(), 0LL);
    Int cur_minus = 0;
    std::vector<Int> last(K, -1);
    REP(d, D) {
        cur_minus += sum - c[a[d]] * (d - last[a[d]]);
        ret += s[d][a[d]] - cur_minus;
        last[a[d]] = d;
    }
    return ret;
}

std::chrono::system_clock::time_point start_time;
std::vector<Int> ans(D);
Int best_score;
std::vector<Int> local_search(Int t) {
    std::vector<Int> nxt = ans;
    if (t % 10 == 0) {
        Int idx = rnd() % (D - 1);
        std::swap(nxt[idx], nxt[idx + 1]);
    } else {
        Int idx = rnd() % D;
        nxt[idx] = rnd() % K;
        return nxt;
    }
    return nxt;
}
const Int INF = 1e9;
void hill_climb() {
    std::vector<Int> cnt(2);
    constexpr double TIME_LIMIT = 1900;
    double start_temp = 50, end_temp = 10;
    REP(t, 1e9) {
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        double dur = std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time).count();
        if (dur > TIME_LIMIT) break;
        // change
        auto nxt = local_search(t);
        Int nxt_score = calc_score(nxt);
        double temp = start_temp + (end_temp - start_temp) * dur / TIME_LIMIT;
        double prob = std::exp((nxt_score - best_score) / temp);
        if (nxt_score >= best_score || prob > (rnd() % INF) / (double)INF) {
            std::cerr << t << " " << best_score << " " << nxt_score << "\n";
            best_score = nxt_score;
            ans = std::move(nxt);
            cnt[t % 2]++;
        }
    }
    dump(cnt);
}

signed main() {
    start_time = std::chrono::system_clock::now();
    // input
    std::cin >> D;
    c.resize(K);
    s = make_vec<Int>(D, K, 0);
    REP(i, K) std::cin >> c[i];
    REP(i, D) REP(j, K) std::cin >> s[i][j];

    // hoge
    ans.resize(D);
    REP(i, D) ans[i] = i % K;
    best_score = calc_score(ans);
    hill_climb();
    // dump(calc_score(ans));
    // REP(i, D) { ans[i] = std::max_element(s[i].begin(), s[i].end()) - s[i].begin(); }
    // dump(calc_score(ans));

    // output
    for (Int x : ans) std::cout << x + 1 << "\n";
    std::cout << std::endl;
}


Measured memory_bytes: 4392
import java.util.Scanner;

/**
 * TITLE : Poor
 * URL : https://atcoder.jp/contests/abc155/tasks/abc155_a
 */
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 ((A == B && B == C) || (A != B && A != C && B != C)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
        sc.close();
    }
}

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

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

int main(){
  int n;
  cin >> n;
  vector<int> P(n);
  rep(i,n)P[i]=i;
  
  int x[n], y[n];
  rep(i,n)cin >> x[i] >> y[i];
  
  double mean = 0;
  double N = 1;
  rep(i,n)N*=(i+1);

  do{
    for(int i=1;i<n; i++) 
      mean += sqrt(pow(x[P[i]]-x[P[i-1]],2.0) 
        + pow(y[P[i]]-y[P[i-1]], 2.0))/N;
  }while(next_permutation(P.begin(), P.end()));
  printf("%.10g\n",mean);
  return 0; 

   
}

Measured memory_bytes: 384
#include <cstdio>
#include <string>

class List
{
    int* data_; //[4000000];
    int begin_;
    int end_;
public:
    List()
    {
        data_ = new int[4000000];
        begin_ = 2000000;
        end_  = 2000000;
    }
    // ~List()
    // {
    //     delete[] data_;
    // }
    void Insert(int X)
    {
        --begin_;
        data_[begin_] = X;
    }
    void Delete(int X)
    {
        int Index = end_;
        for(int i = begin_; i < end_; ++i){
            if(X == data_[i]){
                Index = i;
                break;
            }
        }
        if(Index == end_) return;
        for(int i = Index; i < end_; ++i){
            data_[i] = data_[i+1];
        }
        end_--;
    }
    void DeleteFirst()
    {
        begin_++;
    }
    void DeleteLast()
    {
        end_--;
    }
    void Show()const
    {
        printf("%d", data_[begin_]);
        for(int i = begin_ + 1; i < end_; ++i){
            printf(" %d", data_[i]);
        }
        printf("\n");
    }
};

int main()
{
    List list;
    int n, X;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            list.DeleteFirst();
        }else
        if(com[6] == 'L'){
            list.DeleteLast();
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                list.Insert(v);
            }else
            if(com[0] == 'd'){
                list.Delete(v);
            }
        }
    }
    list.Show();
    return 0;
}

Measured memory_bytes: 6648
n, p = map(int, input().split())
s = list(input())
r = [0] * p
ans = 0
if not (p == 2 or p == 5):
    x, t = 0, 1
    for i in range(-1, -(n + 1), -1):
        x += (int(s[i]) * t)
        x %= p
        r[x] += 1
        t *= 10
        t %= p
    for i in r:
        if i >= 2:
            ans += (i * (i - 1) // 2)
    ans += r[0]
else:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += (i + 1)
print(ans)

Measured memory_bytes: 10812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector< vector<int> > VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    ll l,r; cin>>l>>r;
    ll up = 2019, ans = 2019;
    for(ll i=l; i<=r && i<=l+up; i++){
        for(ll j=i+1; j<=r && j<=l+up; j++){
            ans = min(ans, (i*j)%2019);
        }
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

long long poww(long long a,long long b)
{
	long long res=1,base=a;
	while(b)
	{
		if(b&1)
			res=(res*base)%mod;
		base=(base*base)%mod;
		b>>=1;
	}
	return res;
}

long long fac[maxn],inv[maxn];

void init()
{
	inv[0]=fac[0]=1;
	for(int i=1;i<maxn;i++)
		fac[i]=(fac[i-1]*i)%mod;
	for(int i=1;i<maxn;i++)
		inv[i]=poww(fac[i],mod-2);
}

long long c(long long n,long long m)
{
	if(n < m)
		return 0;
	return fac[n] % mod * inv[n-m] % mod *inv[m] % mod;
}

int n,k;
long long a[maxn];
long long ans_max,ans_min;
int main()
{
	//freopen("1.in","r",stdin);
    init();
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);

	sort(a+1,a+1+n);
	
	for(int i=1;i<=n;i++)
	{
		ans_max=(ans_max + a[i] * c(i-1,k-1)) % mod;
	//	cout<<ans_max<<endl;
		ans_min=(ans_min + a[i] * c(n-i,k-1)) % mod;
	}
	
	printf("%lld\n",(ans_max - ans_min + mod) % mod);
	return 0;
}


Measured memory_bytes: 4096
def main():
    import sys
    input = sys.stdin.readline

    class RollingHash:
        def __init__(self, S, base, mod):
            self.S = S
            self.mod = mod
            self._hash = [0] * (len(S) + 1)
            self.pow = [1] * (len(S) + 1)

            for i, s in enumerate(S):
                self._hash[i + 1] = (self._hash[i] * base + s) % mod
                self.pow[i + 1] = (self.pow[i] * base) % mod

        def get(self, l, r):
            # 0-indexed, [l. r)
            return (self._hash[r] - self._hash[l] * self.pow[r - l]) % self.mod

    S = [ord(s) for s in input().rstrip('\n')]
    T = [ord(t) for t in input().rstrip('\n')]

    RH_S = RollingHash(S, 1007, 1000000007)
    RH_T = RollingHash(T, 1007, 1000000007)
    lt = len(T)
    T_hash = RH_T.get(0, lt)
    for i in range(len(S) - len(T) + 1):
        if RH_S.get(i, i+lt) == T_hash:
            print(i)


if __name__ == '__main__':
    main()



Measured memory_bytes: 94328
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 0;i<n;i++) {
			ans+=sc.nextInt();
			ans--;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25576
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        
        
        System.out.println((a + b) * h /2);
    }
}


Measured memory_bytes: 21844