akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class UF {
private:
    int sz; vector<int> par,nrank,size;
public:
    UF(){}
    UF(int node_size){ sz = node_size; par.resize(sz),nrank.resize(sz),size.resize(sz);
        rep(i,sz){ par[i] = i; nrank[i] = 0; size[i] = 1;} }
    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(nrank[x] < nrank[y]) swap(x,y);
        par[y] = x; size[x] += size[y]; if(nrank[x] == nrank[y]) nrank[x]++; }
    int query(int x){ x = find(x); return size[x]; }
    bool same(int x,int y){ return find(x) == find(y); }
};

ll comb(ll val)
{
    return val*(val-1)/2;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    UF uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a,--b;
        uf.unite(a,b);
    }
    ll a1,a2;
    ll v1 = uf.query(1),v2 = uf.query(0);
    a1 = comb(v1) + comb(n-v1);
    a2 = comb(v2) + comb(n-v2);
    cout << max(a1,a2) - m << "\n";
    return 0;
}


Measured memory_bytes: 1408
#import sys
#input = sys.stdin.readline

MOD = 1000000007

N, M, Q = map(int, input().split())

x = []

for i in range(Q):
    n = list(map(int, input().split()))
    n[0] -= 1
    n[1] -= 1
    x.append(n)

res = 0
a = [0]*10
for a[0] in range(0, M):
    for a[1] in range(a[0], M):
        for a[2] in range(a[1], M):
            for a[3] in range(a[2], M):
                for a[4] in range(a[3], M):
                    for a[5] in range(a[4], M):
                        for a[6] in range(a[5], M):
                            for a[7] in range(a[6], M):
                                for a[8] in range(a[7], M):
                                    for a[9] in range(a[8], M):
                                        tmp = 0
                                        for i in range(len(x)):
                                            if (a[x[i][1]]- a[x[i][0]]) != x[i][2]:
                                                continue
                                            else:
                                                tmp += x[i][3]
#                                                print(tmp)
                                        res = max(res,tmp)

print(res)



Measured memory_bytes: 69948
S = gets.chomp
X = []
X.push('AKIHABARA')
X.push('AKIHBARA')
X.push('AKIHABRA')
X.push('AKIHBRA')
X.push('AKIHABAR')
X.push('AKIHBAR')
X.push('AKIHABR')
X.push('AKIHBR')
X.push('KIHABARA')
X.push('KIHBARA')
X.push('KIHABRA')
X.push('KIHBRA')
X.push('KIHABAR')
X.push('KIHBAR')
X.push('KIHABR')
X.push('KIHBR')
X.each do |t|
  if S == t
    puts 'YES'
    exit
  end
end
puts 'NO'



Measured memory_bytes: 14364
n = int(input())
ans = 0
x = int(n / 15)
for i in range(x):
    ans += 60 + i * 8 * 15

amari = n % 15

plus = int(n / 15) * 15

if amari == 1:
    ans += plus + 1
elif amari == 2 or amari == 3:
    ans += plus + plus + 3
elif amari == 4 or amari == 5 or amari == 6:
    ans += plus + plus + plus + 7
elif amari == 7:
    ans += plus + plus + plus + plus + 14
elif amari == 8 or amari == 9 or amari == 10:
    ans += plus + plus + plus + plus + plus + 22
elif amari == 11 or amari == 12:
    ans += plus + plus + plus + plus + plus + plus + 33
elif amari == 13:
    ans += plus + plus + plus + plus + plus + plus + plus + 46
elif amari == 14:
    ans += plus + plus + plus + plus + plus + plus + plus + plus + 60

print(ans)

Measured memory_bytes: 9232
#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 a, b; cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        string s = to_string(i);
        if(s[0]==s[4] && s[1] == s[3])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll A, B, C; cin >> A >> B >> C;
	ll MAX = max(A, max(B, C));
	ll SUM = A + B + C;

	ll ans = 0;
	if (MAX % 2 != SUM % 2) {
		MAX++;
	}
	ans += ((MAX - A) + (MAX - B) + (MAX - C)) / 2;

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  REP(i, N) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N, Y = map(int, input().split())

    for x in range(N + 1):
        n = N - x
        for y in range(n + 1):
            z = N - x - y
            if x * 10000 + y * 5000 + z * 1000 == Y:
                print(x, y, z)
                return
    print(-1, -1, -1)

