akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 int MOD = 1e9+7;
const ll LINF = 1e18;

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

  ll ans = 0;
  REP(a,n) REP(b,n) {
    if (a==0 || b==0) continue;
    if (n <= a*b) break;
    ans++;
  }

  COUT(ans);
  return 0;
}

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

using namespace std;

#define MOD 1000000007
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626

typedef long long ll;

void solve()
{
    
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    int k;
    cin>>n>>k;
    ll a[n+1];
    for(int i=1; i<=n; i++)cin>>a[i];
    ll prev;
    ll curr=1;
    curr*=a[1];
    curr*=a[k];
    prev=curr;
    for(int i=k+1; i<=n; i++)
    {
        curr=a[i]*a[i-1];
        if(curr<=prev)
        {
            cout<<"No\n";
        }
        else cout<<"Yes\n";
        prev=a[i-k+1]*a[i];
    }
    return 0;
}

Measured memory_bytes: 5176
#include <stdio.h>
#include <map>
using namespace std;

map<int, int> red;
int N,A[100000];

int main()
{
	scanf ("%d",&N);
	int cnt = 0;
	for (int i=0;i<N;i++){
		scanf ("%d",&A[i]);
		red[A[i]] = 0;
	}
	int v = 0;
	for (auto &p : red) p.second = v++;
	for (int i=0;i<N;i++){
		if (red[A[i]] % 2 != i % 2) cnt++;
	}
	printf ("%d\n",cnt/2);

	return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;

int main(){
  ll N,K;
  cin>>N>>K;
  cout<<(N-2)/(K-1)+1<<endl;

}

Measured memory_bytes: 256
#include <iostream>

const int MAXN = 110;
using namespace std;

int h, w;
int col[MAXN][MAXN];
int x, y;
bool flag;

void paint(int c, int cnt)
{
	while(cnt--)
	{
		col[x][y] = c;
		
		if(flag == 0)
		{
			if(y < w -1)
				y++;
		
			else if(y == w -1)
			{
				flag = 1;
				x++;
			}
		}
		
		else
		{
			if(y > 0)
				y--;
			
			else if(y == 0)
			{
				flag = 0;
				x++;
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> h >> w;
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		int foo;
		cin >> foo;
		paint(i, foo);
	}
	
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
			cout << col[i][j] << ' ';
		
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[81][81],b[81][81];
int dp[81][81][12802];

int main() 
{
    int n,m;
    cin >> n >> m;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin >> a[i][j];
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin >> b[i][j];
    }
    
    memset(dp, false, sizeof dp);
    
    dp[0][0][abs(a[0][0]-b[0][0])] = true;
    
    for(int j=1;j<m;j++){
        for(int k=0;k<=12801;k++){
            if(dp[0][j-1][k]){
                dp[0][j][k+(abs(a[0][j]-b[0][j]))] = true;
                dp[0][j][abs(k-(abs(a[0][j]-b[0][j])))] = true;
            }
        }
    }
    
    for(int i=1;i<n;i++){
        for(int k=0;k<=12801;k++){
            if(dp[i-1][0][k]){
                dp[i][0][k+abs(a[i][0]-b[i][0])] = true;
                dp[i][0][abs(k-abs(a[i][0]-b[i][0]))] = true;
            }
        }
    }
    
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            for(int k=0;k<=12801;k++){
                if(dp[i][j-1][k]){
                    dp[i][j][k+abs(a[i][j]-b[i][j])] = true;
                    dp[i][j][abs(k-abs(a[i][j]-b[i][j]))] = true;
                }
                
                if(dp[i-1][j][k]){
                    dp[i][j][k+abs(a[i][j]-b[i][j])] = true;
                    dp[i][j][abs(k-abs(a[i][j]-b[i][j]))] = true;
                }
            }
        }
    }
    
    for(int k=0;k<=12801;k++){
        if(dp[n-1][m-1][k]){
            cout<<k<<endl;
            return 0;
        }
    }
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
vi move1 = {-1,-1,-1,0,0,0,1,1,1};
vi move2 = {1,0,-1,1,0,-1,1,0,-1};

/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    ll n,m; cin >> n >> m;
    /**
     * 隣接するマスの数+1回ひっくり返る
     */
    ll h = min(n,m), w = max(n,m);
    ll cnt = 0, tmp;

    if(h==1) {
         if(w==1) cout << 1 << '\n';
         else if(w==2) cout << 0 << '\n';
         else cout << w-2 << '\n';
    }
    else {
         cout << (h-2)*(w-2) << '\n';
    }


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
while True:
    H,W = [int(x) for x in input().split()]
    if W == 0 and H == 0:
        break
    unit = "#."
    for i in range(H):
        print(unit*(W//2)+unit[0]*(W%2))
        unit = unit[1]+unit[0]                                              
    print("")

Measured memory_bytes: 7724
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class C {
public:
  static void solve(istream &cin, ostream &cout) {
    int n;
    cin >> n;
    vector<int> alphabet(200, INF);
    string ans{};
    rep(_, n) {
      string temp;
      cin >> temp;
      vector<int> temp2(200, 0);
      FOR(i, temp) {
        temp2[i]++;
      }
      REP(i, 'a', 'z' + 1) {
        alphabet[i] = min(alphabet[i], temp2[i]);
      }
    }
    REP(i, 'a', 'z' + 1) {
      rep(j, alphabet[i]) {
        char temp3 = i;
        ans += temp3;
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  C solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3656
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,M,V,P = LI()
A = LI()

A.sort(reverse=True)
cumA = [A[0]]
for i in range(1,N):
    cumA.append(cumA[-1]+A[i])

ans = P
if V < P:
    for i in range(P,N):
        if A[P-1] <= A[i]+M:
            ans += 1
else:
    for i in range(P,N):
        if A[i]+M < A[P-1]:
            continue
        cum = cumA[i-1]-cumA[P-2] if P >= 2 else cumA[i-1]
        cap = (i-P+1)*(M+A[i]) - cum + M*(N-i-1)
        if cap >= M*(V-P):
            ans += 1

print(ans)

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

ll SumFunc(ll a, ll l, ll n)
{
    return n * (a + l) / 2;
}

int main(void)
{
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    //irep(i, k) {
    for(int i = 0; k + i <= n + 1; i++) {
        ll min = SumFunc(0, (k+i)-1, k+i);
        ll max = SumFunc(n-(k+i)+1, n, k+i);
        //cout << min << endl; cout << max << endl;; cout << endl;
        ans += max-min+1;
        ans %= IMOD;
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 3636
MOD = 10 ** 9 + 7
n = gets.to_s.to_i
a = gets.to_s.split.map { |v| v.to_i }
cnt = Array.new(60, 0)

a.each do |v|
  60.times do |i|
    cnt[i] += 1 if v[i] == 1
  end
end

ans = 0
cnt.each_with_index do |v, i|
  ans += (1 << i) * v * (n - v)
  ans %= MOD
end
puts ans


Measured memory_bytes: 37264
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = sc.nextInt();
        int syoukin = syoukin(n) + syoukin(i);
        if (n == 1 && i == 1) syoukin += 400000;

        System.out.println(syoukin);
    }

    static int syoukin(int rank) {
        switch (rank) {
            case 3:
                return 100000;
            case 2:
                return 200000;
            case 1:
                return 300000;
            default:
                return 0;
        }
    }
}


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

int main () {

    int n, x, y;
    int count = 0;
    cin >> n;

    for (int i = 0 ; i < n; i++ ) {
           cin >> x; 
           cin >> y; 
           count += y - x + 1;

    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    int N;
    R(N);
    int an=0;
    FOR(i,1,N){
        int v;
        R(v);
        an+=(v%2==1&&i%2==1);
    }
    W(an);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include<bits/stdc++.h>
#include<cmath>
#include <algorithm> 
#include<map>
#include<string>
#include<unordered_map>
#include <set>
#include <unordered_set>

using namespace std;

const long long N = (1e4 + 7);

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n;
	cin >> n;
	long long ans = 0;
	vector<long long>arr;
	for (int i = 0; i < n; i++) {
		long long t;
		cin >> t;
		arr.push_back(t);
	}
	for (int i = 0; i < n - 1; i++) {
		if (arr[i] > arr[i + 1]) {
			ans = ans + arr[i] - arr[i + 1];
			arr[i + 1] = arr[i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5300
N = int(input())
A = [1,2,3,4,5,6,7,8,9]
B = [1,2,3,4,5,6,7,8,9]

y = []

for i in A:
    for j in B:
        if i*j == N:
            y.append('yes')
if y == []:
    print('No')     
else:
    print('Yes') 

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

using namespace std;
long long n,w;
long long wt[100+1],vl[100+1];
vector<vector<long long> >v(1002,vector<long long>(100006,-1));
long long sol(int idx=0,long long ttlw=0){
    if(idx==n)
        return 0;
    if(v[idx][ttlw]!=-1)
        return v[idx][ttlw];
    if(ttlw+wt[idx]>w)
        return v[idx][ttlw]=sol(idx+1,ttlw);
    return v[idx][ttlw]=max(vl[idx]+sol(idx+1,ttlw+wt[idx]),sol(idx+1,ttlw));
}

int main()
{
    cin>>n>>w;
    pair<int,int>arr[n+1][n+3];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>vl[i];
    }
    cout << sol() << endl;
    return 0;
}


Measured memory_bytes: 786812
s = input()

ans = [0, 0]
for i in range(100):
    for j in range(1, 13):
        if str(i).zfill(2) + str(j).zfill(2) == s:
            ans[0] = 1
        if str(j).zfill(2) + str(i).zfill(2) == s:
            ans[1] = 1

if sum(ans) == 2:
    print("AMBIGUOUS")
elif ans[0] == 1:
    print("YYMM")
elif ans[1] == 1:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;
    std::vector<int> a(n), b(n), c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];

    int ans = 0;
    rep(i,n){
        ans+=b[a[i]-1];
        if(i>=1 && a[i]-a[i-1]==1) ans += c[a[i-1]-1];
    }
    cout << ans << endl;



    return 0;
}

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

string make(string t, string s){
    for(int i = 1; i < s.size(); i++){
        if(s[i] == 'o'){
            if(t[i] == 'S') t += t[i-1];
            else t += t[i-1] == 'S' ? 'W' : 'S';
        }else{
            if(t[i] == 'W') t += t[i-1];
            else t += t[i-1] == 'S' ? 'W' : 'S';
        }
    }
    return t;
}

int main(){
    int n;
    string s;
    cin >> n >> s;
    string tmp[4] = {"SS", "SW", "WS", "WW"};
    for(int i = 0; i < 4; i++)
    for(int i = 0; i < 4; i++){
        string res = make(tmp[i], s);
        if(res[0] == res[n]){
            if(s[0] == 'o'){
                if(res[0] == 'S'){
                    if(res[1] == res[n-1]){
                        cout << res.substr(0, n) << endl;
                        return 0;
                    }
                }else{
                    if(res[1] != res[n-1]){
                        cout << res.substr(0, n) << endl;
                        return 0;
                    }
                }
            }else{
                if(res[0] == 'W'){
                    if(res[1] == res[n-1]){
                        cout << res.substr(0, n) << endl;
                        return 0;
                    }
                }else{
                    if(res[1] != res[n-1]){
                        cout << res.substr(0, n) << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
const ll INF = 4e18;
const ll MOD = 1e9+7;

int a[60], b[60], n, ans;

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

  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, tmp;
    cin >> x;
    tmp = x;
    int cnt = 0;
    while (tmp % 2 == 0) {
      tmp >>= 1;
      cnt++;
    }
    a[cnt]++;
    for (int i = 0; i < 33; i++) {
      b[i] += x&1;
      x>>=1;
    }
  }
  for (int i = 32; i >= 0; i--) {
    if (b[i] & 1) {
      if (a[i] == 0) {
        cout << -1 << endl;
        return 0;
      }
      a[i]--;
      ans++;
      for (int j = i-1; j >= 0; j--) b[j]++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d %d %d",&a,&b,&c);
	if((a==b || a==c || b==c) && (a!=b || a!=c || b!=c)) puts("Yes");
	else puts("No");return 0;
}

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

#ifndef DUMP
#define DUMP(...) void(0)
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int n = size(s), m = size(t);
  int res = m;
  for (int start = 0; start + m <= n; ++start) {
    int cur = 0;
    for (int i = 0; i < m; ++i) {
      cur += s[start + i] != t[i];
    }
    res = min(res, cur);
  }
  cout << res << '\n';
}


Measured memory_bytes: 3644
def main():
    if int(input()) == 1:
        print('Hello World')
    else:
        print(int(input()) + int(input()))


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = deque(input())
B = deque(input())
C = deque(input())

def DFS(N):
	if not eval(N):
		print(N)
	else:
		p = eval("{}.popleft()".format(N))
		DFS(p.upper())

DFS("A")


Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
const int mn=310;
typedef long long ll;
int n;
ll a[mn][mn],b[mn][mn],ans,tmp;
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			scanf("%lld",&a[i][j]);
	memset(b,-1,sizeof(b));
	ans=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++) {
			if (i==j)
				continue;
			bool t=0;
			for (int k=1;k<=n;k++) {
				if (i==k||j==k)
					continue;
				if (a[i][k]+a[k][j]==a[i][j]) {
					t=1;
					break;
				}
			}
			if (!t) {
				b[i][j]=a[i][j];
				ans+=b[i][j];
			}
		}
	ans/=2;
	for (int i=1;i<=n;i++)
		b[i][i]=0;
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++) {
				if (i==j) continue;
				if (b[i][k]==-1||b[k][j]==-1) continue;
				tmp=b[i][k]+b[k][j];
				if (b[i][j]==-1||b[i][j]>tmp)
					b[i][j]=tmp;
			}
	bool A=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (a[i][j]!=b[i][j]) {
				A=0;
				break;
			}
	if (!A) ans=-1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main{
	public static void main(String[]args){
    	Scanner sc=new Scanner(System.in);
    	int x=sc.nextInt();int a=sc.nextInt();int b=sc.nextInt();
        System.out.println((x+a>=b)?(a>=b)?"delicious":"safe":"dangerous");
    }

}


Measured memory_bytes: 23636
def main():
  mod = 10**9+7
  rng = 2000100
  fctr = [1]
  finv = [1]
  fcappend = fctr.append
  fiappend = finv.append
  for i in range(1,rng):
    fcappend(fctr[-1]*i%mod)
  for i in range(1,rng):
    fiappend(pow(fctr[i],mod-2,mod))
  def cmb(n,k):
    if n<0 or k<0:
      return 0
    else:
      return fctr[n]*finv[n-k]*finv[k]%mod

  x1,y1,x2,y2 = map(int,input().split())
  print((cmb(x2+y2+2,x2+1)-cmb(x2+y1+1,y1)-cmb(x1+y2+1,x1)+cmb(x1+y1,x1))%mod)
main()

Measured memory_bytes: 137472
// ABC_123_A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
using namespace std;

#include <iostream>

int main()
{
	int a, b, c, d, e, k = 0;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k)
		cout << ":(";
	else
		cout << "Yay!";
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
S = input()

i = len(S)
while 0 < i:
	#print(i)
	if S[i - 6:i] == "eraser":
		#print(S[i - 6:i])
		i -= 6
	elif S[i - 7:i] == "dreamer":
		#print(S[i - 7:i])
		i -= 7
	elif S[i - 5:i] == "erase" or S[i - 5:i] == "dream":
		#print(S[i - 5:i])
		i -= 5
	else:
		break
print(["YES", "NO"][not(i == 0)])


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String odds, evens;
        Scanner sc = new Scanner(System.in);
        odds = sc.nextLine();
        evens = sc.nextLine();
        sc.close();
        for (int i = 0; i < evens.length(); i++) {
            System.out.printf("%c%c", odds.charAt(i), evens.charAt(i));
        }
        if (odds.length() > evens.length())
            System.out.println(odds.charAt(odds.length()-1));
    }
}


Measured memory_bytes: 22228
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <cmath>

using namespace std;

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		stack<int> mini,ran;
		string tmp;
		cin >> tmp;
		int elcnt = 0, intflag = 0, cnt = 0;
		for (int j = 0; j < tmp.length(); ++j) {
			if ('0' <= tmp[j] && tmp[j] <= '9') {
				if (!intflag) mini.push(tmp[j] - '0');
				else mini.top() = mini.top() * 10 + tmp[j] - '0';
				intflag++;
			} else if (intflag) {
				mini.top() = (mini.top() + 1) / 2;
				intflag = 0;
				cnt++;
			}
			if (tmp[j] == '[') {
				ran.push(cnt);
			} else if (tmp[j] == ']') {
				int num = cnt - ran.top();
				ran.pop();
				if (num != 1) {
					vector<int> tm(num);
					for (int k = 0; k < num; ++k) {
						tm[k] = mini.top();
						mini.pop();
					}
					sort(tm.begin(), tm.end());
					mini.push(tm[0]);
					for (int k = 1; k < (num + 1) / 2; ++k) mini.top() += tm[k];
				}
				cnt = cnt - num + 1;
			}
		}
		cout << mini.top() << endl;
	}

	return 0;
}


Measured memory_bytes: 3164
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 20:14:08 2019

@author: USER
"""

n,m,c = [int(s) for s in input().split(' ')]
b = [int(s) for s in input().split(' ')]
a = [[int(s) for s in input().split()] for i in range(n)]

sum = 0
ans = 0
for i in range(n):
    for j in range(m):
        sum += a[i][j] * b[j]
    sum += c
    if sum > 0:
        ans += 1
    sum = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    int A,B,C,D,E,F,Msum=0,MG=0;
    double per=0.0,max=0.0;
    cin>>A>>B>>C>>D>>E>>F;
    if(A<B){
        int a=A;
        A=B;
        B=a;
    }
    A*=100;
    B*=100;
    bool check=true;
    for(int i=0;i<=F/A+1;i++){
        check=true;
        for(int j=0;j<=F/C+1;j++){
            for(int k=0;k<=F/B+1;k++){
                for(int l=0;l<=F/D+1;l++){
                    int a=A*i;
                    int b=B*k;
                    int c=C*j;
                    int d=D*l;
                    double e=(c+d);
                    int f=((a+b)/100)*E;
                    double sum=a+b+c+d;
                    if(F>=sum&&sum!=0&&f>=e){
                        per=double(e/sum)*100;
                        if(per>max){
                            max=per;
                            Msum=sum;
                            MG=e;
                        }
                    }
                }
            }
        }
    }
    if(Msum==0&&F>=B){
        Msum=B;
    }
    cout<<Msum<<endl<<MG;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	int h, w;
	cin >> h >> w;
	char c[50][50];
	for (int i = 0; i != h; i++) {
		for (int j = 0; j != w; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 0; i != h; i++) {
		for (int j = 0; j != w; j++) {
			if(c[i][j] == '#'){
				if (c[i - 1][j] != '#' && c[i][j - 1] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') {
					cout << "No\n";
					return 0;
				}
			}
		}
	}
	cout << "Yes\n";
	return 0;
}


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

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

  char A, B;
  cin >> A >> B;
  if(A == 'H'){
    if(B == 'H'){
      cout << 'H' << endl;
    }
    else{
      cout << 'D' << endl;
    }
  }
  else{
    if(B == 'H'){
      cout << 'D' << endl;
    }
    else{
      cout << 'H' << endl;
    }
  }
}

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

ll gcd(ll x, ll y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}



int main(){
    string s;
    int a=0,b=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1') a++;
        else b++;
    }
    cout << min(a,b) *2<<endl;
}





Measured memory_bytes: 512
n, x = map(int, input().split())

while n != 0 or x != 0:
	cnt = 0
	i = 1
	while i <= n - 2:
		j = i + 1
		if i >= x:
			break
		while j <= n - 1:
			k = j + 1
			if i + j >= x:
				break
			while k <= n:
				if i + j + k > x:
					break
				if i + j + k == x:
					cnt += 1
				k += 1
			j += 1
		i += 1
	print(cnt)
	n, x = map(int, input().split())


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,M,X;
  cin>>N>>M>>X;
  vector<vector<ll>> A(N,vector<ll>(M+1));
  for(ll i=0;i<N;i++) {
for(ll j=0;j<M+1;j++) {
cin>>A[i][j];
}
  }
  ll min=0;
  for(ll tmp=1;tmp<(1<<N);tmp++) {
bitset<12> s(tmp);
    ll money=0;
    vector<ll> vec(M,0);
    for(ll i=0;i<N;i++) {
if(s.test(i)) {
   money+=A[i][0];
  for(ll j=0;j<M;j++) {
vec[j]+=A[i][j+1];
}
    }
    }
    
    bool g=true;
    for(ll i=0;i<M;i++) {
if(vec[i]<X) {
  g=false;
}
    }
    
    if(g) {
if(min==0||min>money) {
min=money;
}
    }
    
  }
  
  if(min==0) {
cout<<-1<<endl;
  }
  else {
cout<<min<<endl;
  }
}

  
  
  
  
  
  
  
  
  
  
  
  

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

def main():
    x, y, a, b, c = map(int, input().split())
    p = map(int, input().split())
    q = map(int, input().split())
    r = list(map(int, input().split()))
    p = list(reversed(sorted(p)))[:x]
    q = list(reversed(sorted(q)))[:y]
    pqr = list(reversed(sorted(p + q + r)))[:x + y]
    print(sum(pqr))

if __name__ == "__main__":
    main()


Measured memory_bytes: 28832
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
void solve()
{
  int a[6];
  for(int i=1; i<=5; i++)
    cin >> a[i];
    for(int i=1; i<=5; i++)
      if(a[i]!=i)
        cout << i << '\n';
}
int main()
{
  fastio
  solve();
  return 0;
}


Measured memory_bytes: 3536
n, k, q  = list(map(int, input().split()))
a = []
for i in range(q):
    a.append(int(input()))
 
point = [0]*n
for i in range(q):
    point[a[i]-1] += 1

for i in range(n):
    if k-(q-point[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8632
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  auto f = false;
  foreach (e; a) {
    if (e % 2 == 0) {
      if (e % 3 && e % 5) {
        f = true;
      }
    }
  }
  if (f) {
    writeln("DENIED");
  } else {
    writeln("APPROVED");
  }
}


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

using namespace std;


int main()
{
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    if(n>m){
        long long int tmp = m;
        m = n; n = tmp;
    }

    long long int cnt = 0;
    if(n==1&&m==1)cnt=1;
    else if(n==1)cnt=(m-2);
    else cnt=(n-2)*(m-2);
    printf("%lld",cnt);
    return 0;
}


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

int main() { 
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  int e = 50;

  for (int i = 0; i < N; i++){
    int d = 0;
    for (int j = 0; j < 50; j++) {
      if (v.at(i) % 2 == 0) {
        v.at(i) /= 2;
        d += 1;

      } else {
        if (d < e) {
          e = d;
          break;
        }
      }
    }
  }
  cout << e << endl;
}


Measured memory_bytes: 3584
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

void Main(){
	ll n;
	cin >> n;
	vector<pll> d;
	rep(i,n){
		ll a;
		cin >> a;
		d.pb(pll(a, i));
	}
	stable_sort(rall(d));
    
	/*
	rep(i,n) cout << d[i].fi << " " << d[i].se << endl;
	*/
  	
	/*
	for(auto dx : d){
		cout << dx.fi << " " << dx.se << endl;
	}
	//*/    
  
	// dp[i][j] : データ 0 ～ i-1 までを使って左端に j 個, 右端に i-j 個
	vector<vll> dp(n+1, vll(n+1, 0)); 
	dp[0][0] = 0;

	ll temp, temp2;
	rep(i,n){
		rep3(j,0,i+1){
			temp = 0;
			temp2 = 0;
			if(i >= j) {
				// 左端 j 個, 右端 (i-j) 個が埋まっている. データ i を右端へ
				temp = dp[i][j] + d[i].fi * abs(n - d[i].se - 1 - (i-j));
			}
			if(j-1 >= 0) {
				// 左端 (j-1) 個, 右端 (i-j+1) 個が埋まっている. データ i を左端へ
				temp2 = dp[i][j-1] + d[i].fi * abs(d[i].se - (j-1));
			}
			dp[i+1][j] = max(temp, temp2);
		}
	}
  	
	/*
	rep(i,n+1) {
		rep(j,n+1) cout << dp[i][j] << " ";
		cout << endl;
	}
	*/
	ll ans = 0;
	rep3(j,0,n) ans = max(ans, dp[n][j]);
	cout << ans << endl;
	return;
}

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

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




using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> PL;

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;
}


class UnionFind{
    public:
    vector<int> par;
    vector<int> val;
    int root(int input){
        if(par[input]==input) return input;
        return par[input] = root(par[input]);
    }
    void unite(int val1, int val2){
        par[val1] = root(par[val2]);
    }
    bool same(int val1, int val2){
        return root(par[val1]) == root(par[val2]);
    }
    UnionFind(){
        return;
    }
};

int N,Q;




int main() {
    
    string S; cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b, ab, x, y;
	cin >> a >> b >> ab >> x >> y;

	ll ans = 0;
	while (x > 0 || y > 0) {
		if (x > 0 && y > 0) {
			if (a + b > ab * 2) {
				x--;
				y--;
				ans += ab * 2;
			}
			else if (x > 0){
				x--;
				ans += a;
			}
			else {
				y--;
				ans += b;
			}
		}
		else if (x >= 1) {
			if (a > ab * 2) {
				x--;
				ans += ab * 2;
			}
			else {
				x--;
				ans += a;
			}

		}
		else {
			if (b > ab * 2) {
				y--;
				ans += ab * 2;
			}
			else {
				y--;
				ans += b;
			}

		}


	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		try (final java.util.Scanner sc = new java.util.Scanner(System.in)) {
			final int N = sc.nextInt();
			final int[] a = new int[N];
			final int[] b = new int[N];
			for (int i = 0; i < N; ++i) {
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
			}
			
			final int[] events = new int[N + 2];
			for (int i = 0; i < N; ++i) {
				if (a[i] >= events.length) continue ;
				events[a[i]] += 1;
				if (b[i] + 1 >= events.length) continue ;
				events[b[i] + 1] -= 1;
			}
			
			int rvalue = 0;
			int status = 1;
			for (int i = 0; i < events.length; ++i) {
				status += events[i];
				if (i <= status) {
					rvalue = Math.max(rvalue, i - 1);
				}
			}
			System.out.println(rvalue);
		}
	}

}



Measured memory_bytes: 71568
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N, M, Q;
  cin >> N >> M >> Q;

  vector<vector<int>> X(N+1, vector<int>(N+1, 0));
  for(int i = 0; i < M; i++){
    int L, R; cin >> L >> R;
    X[L][R]++;
  }

  vector<vector<int>> C(N+1, vector<int>(N+1,0));
  for(int i = 0; i <= N; i++){
      for(int j = 0; j < N; j++){
          C[i][j+1] = C[i][j] + X[i][j+1];
      }
  }


  vector<int> ans(Q,0);
  for(int i = 0; i < Q; i++){
    int p, q; cin >> p >> q;
    for(int k = p; k <=q; k++){
        ans[i] += C[k][q]-C[k][p-1];
    }
  }

  for(int i = 0; i < Q; i++) cout << ans[i] << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>

#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define fro(j,a,b) for(int j=a;j<b;j++)
#define pb push_back

using namespace std;

int main(){
    int k,x;
    cin>>k>>x;
    int val=k*500;
    if(val==x || val>x){
    	cout<<"Yes";
    }
    else{
    	cout<<"No";
    }

}


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

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if (a * b > c * d) {
		cout << a * b;
	}
	else {
		cout << c * d;
	}
	
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int countab = 0;
	ll tot = 0, c1;
	vector<int> cnt[200005];
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i){
		if (s[i] == 'A'){
			cnt[countab].push_back(1);
		}
		else if (s[i] == 'B' && i != s.size()-1 && s[i+1] == 'C'){
			cnt[countab].push_back(0);
			i++;
		}
		else{
			countab++;
		}
	}
	for (int i = 0; i <= countab; ++i){
		c1 = 0;
		for (int j = 0; j < cnt[i].size(); ++j){
			if (cnt[i][j] == 1){
				c1++;
			}
			else{
				tot += c1;
			}
		}
	}
	cout << tot << '\n';
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long x;
  cin >> x;
  long long res =  x / 11 * 2;
  if (x % 11 <= 6 && x % 11 > 0) res += 1;
  else if (x % 11) res += 2;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


#include <stdio.h>

#include<stdio.h>


long  _attack(ll h,ll *cnt);
long  _attack(ll h,ll *cnt) {
	(*cnt) *= 2;
	if (h<=1) return h;
	h /= 2;
	h=(h==1)?0:h;
	_attack(h,cnt);
}

int main(void)
{
	ll  h,cnt=1;

	ll_cin(h);

	_attack(h,&cnt);
	
	cnt--;
	ll_cout(cnt);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> ans(N + 1, 0);
    for (int i = 2; i <= N; i++){
        int x;
        cin >> x;
        ans.at(x)++;
    }
    for (int i = 1; i <= N; i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 4048
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N;
  cin >> N;
  vector<int> V;
  vector<int> C;
  rep(i, N) {
    int v;
    cin >> v;
    V.push_back(v);
  }
  rep(i, N) {
    int c;
    cin >> c;
    C.push_back(c);
  }
  int result = 0;
  rep(i, N) {
    int point = V[i] - C[i];
    if (point > 0) {
      result += point;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define inf 10000000000000

int main()
{    
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef APNA_IO
    	freopen("input.txt","r",stdin);
    	freopen("output.txt","w",stdout);
    #endif

	ll n;
	cin>>n;
	ll h[n][3];

	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<3;j++)
		{
			cin>>h[i][j];
		}
	}
    
    pll d[3];
    d[0].ff=1;
    d[0].ss=2;
    d[1].ff=0;
    d[1].ss=2;
    d[2].ss=1;
    d[2].ff=0;



	for(int i=1;i<n;i++)
		{
			for(int j=0;j<3;j++)
			{
				h[i][j]+=max(h[i-1][d[j].ss],h[i-1][d[j].ff]);
			}
		}

	cout<<max(max(h[n-1][0],h[n-1][1]),h[n-1][2]);

}

Measured memory_bytes: 2560
n = int(input())
s = input()
r = list(s).count('R')
g = list(s).count('G')
b = list(s).count('B')

ans = r*g*b
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)
        if (k<n and s[i] !=s[j] and s[j] !=s[k] and s[k]!=s[i]):
            ans -=1
print(ans)

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

int main(void) {
    int n;
    vector<int> x, o;
    cin >> n;
    x.resize(n);
    o.resize(n);
    for (int  i = 0; i < n; i++) {
        cin >> x[i];
        o[i] = x[i];
    }
    sort(x.begin(), x.end());
    for (int i = 0; i < n; i++) {
        if (distance(x.begin(), lower_bound(x.begin(), x.end(), o[i])) < n / 2)
            cout << x[n / 2] << endl;
        else 
            cout << x[n / 2 - 1] << endl;
     }
}


Measured memory_bytes: 3712