akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N, A, B; cin >> N >> A >> B;
	string S; cin >> S;

	ll cnt1{0};
	ll cnt2{0};

	REP(i, N)
	{
		char t = S[i];

		if (t == 'a')
		{
			if (cnt1 < (A+B))
			{
				std::cout << "Yes"<< std::endl;
				++cnt1;
				continue;
			}
		}
		else if (t == 'b')
		{
			if (cnt1 < (A+B) && cnt2 < B)
			{
				std::cout << "Yes" << std::endl;
				++cnt1;
				++cnt2;
				continue;
			}
		}
	   	std::cout << "No" << std::endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3648
n=int(input())
card=list(map(int,input().split()))
A=0
B=0
count=0
while len(card)!=0:
    point=max(card)
    if count%2==0:
        A +=point
    else:
        B +=point
    count +=1
    card.remove(point)
print(A-B)

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char s[200];

void solve(){
	cin >> s;
	int n = 15;
	int cnt = 0;
	REP(i, 0, n) {
		if (s[i] != 'x') {
			s[i] = 'o';
			cnt++;
		}
	}
	if (cnt >= 8) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
import itertools


h, w, k = map(int, input().split())

DP = [0] * w
DP[0] = 1
mod = 10**9 + 7

patterns = []

for line_count in range(w):
    candidates = itertools.combinations(range(w-1), line_count)

    for pattern in candidates:
        usable = True
        prev = 10

        for num in pattern:
            if num == prev + 1:
                usable = False
                break
            else:
                prev = num

        if usable:
            patterns.append(pattern)

for i in range(h):
    next_DP = [0] * w

    for pattern in patterns:
        straight = set(range(w))
        for line in pattern:
            next_DP[line] += DP[line+1]
            next_DP[line] %= mod
            next_DP[line+1] += DP[line]
            next_DP[line+1] % mod
            straight.discard(line)
            straight.discard(line+1)

        for line in straight:
            next_DP[line] += DP[line]
            next_DP[line] %= mod

    DP = next_DP.copy()

ans = DP[k-1]
print(ans%mod)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int main() {
	cin >> n;
	
	cout << n * 800 - (n / 15) * 200 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int com(int a[], int b[]){
	int n=0;
	for (int i = 0; i < 28; i++){
		if (a[i] >= 1 && b[i] >= 1){
			n++;
		}
	}
	return n;
}
int l[28],f[28];
int main()
{
	int n, r = 0,a,max1=-1;
	cin >> n;
	string s;
	cin >> s;


	for (int i = 0; i < n; i++){
		for (int j = 0; j <28; j++){
			l[j] = 0;
			f[j] = 0;
		}
		for (int j = 0; j < i; j++){
			l[s[j] - 'a']++;
		}
		for (int j = i; j < n; j++){
			f[s[j] - 'a']++;
		}
		a = com(l, f);
		if (a>max1){
			max1 = a;
		}
	}
	cout << max1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, maxv = -2000000000;
    cin >> n;
    int R[200000];
    
    //input
    for (int i = 0; i < n; i++) {
        cin >> R[i];
    }

    int minv = R[0];
    //calculate
    for (int i = 1; i < n; i++) {
        if (maxv < R[i]-minv) maxv = R[i]-minv;
        if (minv > R[i]) minv = R[i];
    }

    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3864
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))
    odd = [x % 2 == 1 for x in a].count(True)
    even = n - odd

    flag = False
    if odd == 0:
        if even >= 2:
            flag = True
    elif odd % 2 == 0:
        flag = True

    print("YES") if flag else print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 90748
# -*- coding: utf-8 -*-
import math


def main():
    """Function."""
    n = int(input())
    a, b = map(int, input().split())
    ps = list(map(int, input().split()))

    low, middle, large = 0, 0, 0

    for i in range(n):
        if ps[i] <= a:
            low += 1
        elif ps[i] > b:
            large += 1
        else:
            middle += 1

    print(min([low, middle, large]))



if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long N,W;
  cin>>N>>W;
  long long val[N+1],ww[N+1];
  long long dp[N+1][W+1];
  for(int i=1;i<=N;i++){
    cin>>ww[i]>>val[i];
  }
  for(int i=0;i<=N;++i)
  {
    for(int curr=0;curr<=W;++curr)
    {
      if(i==0 || curr==0)
        dp[i][curr]=0;
      else if(ww[i]<=curr)
      	dp[i][curr]=max(dp[i-1][curr],dp[i-1][curr-ww[i]]+val[i]);
      else
        dp[i][curr]=dp[i-1][curr];
    }
  }
  cout<<dp[N][W]<<"\n";
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

vector<bool> IsPrime;

void sieve(int max){
    IsPrime.assign(max, true);
    IsPrime[0] = false;
    IsPrime[1] = false;
    for(int i = 2; i*i <= max; i++){
        if(IsPrime[i]){
            for(int j = 2; i*j <= max; j++)IsPrime[i*j] = false;
        }
    }
}
int main(){
    sieve(100000);
    vector<int> sum(100001, 0);
    for(int i = 1; i <= 100000; i++){
        if(IsPrime[i] == true && IsPrime[(i + 1)/2] == true && i%2 == 1){
            sum[i] = sum[i - 1] + 1;
        }else sum[i] = sum[i - 1];
    }
    int Q; cin >> Q;
    vector<int> ans;
    rep(i, Q){
        int l, r; cin >> l >> r;
        l--;
        ans.push_back(sum[r] - sum[l]);
    }
    rep(i, Q) cout << ans[i] << endl;
}


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

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
//-------------------ここから回答する-----------------------

void solve(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<bool> f(n, true);
    const int INF = 1e9;
    int res = INF;
    while (n > 1)
    {
        auto mn = min_element(a.begin(), a.end());
        vector<int> tmp;
        tmp.push_back(*mn);
        int dis = distance(a.begin(), mn);
        rep(i, n)
        {
            if (dis == i)
                continue;
            if (a[i] % *mn != 0)
                tmp.push_back(a[i] % *mn);
            else
                --n;
        }
        a = tmp;
        res = min(res, *mn);
        // for (auto i : a)
        //     cout << i << " ";
        // cout << endl;
    }
    cout << res << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 4220
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int a,b,c,d,sum=0;
  scanf("%d%d%d%d%*c",&a,&b,&c,&d);
  if(a>b)
  {
      sum=b*c+(a-b)*d;
  printf("%d",sum);
  }
  else
    {
      sum=a*c;
  printf("%d",sum);
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    
    string T = "ATCG";
    int ans = 0;
    
    for(int i = 0; i < S.size(); i++){
       
        int now = 0;
        for (int j = i; j < S.size(); j++){
             bool ok = false;
             for(int k = 0;  k < T.size(); k++) {
                 if (S[j] == T[k]) ok = true;
             }
            if (ok) {
                now++;
                ans = max(ans, now);
            } else {
                break;
            }
        }
    
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
num = ["A"] * n
for i in range(m):
    s, c = map(int, input().split())
    if n>1 and s == 1 and c == 0:
        print(-1)
        exit()
    elif num[s - 1] != "A" and num[s - 1] != c:
        print(-1)
        exit()
    num[s - 1] = c

for j in range(n):
    if num[j] == "A":
        num[j] = 0
    if n>1 and num[0] == 0:
        num[0] = 1
print(int("".join(map(str, num))))


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC155E()
{
	string T;
	cin >> T;
	string S = "0";
	S += T;
	int N = S.size();
	ll ct = 0;
	for (int i = N-1; i > -1; --i)
	{
		if (S[i] <= '4' || (S[i] == '5' && S[i-1] < '5'))
		{
			ct += S[i] - '0';
		}
		else
		{
			int x = S[i] - '0';
			int j = i;
			while (S[j - 1] == '9')
			{
				S[j - 1] = '0';
				--j;
			}
			++S[j - 1];
			ct += 10 - x;
		}
	}
	cout << ct << endl;

}


int main()
{
	ABC155E();
	return 0;
}


Measured memory_bytes: 2308
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
using ull = unsigned long long;
#define rep(i,n) for(ull i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ull> a(n);rep(i,n){cin>>a[i];}
#define in(a) ull a;cin>>a;
int main()
{
	in(r);
	cout << 3 * r * r;
}


Measured memory_bytes: 256
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, X, Y = LI()
    X -= 1
    Y -= 1
    cnt = [0] * N

    for i in range(N):
        for j in range(i + 1, N):
            dist = min(abs(i - j), abs(X - i) + 1 +
                       abs(Y - j), abs(Y - i) + 1 + abs(X - j))
            cnt[dist] += 1

    for i in cnt[1:]:
        print(i)


main()


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

const int MOD = (int)1e9+7;

int main(){
  int a,b;
  cin >> a >> b;

  if(a>0) cout << "Positive" << endl;
  else if(a<=0 && 0<=b) cout << "Zero" << endl;
  else if((b-a)%2==0) cout << "Negative" << endl;
  else  cout << "Positive" << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp111 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int x = st[1];

            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            long ans = 0;
            int over = 0;

            for (int i = 0; i < N; i++) {
                over = 0;
                if (i == 0) {
                    over = Math.Max(0, a[0] - x);
                    ans += over;
                    a[0] -= over;
                    continue;
                }
                over = Math.Max(0, a[i] + a[i - 1] - x);
                ans += over;
                a[i] -= over;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 32220
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

int main() {
    int n,y;
    cin >> n >> y;
    bool can = false;
    for (int i=0;i<=n;i++){
        for (int j=0;j<=n-i;j++){
            int k=n-i-j;
            ll money = 10000*i+5000*j+1000*k;
            if(money==y){
                printf("%d %d %d",i,j,k);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}
///////////////////////////

ll beki(ll n) {
	if (n == 0) { return 1;}
	return 10 * beki(n - 1);
}



int main() {

	ll N;
	cin >> N;
	double A, T;
	cin >> T >> A;

	double H[MAX];
	repn(i, N) cin >> H[i];

	ll ans = 1;
	double min = abs(T - H[1] * 0.006 - A);

	repn(i, N) {
		double x = abs(T - H[i] * 0.006 - A);
		if (min > x) {
			min = x;
			ans = i;
		}
	}
	
	cout << ans;
	
	system("PAUSE");
}

Measured memory_bytes: 504
"""
108345237845804
498073591
are an example match, because (1,4) and (4,1)
each integer can be encoded as this kind of pair
if there is also
4768281
then we have 2 matches so far, because the
first matches with the second and third
considering 1 and 11 and 111 and 1111 and 11111
each are encoded as (1,1), so we get 9 matches from just these 5...
solution :
just count how many integers get encoded as a certain pair, then calculate
the number of pairs that would be made from them
eg if (1,4) = 10 and (4,1) = 5 then there are 5*10 = 50 pairs
How many encodings? no leading zero, so also ending zero wont get a match,
so 1 to 9 and 1 to 9, is 9*9=81 encodings
"""


def handstand(N):
    # first count how many integers have a given encoding
    count_encoding = {(x, y): 0 for x in range(1, 10) for y in range(1, 10)}
    for i in range(1, N+1):
        string_convert = str(i)
        start_val = int(string_convert[0])
        end_val = int(string_convert[-1])
        if end_val == 0: continue
        count_encoding[start_val, end_val] += 1
    # now count the encoding matches
    matches_count = 0
    for x in range(1, 10):
        for y in range(1, 10):
            matches_count += count_encoding[x, y]*count_encoding[y, x]
    return matches_count


if __name__ == "__main__":
    test1 = "25"
    test2 = "1"
    test3 = "100"
    test4 = "2020"
    test5 = "200000"
    test6 = "16"
    test = test4
    # in_val = int(test)
    in_val = int(input())
    print(handstand(in_val))


Measured memory_bytes: 3064
import std.stdio;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
import std.math;
import std.range;
 
void main() {
    auto S = readln.chomp.dup;
    auto T = readln.chomp.dup;
    auto findResult = iota(S.length-T.length+1).retro
        .find!(i =>
                iota(T.length)
                .all!(j => S[i+j] == T[j] || S[i+j] == '?'));
    if (findResult.length == 0) {
        writeln("UNRESTORABLE");
        return;
    }
    auto minPos = findResult[0];
    S = S.replace("?", "a");
    S[minPos..minPos+T.length] = T;
    writeln(S);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    ll ans = 0;
    cin >> n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=n-1;i>=0;i--){
        if((a[i]+ans)%b[i]!=0){
            ans+=(b[i]-(a[i]+ans)%b[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
n, m, c = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
a = []
for i in range(n):
    a.append(list(map(int, input().split(" "))))
    

count = 0
for i in range(n):
    ans = c
    for j in range(m):
        ans += a[i][j] * b[j]

    if(ans > 0): count += 1

print(count)

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

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (pow(a, 2) == pow(b, 2) + pow(c, 2) || pow(b, 2) == pow(a, 2) + pow(c, 2) || pow(c, 2) == pow(a, 2) + pow(b, 2) ? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 3088
s = input()
if s == "SUN":
  print ("7") 
elif s== "MON":
  print ("6")
elif s== "TUE":
  print ("5")
elif s== "WED":
  print ("4")
elif s== "THU":
  print ("3")
elif s== "FRI":
  print ("2")
else:
  print("1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

#define N 60
ll comb[N][N];
void calc(){
    comb[0][0]=1;
    rep(i,1,N-1){
        rep(j,0,i){
            if(j==0)comb[i][j]=comb[i-1][j];
            else comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
        }
    }
}

int main(){
    calc();
    
    ll n,a,b;cin>>n>>a>>b;
    ll v[n];rep(i,0,n-1)cin>>v[i];
    sort(v,v+n);
    ll s[n];s[n-1]=v[n-1];
    for(ll i=n-2;i>=0;i--)s[i]=s[i+1]+v[i];
    double ans=0;
    ll anscount=0;
    rep(k,a,b){
        double ave=s[n-k]/(double)k;
        if(k==a){
            ll x=lower_bound(v,v+n,v[n-k])-v;
            ll y=upper_bound(v,v+n,v[n-k])-v;
            ll A=y-x;
            ll B=y-(n-k);
            anscount=comb[A][B];
            ans=ave;
        }else if(v[n-1]==v[n-k]){
            ll x=lower_bound(v,v+n,v[n-k])-v;
            ll y=upper_bound(v,v+n,v[n-k])-v;
            ll A=y-x;
            ll B=y-(n-k);
            anscount+=comb[A][B];
        }
    }
    printf("%5.10lf\n%lld\n",ans,anscount);
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    b = list(map(int, input().split()))
    b = [b[0]] + b + [b[-1]]
    print(sum([min(b[i], b[i+1]) for i in range(n)]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin >> s;

	if(s>"2019/04/30"){
		cout << "TBD" << endl;
	}else{
		cout << "Heisei" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    int ans = 0;
    for(int a=0; a<10; a++) for(int b=0; b<10; b++) for(int c=0; c<10; c++) for(int d=0; d<10; d++) if(a+b+c+d == n) ans++;
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include<math.h>
#include <vector>
using namespace std;

void func_d2() {
	int N;
	cin >> N;

	int* A = new int[N];
	int* B = new int[N];
	int cnt = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = 0;
	}

	for (int i = N - 1; i >= 0; i--) {
		int value = 0;
		for (int j = i; j < N; j += (i + 1)) {
			value += B[j];
		}
		if (value % 2 != A[i]) {
			B[i] = 1;
			cnt += 1;
		}
	}

	
		cout << cnt << endl;
		for (int i = 0; i < N; i++) {
			if (B[i]) {
				cout << i + 1 << " ";
			}
		}
	
	free(A);
	free(B);
}

int main()
{
	func_d2();
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll dp[N][2];
ll mul(ll a, ll b) {
	return (a * b) % Mod;
}
ll sum(ll a, ll b) {
	return (a + b) % Mod;
}
vector<ll> G[N];
void DFS(ll v, ll par = 0) {
	for (auto u : G[v])
		if (u ^ par)
			DFS(u, v);
	dp[v][0] = dp[v][1] = 1;
	for (auto u : G[v])
		if (u ^ par) {
			dp[v][0] = mul(dp[v][0], sum(dp[u][1], dp[u][0]));
			dp[v][1] = mul(dp[v][1], dp[u][0]);
		}
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
    for (int i = 0 ; i < n - 1; i ++) {
    	ll v , u;
    	cin >> v >> u;
    	G[v].pb(u);
    	G[u].pb(v);
	}
	DFS(1);
	cout << sum(dp[1][1], dp[1][0]) << endl;
    return (0);
}

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

const int N = (int)1e6 + 6;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int r;
	cin >> r;
	cout << r * r;	
	return 0;
}

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

using State = string::const_iterator;
using C = complex<int>;

constexpr int MAX = 10000;
bool overflow;

C expr(State &itr);
C term(State &itr);
C factor(State &itr);
C number(State &itr);

void check(C x){
    if(abs(x.real()) > MAX || abs(x.imag()) > MAX){
        overflow = true;
    }
}

void next_char(State &itr, char expected){
    if(*itr == expected){
        itr++;
    }else{
        // error
        cout << "expected " << expected << " but" << *itr << endl;
        while(*itr){
            cout << *itr;
            itr++;
        }
        cout << endl;
    }
}

C expr(State &itr){
    C res = term(itr);
    while(1){
        if(*itr == '+'){
            next_char(itr, '+');
            res += term(itr);
            check(res);
        }else if(*itr == '-'){
            next_char(itr, '-');
            res -= term(itr);
            check(res);
        }else{
            break;
        }
    }
    return res;
}

C term(State &itr){
    C res = factor(itr);
    while(1){
        if(*itr == '*'){
            next_char(itr, '*');
            res *= factor(itr);
            check(res);
        }else{
            break;
        }
    }
    return res;
}

C factor(State &itr){
    C res;
    if(*itr == '('){
        next_char(itr, '(');
        res = expr(itr);
        next_char(itr, ')');
    }else{
        res = number(itr);
    }
    check(res);
    return res;
}

C number(State &itr){
    C res;
    if(*itr == 'i'){
        itr++;
        res = C(0,1);
    }else{
        int x = 0;
        while(isdigit(*itr)){
            x = x*10 + *itr-'0';
            check(C(x,0));
            itr++;
        }
        res = C(x,0);
    }
    check(res);
    return res;
}

int main(){
    string formula;
    while(cin >> formula){
        State begin = formula.begin();
        overflow = false;
        C ans = expr(begin);
        if(!overflow){
            if(abs(ans)==0){
                cout << 0 << endl;
            }
            else if(abs(ans.real())>0){
                cout << ans.real();
                if(ans.imag()!=0){
                    if(ans.imag() > 0) cout << '+';
                    cout << ans.imag() << 'i';
                }
                cout << endl;
            }else{
                cout << ans.imag() << 'i' << endl;
            }
        }else{
            cout << "overflow" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int A, B;
    cin>>A>>B;

    if (A > 9 || B > 9) cout<<"-1"<<endl;
    else cout<<A * B<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



const ll MAX = 100010;        // Set
using Vertex = pair<ll, ll>;  // (dist, id)
class Edge
{
public:
    ll to;
    ll cost;
    Edge() : to{0}, cost{0} {}
    Edge(ll a, ll b) : to{a}, cost{b} {}
};

vector<vector<Edge> > Graph(MAX, vector<Edge>(0));
vll dist(MAX, inf);

void dijkstra(ll s)
{
    fill(dist.begin(), dist.end(), inf);
    dist[s] = 0;
    priority_queue<Vertex, vector<Vertex>, greater<Vertex> > pq;    

    pq.push(Vertex(0, s));
    while(! pq.empty()) {
        // Enqueue first node
        Vertex now = pq.top(); pq.pop();
        ll vertex = now.second;
        if (dist[vertex] < now.first) continue;
        // Check for each adjacent node
        for (Edge edge : Graph[now.second]) {
            if (dist[edge.to] > dist[now.second] + edge.cost) {
                dist[edge.to] = dist[now.second] + edge.cost;
                pq.push(Vertex(dist[edge.to], edge.to));
            }
        }
    }
}

// TODO: Graph[from].push_back(Edge(to, cost))
int main()
{
        ll N;
        cin >> N;
        rep(i, 0, N-1) {
                ll a, b, c;
                cin >> a >> b >> c;
                Graph[a].push_back(Edge(b, c));
                Graph[b].push_back(Edge(a, c));
        }

        ll Q, K;
        cin >> Q >> K;
        dijkstra(K);
        rep(i, 0, Q) {
                ll x, y;
                cin >> x >> y;
                cout << dist[x] + dist[y] << endl;
        }
}

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

int main() {
  int x, y;
  cin >> x >> y;
  
  bool ans = true;
  
  if (y % 2 == 1){
    ans = false;
  }
  else if (x*2 > y || x*4 < y){
    ans = false;
  }
  if (ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cfenv>
#include <cmath>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 0x3f //plus infinite

typedef struct item{
  string name;
  int number;
  int money;
}item;

long long int a[200002];
long long int b[200002];

int main(){
  double R;
  cin >> R;

  printf("%-16.10lf\n",M_PI*R*2.0);

  return 0;
}

/*文字列の辞書順について
 *C++の順序では'0'～'9'→'A'～'Z'→'a'～'z'の順に
 *                       なっていることに注意しましょう。
 */

/*行単位での入力
 * getline(cin,文字列変数);
 */


Measured memory_bytes: 3788
n,k = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i)

l = 0
r = a_arr.max

# 二分探索
while true do
  len = (r + l) / 2
  break if len == 0

  tmp_k = 0
  a_arr.each do |a|
    tmp_k += (a / len.to_f).ceil - 1
  end

  if tmp_k <= k
    r = len
  else
    l = len
  end

  if r - l <= 1
    break
  end
end

puts l + 1


Measured memory_bytes: 29772
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    string s;
    cin >> s;

    int cnt = (int)s.size() - 2;
    cout << s[0] << cnt << s[cnt + 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
const int P=1e9+7;

int n,k;
struct Edge{int v,to;}E[M<<1];int Head[M],e_tot;
void Link(int u,int v){E[++e_tot]=(Edge){v,Head[u]},Head[u]=e_tot;}

long long Fact[M],Inv[M],Finv[M];
void Init(){
	Fact[0]=Inv[0]=Finv[0]=Fact[1]=Inv[1]=Finv[1]=1;
	for(int i=2;i<=k;i++){
		Fact[i]=Fact[i-1]*i%P;
		Inv[i]=(P-P/i)*Inv[P%i]%P;
		Finv[i]=Finv[i-1]*Inv[i]%P;
	}
}
long long Permutation(int x,int y){
	if(x<y)return 0;
	return Fact[x]*Finv[x-y]%P;
}

long long dfs(int u,int f){
	long long ret=1;int c=0;
	for(int i=Head[u];i;i=E[i].to){
		int v=E[i].v;if(v==f)continue;
		(ret*=dfs(v,u))%=P;c++;
	}
	if(f==-1)(ret*=Permutation(k-1,c))%=P;
	else (ret*=Permutation(k-2,c))%=P;
	return ret;
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		Link(u,v);Link(v,u);
	}
	Init();
	printf("%lld\n",k*dfs(1,-1)%P);
	return 0;
} 

Measured memory_bytes: 7168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[][] array = new Integer[n][m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a>=1&&a<=9) {
			if(b>=1&&b<=9) {
				System.out.println(a*b);
			}
			else {
				System.out.println("-1");
			}
		}
		else {
			System.out.println("-1");
		}
	}
}

Measured memory_bytes: 22224
fun main(arg: Array<String>) {
    val s = readLine()!!

    if(s.length < 2 || s.length % 2 != 0) {
        println("No")
        return
    }
    for(i in 0..s.length - 1 step 2) {
        if(s[i] != 'h' || s[i + 1] != 'i') {
            println("No")
            return;
        }
    }
    println("Yes")
}

Measured memory_bytes: 33404
#include<stdio.h>
int main(){
    int n,x;
    scanf("%d %d", &n, &x);
    int sum=0;
    int d=0;
    for(int i=0;i<n;i++){
        int l;
        scanf("%d", &l);
        if(d<=x)sum++;
        d+=l;
    }
    if(d<=x)sum++;
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String T = sc.next();
    String S = sc.next();
    String[] oT = new String[T.length()-S.length()+1];
    for(int i = 0;i<oT.length;i++){
      oT[i] = T.substring(i,i+S.length());
    }
    int max = 0;
    for(int i = 0;i<oT.length;i++){
      int SM=0;
      for(int j = 0;j<S.length();j++){
        if(S.charAt(j)==oT[i].charAt(j)){
          SM++;
        }
      }
      if(SM>max){
        max = SM;
      }
    }
    System.out.println(S.length()-max);
  }
}

Measured memory_bytes: 36184
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<long long> H(N), A(N);
    for (auto& h : H) cin >> h;
    for (auto& a : A) cin >> a;
    map<long long, long long> B;
    for (int i = 0; i < N; i++) {
        auto it = B.lower_bound(H[i]);
        if (it == begin(B)) {
            it = B.insert(it, make_pair(H[i], A[i]));
        } else {
            it = B.insert(it, make_pair(H[i], A[i] + prev(it)->second));
        }
        auto it2 = next(it);
        while (it2 != end(B) && it2->second <= it->second) {
            it2 = B.erase(it2);
        }
    }
    cout << prev(end(B))->second << endl;
    return 0;
}

Measured memory_bytes: 15872
object Main {
  def solve(S: String): Int = {
    val N = S.length
    def step(c: Char, i: Int, cnt: Int): Int = i match {
      case `N` => cnt
      case _ =>
        val nextCnt = cnt + (if (S(i) == c) 0 else 1)
        step(S(i), i + 1, nextCnt)
    }
    step(S(0), 1, 1) - 1
  }

  def main(args: Array[String]): Unit = {
    val in = io.Source.fromInputStream(System.in).getLines()
    val S = in.next()
    println(solve(S))
  }
}


Measured memory_bytes: 29276
#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>;
    
int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> dist(n);
    rep(i,n){
        if(i==n-1) dist[i] = k + a[0] - a[i];
        else dist[i] = a[i+1] - a[i];
    }

    int ans = *max_element(dist.begin(), dist.end());
    ans = k - ans;
    cout << ans  << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
//#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
int dp[3001][3001];
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s,t;
        cin>>s>>t;
        int n = s.length(),m=t.length();
        
        FF(i,1,n+1)
        {
            FF(j,1,m+1)
            {
                if(s[i-1]==t[j-1])
                {
                    dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
                }
                else
                {
                    dp[i][j]=max(dp[i][j],dp[i-1][j]);
                    dp[i][j]=max(dp[i][j],dp[i][j-1]);
                }
            }
        }
        string ans = "";
        while(n&&m)
        {
            if(dp[n][m]==dp[n-1][m])n--;
            else if(dp[n][m]==dp[n][m-1])m--;
            else
            {
                n--;
                m--;
                ans+=s[n];
            }
        }
        reverse(all(ans));
        cout<<ans<<"\n";
        
        
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



Measured memory_bytes: 70656
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;


int main() {

	string S; cin >> S;
	long K; cin >> K;
	int res = 1;

	for (long i = 0; i <= min((long)(S.length() - 1),K - 1); i++) { if (S[i] != '1') { res = S[i] - 48; break; } }

	cout << res << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5+5 , M = 1e3+5, OO = 0x3f3f3f3f;
typedef long long ll;
int n, d;
int a[N];
int main()
{
    cin >> n;
    for(int i =0; i<n; ++i) cin >> a[i];
    int lst = a[n-1];
    bool f = 1;
    for(int i=n-2; i>=0; --i)
    {
        if(a[i] > lst)
        {
            if(a[i] == lst+1) a[i]--;
            else
            {
                f=0;
                break;
            }
        }
        lst = a[i];
    }
    /*
    for(int i=0; i<n; ++i) cout << a[i] << " ";
    cout << endl;
    */
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
def prime_factorize(N): 
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    print(len(prime_factorize(g))+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		for(int i = 1;i < 4;i++){
			if(a != i && b != i){
				System.out.println(i);
			}
		}
		
		
	}
}

Measured memory_bytes: 35632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        List<Integer> list1 = new ArrayList<>(Arrays.asList(1,3,5,7,8,10,12));
        List<Integer> list2 = new ArrayList<>(Arrays.asList(4,6,9,11));
      
        String result = "No";
        if ((list1.contains(x) && list1.contains(y)) || (list2.contains(x) && list2.contains(y)) || (x == 2 && y == 2)) result = "Yes";
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int MAX_N = 1001;

int n, m;
int p[MAX_N];
std::vector<int> sums;

int main() {
	while (1) {
		std::cin >> n >> m;
		if (n + m == 0)
			break;
		sums.clear();
		for (int i = 0; i < n; ++i)
			std::cin >> p[i];
		++n;
		p[n - 1] = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = i; j < n; ++j)
				sums.push_back(p[i] + p[j]);
		}
		std::sort(sums.begin(), sums.end());
		sums.erase(std::unique(sums.begin(), sums.end()), sums.end());
		int res = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				auto it = std::upper_bound(sums.begin(), sums.end(), m - p[i] - p[j]);
				if (it != sums.begin()) {
					--it;
					res = std::max(res, (*it) + p[i] + p[j]);
				}
			}
		}
		std::cout << res << std::endl;
	}
	return 0;
}

Measured memory_bytes: 4904
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int A[150];

int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  rep(i, n) scanf("%d", &A[i]);
  int sum = 0, pos = 0;
  for (int i = 0; i < n; i++) {
    if (pos <= x) sum++;
    pos += A[i];
  }
  if (pos <= x) sum++;
  printf("%d", sum);
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  vector<vector<int>> light_count(h, vector<int>(w, 0));
  vector<vector<int>> light_column_count(h, vector<int>(w, 0));
  rep(i, h){
    cin >> grid[i];
  }
  int ans = 0;
  rep(i, h){
    rep(j, w){
      if(grid[i][j] == '#')continue;
      if(j == 0)light_count[i][j]++;
      else light_count[i][j] = light_count[i][j-1] + 1;
    }
  }
  rep(i, h){
    for (int j = w - 1; j > 0; j--){
      if(grid[i][j] == '#')continue;
      if(grid[i][j - 1] == '.')light_count[i][j - 1] = light_count[i][j];  
    }
  }
  rep(i, w){
    int cn = 0;
    rep(j, h){
      if(grid[j][i] == '#'){
        cn = 0;
        continue;
      }
      cn++;
      light_column_count[j][i] += cn;
    }
  }
  rep(i, w){
    for (int j = h - 1; j > 0; j--){
      if(grid[j][i] == '#')continue;
      if(grid[j-1][i] == '.')light_column_count[j-1][i] = light_column_count[j][i];
    }
  }
  rep(i,h){
    rep(j,w){
      ans = max(light_count[i][j] + light_column_count[i][j]-1, ans);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 42540
#include<iostream>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	int arr[n];
  	for (int i = 0; i < n; i++)
      cin >> arr[i];
  	int k = 0;
  	for (int i = 0; i < n; i++){
    	(arr[i] == i+1)?	k = k : k += 1;
    }
	(k > 2)? cout << "NO"<< '\n' : cout << "YES\n";
  
	return 0;
}

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

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, cnt = 0, tmp, ans = 0;
	long long M, sum=0;
	
	cin >> N >> M;

	vector<long long> A(N), S(N+1);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	S[0] = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
		S[i] = sum%M;
	}
	sort(S.begin(), S.end());

	int j = 0;
	for (int i = 1; i < N+1; i++) {
		if (S[j] == S[i]) {
			cnt++;
			ans += cnt;
		}
		else {
			j = i;
			cnt = 0;
		}
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



char c;

int main () {
  cin >> c;
  c++;
  cout << c << "\n";
}

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

#define X first
#define Y second
#define N 105
#define M 1010
typedef long long ll;
typedef pair<int,int> pii;

const int INF=1<<30;

int n;
int c1,c2;

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);

	int x; scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x&1) c1++;
		else c2++;
	}
	if (c1&1) printf("NO\n");
	else printf("YES\n");
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        if (n >= m) {
            System.out.println(0);
            return;
        }
        int[] ary = new int[m];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            ary[i] = a;
        }
        int[] diff = new int[m - 1];
        Arrays.sort(ary);
        for (int i = 0; i < m - 1; i++) {
            diff[i] = ary[i + 1] - ary[i];
        }
        Arrays.sort(diff);
        int ans = 0;
        for (int i = 0; i < m - (n - 1) - 1; i++) {
            ans += diff[i];
        }
        System.out.println(ans);
    }
}

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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

int main()
{
    int A, B, X;
    cin >> A >> B >> X;

    if (A + B < X || A > X)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256