main()


Measured memory_bytes: 3060
# APC001B - Two Arrays
def main():
    n = int(input())
    arr = [tuple(map(int, input().rstrip().split())) for _ in range(2)]
    cnt = 0
    for a, b in zip(arr[0], arr[1]):
        if a > b:
            cnt += a - b
        else:
            cnt -= (b - a) // 2
    print("Yes" if cnt <= 0 else "No")


if __name__ == "__main__":
    main()

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), s(2 * N + 1, 0);
    rep(i, N) cin >> A[i];
    rep(i, 2 * N) s[i + 1] = s[i] + A[(2 * i) % N];
    rep(i, N) {
        ll ans;
        if (i % 2) {
            ans = s[N] / 2 - s[(i + N) / 2 + N] + s[(i + N) / 2 + N - N / 2];
        } else {
            ans = s[N] / 2 - s[i / 2 + N] + s[i / 2 + N - N / 2];
        }
        cout << ans * 2;
        if (i == N - 1) cout << "\n";
        else cout << " ";
    }
    //rep(i, 2 * N + 1) cout << s[i] << "\n";
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    while(a.at(i) % 2 == 0){
      ans++;
      a.at(i) /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main() {
    LL n, i = 10, fc=0, ans;
    cin >> n;
    if (n % 2 != 0){
        ans = 0;
    }else{
    	i = n / 10 * 10;
        int j=1;
        while(i / 5 >= 1){
            fc += i / 10;
            i /= 5;
            j++;
        }
        ans = fc;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (A > B) {
		cout << A * 2 - 1 << endl;
	}
	else if (A < B) {
		cout << B * 2 - 1 << endl;
	}
	else {
		cout << A * 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using namespace boost::multiprecision;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
    int cnt[100000];
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,q;
    char s[100000];
    scanf("%d%d",&n,&q);
    scanf("%s",s);
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')cnt[i+1]++;
        cnt[i+1]+=cnt[i];
    }
    rep(i,q){
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",cnt[r-1]-cnt[l-1]);
    }
}


Measured memory_bytes: 1280
from collections import deque
N,K = map(int,input().split())
es = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(N-1)]
tr = [[] for i in range(N)]
for i,(a,b) in enumerate(es):
    tr[a].append((b,i))
    tr[b].append((a,i))

def reachable_points(root_v, cant_visit_v):
    visited = [0] * N
    visited[root_v] = visited[cant_visit_v] = 1
    q = deque([(root_v,0)])
    ret = 0
    while q:
        v,dep = q.popleft()
        if dep == K//2: break
        for to,_ in tr[v]:
            if visited[to]: continue
            ret += 1
            q.append((to,dep+1))
            visited[to] = 1
    return ret

def reachable_edges(root_e):
    a,b = es[root_e]
    return reachable_points(a,b) + reachable_points(b,a)

if K%2:
    ans = N
    for center_e in range(N-1):
        ans = min(ans, N - 2 - reachable_edges(center_e))
    print(ans)
else:
    ans = N
    for center_v in range(N):
        ans = min(ans, N - 1 - reachable_points(center_v, center_v))
    print(ans)

Measured memory_bytes: 4328
n = int(input())
s_list = [int(input()) for nesya in range(n)]
total = sum(s_list)
s_list.sort()
t = 0
if total%10 != 0:
  print(total)
else:
  for s in s_list:
    if s%10 != 0:
      print(total-s)
      break
    t += 1
if t == n:
  print(0)

Measured memory_bytes: 3064
//Created by Aminul on 8/2/2020.

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        
        pw.println(in.nextInt() >= 30 ? "Yes" : "No");
          
        pw.close();
    }

    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N), c(N);
  for (int i=0; i<N; i++) {
    cin >> v.at(i);
  }
  for (int i=0; i<N; i++) {
    cin >> c.at(i);
  }
  int toku;
  for (int i=0; i<N; i++) {
    if (v.at(i)-c.at(i)>0) {
      toku += v.at(i) - c.at(i);
    }
  }
  cout << toku << endl;
}


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

