akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
using namespace std ;

#define MAXN 100007

int n , m , cnt , lim ;
int a[ MAXN ] ;

int b[ MAXN ] ;
int lft[ MAXN ] ;
int add[ MAXN ] ;

bool f ( int id ) {
    int val = a[ id ] + m ;
    long long sm = 0 ;
    long long lg = 0 ;
    for ( int i = n ; i >= 1 ; -- i ) {
        if ( i == id ) { continue ; }
        int aux = val - a[ i ] ;
        if ( aux < 0 ) { ++ lg ; continue ; }
        sm += min ( aux , m ) ;
    }
    sm = 1LL * m * ( cnt - 1 ) - sm ;
    long long sr = 0 ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        if ( i == id ) { continue ; }
        if ( sm <= 0 ) {
            if ( a[ i ] > val ) { ++ sr ; }
            continue ;
        }
        int aux = 0 ;
        if ( a[ i ] > val ) { aux = m ; }
        else {
            aux = m - min ( val - a[ i ] , m ) ;
        }
        sm -= aux ;
        if ( aux > 0 ) { ++ sr ; }
    }
    return ( sr + 1 <= lim ) ;
}

void input ( ) {
    scanf ( "%d%d%d%d" , &n , &m , &cnt , &lim ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
    sort ( a + 1 , a + n + 1 , greater < int > ( ) ) ;
}

void solve ( ) {
    int l , r , mid ;
    l = 1 ;
    r = n ;
    while ( r - l > 3 ) {
        mid = ( l + r ) / 2 ;
        if ( f ( mid ) == false ) { r = mid ; }
        else { l = mid ; }
    }
    while ( f ( r ) == false ) { -- r ; }
    printf ( "%d\n" , r ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		if(t.startsWith(s) &&  t.length()-1==s.length())  System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 35640
class PriorityQueue
  # min heap
  def initialize(source = [])
    @heap = []
    source.each { |e| push(e) }
  end

  def size
    @heap.size
  end

  def empty?
    @heap.empty?
  end

  def top
    @heap.first
  end

  def push(value)
    @heap << value
    new_node_index = @heap.size - 1

    while new_node_index > 0 do
      parent_node_index = (new_node_index - 1) / 2

      break if @heap[parent_node_index] <= value

      @heap[parent_node_index], @heap[new_node_index] = @heap[new_node_index], @heap[parent_node_index]
      new_node_index = parent_node_index
    end

    @heap[new_node_index] = value
  end

  def pop
    min = top

    tmp_node = @heap.pop

    tmp_index = 0
    while (tmp_index * 2 + 1) < size do
      tmp_left_child_index  = tmp_index * 2 + 1
      tmp_right_child_index = tmp_index * 2 + 2
      min_child_index = tmp_left_child_index

      if tmp_right_child_index < size && @heap[tmp_left_child_index] > @heap[tmp_right_child_index]
        min_child_index = tmp_right_child_index
      end

      break if @heap[min_child_index] >= tmp_node

      @heap[tmp_index] = @heap[min_child_index]
      tmp_index = min_child_index
    end

    @heap[tmp_index] = tmp_node unless empty?

    min
  end
end

n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

pq = PriorityQueue.new()
a.each do |x|
  pq.push(-x)
end

m.times do
  t = pq.pop()
  t *= -1
  t /= 2
  pq.push(-t)
end

ans = 0
n.times do
  ans -= pq.pop()
end

puts ans


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<int> > vvi;
typedef set<int> si;
typedef map<string, int> msi;
typedef map<int, int> mii;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) SORT(x),(x).erase(unique((x).begin(),(x).end()),(x).end())
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define SZ(a) int((a).size())
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,b) memset(a,b,sizeof(a))

#define FOR(i,a,b) for (int i = int(a); i < int(b); i++)
#define FORD(i,a,b) for(int i=int(b)-1; i>=int(a); i--)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i,n) for (int i = 1; i <= int(n); i++)
#define REV(i, n) for (int i = int(n)-1; i >=0 ; i--)

#define sd(n) scanf("%d",&n)
#define dsd(n) int n; scanf("%d",&n)
#define sd2(a,b) scanf("%d%d",&a,&b)
#define dsd2(a,b) int a,b; scanf("%d%d",&a,&b)
#define sd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define dsd3(a,b,c) int a,b,c; scanf("%d%d%d",&a,&b,&c)
#define pd(n) printf("%d\n",n)
#define pds(n) printf("%d ",n)
#define sll(n) scanf("%lld",&n)
#define dsll(n) ll n; scanf("%lld",&n)
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define dsll2(a,b) ll a,b; scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define dsll3(a,b,c) ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c)
#define pll(n) printf("%lld\n",n)	
#define plls(n) printf("%lld ",n)	
#define print(x) cout<< x << "\n"

