akhauriyash/Code-Regression huggingface dataset:
use std::cmp::{self, Ordering};
use std::collections::*;
use std::io::{self, Read};

const MOD: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n: usize = sc.read().unwrap();
    let k: usize = sc.read().unwrap();

    println!("{}", n - k + 1);
}

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

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}

ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}

int main(void) {
	int a,b,n,s,f;
	cin >> a >> b;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> s >> f;
		if ((a<f && f<b) || (a<s && s<b) || (s<=a && b<=f)) {
			ans = 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

const ll MODVAL = 1000000007LL;

ll mod_minus(ll x, ll modval) {
    if (x >= 0) {
        return x % modval;
    } else {
        ll mm = ((-x) % modval);
        if (mm == 0) {
            return 0;
        } else {
            return modval - mm;
        }
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

using iwasi = tuple<ll, ll, ll>;

int main() {
    ll N;
    cin >> N;

    map<iwasi, ll> iwasis;
    ll zeroiwasi = 0;
    for (ll i = 0; i < N; i++) {
        ll a;
        ll b;
        cin >> a >> b;
        iwasi iw;
        if (b == 0 && a == 0) {
            zeroiwasi++;
            continue;
        } else if (a == 0) {
            iw = make_tuple(0, 0, 1);
        } else if (b == 0) {
            iw = make_tuple(0, 1, 0);
        } else {
            int sign = 1;
            if (a < 0) {
                a = -a;
                sign = -sign;
            }
            if (b < 0) {
                b = -b;
                sign = -sign;
            }
            ll g = gcd(a, b);
            iw = make_tuple(sign, a / g, b / g);
        }
        if (iwasis.count(iw) == 0) {
            iwasis[iw] = 0;
        }
        iwasis[iw]++;
    }

    vector<ll> pow2tbl(N + 1);
    pow2tbl[0] = 1;
    for (ll i = 1; i <= N; i++) {
        pow2tbl[i] = (pow2tbl[i - 1] * 2) % MODVAL;
    }

    ll frees = N - zeroiwasi;
    ll total = 1;
    for (auto iw : iwasis) {
        ll s, a, b;
        tie(s, a, b) = iw.first;
        if (s < 0 || (s == 0 && a == 0)) {
            continue;
        }
        auto riw = make_tuple(-s, b, a);
        if (iwasis.count(riw)) {
            ll fnum = iw.second;
            ll rnum = iwasis[riw];
            frees = frees - fnum - rnum;
            ll mult = mod_minus(pow2tbl[fnum] + pow2tbl[rnum] - 1, MODVAL);
            total = (total * mult) % MODVAL;
        }
    }
    total = mod_minus(total * pow2tbl[frees], MODVAL);
    total = mod_minus(total - 1 + zeroiwasi, MODVAL);  // 一匹もいない場合を除去. 0,0のイワシを一匹のみ入れるのは可
    print(total);
}


Measured memory_bytes: 20232
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

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

int count_color(vector<vector<int> > &m) {
  if(m[0][0] != maxc) return 0;
  int c = m[0][0];
  int ret = 0;
  queue<pair<int,int> > q;
  q.push(make_pair(0,0));
  while(!q.empty()) {
    pair<int,int> p = q.front(); q.pop();
    if(m[p.second][p.first] == -1) continue;
    ret++;
    m[p.second][p.first] = -1;
    for(int k=0; k<4; ++k) {
      int nx = p.first + dx[k], ny = p.second + dy[k];
      if(nx < 0 || nx > m[0].size()-1 || ny < 0 || ny > m.size()-1) continue;
      if(m[ny][nx] == c) q.push(make_pair(nx,ny));
    }
  }
  return ret;
}

vector<vector<int> > change(vector<vector<int> > m,int c) {
  int nc = m[0][0];
  queue<pair<int,int> > q;
  q.push(make_pair(0,0));
  while(!q.empty()) {
    pair<int,int> p = q.front(); q.pop();
    m[p.second][p.first] = c;
    for(int k=0; k<4; ++k) {
      int nx = p.first + dx[k], ny = p.second + dy[k];
      if(nx < 0 || nx > m[0].size()-1 || ny < 0 || ny > m.size()-1) continue;
      if(m[ny][nx] == nc) q.push(make_pair(nx,ny));
    }
  }
  return m;
}

int dfs(int depth,vector<vector<int> > m) {
  //  cout<<depth<<endl;
  if(depth == 5) {
    return count_color(m);
  }

  int ret = 0;
  for(int i=1; i<=6; ++i) {
    //    cout<<i<<endl;
    if(m[0][0] == i) continue;
    vector<vector<int> > nm = change(m,i);
    ret = max(ret, dfs(depth+1,nm));
  }
  return ret;
}

int main() {
  int h,w,c;
  while(cin>>h>>w>>c, h|w|c) {
    maxc = c;
    vector<vector<int> > mp(h,vector<int>(w,0));

    for(int i=0; i<h; ++i) {
      for(int j=0; j<w; ++j) {
        cin>>mp[i][j];
      }
    }

    cout<<dfs(0,mp)<<endl;
  }
}

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

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

int dp[7][7001];
int card[7], cnt[7];
int N, M;

int dfs(int pos, int now) {
	if (pos == -1) return now == 0;
	if (now < 0) return 0;
	
	if (dp[pos][now] != -1) return dp[pos][now];
	
	dp[pos][now] = 0;
	REP(i, cnt[pos] + 1) dp[pos][now] += dfs(pos - 1, now - card[pos] * i);
	
	return dp[pos][now];
}

int main() {
	while (cin >> M, M) {
		REP(i, M) scanf("%d %d", &card[i], &cnt[i]);
		cin >> N;
		
		fill(dp[0], dp[7], -1);
		REP(i, N) {
			int n;
			scanf("%d", &n);
			cout << dfs(M - 1, n) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1432
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    print(sum(a)-n)

if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#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 mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,t; cin>>n>>t;
    vll a(n);
    rep(i,n) cin>>a[i];
    vll ma(n+1);
    RFOR(i,n-1,0) chmax(ma[i],max(a[i],ma[i+1]));
    map<ll,int> cnt;
    rep(i,n){
        cnt[ma[i+1]-a[i]]++;
    }
    int ans = cnt.rbegin()->se;
    cout<<ans<<"\n";
    return 0;
}


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


int main(){
    long long x;
    cin >> x;
    x = abs(x);
    unsigned long long k, d;
    cin >> k >> d;
    if(d==1)
    {
        if(x < k)
        {
            cout << (x % 2 != k % 2) << endl;
        }else
        {
            cout << x - k << endl;
        }
    }
    else if(x/d < k)
    {
        long long ans1 = x % d;
        long long ans2 = x % d - d;
        if(int((x-ans1)/d) % 2 == k%2)
        {
            cout << ans1 << endl;
        }else
        {
            cout << abs(ans2) << endl;
        }
    }else
    {
        long long ans = x - k * d;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;

int main(){
  string n;
  string a;

  for(int i=0;i<3;i++){
    cin >> n;
    a.push_back(n[0]);
  }

  cout << a << endl;

  return 0;

}


Measured memory_bytes: 256
N = int(input())
S = [x for x in input()]
Q = int(input())

#A1 ... AnのBIT(1-indexed)
BIT = [[0] * (N + 1) for _ in range(26)]

#A1 ~ Aiまでの和 O(logN)
def BIT_query(input_BIT, idx):
    res_sum = 0
    while idx > 0:
        res_sum += input_BIT[idx]
        idx -= idx&(-idx)
    return res_sum

#Ai += x O(logN)
def BIT_update(input_BIT,idx,x):
    while idx <= N:
        input_BIT[idx] += x
        idx += (idx&(-idx))
    return

for i, c in enumerate(S):
    BIT_update(BIT[ord(c)-ord('a')], i+1, 1)
  
for _ in range(Q):
    a, b, c = input().rstrip().split()
    if int(a) == 1:
        BIT_update(BIT[ord(S[int(b)-1])-ord('a')], int(b), -1)
        BIT_update(BIT[ord(c)-ord('a')], int(b), 1)
        S[int(b)-1] = c
    else:
        count = 0
        for i in range(26):
            if BIT_query(BIT[i], int(b)-1) != BIT_query(BIT[i], int(c)):
                count += 1
        print(count)

Measured memory_bytes: 166508
N, K = map(int, input().split())

if (N-1)*(N-2)/2 < K:
    print(-1)
else:
    diff = int(((N-1)*(N-2)/2 - K))
    print(N-1+diff)
    for i in range(1, N):
        start = 1
        end = i+1
        print(str(start) + " " + str(end))
    cnt = 0
    isEnd = False
    for i in range(1, N):
        start = i+1
        if isEnd:
            break
        for j in range(i+1, N):
            if cnt == diff:
                isEnd = True
                break
            end = j +1
            print(str(start) + " " + str(end))
            cnt += 1


Measured memory_bytes: 3332
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    L = 10
    N = int(readline())
    MP = [list(map(int, readline().split())) for i in range(L)]
    P = []
    for i in range(L):
        for j in range(L):
            if MP[i][j]:
                P.append((j, i))
    A = [(0, 0), (-1, 1), (0, 1), (1, 1), (0, 2)]
    B = [(0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2)]
    C = [(0, 0), (-1, 1), (0, 1), (1, 1), (-2, 2), (-1, 2), (0, 2), (1, 2), (2, 2), (-1, 3), (0, 3), (1, 3), (0, 4)]
    ans = []
    K = len(P)
    def dfs(i, k):
        if i == K:
            return (k == N)
        x, y = P[i]
        if MP[y][x] == 0:
            if dfs(i+1, k):
                return 1
        if 0 < x < L-1 and y < L-2 and all(MP[y+q][x+p] for p, q in A):
            for p, q in A:
                MP[y+q][x+p] -= 1
            if dfs(i, k+1):
                ans.append((x, y+1, 1))
                return 1
            for p, q in A:
                MP[y+q][x+p] += 1
        if x < L-2 and y < L-2 and all(MP[y+q][x+p] for p, q in B):
            for p, q in B:
                MP[y+q][x+p] -= 1
            if dfs(i, k+1):
                ans.append((x+1, y+1, 2))
                return 1
            for p, q in B:
                MP[y+q][x+p] += 1
        if 1 < x < L-2 and y < L-4 and all(MP[y+q][x+p] for p, q in C):
            for p, q in C:
                MP[y+q][x+p] -= 1
            if dfs(i, k+1):
                ans.append((x, y+2, 3))
                return 1
            for p, q in C:
                MP[y+q][x+p] += 1
    dfs(0, 0)
    for x, y, t in ans:
        write("%d %d %d\n" % (x, y, t))
solve()



Measured memory_bytes: 5712
#include<cstdio>
#include<algorithm>
#define MAXN 1000+10

using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    long long ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans%=(1000000007);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

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

class a1 {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s; in>>s;
        int res=0;
        f(i, s.length()-1){
            if((s[i+1]=='W' and s[i]=='B') or (s[i+1]=='B' and s[i]=='W')) res++;
        }
        out<<res;

	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	a1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define ll long long
#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define MAX_V 105
struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1000000007;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

modint dp[101][4][4][4];
 
int main(){
    int n;
    cin >> n;

    REP(i, 4) REP(j, 4) REP(k, 4) {
        if((i == 0 && j == 2 && k == 1) || (i == 0 && j == 1 && k == 2) || (i == 2 && j == 0 && k == 1)) continue; 
        dp[3][i][j][k] = 1;
    }

    REPN(i, 3, n) {
        REP(s1, 4) REP(s2, 4) REP(s3, 4) REP(new_, 4) {
            modint tmp = dp[i][s1][s2][s3];
            /* ?AGC, ?ACG, ?GAC, A?GC, AG?C */
            if((s2 == 0 && s3 == 2 && new_ == 1) || (s2 == 0 && s3 == 1 && new_ == 2) || (s2 == 2 && s3 == 0 && new_ == 1) || (s1 == 0 && s3 == 2 && new_ == 1) || (s1 == 0 && s2 == 2 && new_ == 1)) continue;
            dp[i+1][s2][s3][new_] += dp[i][s1][s2][s3];
        }
    }

    modint ans = 0;
    REP(i, 4) REP(j, 4) REP(k, 4) ans += dp[n][i][j][k];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back 8 7
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define E endl
#define M 1000000007
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int main()
{
   ll n;
   cin>>n;
   map<ll,ll>k;
   for(ll i=1;i<=n;i++)
   {
   	ll c;
   	cin>>c;
   	 k.insert(pair<ll,ll>(c,i));
   }
   map<ll,ll>::iterator itr; 
   for(itr=k.begin();itr!=k.end();itr++)
   {
   	 cout<<itr->second<<" ";
   }
}

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

int main(int argc, char const *argv[]) {

  int A[3];
  int i, j, t;
  int task; //労力
  //入力
  scanf("%d%d%d", &A[0], &A[1], &A[2] );
  //労力の計算
  for ( i = 1; i < 3; i++) {
    for ( j = i-1; j >= 0; j--) {
      if ( A[j] < A[j+1] ) {
        t = A[j];   A[j] = A[j+1];   A[j+1] = t;
      }
      else
      break;
    }
  }
  //労力の計算
  task = abs(A[0]-A[1])+abs(A[1]-A[2]);
  //出力
  printf("%d\n", task );
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  i64 k;
  cin >> n >> k;
  vi32 a(n);
  cin >> a;
  sort(all(a));
  auto f = [&](i64 x) {
    i64 ret = 0;
    rep(i, n) {
      if (a[i] < 0) {
        ret += partition_point(a.begin() + i + 1, a.end(), [&](int y) {
          return (i64) y * a[i] >= x;
        }) - (a.begin() + i + 1);
      } else if (a[i] > 0) {
        ret += a.end() - partition_point(a.begin() + i + 1, a.end(), [&](int y) {
          return (i64) y * a[i] < x;
        });
      } else {
        if (x <= 0) ret += n - (i + 1);
      }
    }
    return ret;
  };
  i64 L = (i64) n * (n - 1) / 2 - k + 1;
  i64 ok = -2e18, ng = 2e18;
  while (abs(ok - ng) > 1) {
    i64 md = (ok + ng) / 2;
    (f(md) < L ? ng : ok) = md;
  }
  cout << ok << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    long long A,B,V,W,T,AT,BT;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if(A<B){
        AT=A+T*V;
        BT=B+T*W;
        if(AT>=BT){
            cout << "YES" <<endl;
        }else{
            cout << "NO" <<endl;
        }
    }else{
        AT=A-T*V;
        BT=B-T*W;
        if(AT<=BT){
            cout << "YES" <<endl;
        }else{
            cout << "NO" <<endl;
        }
    }
    return 0;
}    

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

int main(){
   int a;
   cin >> a;
   int b = a%10;
   if(b==2 || b==4 || b==5 || b==7 || b==9) cout << "hon" << endl;
   if(b==0 ||b==1 || b==6 || b==8) cout << "pon" << endl;
   if(b==3) cout << "bon" << endl;
   
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <string>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main()
{
	int i, j, k, l, n, ans;
	while (cin >> n) {
		ans = 0;
		for (i = 0; i < 10; ++i) {
			for (j = 0; j < 10; ++j) {
				for (k = 0; k < 10; ++k) {
					for (l = 0; l < 10; ++l) {
						if (i + j + k + l == n)++ans;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2992
#include <iostream>

using namespace std;

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

    int ans =
        (N < 105) ? 0 :
        (N < 135) ? 1 :
        (N < 165) ? 2 :
        (N < 189) ? 3 :
        (N < 195) ? 4 : 5;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
z = 0

for i in range(N):
  if B[i]<=A[i]:
    z+=B[i]
  elif A[i]<B[i]<=A[i]+A[i+1]:
    z+=B[i]
    A[i+1]-=B[i]-A[i]
  else:
    z+=A[i]+A[i+1]
    A[i+1]=0

print(z)

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

int main(){
    int a, b, c, t;
    cin >> a >> b >> c;
    
    if (a > b) {t = a; a = b; b = t;}
    if (b > c) {t = b; b = c; c = t;}
    if (a > b) {t = a; a = b; b = t;}
    
    cout << a <<" "<< b <<" "<< c << endl;
    
    return 0;
    
    
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

template<typename T>
struct Acc2D {
  vector<vector<T>> sum;
  Acc2D(vector<vector<T>> v) {
    const int N = v.size() + 1;
    sum.resize(N);
    fill(sum.begin(), sum.end(), vector<T>(N, 0));
    for (int i = 0; i < v.size(); ++i) {
      for (int j = 0; j < v.size(); ++j) {
        sum[i + 1][j + 1] = v[i][j] - sum[i][j] + sum[i][j + 1] + sum[i + 1][j];
      }
    }
  }
  T query(int ai, int aj, int bi, int bj) {
    return sum[bi][bj] + sum[ai][aj] - sum[ai][bj] - sum[bi][aj];
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  while (cin >> n >> k) {
    vector<pair<int, int>> b;
    vector<pair<int, int>> w;
    for (int i = 0; i < n; ++i) {
      int p, q;
      char c;
      cin >> p >> q >> c;
      if (c == 'B') b.push_back(make_pair(p, q));
      if (c == 'W') w.push_back(make_pair(p, q));
    }

    each (i, b) {
      i.first %= 2 * k;
      i.second %= 2 * k;
    }
    each (i, w) {
      i.first += k;
      i.first %= 2 * k;
      i.second %= 2 * k;
    }

    vector<vector<int>> g(2 * k, vector<int>(2 * k, 0));

    each (i, b) ++g[i.first][i.second];
    each (i, w) ++g[i.first][i.second];

    Acc2D<int> acc(g);

    int mx = 0;
    for (int i = 0; i < k; ++i) {
      for (int j = 0; j < k; ++j) {
        int sum = 0;

        sum += acc.query(0, 0, i, j);
        sum += acc.query(i, j, i+k, j+k);
        sum += acc.query(i+k, j+k, k+k, k+k);

        sum += acc.query(0, j+k, i, k+k);
        sum += acc.query(i+k, 0, k+k, j);

        mx = max({mx, sum, n - sum});
      }
    }
    cout << mx << endl;
  }

  return 0;
}


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

int main() {
	// your code goes here
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
				cout<<"OK";
				return 0;
		}
	
	}
	cout<<"NG";
	return 0;
}

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

int main()
{
ll n , m ;
cin >> n >> m ;
vector<ll> x(n);
rep(i, n){
  cin >> x[i];
}
sort(x.begin(),x.end());
vector<vector<ll>> v(m);
rep(i,n)v[x[i]%m].push_back(x[i]);
rep(i,(m-1)/2){
  ll ind=m-1-i,num=0;
  if(v[i+1].size()>v[m-1-i].size())ind=i+1;
  rep(j,v[ind].size()){
    if(j!=v[ind].size()-1&&v[ind][j]==v[ind][j+1]){num+=2;j++;}
  }
  ans+=min(v[i+1].size(),v[m-1-i].size())+min(num/2,abs((ll)v[i+1].size()-(ll)v[m-1-i].size())/2);
}
ans+=v[0].size()/2;
if(m%2==0)ans+=v[m/2].size()/2;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{ ll n,i,j,s;
cin>>n>>s;
ll w[n+1],v[n+1];
for(i=1;i<=n;i++) cin>>w[i]>>v[i];
ll dp[n+1][s+1];
for(i=0;i<n+1;i++) dp[i][0]=0;
for(i=0;i<s+1;i++) dp[0][i]=0;

for(i=1;i<=n;i++)
{ for(j=1;j<=s;j++)
{  if(w[i]>j) {
	dp[i][j]=dp[i-1][j];
}
else {
	dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
	
}
	
	

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

	
	
	
}

Measured memory_bytes: 82552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, k;
	cin >> n >> k;
	vi d(k);
	vvi a(k,vi(0));
	V<bool> have(n,false);

	rep(i, k) {
		cin >> d[i];
		rep(j, d[i]) {
			int aa;
			cin >> aa;
			have[aa - 1] = true;
		}
	}

	int ans = 0;
	rep(i, n)if (have[i] == false)ans++;

	
	cout << ans << endl;

}

Measured memory_bytes: 3632
import math
from collections import Counter


n = int(input())
votes = []

for _ in range(n):
    votes.append(input())

counter = Counter(votes).most_common()
max_votes = counter[0][1]

candidates = [cand for cand in counter if cand[1] == max_votes]

for candidate in sorted(candidates):
    print(candidate[0])

Measured memory_bytes: 45036
#include <iostream>

using namespace std;

int main() {
    int a[100][100];
    int b[100];
    int c[100];

    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 < m; i++)
        cin >> b[i];

    for (int i = 0; i < n; i++) {
        c[i] = 0;
        for (int j = 0; j < m; j++)
            c[i] += a[i][j] * b[j];
    }

    for (int i = 0; i < n; i++)
        cout << c[i] << endl;

    return 0;
}



Measured memory_bytes: 3128
n,k=map(int,input().split())
p=list(map(int,input().split()))
for i in range(n):
	p[i]=p[i]*(p[i]+1)/2/p[i]
q=sum(p[:k])
a=q
for i in range(n-k):
	a+=p[i+k]
	a-=p[i] 
	q=max(a,q)
print(q)





Measured memory_bytes: 25060
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

int main(){
  	int n;
    string s;
    cin>>n>>s;
  	int64_t ans=0;
    for(int i=0; i<n; i++) {
        for(int j=0; j<i; j++) {
            if(s[i]==s[j]) continue;
            for(int k=0; k<j; k++) if(s[j] != s[k] && s[i] != s[k] && j-i != k-j) ans++;
        }
    }
	printf("%" PRId64 "\n", ans);
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const ld eps = 1e-8;
const ld INF = 1e10;
using P = pair<ld, int>;

int main()
{
	int n, m, s, g;
	while (cin >> n, n) {
		vector<vector<P>> G(n);
		vector<ld> x(n), y(n);
		for (int i = 0, b; i < n; i++) {
			cin >> b; b--; cin >> x[b] >> y[b];
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				ld dis = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
				if (dis <= 50.0 + eps) {
					G[i].push_back(P(dis, j));
					G[j].push_back(P(dis, i));
				}
			}
		}
		cin >> m;
		while (m--) {
			cin >> s >> g; s--; g--;
			vector<ld> d(n, INF);
			d[s] = 0;
			for (int i = 0; i < n - 1; i++) {
				for (int j = 0; j < n; j++) {
					for (auto v : G[j]) {
						d[v.second] = min(d[v.second], d[j] + v.first);
					}
				}
			}
			if (d[g] == INF) {
				cout << "NA" << endl;
				continue;
			}
			vector<int> res;
			int tmp = g; res.push_back(g + 1);
			while (tmp != s) {
				for (auto v : G[tmp]) {
					if (d[v.second] + v.first <= d[tmp] + eps) {
						res.push_back(v.second + 1);
						tmp = v.second;
						break;
					}
				}
			}
			reverse(res.begin(), res.end());
			for (int i = 0; i < (int)res.size(); i++) {
				cout << res[i] << " \n"[i + 1 == (int)res.size()];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3196
#include<iostream>
using namespace std;
typedef unsigned long long ll;
typedef long double ld;

ll gcd(ll a,ll b){
    ll result = a % b;
    if (result == 0) return b;
    return gcd(b,result);
}

int main(){
    int N;
    cin >> N;
    ll T;
    ll tmp;
    ll tg;
    cin >> tg;
    for (int i=1;i<N;i++){
        cin >> T;
        if (tg < T) tmp = gcd(T,tg);
        else tmp = gcd(tg,T);
        if (tg > T) tg = ll(ld(tg/tmp)*T + 0.5);
        else tg = ll(ld(T/tmp)*tg + 0.5);
    }
    cout << tg << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String val = null;
        if (S.equals("A")) val = "T";
        else if (S.equals("T")) val = "A";
        else if (S.equals("G")) val = "C";
        else if (S.equals("C")) val = "G";

        System.out.println(val);
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(cin >> n,n) {
    string s[n];
    map<string, int> id;
    vector<int> v[30];
    REP(i,n) {
      cin >> s[i];
      id[s[i]] = i;
      int m;
      cin >> m;
      REP(j,m) {
        int d;
        cin >> d;
        v[d].push_back(i);
      }
    }
    int score[n];
    memset(score,0,sizeof(score));
    REP(i,30) {
      FOR(it, v[i]) {
        score[*it] += n-v[i].size()+1;
      }
    }
    typedef pair<int,string> psi;
    vector<psi> vv;
    REP(i,n) {
      vv.push_back(psi(score[i],s[i]));
    }
    sort(ALL(vv));
    cout << vv[0].first << " " << vv[0].second << endl;
  }
}

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

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

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

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

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

const ll INF = 1e9+7;

int R, C, N;
bool bound(int x, int y){
	if( x == 0 || x == R || y == 0 || y == C )
		return true;
	return false;
}

int getpos(int x, int y){
	if( x == 0 ){
		return y;
	}else if( y == C ){
		return C + x;
	}else if( x == R ){
		return C + R + (C-y);
	}else if( y == 0 ){
		return C + R + C + (R-x);
	}
}

int main(){
	//ios_base::sync_with_stdio(0);
	vector<pii> v;

	cin >> R >> C >> N;
	rep(i,N){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if( bound(x1,y1) && bound(x2,y2) ){
			int a = getpos(x1,y1);
			int b = getpos(x2,y2);
			if( a > b ) swap(a, b);
			v.eb(a, b);
		}
	}
	sort(all(v));
	//for(auto t: v) cout << t.X << ","  << t.Y << " "; cout << endl;

	bool ans = true;
	stack<int> st;
	for(auto t: v){
		while( !st.empty() && st.top() < t.X ){
			st.pop();
		}
		if( !st.empty() && st.top() < t.Y ){
			ans = false;
		}
		st.push( t.Y );
	}

	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 1400
using System;

class Program
{
 static void Main(string[] args)
 {
   string str = Console.ReadLine();
   int length = str.Length;
   int readPoint = 0;
   bool result = true;
   
   while( readPoint < length )
   {
     if( ( readPoint + 6 ) < length )
     {
       if( str.Substring(readPoint, 5) == "dream" )
       {
         if( ( readPoint + 7 ) < length )
         {
           if( str.Substring(readPoint+5, 2) == "er" )
           {
             if( str[readPoint+7] == 'a' )
             {
               readPoint += 5;
             }
             else
             {
               readPoint += 7;
             }
           }
           else
           {
             readPoint += 5;
           }
         }
         else
         {
           if( str.Substring(readPoint+5, 2) == "er" )
           {
             readPoint += 7;
           }
           else
           {
             result = false;
             break; 
           }
         }
       }
       else if( str.Substring(readPoint, 5) == "erase" )
       {
         if( str[readPoint+5] == 'r' )
         {
           readPoint += 6;
         }
         else
         {
          readPoint += 5; 
         }
       }
       else
       {
         result = false;
         break; 
       }
     }
     else if( ( readPoint + 5 ) < length )
     {
       if( str.Substring(readPoint, 5) == "dream" )
       {
         readPoint += 5;
       }
       else if( str.Substring(readPoint, 5) == "erase" )
       {
         if( str[readPoint+5] == 'r' )
         {
           readPoint += 6;
         }
         else
         {
          readPoint += 5; 
         }
       }
     }
     else if( ( readPoint + 4 ) < length )
     {
       if( str.Substring(readPoint, 5) == "dream" )
       {
         readPoint += 5;
       }
       else if( str.Substring(readPoint, 5) == "erase" )
       {
          readPoint += 5; 
       }
       else
       {
         result = false;
         break;
       }
     }
     else
     {
       result = false;
       break;
     }
   }
   
   Console.WriteLine("{0}",(result?"YES":"NO"));
 }
}

Measured memory_bytes: 13280
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int[] T = new int[q];
			for(int i=0; i<q; i++) {
				T[i] = sc.nextInt();
			}
			Arrays.sort(T);
			
			int ans = 0;
			for(int i=0, j=0; i<n && j<q; i++) {
				if(S[i] == T[j]) {
					ans++;
					j++;
				}
				else if(S[i] > T[j]) {
					i--;
					j++;
				}
			}
			System.out.println(ans);
		}
	}	
}



Measured memory_bytes: 68340
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
}; 


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        if (n%2==0) {
            cout << 0.5 << endl;
        } else {
            cout << 1.0*(n+1)/(2.0*n) << endl;
        }

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int, int> ma;
    rep(i,n){
        ma[a[i]-1]++;
        ma[a[i]]++;
        ma[a[i]+1]++;
    }
    int ans = 0;
    for(auto p : ma){
        ans = max(ans, p.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        var count = new int[A.Max() + 3];
        foreach (int a in A) count[a + 1]++;
        int ans = Enu.Range(1, count.Length - 2).Max(i => count[i - 1] + count[i] + count[i + 1]);
        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

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

int main(){
    int a;
    cin>>a;
    if(a < 1200){
        cout<<"ABC"<<endl;
    }else if(a < 2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }

    return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  int i;
  int x[6];
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

  for (i = 1; i < 6; i++){
    if (x[i - 1] == 0){
      cout << i << endl;
      i = 6;
    }
  }

}

Measured memory_bytes: 3652
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    char[] s = scan.next().toCharArray();
    char[] t = scan.next().toCharArray();
    scan.close();
    
    for(int i=0;i<s.length;i++){
      if(s[i]==t[i]){continue;}
      else{
        char c1=s[i];
        char c2=t[i];
        for(int j=0;j<i;j++){
          if(s[j]==c1||s[j]==c2){
            System.out.println("No");
            return;
          }
        }
        for(int j=i;j<s.length;j++){
          if(s[j]==c1){
            s[j]=c2;
          }else if(s[j]==c2){
            s[j]=c1;
          }
        }
      }
    }
    
    System.out.println("Yes");
    return;
  }
}

Measured memory_bytes: 28544
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

map<string,vector<string>> mp;
map<string,set<string>> memo;


vector<string> split(string s,char ch){
	vector<string> ret;
	string tmp ="";
	rep(i,s.size()){
		if(s[i]==ch){
			ret.pb(tmp);
			tmp = "";
		}else tmp+=s[i];
	}
	if(tmp.size())ret.pb(tmp);
	return ret;
}


set<string> solve(string s){
	if( memo.count(s)!=0 )return memo[s];
	
	vector<string> members = mp[s];
	set<string> ret;
	rep(i,members.size()){
		if( mp.count(members[i])==0 )ret.insert(members[i]);
		else{
			set<string> tmp = solve(members[i]);
			for(auto &elm:tmp)ret.insert(elm);
		}
	}
	memo[s] = ret;
	return ret;
}


int main(){
	int n;
	while(cin>>n&&n){
		mp.clear();
		memo.clear();
		string group1;
		rep(i,n){
			string s;
			cin>>s;
			vector<string> vs = split(s,':');
			assert(vs.size()==2);
			vector<string> members = split(vs[1].substr(0,vs[1].size()-1),',');
			mp[vs[0]] = members;
			if(i==0)group1 = vs[0];
		}
		set<string> res = solve(group1);
		cout<<res.size()<<endl;
	}
}

Measured memory_bytes: 3520
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define vi vector<long long>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less   
using namespace __gnu_pbds;  
using namespace std;  
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> set1;
ll mod=1000000007;
ll large=1e18;
ll neg=-1e18;
ll N=500000;
ll mod1=998244353;
struct pii
{
   ll x;
   ll y;
};
struct edge
{
   ll from;
   ll to;
   ll w;
   ll id;
};
ll find(ll a,ll p[])
{
   //cout<<"find "<<a<<endl;
   if(a==p[a])
   return a;
   else return p[a]=find(p[a],p);

}
void join(ll a,ll b,ll p[],ll sz[])
{
   a=find(a,p);
   b=find(b,p);
   if(a!=b)
   {
      if(sz[a]<sz[b])
      swap(a,b);
      sz[a]+=sz[b];
      p[b]=a;
   }
}
ll power(ll a,ll b,ll mod)
{
   ll res=1;
   while(b>0)
   {
      if(b&1)
      res=(res*a)%mod;
      b=b/2;
      a=(a*a)%mod;
   }
   return res;
}
ll inverse(ll x, ll p)
{
   return power(x,p-2,p);
}
ll hash1(ll x,ll y)
{
   return x+y+x*y;
}
/*ll f[200000]={0};

void ini()
{
   f[0]=1;
   for(ll i=1;i<=200000;i++)
   f[i]=(i*f[i-1])%mod;
}*/
void build(ll tree[],ll v,ll l,ll r,ll dp[])
{
   if(l==r)
      tree[v]=dp[l];
   else
   {
      ll m=(l+r)/2;
      build(tree,2*v,l,m,dp);
      build(tree,2*v+1,m+1,r,dp);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}
ll query(ll tree[],ll v,ll l,ll r,ll tl,ll tr)
{
   if(l==tl && tr==r)
   {
    //  cout<<"max of "<<tl<<" "<<tr<<" "<<tree[v]<<endl;
      return tree[v];
   }
   else
   {
      ll m=(l+r)/2;
      if(tr<=m)
      {
         ll z1= query(tree,2*v,l,m,tl,tr);
     //    cout<<"max of "<<tl<<" "<<tr<<" "<<z1<<endl;
         return z1;
      }
      else if(tl>m)
      {
         ll z2= query(tree,2*v+1,m+1,r,tl,tr);
      //   cout<<"max of "<<tl<<" "<<tr<<" "<<z2<<endl;
         return z2;
      }
      else 
      {
         ll z=query(tree,2*v,l,m,tl,m);
         ll z1=query(tree,2*v+1,m+1,r,m+1,tr);
       //  cout<<"max of "<<tl<<" "<<tr<<" "<<max(z1,z)<<endl;
         return max(z1,z);
      }
      
      
   }
}
void update(ll tree[],ll v,ll l,ll r,ll pos,ll element)
{
   if(l==r && l==pos)
   tree[v]=element;
   else
   {
      ll m=(l+r)/2;
      if(pos<=m)
      update(tree,2*v,l,m,pos,element);
      else
      update(tree,2*v+1,m+1,r,pos,element);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}

/*ll ncr(ll n,ll r)
{
   ll res=1;
   ll k=f[n];
   ll v=inverse(f[n-r],mod);
   ll u=inverse(f[r],mod);
   ll x=(u*v)%mod;
   k=(k*x)%mod;
   return k;
}*/
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   cin>>s;
   for(ll i=0;i<3;i++)
   cout<<s.at(i);
   cout<<endl;
   return 0;
}

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

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

    int num = n % 10;
    if (num == 2 || num == 4 || num == 5 || num == 7 || num == 9) {
        cout << "hon" << endl;
    } else if (num == 0 || num == 1 || num == 6 || num == 8) {
        cout << "pon" << endl;
    } else if (num == 3) {
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    long sum = 0,tmp_sum = 0;
    int len = s.length;
    long tmp = 0;
    for(int i=0;i<(1<<(len-1));i++){
      tmp = 0;
      tmp_sum = 0;
      
      for(int j=0;j<len-1;j++){
        if( ((i>>(len -2 -j)) & 1) ==1){
          tmp_sum = tmp_sum + tmp*10 + (s[j]-'0');
          tmp = 0;
        }else{
          tmp = tmp*10 + (s[j]-'0');
        }
      }
      tmp_sum = tmp_sum + tmp*10 + (s[len-1]-'0');
      sum+=tmp_sum;
    }
    
    System.out.println(sum);
    System.out.flush();
    
  }
}

Measured memory_bytes: 23508
#include<iostream>
using namespace std;
int main()
{
	int a,b,i;
	long long m,n;
	cin>>a>>b;
	m=b;
	n=a;
    for(i=a;i>1;i--)
    {
    	m=m*10+b;    	
	}
	for(i=b;i>1;i--)
    {
    	n=n*10+a;    	
	}
	if(m>n)cout<<m;
	else cout<<n;
 } 

Measured memory_bytes: 256