int main() {
  ll n, a;
  cin >> n;
  multiset<ll, greater<>> st;
  rep(i, n) {
    cin >> a;
    st.insert(a);
  }
  ll ans = 0;
  while(!st.empty()) {
    auto it = st.begin();
    st.erase(it);
    ll p = 2;
    while(p <= *it) {
      p *= 2;
    }
    auto jt = st.find(p - *it);
    if(jt == st.end()) continue;
    st.erase(jt);
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9600
module Main where

import Control.Applicative
import Text.Printf

so :: Int -> String
so t = printf "%d:%d:%d" h m s
  where
    h = t`div`3600
    m = (t-h*3600)`div`60
    s = t-h*3600-m*60

main :: IO ()
main = putStrLn =<< so <$> readLn

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char str[25];
    cin>>str;
    char rev[25];
    for(int i=0;i<strlen(str);i++)
        rev[i]=str[strlen(str)-i-1];
    rev[strlen(str)]='\0';
    cout<<rev<<endl;
}

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

#define pi acos(-1);
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    long double r;
    cin>>r;
    cout<<fixed<<setprecision(20);
    cout<<2*r*pi;
    nl;
    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define eps (1e-6)
#define xx first
#define yy second
#define ln 17
#define off 2

#define sq(x) ((x)*(x))

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define log 20
#define mod 1000000007LL
#define INF 1000000000000000000LL
#define maxn 300005

int a[maxn] , cnt[maxn] , pos[maxn] ;

int main()
{
    int n , m ;
    int q ;

    scanf("%d %d",&n,&m) ;
    scanf("%d",&q) ;

    for(int i=1; i<=q ; i++) scanf("%d",&a[i]) ;

    vector <int> perm ;
    set<int> st ;
    for(int i=1 ; i<=m ; i++) st.insert(i) ;

    for(int i=q ; i>=1 ; i--)
    {
        if( st.find(a[i]) != st.end() )
        {
            perm.pb(a[i]) ;
            st.erase( st.find(a[i]) ) ;
        }
    }

    for(int v: st) perm.pb(v) ;

    while( perm.size() >= 2 )
    {
        int sz = perm.size() ;
        if( perm[sz-2] < perm[sz-1] ) perm.pop_back() ;
        else break ;
    }

    perm.pop_back() ;

    for(int i=1 ; i<=m ; i++) pos[i] = -1 ;
    for(int i=0 ; i<perm.size() ; i++) pos[ perm[i] ] = i ;

    for(int i=q ; i>=1 ; i--)
    {
        if( pos[ a[i] ] == -1 ) continue ;

        if( pos[ a[i] ] == 0 ) cnt[ pos[ a[i] ] ]++ ;
        else{
            cnt[ pos[ a[i] ] ]++ ;
            cnt[ pos[ a[i] ] ] = min( cnt[ pos[a[i]] ] , cnt[ pos[a[i]] - 1 ] ) ;
        }
    }

    int fl = 1 ;

    for(int i=0 ; i<perm.size() ; i++)
    {
        if( cnt[i] < n ) fl = 0 ;
    }

    if(fl) printf("Yes\n") ;
    else printf("No\n") ;

    return 0 ;
}


Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    int num = min(min(a, b), min(min(c, d), e));
    int tmp = (n + num - 1) / num;
    cout << tmp + 4 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int x = sc.nextInt();
        int y = sc.nextInt();

        if (y%2 == 1) {
            System.out.println("No");
            return;
        }

        if (x * 2 <= y && x * 4 >= y) {
            System.out.println("Yes");

        } else {
            System.out.println("No");
        }



        sc.close();
    }

}

Measured memory_bytes: 35792
fun main(args: Array<String>) {
    abc117c()
}