#define trace(x) cout << '>' << #x << ':' << x << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);
const int oo = 0x3f3f3f3f;

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

/////////////////////////////////////////////////////////////////////

const int MAX_N = 110;
//int arr[MAX_N];

int main(){
    dsd2(n,K);
    vi V(n);
    REP(i,n) sd(V[i]);
    vi A(n,INF);
    A[0]=0;
    REP(i,n){
        REP1(j,K){
            if(i+j>=n) break;
            A[i+j]=min(A[i+j],abs(V[i+j]-V[i])+A[i]);
        }
    }
    pd(A[n-1]);
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
x=input()
x=x.split()
d=int(x[0])
x=int(x[1])
o=0
for i in range(n):
  a=int(input())
  b=0
  c=0
  while (c*a+1)<=d:
    o+=1
    c+=1
    
o+=x
print(str(o))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

// ■■■■■■■■■■■■■■■■headerここまで■■■■■■■■■■■■■■■■

/// <summary>
/// ある数を素因数分解する。
/// </summary>
/// <param name='x'>素因数分解する対象の数値を指定。</param>
/// <returns>
/// 素数とその指数を関連付ける連想配列を返す。
/// 例えば、x=12の場合、戻り値の連想配列mはm[2]=2,m[3]=1となる。
/// </returns>
/// <remarks>計算オーダーはO(√N)。xが17桁で約1秒。（当然処理系によるが、競技プロの目安値として。）</remarks>
inline std::map<long long, int> calc_prime_factor(long long x) {
    std::map<long long, int> ret;
    // 2,3を先にやる。
    while (x % 2 == 0) {
        ret[2]++;
        x /= 2;
    }
    while (x % 3 == 0) {
        ret[3]++;
        x /= 3;
    }
    bool sw = true;
    long long factor = 5ll;
    while (factor * factor <= x) {
        while (x % factor == 0) {
            ret[factor]++;
            x /= factor;
        }
        // 6n+1と6n+5のみを対象とするための更新式
        factor += sw ? 2 : 4;
        sw != sw;
    }
    if (x != 1) ret[x] = 1;
    return ret;
}

int main() {

    ll n;
    cin >> n;

    auto primeFactor = calc_prime_factor(n);
    int result = 0;
    for (auto it = primeFactor.begin(); it != primeFactor.end(); it++) {
        int exponent = (*it).second;
        for (int i = 1; i < 1000; i++) {
            exponent -= i;
            if (exponent < 0) break;
            result++;
        }
    }
    cout << result << endl;

    return 0;

}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



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

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n%i == 0LL) {
            res.push_back(i);
            long long temp = n/i;
            if (i != temp) res.push_back(temp);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int n;
ll a;


int main() {
    while (cin >> n) {
        ll d;
        cin >> d;
        for (int i = 1; i < n; ++i) {
            cin >> a; d = gcd(a, d);
        }
        vector<ll> res = divisor(d);
        for (int i = 0; i < res.size(); ++i) cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using vint = vector<int>;

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

bool check(ll N, ll val) {
    while(N % val == 0) {
        N /= val;
    }
    return (N % val) == 1;
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;

    if (N == 2) {
        cout << 1 << endl;
        return 0;
    }

    for(ll i=1; i*i <= N-1; i++) {
        if ((N-1) % i == 0) {
            if (i != 1) ans++;
            if (i*i != N-1) {
                ans++;
            }
        }
    }

    for(ll i=1; i*i <= N; i++) {
        if (N % i == 0) {
            if (i != 1) ans += check(N, i);
            if (i*i != N) {
                ans += check(N, N/i);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int N,a,b,c,d,i,j,k,p[4][3][10];
	scanf("%d",&N);
	for(i=0;i<4;i++)for(j=0;j<3;j++)for(k=0;k<10;k++)p[i][j][k]=0;
	for(i=0;i<N;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		p[a-1][b-1][c-1]+=d;
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++)printf(" %d",p[i][j][k]);
			printf("\n");
		}
		if(i!=3)printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define UNVISITED -1
#define POS_INF 1 << 25
#define NEG_INF -1 << 25
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
using namespace std;

typedef long long int64;
typedef pair<int, int> ii;

int main(){ _
  int n, m; cin >> n >> m;
  vector<bool> row(n, false), col(m, false);
  vector< vector<char> > table(n, vector<char> (m, 0));
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      cin >> table[i][j];
      if(table[i][j] == '#'){
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for(int i = 0; i < n; ++i) {
    if(!row[i]) continue;
    for(int j = 0; j < m; ++j) {
      if(!col[j]) continue;
      cout << table[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vi data(n);
    int sum = 0;
    rep(i, n) {
        cin >> data[i];
        sum += data[i];
    }

    if (sum % 10) {
        cout << sum << endl;
        return 0;
    }
    sort(all(data));

    rep(i, n) {
        if ((sum - data[i]) % 10) {
            cout << sum - data[i]<< endl;
            return 0;
        }
    }

    cout << 0 << endl;



    return 0;
}



Measured memory_bytes: 256
import sys
A, B = map(int, input().split())
Am = -(-A * 100 // 8)
AM = (A + 1) * 100 // 8
Bm = int(B * 10)
BM = int((B + 1) * 10)
for m in range(Am, AM):
    for mm in range(Bm, BM):
        if m == mm:
            print(m)
            sys.exit()
else:
    print('-1')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define LL long long
const int N=105;
const LL mod=1000000007;
int a[N];
LL sqrr(LL x){return x*x%mod;}
LL mi2(int x){
    if (!x) return 1;if (x==1) return 2;
    LL ans=sqrr(mi2(x>>1));
    if (x&1) ans=ans*2%mod;
    return ans;
}
LL dp(int l,int r,int h,int ff){
    if (l>r) return 1ll;
    if (l==r) return mi2(a[l]-h);
    int i,mini=0;
    for (i=l;i<=r;i++) if (a[i]<a[mini]) mini=i;
    if (ff) return dp(l,mini-1,a[mini],ff)*dp(mini+1,r,a[mini],ff)%mod*mi2(a[mini]-h)%mod;
    else{
        LL ans1=dp(l,mini-1,a[mini]-1,0)*dp(mini+1,r,a[mini]-1,0)%mod*2ll%mod;
        LL ans2=dp(l,mini-1,a[mini],1)*dp(mini+1,r,a[mini],1)%mod*(mi2(a[mini]-h)+mod-2)%mod;
        return (ans1+ans2)%mod;
    }
}
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int i,n;
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%d",&a[i]);
    a[0]=0x7fffffff;
    printf("%lld\n",dp(1,n,0,0));

    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,m,cnt;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  cin>>m;
  vector<int> p(m),x(m);
  rep(i,m) cin>>p[i]>>x[i];
  cnt=vec_sum(v);
  rep(i,m){
    cout<<cnt-v[p[i]-1]+x[i]<<endl;
  }
  
  
  
  
  
}
///////////////////////////

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79624
n = int(input())
p_cost, t_cost = map(int, input().split())
p_cal = int(input())
t_cal = []
for i in range(n) :
    t_cal.append(int(input()))

t_cal.sort(reverse = True)

total_cost = p_cost
total_cal = p_cal
max_total_cal_par_doll = total_cal // total_cost
for i in range(n) :
    total_cost += t_cost
    total_cal += t_cal[i]
    total_cal_par_doll = total_cal // total_cost
    if max_total_cal_par_doll < total_cal // total_cost :
        max_total_cal_par_doll = total_cal // total_cost
        
print(max_total_cal_par_doll)
    


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

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


Measured memory_bytes: 256
N,B,C = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0;
for i in range(N):
    g = 0;
    a = list(map(int,input().split()))
    for j in range(B):
        g+=a[j]*b[j]
    if g+C>0: cnt+=1;
print(cnt)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()

{
    int a,b;
    cin>>a>>b;

    if (a>b && b!=1){
        cout<<"Alice";
    }
    if (b>a && a!=1){
        cout<<"Bob";
    }
     else if (a>b && b==1){
            cout<<"Bob";}
     else if (b>a && a==1){
        cout<<"Alice";
      }
    else if (a==b){
        cout<<"Draw";
      }
return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, ans = 0;
vector<ll> s(5);
int main() {
	cin >> n;
	REP(i, 5)cin >> s[i];
	sort(ALL(s));
	cout << 4 + (n + s[0] - 1) / s[0] << endl;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      
      	if(N == 1) {
        	System.out.println("Hello World");  
        } else if(N == 2) {
        	int A = sc.nextInt();
          	int B = sc.nextInt();
          	System.out.println(A + B);
        }
    }
}

Measured memory_bytes: 21076
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    string s;
    cin >> s;
    if (s.size() == 2) {
        OUT(s);
        return 0;
    } else {
        for (int i = 2; i >= 0; i--) {
            cout << s[i];
        }
        cout << endl;
    }
}


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

#define ll long long
#define fore(i, n) for(i=0;i<n;i++)

template<typename T>
void output_vector(const vector<T>&v, int start=-1, int end=-1)
{
	if(start<0)start=0;
	if(end<0)end=v.size();
	
	for (int i = start; i < end; i++)
        cout << v[i]<<"\n";
}

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll x, k, d, mn; cin>>x>>k>>d;
	x=abs(x);
	ll p=x/d;
	ll t=min(p, k);
	k-=t;
	x-=t*d;
	if(k==0)
	    cout<<x<<endl;
	else
	{
	    if(k%2==1) cout<<abs(x-d)<<endl;
	    else cout<<x<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    if (n % 2 == 0)
        cout << n;
    else cout << n*2;
}

Measured memory_bytes: 3548
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()

#define equal equalll
#define less lesss
const int N = 1e6 + 10;
const long long INF = 1e9 + 19;

int r, c;
int n;
vector < pair < int, int > > e[N];
bool use[N];
long long dist[N];
bool fail = 0;

void read() {
	scanf("%d%d%d", &r, &c, &n);
	for (int i = 0; i < n; i++) {
		int v, u, cost;
		scanf("%d%d%d", &v, &u, &cost); v--; u--;	
		e[v].pb(mp(u + r, -cost));
		e[u + r].pb(mp(v, cost));
	}
}

vector<int> whoR;
vector<int> whoC;
		   

void dfs(int v, long long w) {
	if (v < r)
		whoR.pb(v);
	else
		whoC.pb(v);
	use[v] = 1;
	dist[v] = w;
	for (auto x: e[v]) {
		int u = x.fr;
		long long ncost = dist[v] + x.sc;
		if (!use[u]) {
			dfs(u, ncost);
		}
		else {
			if (dist[u] != ncost)
				fail = 1;
		}
	}

}

void solve() {
	for (int i = 0; i < r; i++) {
		if (!use[i]) {
			whoR.clear();
			whoC.clear();
			dfs(i, 0);
			long long mnR = 1e18;	
			for (auto v: whoR)
				mnR = min(mnR, dist[v]);
			for (auto v: whoR)
				dist[v] -= mnR;
			for (auto u: whoC)
				dist[u] -= mnR;
		}
	}
	//for (int i = 0; i < r + c; i++)
		//cerr << dist[i] << " ";
	//cerr << endl;

	long long mnR = 1e18;
	long long mnC = 1e18; 
	for (int i = 0; i < r; i++)
		mnR = min(mnR, dist[i]);

	for (int i = r; i < r + c; i++)
		if (use[i])
			mnC = min(mnC, -dist[i]);

	//db2(mnR, mnC);
	if (mnC + mnR < 0)
		fail = 1;

	if (fail)
		puts("No");
	else
		puts("Yes");

}

void stress() {

}

int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}



Measured memory_bytes: 33708
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  string s,t;cin>>s>>t;
  int a,b;cin>>a>>b;
  string u;cin>>u;
  cout<<(u.compare(s)==0?a-1:a)<<" "<<(u.compare(s)==0?b:b-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int n = 1000000;

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

ll lcm(ll x, ll y){
    return (x*y)/gcd(x,y);
}

int main(){
    ll a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;
V<int> a, b;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n), b.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    ll ans = 0;
    for (int i = 0; i < 29; i++) {
        // i bit 目を見る時は i bit 以下だけでいいのでマスク
        int mask = (1 << (i + 1)) - 1;
        V<int> rema(n), remb(n);
        for (int i = 0; i < n; i++) rema[i] = a[i] & mask;
        for (int i = 0; i < n; i++) remb[i] = b[i] & mask;
        sort(ALL(remb));
        ll bcnt = 0;
        // a + b の取りうる値は 2 * (2^(i+1) - 1) = 4 * 2^i - 2 < 4 * 2^i
        // 2^i bit 目が立つのは [2^i, 2*2^i-1], [3*2^i, 4*2^i-1]
        for (int j = 0; j < n; j++) {
            bcnt += lower_bound(ALL(remb), (1 << (i + 1)) - rema[j]) - lower_bound(ALL(remb), (1 << i) - rema[j]);
            bcnt += lower_bound(ALL(remb), (1 << (i + 2)) - rema[j]) - lower_bound(ALL(remb), ((1 << i) + (1 << (i + 1))) - rema[j]);
        }
        if (bcnt & 1) ans += 1 << i;
    }
    cout << ans << '\n';
    return 0;
}


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


void Main()
{
  ll n; cin >> n;
  if (n < 3) {cout << 0 << endl; return;}
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  ll cnt = 0;
  for (int i = 0; i < n-2; i++) {
    ll a = l[i];
    for (int j = i+1; j < n-1; j++) {
      ll b = l[j];
      for (int k = j+1; k < n; k++) {
        ll c = l[k];
        if (a==b or b==c or c==a) continue;
        if (a+b > c and b+c > a and c+a > b) cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 3668
N,M = map(int,input().split())
 
L = []
R = []
for _ in range(M):
  x,y = map(int,input().split())
  L.append(x)
  R.append(y)
 
if min(R) >= max(L):
  print(min(R)-max(L)+1)
else:
  print(0)

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

int main () {
  string s;
  int a = 0, ans = 0;
  cin >> s;
  
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      a ++;
    }
    if (s[i] != 'R' || i == 2) {
      ans = max(a,ans);
      a = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
  int a,b;
  int x,y;
  cin>>a>>b>>x>>y;
  
  if((x+b-1)/b<=(a+y-1)/y){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return(0);
}

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

#define M 500000
#define P 10
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
int find(int,Node);


int main() {

  int m,k,i,f;
  char s[10];

  scanf("%d",&m);

  for (i=0 ; i<m ; i++){
    scanf("%s",s);

    if(s[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    if(s[0]=='f'){
      scanf("%d",&k);
      f=find(k,root);
      if(f==0) printf("no\n");
      else printf("yes\n");
    }

    else if(s[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  Node x = root;
  Node y = NIL;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }

  z->parent=y;

  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;

}

void inorder(Node r){
  if(r->left!=NIL) inorder(r->left);
  printf(" %d",r->key);
  if(r->right!=NIL)inorder(r->right);
}


void preorder(Node r){
    printf(" %d",r->key);
    if(r->left!=NIL) preorder(r->left);
    if(r->right!=NIL)preorder(r->right);
}


int find(int k,Node r){

  int a=0;
  Node x=r;

  while(x!=NIL){
    if(k < x->key) x = x->left;
    else if (k > x->key) x = x->right;
    else {
      a=1;
      break;
    }
  }

  return a;
}



Measured memory_bytes: 20468
#include<stdio.h>
#define N 10000
#define Q 500

int main(){
  int n,i,j,q;
  int S[N];
  int T[Q];
  int count=0;
  int a;
  /*1列目*/
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
   
  }
  /*2列め*/
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  
 
}
  /*重複個数計算*/
  for(i=0;i<q;i++){
    
    for(j=0;j<n;j++){
     
       
      if(S[j]==T[i]){
	a=S[i];

	count++;
	break;
      }
	
      
    }
  }
  /*表示*/
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2756
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBouquet solver = new DBouquet();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBouquet {
        int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            long a = in.nextInt();
            long b = in.nextInt();
            long ans = ((pow(2, n) - 1 - ncr(n, a) + MOD) % MOD - ncr(n, b) + MOD) % MOD;
            out.println(ans);
        }

        long pow(long x, long c) {
            if (c == 0) return 1;
            else {
                long a = pow(x, c / 2);
                return (c % 2 == 0) ? (a * a) % MOD : ((a * a) % MOD * x) % MOD;
            }
        }

        long ncr(long n, long r) {
            long ans = 1;
            for (long i = n; i > n - r; i--) {
                ans = (ans * i) % MOD;
                ans = (ans * pow(n - i + 1, MOD - 2)) % MOD;
            }
            return ans;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;
using P = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return x ? mod - x : 0;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  friend ostream& operator << (ostream& os, const mint& m) noexcept {
    return os << m.x;
  }

  friend istream& operator<< (istream& is, mint& m) noexcept {
    return is >> m.x;
  }
};

struct combination {
  vector<mint> fact, ifact;  // 階乗と階乗の逆元
  combination(int n):fact(n+1),ifact(n+1) {  // 階乗と階乗の逆元を n まで求める
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

  ll n, k;
  cin >> n >> k;

  combination comb(n);

  for (int i = 1; i <= k; i++) {
    mint blue = comb(k - 1, i - 1);  // 青の並べ方
    mint red;
    red += comb(n - k - 1, i - 2);
    red += comb(n - k - 1, i - 1);
    red += comb(n - k - 1, i - 1);
    red += comb(n - k - 1, i);
    if (n - k == 0 && i == 1) red = 1;
    mint ans = blue * red;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        h: [i32; n],
    }
    let mut ans = 0;
    let mut cnt = 0;
    for i in 1..n {
        if h[i] <= h[i - 1] {
            cnt += 1;
        }
        else {
            cnt = 0;
        }
        if cnt > ans {
            ans = cnt;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1e9


int main(void){
    int N,K;
    cin>>N>>K;
    vector<ll> h(N+2);
    for (int i=0;i<N;i++) cin>>h[i];
    vector<ll> dp(N+K,INF);

    dp[0]=0;

    for (int i=0;i<N;i++){

        for (int j=1;j<=K;j++){
            if (dp[i+j] > dp[i] + abs(h[i]-h[i+j])){
                dp[i+j] = dp[i] + abs(h[i]-h[i+j]);
            }
        }
    }

    cout<<dp[N-1]<<endl;


    return 0;
}

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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust";
    else
        cout << "win";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();
	static PrintStream out = System.out;

	public static void main(String args[]) {
		int K = ni();
		int T = ni();
		int a[] = na(T);

		int max = 0;
		for (int i=0;i<T;i++) {
			max = Math.max(max, a[i]);
		}

		int nokori = K - max;
		int ans = Math.max(0, max - nokori - 1);

		System.out.println(ans);
	}

	private static String next() {
		return sc.next();
	}

	private static int ni() {
		return sc.nextInt();
	}

	private static long nl() {
		return sc.nextLong();
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for(int i = 0;i < n;i++) a[i] = ni();
		return a;
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for(int i = 0;i < n;i++) a[i] = ni();
		return a;
	}

	private static double nd() {
		return Double.parseDouble( next() );
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 8148
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        sc.close();

        if (a.substring(a.length() - 1).equals(b.substring(0, 1))
                && b.substring(b.length() - 1).equals(c.substring(0, 1))) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int GCD(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(x%y!=0){
    int temp=x;
    x=y;
    y=temp%y;
  }
  return y;
}

int par[100001],r[100001];

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    r[i]=0;
  }
}

int find(int x){
  if(par[x]==x){
    return x;
  }
  else{
    return par[x]=find(par[x]);
  }
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(r[x]<r[y]){
    par[x]=y;
  }
  else{
    par[y]=x;
    if(r[x]==r[y]) r[x]++;
  }
}

bool same(int x,int y){
  return find(x)==find(y);
}

int main() {
  int n,m;
  cin>>n>>m;
  init(n);
  for(int i=0;i<m;i++){
    int x,y,z;
    cin>>x>>y>>z;
    x--;y--;
    unite(x,y);
  }
  set<int> memo;
  for(int i=0;i<n;i++){
    memo.insert(find(i));
  }
  cout<<memo.size()<<endl;
  return 0;
}


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

int main() {
    int n, m;
    while (cin >> n >> m, n | m) {
        vector<int> a(n), b(m);
        rep(i, n) cin >> a[i];
        rep(i, m) cin >> b[i];

        ll sum1 = 0, sum2 = 0;
        rep(i, n) sum1 += a[i];
        rep(i, m) sum2 += b[i];

        int ans1 = INF, ans2 = INF;
        rep(i, n) {
            rep(j, m) {
                if (sum1 - a[i] + b[j] == sum2 + a[i] - b[j] && ans1 + ans2 > a[i] + b[i])
                    ans1 = a[i], ans2 = b[j];
            }
        }

        if (ans1 == INF && ans2 == INF)
            cout << -1;
        else
            cout << ans1 << " " << ans2;
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 3104
x,y,z,k=map(int,input().split());a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))
aa=[]
for i in a:
  for j in b:aa.append(i+j)
aa.sort(reverse=1)
aa=aa[:k+1]
s=[]
for i in aa:
  for j in c:s.append(i+j)
s.sort(reverse=1)
for i in range(k):print(s[i])

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

int main(){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if((x-r) < 0 || (x+r) > w || (y-r) < 0 || (y+r) > h)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vector<int> v;
int n;

inline ll solve(bool sg) {
    ll sum = 0, cnt = 0;
    fore(i,0,n) {
        sum += v[i];
        if (sg && sum >= 0) {
            cnt += sum+1;
            sum = -1;
        } else if (!sg && sum <= 0) {
            cnt += -sum+1;
            sum = 1;
        }
        sg ^= 1;
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    cin >> n;
    fore(i,0,n) {
        int a;
        cin >> a;
        v.pb(a);
    }
    ll a = solve(0);
    ll b = solve(1);
    cout << min(a, b) << endl;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(void)
{
  int c[3][3],c1[3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      scanf("%d",&c[i][j]);
    }
  }
  for(int i=1;i<3;i++){
    for(int j=1;j<3;j++){
      if(c[i-1][j]-c[i-1][j-1]!=c[i][j]-c[i][j-1]){
        puts("No");
        return 0;
      }else if(c[i][j-1]-c[i-1][j-1]!=c[i][j]-c[i-1][j]){
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int x[300010],t[300010],l[300010],r[300010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),L=gi();
	ll ans=0;
	for(int i=1;i<=n;++i)x[i]=gi();
	for(int i=1;i<=n;++i)t[i]=gi(),ans+=(1ll*t[i]+2*L-1)/2/L*2*L;
	for(int i=1;i<=n;++i){
		t[i]%=L*2;
		l[i]=(t[i]&&t[i]<=x[i]*2);
		r[i]=(t[i]&&t[i]<=(L-x[i])*2);
	}
	for(int i=1,x=0,y=0;i<n;++i)
		if(x&&r[i])y+=l[i],--x,ans-=L*2;
		else if(!l[i]&&r[i]){if(y)--y,++x;}
		else x+=l[i];
	if(!r[n])ans+=L*2;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4992