fun abc117c() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val xList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()

    // コマの個数が1個のパターン
    if (n == 1) {
        return println(xList.max()!! - xList.min()!!)
    }

    // 座標の個数が1個 or 座標の個数<=コマの個数のパターン
    if (m == 1 || m <= n) {
        return println(0)
    }

    // 以下はコマが2個以上 and 座標の個数>コマの個数のパターン

    val distanceList = mutableListOf<Long>()
    (1 until xList.size).forEach {
        distanceList.add(xList[it].toLong() - xList[it - 1].toLong())
    }

    val sortedDistanceList = distanceList.sorted()

    // コマの個数-1つ、座標間の移動を省けると考える
    val answer = sortedDistanceList.dropLast(n - 1)

    println(answer.sum())
}


Measured memory_bytes: 52188
inpt = map(int, raw_input().split())
five = 0
seven = 0

for i in range(0, 3):
	if inpt[i] == 5: five = five + 1
	if inpt[i] == 7: seven = seven + 1

if five == 2 and seven == 1: print 'YES'
else: print 'NO'


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<int> A(N), B(N);
  for(int i = 0; i < N; i++) {
    A.at(i) = L + i;
    if(L + i >= 0) {
      B.at(i) = A.at(i);
    }
    else B.at(i) = -A.at(i);
  }
  sort(B.begin(), B.end());
  int k;
  for(int i = 0; i < N; i++) {
    if(A.at(i) == B.at(0) || A.at(i) == -B.at(0)) {
      k = i;
    }
  }
  int S;
  for(int i = 0; i < k; i++) {
    S += A.at(i);
  }
  for(int i = k + 1; i < N; i++) {
    S += A.at(i);
  }
  cout << S << endl;
}

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

#define ll long long

ll N,K;
vector<ll> logs;
int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; i++) 
    {
        ll tmp;
        cin >> tmp;
        // cout << tmp;
        logs.push_back(tmp);
    }

    ll lo = 1;
    ll hi = 1000000000;
    ll mid;
    while (1)
    {
        if (hi <= lo) {
            mid = lo;
            break;
        }
        mid = (hi + lo) / 2;
        // cout << hi << " " << lo << " " << mid << endl;
        ll cut = 0;
        for (auto& len : logs)
        {
            cut += ceil((double)len / (double)mid) - 1;
        }

        // cout << hi << " " << lo << " " << mid << " " << cut << endl;

        if (cut <= K)
        {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }

    cout << mid << endl;
    return 0;

}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    int ans = 0;
    int a = 0, b = 0, ab = 0;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        if (s.front() == 'B' && s.back() == 'A') ab++;
        else if (s.front() == 'B') b++;
        else if (s.back() == 'A') a++;

        int len = s.length();
        for (int j = 0; j < len - 1; j++) {
            if (s[j] == 'A' && s[j + 1] == 'B') ans++;
        }
    }

    if (ab > 0) {
        ans += ab - 1;
        if (a > 0) a--, ans++;
        if (b > 0) b--, ans++;
    }
    ans += min(a, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 55;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    bool co = true;
    FOR(i,1,n)
        if (a[i] != i) co = false;
    if (co) {
        cout << "YES";
        return 0;
    }
    FOR(i,1,n)
        FOR(j,i+1,n) {
            swap(a[i], a[j]);
            co = true;
            FOR(k,1,n)
                if (a[k] != k) co = false;
            if (co) {
                cout << "YES";
                return 0;
            }
            swap(a[i], a[j]);
        }
    cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
int K;
cin >> K >> S;
if (S.size() <= K) cout << S << endl;
else {
  for (int i = 0;i < K;i++) cout << S.at(i);
  cout << "..." << endl;
}

return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int n;

  cin >> n;

  int mn = 10000005;

  int count = 0;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;

    if (k <= mn) {
      count++;
      mn = k;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
score=[a[0],0,a[1]+a[2],sum(a[3:])]
ans=10**18
i,k=1,3
for j in range(2,n-1):
  score[1]+=a[j-1]
  score[2]-=a[j-1]
  while abs(score[0]-score[1])>abs(score[0]+a[i]-score[1]+a[i]):
    score[0]+=a[i]
    score[1]-=a[i]
    i+=1
  while abs(score[2]-score[3])>abs(score[2]+a[k]-score[3]+a[k]):
    score[2]+=a[k]
    score[3]-=a[k]
    k+=1
  ans=min(ans,max(score)-min(score))
print(ans)

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

int main (void)
{
	int input[100][100],r,c,sumA[100],sumB[100];
	int i,j;
	
	scanf("%d %d",&r,&c);
	
	for(i = 0 ; i < 100 ; i++)
	{
		sumA[i] = 0;
		sumB[i] = 0;
	}
	
	for(i = 0 ; i < r ; i++)
	{
		for(j = 0 ; j < c ; j ++)
		{
			scanf("%d",&input[i][j]);
			sumA[i] = sumA[i] + input[i][j];
		}
	}
	
	for(i = 0 ; i < r ; i++)
	{
		for(j = 0 ; j < c ; j++)
		{
			sumB[j] = sumB[j] + input[i][j];
		}
	}
	
	for(i = 0 ; i < r ; i++)
	{
		for(j = 0 ; j < c ; j++)
		{
			printf("%d ",input[i][j]);
		}
		printf("%d\n",sumA[i]);
	}
	
	for(i = 0 ; i < r ; i++)
	{
		sumB[c] = sumB[c] + sumA[i];
	}
	
	for(i = 0 ; i < c + 1 ; i++)
	{
		printf("%d",sumB[i]);
		if(i != c)
		{
			printf(" ");
		}
	}
	
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int N,M,p;
	cin >> N >> M >>p;

	int d[10001];
	d[0] = p;

	for(int i=1; i<=M; i++){
		cin >> d[i];
	}

	sort(d, d+M+1);

	int c_min = N-1;

	for(int i=0; i<M+1; i++){
		int q = d[i];
		int r1 = d[(i-1+M+1)%(M+1)];
		int r2 = d[(i+1)%(M+1)];

		int c1 = ((p-q+N)%N)*2+(r1-p+N)%N;
		int c2 = ((q-p+N)%N)*2+(p-r2+N)%N;

		c_min = min(c_min, min(c1,c2));
	}

	cout << c_min*100 << endl;

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n, d;
    double a, b;
    double maxtan = 0;
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        cin >> b >> a;
        double c = a / b;
        maxtan = max(maxtan, c);
    }
    printf("%.6lf\n", maxtan * d);
    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	put(m2 - m1);
	return 0;
}


Measured memory_bytes: 256
# include<iostream>
using namespace std;
char s[300005];
int a[300005];
int b[300005];
int main(void)
{
    int n, i;
    cin >> n;
    cin >> s;
    a[0] = 0;
    for(i = 1; s[i] != '\0'; ++i)
    {
        if(s[i-1] == 'E')
            a[i] = a[i-1]+1;
        else
        {
            if(i == 1)
                a[i] = 0;
            else
                a[i] = a[i-1];
        }
    }
    b[n-1] = 0;
    for(i = n-2; i >= 0; --i)
    {
         if(s[i+1] == 'W')
            b[i] = b[i+1]+1;
        else
        {
            if(i == n-2)
                b[i] = 0;
            else
                b[i] = b[i+1];
        }
    }
    int minn = 1000000000;
    for(i = 0; s[i] != '\0'; ++i)
    {
        if(minn > n-1-(a[i]+b[i]))
            minn= n-1-(a[i]+b[i]);
    }
    cout << minn <<endl;
}


Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define LSTAGE 1



int main()
{

    ll n;
//    cin >> n;
//    map<ll, bool> v;
//    for(ll i=  0; i < n; i++)
//    {
//        ll r;
//        cin >> r;
//        if(v.count(r)==0)
//        {
//            v[r] = false;
//        }
//
//        v[r] = (!v[r]);
//
//    }
//    map<ll, bool> :: iterator it;
//    ll area = 0;
//    ll a= 0, b= 0;
//    for(it = v.begin(); it!=v.end(); it++)
//    {
//
////        cout << it->F<<endl;
//        if(it->S)
//            area++;
//    }
//    cout << area ;



ll l, r;
ll t = 0;
cin >> n;
while(n--)
{
    cin >> l >> r;
    t +=(r-l)+1;
}
cout << t;



    return 0;
}


Measured memory_bytes: 256
import java.lang.IllegalArgumentException

fun main(args: Array<String>) {
	val (n, m) = readLine()?.split(" ")?.map {it.toInt()} ?: throw IllegalArgumentException()
	val unionFind = UnionFind(n)
	for (i in 0 until m) {
		unionFind.addUnion(readLine()?.split(" ")?.map {it.toInt()} ?: throw IllegalArgumentException())
	}
	println(unionFind.maxUnionSize())
}

data class UnionFind(val n: Int, val parentList: MutableList<Int> = MutableList(n+1) {it}, val unionNumberList: MutableList<Int> = MutableList(n+1) {1}) {
	fun addUnion(friends: List<Int>) {
		val (parent, child) = if (friends[0] < friends[1]) Pair(friends[0], friends[1]) else Pair(friends[1], friends[0])
		val indexOfRootParent = findRoot(parent)
		val indexOfRootChild = findRoot(child)
		//2人が同じグループに所属していた場合、そのまま。
		if (indexOfRootParent == indexOfRootChild) return
		//2人が異なるグループに所属していた場合、2つのグループのメンバーが全てParent側に所属するようにする。
		//println("${indexOfRootChild}, ${indexOfRootParent}, ${unionNumberList[indexOfRootChild]}, ${unionNumberList[indexOfRootParent]}")
		unionNumberList[indexOfRootParent] += unionNumberList[indexOfRootChild]
		//Child側のグループは0人になる
		unionNumberList[indexOfRootChild] = 0
		//Childのrootの親を設定する
		parentList[indexOfRootChild] = indexOfRootParent
	}
	
	private fun findRoot(i: Int): Int {
		//rootならrootのindex、rootじゃないなら親がrootか調べる。
		return if (parentList[i] == i) i else {
			parentList[i] = findRoot(parentList[i])
			parentList[i]
		}
	}
	
	fun maxUnionSize(): Int {
		return unionNumberList.max() ?: return 0
	}
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int N, M, X;
int C[100001];
vector<vector<int>> A;

void dfs() {

}

int main() {
    cin >> N >> M >> X;
    A.resize(N);
    REP(i, N) {
        A.at(i).resize(M);
        cin >> C[i];
        REP(j, M) {
            cin >> A.at(i).at(j);
        }
    }

    ll min_cost = inf;
    REP(s, 1<<N) {
        ll cost = 0;
        vector<int> d(M, 0);
        REP(i, N) {
            if (s>>i&1) {
                cost += C[i];
                REP(j, M) d[j] += A[i][j];
            }
        }
        bool ok = true;
        REP(j, M) if (d[j] < X) ok = false;
        if (ok) min_cost = min(min_cost, cost);
    }

    if (min_cost == inf) cout << -1 << endl;
    else cout << min_cost << endl;
}


Measured memory_bytes: 3672
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 05 Jul 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int n = Integer.parseInt(st.nextToken());
        String a;
        int AC, WA, TLE, RE;
        AC = WA = TLE = RE = 0;
        while (n-- > 0) {
            a = br.readLine();

            if (a.equals("AC")) AC++;
            else if (a.equals("WA")) WA++;
            else if (a.equals("TLE")) TLE++;
            else RE++;
        }
        br.close();

        System.out.println("AC x " + AC);
        System.out.println("WA x " + WA);
        System.out.println("TLE x " + TLE);
        System.out.println("RE x " + RE);
    }
}


Measured memory_bytes: 42968
import java.util.*

val sc = Scanner(System.`in`)
val A = sc.nextInt()
val B = sc.nextInt()
val C = sc.nextInt()
val D = sc.nextInt()

fun main(args: Array<String>) {
    println(Math.max(0, arrayOf(B - A, D - C, B - C, D - A).min()!!))
}


Measured memory_bytes: 35908
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int X = scan.nextInt();
        int Y = scan.nextInt();
        int answer = 0;
        answer = X * Math.min(N, K);
        if (K < N) {
            answer += Y * (N - K);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

const int N=5e5+50; 

void read(int &x){
	x=0; 
	char c=getchar(); 
	for(;!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

int n,a[N],odd,even,exist;

int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

void maintain(){
	int g=a[1];
	rep(i,2,n)g=gcd(g,a[i]); 
	rep(i,1,n)a[i]/=g;
	odd=even=exist=0; 
	rep(i,1,n){
		odd+=a[i]%2==1;
		even+=a[i]%2==0; 
		exist|=a[i]==1;
	}
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	read(n); 
	rep(i,1,n)read(a[i]); 
	int cur=1,win; 
	do{
		maintain(); 
		rep(i,1,n)Pr("%d ",a[i]);Pr("\n"); 
		if(even%2==1){
			win=cur;
			break;
		}else if(odd>1){
			win=!cur;
			break;
		}else{
			if(exist){
				win=!cur; 
				break;
			}
			rep(i,1,n)a[i]/=2; 
		}
		cur=!cur; 
	}while(true);
	puts(win==1?"First":"Second"); 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
	
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)


int main(){
	int n;
	cin >> n;
	int a,b;
	cin >> a >> b;
	if(a % n == 0 || b % n == 0) cout << "OK";
	else if((b/n) - (a/n) > 0) cout << "OK";
	else cout << "NG";
}

Measured memory_bytes: 3636
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define vpush(v,x) v.push_back(x);
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,w,h;
    string s;
    cin>>a>>b;
    if(a>12){
        cout<<b;
    }
    else if(a>5){
        cout<<b/2;
    }
    else{
        cout<<0;
    }
    return(0);
}

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

using namespace std;

int N, M;

int main()
{
    scanf("%d%d", &N, &M);
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<M; j++)
        {
            string s;
            cin>>s;
            if(s=="snuke")
                return 0*printf("%c%d\n", j+'A', i+1);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
bool check(int x) {
	string p = to_string(x);
	string t = p;
	reverse(p.begin(), p.end());
	return t == p;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll n, m;
	cin >> n >> m;
	ll answer = 0;
	if (n > m) {
		swap(n, m);
	}
	if (n == 1 && m == 1) {
		cout << 1 << '\n';
		return 0;
	}
	if (n == 1) {
		cout << m - 2 << '\n';
		return 0;
	}  
	ll p1 = max(n - 2, 0ll);
	ll p2 = max(m - 2, 0ll);
	answer += p1 * p2;
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256
let id x = x

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
    let h = Array.init n (fun _ -> Scanf.scanf "%d\n" id) in
    Array.sort (-) h;
    Array.init (n-k+1) (fun i -> h.(i+k-1) - h.(i))
    |> Array.fold_left min 1000000001
    |> Printf.printf "%d"


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int i;
  int d = 0;
  bool chk = false;
  for(i=1;i<=n;i++){
    int l;
    cin >> l;
    d += l;
    if(d>x){
      chk = true;
      cout<<i<<endl;
      break;
    }
  }
  if(!chk)cout<<n+1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int X;

	cin >> X;
	int i=0;

	while(i*(i+1)/2 < X){
		i++;
	}
	cout << i;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<algorithm>
#include<numeric>
#include<cstring>
#include<set>
#define MAXN 1000000
using namespace std;
typedef long long ll;

int main()
{
    set<int> s;
    int N;
    scanf("%d",&N);
    int a;
    for(int i=0;i<N;i++){
        scanf("%d",&a);
        bool flag=s.insert(a).second;
        if(!flag)
            s.erase(a);
    }
    int ct=s.size();
    printf("%d\n",ct);
    return 0;
}


Measured memory_bytes: 4864
function Main(input) {
  input = parseInt(input);
  var f= (input + "").length;
  for(i=0; i<=Math.sqrt(input); i++){
    m=Math.max((i + "").length,(input/i+"").length);
    if (input%i==0 && m<f){
      f=m;
    }
  }
  console.log('%s', f);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17216
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int flag=0;

  cin>>s;

  for(int i=0;i<s.size();i++){
    for(int j=0;j<i;j++){
      if(s[j]==s[i]){
	flag=1;
	break;
      }
    }
    if(flag==1) break;
  }

  if(flag==0) cout<<"yes"<<endl;
  else cout<<"no"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]){
  int comb[1000001];
  int n,i,j;

  for(i = 2;i < 1000001;i++){
    comb[i] = 1;
  }

  comb[1] = comb[0] = 0;

  for(i = 2;i < 1001;i++){

    if(comb[i] == 0){continue;}
    
    for(j = 2;(j*i) < 1000001; j++){
      comb[j*i] = 0;
    }
  }

  while(scanf("%d",&n) != EOF){
    int sum = 0,count = 0;
    if(n == 0){break;}
    
    for(i = 2;i <= 1000000;i++){
      if(comb[i] == 1){
	count++;
	sum += i;
	if(count == n){
	  break;
	}
      }
    }

    printf("%d\n",sum);
    
  }
  
  
  return 0;    
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = scan.nextInt();
            y[i] = scan.nextInt();
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
        }
        for(int i = 0; i < n; i++){
            if(a[i] >= 5 && b[i] >= 2) System.out.println((x[i] * a[i] + y[i] * b[i]) * 4 / 5);
            else if(a[i] >= 5) System.out.println((int) (Math.min(x[i] * a[i] + y[i] * b[i], (x[i] * a[i] + y[i] * 2) * 4 / 5)));
            else if(b[i] >= 2) System.out.println((int) (Math.min(x[i] * a[i] + y[i] * b[i], (x[i] * 5 + y[i] * b[i]) * 4 / 5)));
            else System.out.println((int) (x[i] * a[i] + y[i] * b[i]));
        }
        scan.close();
    }
}


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

using namespace std;

int main() {
    int x, y, z, k;
    long long ll;
    vector<long long> a, b, c;
    cin >> x >> y >> z >> k;
    for (int i = 0; i < x; ++i) {
        cin >> ll;
        a.push_back(ll);
    }
    for (int i = 0; i < y; ++i) {
        cin >> ll;
        b.push_back(ll);
    }
    for (int i = 0; i < z; ++i) {
        cin >> ll;
        c.push_back(ll);
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    vector<long long> v;
    for (int l = 0; l < x; ++l) {
        for (int m = 0; m < y; ++m) {
            for (int n = 0; n < z; ++n) {
                if ((l + 1) * (m + 1) * (n + 1) <= k) {
                    v.push_back(a[l] + b[m] + c[n]);
                } else {
                    break;
                }
            }
        }
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < k; ++i) {
        cout << v[i] << endl;
    }
}


Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C; cin >> A >> B >> C;
    int X, Y; cin >> X >> Y;
    int ans = INF2;
    rep(i, max(X, Y) + 1) {
        int cost = i * C * 2;
        int needA = max(0LL, X - i);
        int needB = max(0LL, Y - i);
        ans = min(ans, needA * A + needB * B + cost);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
h, n = map(int, input().split())
magic = []
for i in range(n):
    magic.append(list(map(int, input().split())))

# 一次元で可能
dp = [10**10 for _ in range(h+1)]
dp[0] = 0

for damage, cost in magic:
    for j in range(h+1):
        nj = min(j+damage, h)
        dp[nj] = min(dp[nj], dp[j]+cost)

#print(dp)
print(dp[h])


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

int bubble_sort(int A[], int N) {
  int i, tmp, cnt, sorted;
  bool flag = 1;
  cnt = 0;
  sorted = 0;
  
  while (flag == 1) {
    flag = 0;
    for (i = 0; i <  N - 1 - sorted; i++) {
      if (A[i] > A[i+1]) {
        // swap
        tmp = A[i+1];
        A[i+1] = A[i];
        A[i] = tmp;
        
        cnt++;
        flag = 1;
      }
    }
    sorted++;
  }

  return cnt;
}

int main() {
  int i, N, cnt;
  int A[100];
  
  cin >> N;
  for (i = 0; i < N; i++) cin >> A[i];

  cnt = bubble_sort(A, N);

  for (i = 0; i < N; i++) {
    if (i > 0) cout << ' ';
    cout << A[i];
  }
  cout << endl;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3092