akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

enum {
	UP,
	DOWN,
	LEFT,
	RIGHT
};

int main(void) {
	char puttern[100][101];
	int x,y;
	int direction;
	int nomove;
	int putternsize;
	int datamax,datanum;
	scanf("%d",&datamax);
	for(datanum=0;datanum<datamax;datanum++) {
		if(datanum>0)puts("");
		scanf("%d",&putternsize);
		for(y=0;y<putternsize;y++) {
			for(x=0;x<putternsize;x++)puttern[y][x]=' ';
			puttern[y][putternsize]=0;
		}
		x=0;
		y=putternsize-1;
		direction=UP;
		nomove=0;
		while(1) {
			puttern[y][x]='#';
			switch(direction) {
				case UP:
					if(y<=0 || (y>1 && puttern[y-2][x]=='#')	
						|| (y>0 && puttern[y-1][x]=='#')	
						|| (y>0 && x>0 && puttern[y-1][x-1]=='#')
						|| (y>0 && x<putternsize-1 && puttern[y-1][x+1]=='#')) {
						direction=RIGHT;
						nomove++;
					} else {
						y--;
						nomove=0;
					}
					break;
				case DOWN:
					if(y>=putternsize-1 || (y<putternsize-2 && puttern[y+2][x]=='#')	
						|| (y<putternsize-1 && puttern[y+1][x]=='#')	
						|| (y<putternsize-1 && x>0 && puttern[y+1][x-1]=='#')
						|| (y<putternsize-1 && x<putternsize-1 && puttern[y+1][x+1]=='#')) {
						direction=LEFT;
						nomove++;
					} else {
						y++;
						nomove=0;
					}
					break;
				case LEFT:
					if(x<=0 || (x>1 && puttern[y][x-2]=='#')	
						|| (x>0 && puttern[y][x-1]=='#')	
						|| (x>0 && y>0 && puttern[y-1][x-1]=='#')
						|| (x>0 && y<putternsize-1 && puttern[y+1][x-1]=='#')) {
						direction=UP;
						nomove++;
					} else {
						x--;
						nomove=0;
					}
					break;
				case RIGHT:
					if(x>=putternsize-1 || (x<putternsize-2 && puttern[y][x+2]=='#')	
						|| (x<putternsize-1 && puttern[y][x+1]=='#')	
						|| (x<putternsize-1 && y>0 && puttern[y-1][x+1]=='#')
						|| (x<putternsize-1 && y<putternsize-1 && puttern[y+1][x+1]=='#')) {
						direction=DOWN;
						nomove++;
					} else {
						x++;
						nomove=0;
					}
					break;
			}
			if(nomove>=4)break;
		}
		for(y=0;y<putternsize;y++)puts(puttern[y]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<S.size();++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
inline int read()
{
	char c=getchar(); int ret=0;
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
#define N 100043
long long n,a[N],b[N],ss;
int main()
{
	n=read()+1;
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n-1;++i) b[i]=read();
	for(int i=1;i<=n;++i){
		if(a[i]<=b[i-1]){
			ss+=a[i];
			a[i]=0;
			continue;
		}
		a[i]-=b[i-1]; ss+=b[i-1];
		if(a[i]<=b[i]){
			ss+=a[i];
			b[i]-=a[i];
			a[i]=0;
			continue;
		}
		ss+=b[i];
		b[i]=0;
	}
	cout<<ss;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(int i=0; i<n; ++i)
#define ford(i,n) for(int i=n-1; i>=0; --i)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
    #define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gcd __gcd

//Printing template
#define pf2(a,b) cout<<a<<" "<<b<<"\n"
#define pf3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define pf4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"

#define fast_cin() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> i_set;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ll_set; 
/* new_data_set p; */
/* *p.find_by_order(3); The value at third place */
/* p.order_of_key(7); The expected index in the set in sorted order */



int main(int argc, char const *argv[]){
    fast_cin();
    char c;
    cin>>c;
    cout<<(char)(c+1)<<"\n";
    return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

L = I()
print(pow(L / 3, 3))

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

int main() {
  int N;
  cin >> N;
  auto h = vector<int>(N);
  for(auto i=0; i<N; ++i) {
    cin >> h[i];
  }
  auto v = vector<int>(N);
  fill(v.begin(), v.end(), 0);
  v[1] = abs(h[1] - h[0]);
  for(auto i=2; i<N; ++i) {
    v[i] = min(v[i-2] + abs(h[i] - h[i-2]), v[i-1] + abs(h[i] - h[i-1]));
  }
  cout << v[N-1];
  return 0;
}


Measured memory_bytes: 1024
import sys

s = input()
if(len(s) % 2 == 1):
  print("No")
  sys.exit()
  

n = 0
for i in range(int(len(s)/2)):
  if(s[n] != "h" or s[n + 1] != "i"):
    print("No")
    sys.exit()
print("Yes")

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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<pair<ll,ll>> ins(n);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    ins[i] = make_pair(a,b);
  }
  
  sort(ins.begin(),ins.end());
  
  ll cnt=0,i=0;
  while(cnt < k){
    cnt += ins[i].second;
    i++;
  }
  
  //cout << i << endl;
  cout << ins[i-1].first << endl;

  return(0);
}

Measured memory_bytes: 4828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);
			long[] sum = new long[n+1];
			for (int i = 1; i < n+1; i++) {
				sum[i] = sum[i-1] + a[i-1];
			}

			Map<Long,Integer> map = new HashMap<>();
			for (long l : sum) {
				map.merge(l, 1, Integer::sum);
			}

			long ans = 0;
			for (Entry<Long,Integer> e : map.entrySet()) {
				long m = e.getValue();
				ans += m*(m-1)/2;
			}

			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 52616
K = int(input())
count = 9

def calc(keta, num):
    global count
    if keta == 0:
        if num[-1] == "9":
            count += 1
            if count == K:
                print(num + str(int(num[-1]) - 1))
                quit()
            count += 1
            if count == K:
                print(num + str(int(num[-1])))
                quit()
        elif num[-1] == "0":
            count += 1
            if count == K:
                print(num + str(int(num[-1])))
                quit()
            count += 1
            if count == K:
                print(num + str(int(num[-1]) + 1))
                quit()
        else:
            count += 1
            if count == K:
                print(num + str(int(num[-1]) - 1))
                quit()
            count += 1
            if count == K:
                print(num + str(int(num[-1])))
                quit()
            count += 1
            if count == K:
                print(num + str(int(num[-1]) + 1))
                quit()
    else:
        if num[-1] == "9":
            calc(keta-1,num+str(int(num[-1]) - 1))
            calc(keta-1,num+str(int(num[-1])))
        elif num[-1] == "0":
            calc(keta-1,num+str(int(num[-1])))
            calc(keta-1,num+str(int(num[-1]) + 1))
        else:
            calc(keta-1,num+str(int(num[-1]) - 1))
            calc(keta-1,num+str(int(num[-1])))
            calc(keta-1,num+str(int(num[-1]) + 1))

if K < 10:
    print(K)
    quit()

while(True):
    for i in range(10000):
        for k in range(1,10):
            calc(i, str(k))

Measured memory_bytes: 3192
#include<iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
if(n==1) n=14;
if(m==1) m=14;
if(n==m){ 
   cout<<"Draw"<<endl;
}else if(n>m){
   cout<<"Alice"<<endl;
}else{
   cout<<"Bob"<<endl;
   } 
system("pause");
return 0;
} 

Measured memory_bytes: 504
def getWorkDay(S,N,C,K):
    cnt = 0
    day = 0
    flag = False
    L = [0] * N
    for i in range(N):
        if cnt >= K:
            break
        if flag:
            day += 1
            if S[i] == 'o' and day > C:
                cnt += 1
                L[i] = cnt
                day = 0
        else:
            if S[i] == 'o' and day == 0:
                cnt += 1
                L[i] = cnt
                day = 0
                flag = True
    return L

def main():
    N, K, C = map(int, input().split())
    S = list(input())
    L = getWorkDay(S,N,C,K)
    S.reverse()
    R = getWorkDay(S,N,C,K)
    R.reverse()
    cnt = 0
    max_R = max(R)
    for i in range(N-1,-1,-1):
        if R[i]:
            R[i] = max_R - cnt
            cnt += 1

    for i in range(N):
        if L[i] and R[i] and L[i] == R[i]:
            print(i+1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 64496
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

typedef long long ll;

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

	ll ans = N;

	for(ll i = 1; i*i <= N;i++){
		if(N%i == 0){
			ans = min(ans, i+(N/i)-2);
		}
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		long a=sc.nextLong();	//a以上
		long b=sc.nextLong();	//b以下
		long x=sc.nextLong();	//xで割り切れる

		long num=0;	//求める個数

		if(a%x==0) num=(b/x)-(a/x)+1;
		else num=(b/x)-(a/x);

		//答えを出力
		System.out.println(num);
	}
} 

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

 int main(){

int A, B, C, X;
cin >> A >> B >> C >> X;
int res = 0;

for(int i=0; i<=A; i++){
       for(int j=0; j<=B; j++){
              for(int k=0; k<=C; k++){
                     int total = 500*i + 100*j + 50*k ;
                     if (total == X) res++;
}}}
cout << res <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 int main(){
   int a[100],N,i,j,k,key;
   scanf("%d",&N);
    for(i=1;i<N+1;i++){
     scanf("%d",&a[i]);
   }
   for(j=1;j<N+1;j++){
     key=a[j];
     i=j-1;
     while( i>0 && a[i]>key){
       a[i+1]=a[i];
       i--;
       a[i+1]=key;
     }
     for(k=1;k<N;k++){
	 printf("%d ",a[k]);
   }
     printf("%d",a[N]);
       printf("\n");
   }
     
     return 0;
 }


Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x[105],ans=100000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=100;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=abs(i-x[j])*abs(i-x[j]);
        }
        if(ans>sum){
            ans=sum;
        }
    }
    cout<<ans<<endl;
    return(0);
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
from collections import Counter
MOD = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))
li = [0] * (2001)
for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            li[a[i]] += 1
ans = 0
dic = Counter(a)
num = 0
for i in sorted(dic.keys()):
    if i > 1:
        ans += dic[i] * (num * (k - 1) * k // 2) + li[i] * k
        ans %= MOD
    num += dic[i]
print(ans)


Measured memory_bytes: 3572
#include<iostream>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

int main(){

  int a[111111];
  int n;
  cin>>n;
  memset(a,0,100001);
  for(int i = 0;i<n;i++){
    int tmp;
    cin>>tmp;
    a[tmp]++;
  }
  /*
  for(int i = 0;i<=100000;i++){
    if(a[i]>10)
      cout<<i<<":"<<a[i]<<endl;
  }
  */
  int ans = 0;
  for(int i = 0;i<100000;i++){
    int tmp = a[i];
    tmp += (i-1>0)?a[i-1]:0;
    tmp += (i+1<=100000)?a[i+1]:0;
    ans = max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll n;
cin>>n;
ll i;
cin>>i;
cout<<n-i+1<<endl;
}









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

int main() {
	string S;
	cin >> S;
	int check = 0;
	for (int i = 0; i < (S.length() - 1); i++) {
		if(S[i] == S[i + 1]){
			check = 1;
			cout << "Bad" << endl;
			break;
		}
	}
	if(!check){
		cout << "Good" << endl;
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
  
  for (int j=0; j<H; j++) {
    cout << '#';
    for (int i=0; i<W; i++) {
      char A;
      cin >> A;
      cout << A;
    }
    cout << '#' << endl;
  }
  
  for (int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); \
				cin.tie(0); \
				cout.tie(0)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(_v)             _v.begin(), _v.end()
#define sz(_v)              (int) _v.size()
#define first(_obj)         (*_obj.begin())
#define last(_obj)          (*prev(_obj.end()))
#define FIND(_obj, _val)    (_obj.find(_val) != _obj.end())
#define RESET(_a, _v)       fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define REP(_i, _n)         for (int _i = 0; _i < (int) _n; _i++)
#define FOR(_i, _a, _b)     for (int _i = (int) _a; _i <= (int) _b; _i++)
#define FORD(_i, _a, _b)    for (int _i = (int) _a; _i >= (int) _b; _i--)
#define FORIT(_it, _obj)    for (auto _it = _obj.begin(); _it != _obj.end(); _it++)

// DEBUG UTIL
template<typename TF>
void debug(ostream &out, TF const &f) {
    out << f << std::endl;
}
 
template<typename TF, typename ... TR>
void debug(ostream &out, TF const &f, TR const& ... rest) {
    out << f << " ";
    debug( out, rest... );
}
 
#define DEBUG(...) debug(cerr, "[", #__VA_ARGS__, "]:", __VA_ARGS__)

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vi = vector<int>;
using vii = vector<pii>;
using vll = vector<ll>;
using vs = vector<string>;

const int DR[] = {-1, 0, 1, 0, -1, 1, 1, -1}; // ccw
const int DC[] = {0, -1, 0, 1, -1, -1, 1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = 1073741823;
const ll INFLL = 4e18;
const int MAX = 1e5;
const int NMAX = 100;

int N, K, mv[NMAX+5], dp[MAX+5];
set<int> nim;

void read() {
	cin >> N >> K;
	REP(i, N) cin >> mv[i];
}

void solve() {
	dp[0] = 0;

	FOR(i, 1, K) {
		nim.clear();

		REP(j, N) {
			if (i - mv[j] < 0) break;

			nim.insert(dp[i - mv[j]]);
		}

		int now = 0;
		auto it = nim.begin();
		while (it != nim.end() && *it == now) now++, it++;

		dp[i] = now;
	}

	cout << (dp[K] ? "First\n" : "Second\n");
}

int main() {
	FAST_IO;
	int TC = 1;
	FOR(tc, 1, TC) {
		read();
		solve();
	}
}

Measured memory_bytes: 640
use proconio::input;
use std::collections::HashMap;
fn main() {
    input! {
        n:usize,
        a:[usize;n],
    }

    let mut left: HashMap<i64, i64> = HashMap::new();
    let mut right: HashMap<i64, i64> = HashMap::new();

    for i in 0..n {
        (*left.entry(i as i64 + a[i] as i64).or_insert(0)) += 1;
        (*right.entry(i as i64 - a[i] as i64).or_insert(0)) += 1;
    }
    let mut ans = 0;
    for (key, value) in &left {
        ans += right.get(key).unwrap_or(&0) * value;
    }

    println!("{}", ans);
}


Measured memory_bytes: 16180
eval"N,S,*A="+`dd`.split*?,
d=[k=0]*-~S
m=998244353
A.map{|a|S.downto(a){|i|d[i]+=(i>a ?d[i-a]:k+1)*(S>i ?1:N-k)%m};k+=1}
p d[S]%m

Measured memory_bytes: 2312
#include <cstdio>
#include <cstring>

const int N = 100000;

int m;
char s[N + 1];

int main()
{
    scanf("%s%d", s, &m);
    int n = strlen(s);
    for (int i = 0; i < n - 1; ++ i) {
        if (s[i] == 'a') {
            continue;
        }
        int need = 'z' - s[i] + 1;
        if (need <= m) {
            m -= need;
            s[i] = 'a';
        }
    }
    s[n - 1] = 'a' + (s[n - 1] - 'a' + m) % 26;
    puts(s);
}



Measured memory_bytes: 888
# coding: utf-8
# Your code here!
from statistics import mean, median,variance,stdev
n = int(input())
l = list(map(int,input().split(" ")))
m = mean(l)
d = 1000
ans = 10000
for i in range(n):
    a = l[i]
    t = abs(m - a)
    if t < d:
        d = t
        ans = i
print(ans)

Measured memory_bytes: 5648
import sys

def f(s,t):
    if s>=t and -s<=t:
        return 0
    elif s<=t and -s<=t:
        return 1
    elif s<=t and -s>=t:
        return 2
    else:
        return 3

n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
for i in range(1,n):
    if sum(xy[i])%2!=sum(xy[i-1])%2:
        print(-1)
        sys.exit()
        
data_1=["R","U","L","D"]
data_2=[[1,0],[0,1],[-1,0],[0,-1]]
    
arms=[2**i for i in range(32)]

if sum(xy[0])%2==1:
    print(len(arms))
    print(*arms)
    for X,Y in xy:
        x,y=X,Y
        ans=[]
        i=31
        while i>=0:
            c=f(x,y)
            ans.append(data_1[c])
            x-=arms[i]*data_2[c][0]
            y-=arms[i]*data_2[c][1]
            i-=1
        print("".join(ans[::-1]))
else:
    arms=[1]+arms
    print(len(arms))
    print(*arms)
    for X,Y in xy:
        x,y=X,Y
        ans=[]
        i=32
        while i>=1:
            c=f(x,y)
            ans.append(data_1[c])
            x-=arms[i]*data_2[c][0]
            y-=arms[i]*data_2[c][1]
            i-=1
        if x==1:
            ans.append("R")
        elif x==-1:
            ans.append("L")
        elif y==1:
            ans.append("U")
        else:
            ans.append("D")
        print("".join(ans[::-1]))

Measured memory_bytes: 46320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

int a(int i)
{
  int ans = 0;
  for (; i > 0; i--) {
    ans += i;
  }
  return ans;
}

int main(int argc, char** argv)
{
  int N;
  std::cin >> N;

  std::unordered_map<std::string, int> dic;
  std::string S;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    
    std::cin >> S;
    std::sort(std::begin(S), std::end(S));
    if (dic.find(S) == std::end(dic)) {
      dic[S] = 0;
    }
    else {
      dic[S]++;
      ans += dic[S];
    }
  }

  //for (auto & e : dic) {
  //  if (e.second > 1) {
  //    ans += a(e.second-1);
  //  }
  //}

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 10660
const log = console.log;

const createDigitArray = (v: number, capacity: number, base = 10) => {
  const array = new Array<number>(capacity);

  for (let i = 0; i < capacity; i += 1) {
    if (v === 0) break;
    array[i] = v % base;
    v = (v / base) | 0;
  }

  return array;
};

const sumReducer = (accumulator: number, currentValue: number) =>
  accumulator + currentValue;
const sum = (numbers: number[]) => numbers.reduce(sumReducer, 0);

// ----

function Main(input: string): void {
  const n = +input;

  log(n % sum(createDigitArray(n, 10, 10)) === 0 ? "Yes" : "No");
}

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

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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, 0, n - 1) { cin>> a[i]; }
  int cost = inf;
  rep(i, -100, 100) {
    int curr_cost = 0;
    rep(j, 0, n - 1) {
      curr_cost += sqr(a[j] - i);
    }
    cost = min(cost, curr_cost);
  }
  cout << cost;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

long long int n;
vector<int> v;

void func(long long int a){
  if(a > n) return;
  v.push_back(a);

  a *= 10;

  func(a+3);
  func(a+5);
  func(a+7);
}

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

  int cnt = 0;
  for(int i=0; i<v.size(); i++){
    string s = to_string(v[i]);
    bool f[3] = {false, false, false};
    for(int i=0; i<s.size(); i++){
      if(s[i] == '3') f[0] = true;
      if(s[i] == '5') f[1] = true;
      if(s[i] == '7') f[2] = true;
    }
    if(f[0] && f[1] && f[2]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}




///


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

typedef long long ll;
#define MAX_N 10000
#define INF 0x3f3f3f3f

using namespace std;

int N, A, B;
int ans;

int main()
{
	while (~scanf("%d %d %d", &N, &A, &B)) {
		cout << ((A*N > B) ? B : (A*N) ) << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int maze[1005][1005];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, m;
	int a, b;
	cin >> n >> m;
	cin >> a >> b;
	int n1 = 0, n2 = 1;
	rep (i, 1, n) {
		rep (j, 1, a) {
			maze[i][j] = n1;
		}
		rep (j, a + 1, m) {
			maze[i][j] = n2;
		}
		if (i == b) swap(n1, n2);
	}
	int flag = 1;
	rep (i, 1, n) {
		int a0 = 0;
		int a1 = 0;
		rep (j, 1, m) {
			++(maze[i][j] ? a1 : a0);
		}
		if (a != min(a0, a1)) flag = 0;
	}
	rep (j, 1, m) {
		int a0 = 0;
		int a1 = 0;
		rep (i, 1, n) {
			++(maze[i][j] ? a1 : a0);
		}
		if (b != min(a0, a1)) flag = 0;
	}
	if (!flag) {
		cout << -1 << endl;
		return 0;
	}
	rep (i, 1, n) {
		rep (j, 1, m) {
			cout << maze[i][j];
		}	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
import fractions

n,start=map(int,input().split())
x=list(map(int,input().split()))
dist=[]
for i in range(n):
    dist.append(abs(x[i]-start))
ans=dist[0]
for i in range(1,n):
    ans=fractions.gcd(ans,dist[i])

print(ans)


Measured memory_bytes: 88852
#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 n;
    cin >> n;
    vector<int> w;
    vector<int> r;
    rep(i,n){
        char c;
        cin >> c;
        if(c=='R'){
            r.push_back(i);
        }else{
            w.push_back(i);
        }
    }
    if(w.size()==0 || r.size()==0){
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    rep(i, w.size()){
        if(r.size()-1-i<0) break;
        if(w[i]>r[r.size()-1-i]) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb 	push_back
#define ll  long long
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define debug(x) cerr<<#x<<" =: "<<x<<endl;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Find find_by_order
#define Order order_of_key
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 mrand(random_device{}());
ll rnd(ll x) { return mrand() % x;}
ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;while(b){if(b&1) ans=ans*a%mod;b>>=1;a=a*a%mod;}return ans;}
ll phi(ll n){ll ans=n;for(ll i=2;i*i<=n;i++){if(n%i==0) {while(n%i==0) n/=i;ans=ans*(i-1)/i;}}if(n>1) ans=ans*(n-1)/n;return ans;}
//head

const int maxn = 1e6 + 7;
vector<int> vec[maxn];
int a[maxn], ans[maxn];
set<int> s;

int main (){
    string ss; cin >> ss;
    int tmp = 0;
    ll ans = 0;
    map<int,int>mp;
    reverse(all(ss));
    int cc = 1;
    mp[0]=1;
    for(auto x:ss) {

        tmp += (x - '0') * cc;
        tmp %= 2019;

        ans += mp[tmp];
        mp[tmp] ++;

        cc *= 10;
        cc %= 2019;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }


#define M_DEBUG if (1)

/******************************************************************************
	Main
******************************************************************************/
int main()
{
	int x = -1;
	cin >> x;
	assert(x >= 0 && x <= pow(10, 9));

	int ptr_500 = x / 500;
	x = x % 500;
	int ptr_5 = x / 5;
	
	cout << ptr_500 * 1000 + ptr_5 * 5 << endl;

	return 0;
}


Measured memory_bytes: 256
using System;

public class Program{
    public static void Main(){
        // Your code here!
     
     string a=Console.ReadLine();
     int A=int.Parse(a);
     string b=Console.ReadLine();
     int B=int.Parse(b);
     string c=Console.ReadLine();
     int C=int.Parse(c);
     
     string x=Console.ReadLine();
     int X=int.Parse(x);
     
     int count=0;
     
     for(int k=0;k<=A;k++) {
         for(int j=0;j<=B;j++) {
             for(int i=0;i<=C;i++) {
                 if(X==500*k+100*j+50*i) {
                    count++; 
                 }
             }
        }
     }
     
    Console.WriteLine(count);
    
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		if(c>=b||a>=d)
		printf("0\n");
		else if(c>=a&&d<=b)
		printf("%d\n",d-c);
		else if(a>=c&&b<=d)
		printf("%d\n",b-a);
		else if(c>=a&&c<=b&&b<=d)
		printf("%d\n",b-c);
		else
		printf("%d\n",d-a);
	}
	return 0;
}


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

vector<int> con[100001];
ll k;

ll dfs(int n, int parent){
    ll s = 1;
    ll i = 0;
    for(auto it = con[n].begin(); it != con[n].end(); ++it){
        if(*it == parent) continue;
        s = s * (k - 2 - i) % MOD;
        s = s * dfs(*it, n) % MOD;
        i++;
    }
    return s;
}

int main(){
    ll n, i, j;
    cin >> n >> k;
    for(i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        con[a].push_back(b);
        con[b].push_back(a);
    }
    ll s = k;
    for(i = 0; i < con[1].size(); i++){
        s = s * (k - 1 - i) % MOD;
        s = s * dfs(con[1][i], 1) % MOD;
    }
    cout << s << endl;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll n, W;
ll v[110], w[110];
ll dp[110][110000];
 
int main(){
    cin >> n >> W;
    for(int i = 1;i <= n;i++)cin >> w[i] >> v[i];
 
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= W;j++){
            dp[i][j] = dp[i-1][j];
            if(j-w[i] >= 0)
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

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

int main() {

    //input
    int N;
    cin >> N;
    vector<int> card(N);
    for (int i=0; i<N; i++) {
        cin >> card.at(i);
    }

    int A=0;
    int B=0;
    sort(card.begin(),card.end(),greater<int>());
    for (int i=0; i<N; i++) {
        if (i%2 == 0) {
            A += card.at(i);
        }
        else {
            B += card.at(i);
        }
    }
    
    cout << A-B << endl;
}

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

int main() {
  //input
  int N;
  cin >> N;
  vector<int> B(N-1);
  rep(i,N-1) {
    cin >> B.at(i);
  }
  //calc
  int answer;
  answer += B.at(0);
  for(int i = 1; i < N-1; i++) {
    answer += min(B.at(i), B.at(i-1));
  }
  answer += B.at(N-2);
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int n, s;
int c = 0;
int i = 0;
int j = 0;
int q = 0;
int sum = 0;
int date[15] = { 0 };



int sub(int start,int n,int x){
	if (x == n){
		for (int i = 0; i < n; i++){
			
				sum += date[i];
		}
		if (sum == s){
			q++;
		}
		sum = 0;
		return 0;
	}

	for (int i = start; i < 10;i++){

		date[x] = i;

		sub(i + 1, n, x + 1);
	
	}


}



int main(){

	n = 0;
	while (true){
		cin >> n >> s;
		if (n == 0 && s == 0)break;
		sub(0, n, 0);


		cout << q << endl;
		q = 0;
	}
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    long long tmp = INT64_MAX;
    int ans = 1;
    vector<pair<int, int>> XL(N);
    for (auto & xl : XL) cin >> xl.first >> xl.second;
    sort(XL.begin(), XL.end());
    for (int i = 0; i < N; ++i) {
        long long x = XL[i].first, l = XL[i].second;
        if (tmp <= x-l) {
            ++ans;
            tmp = x+l;
        } else {
            tmp = min(tmp, x + l);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let r: u64 = iter.parse();
    let d: u64 = iter.parse();
    let x2000: u64 = iter.parse();

    let v = (0..10)
        .scan(x2000, |st, _| {
            *st = r * *st - d;
            Some(*st)
        })
        .collect::<Vec<_>>();

    println!(
        "{}",
        v.into_iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join("\n")
    );
}

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

using namespace std;

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

	vector<int> a(n, 0);
	int tmp = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int a_min = *min_element(a.begin(), a.end());
	int a_max = *max_element(a.begin(), a.end());

	if (a_max == 0) {
		cout << "Yes" << endl;
		return 0;
	} else if (n % 3 > 0) {
		cout << "No" << endl;
		return 0;
	}

	vector<int> bits(32, 0);
	for (auto x: a) {
		int idx = 0;
		while (x > 0) {
			if (x & 1) {
				bits[idx]++;
			}
			idx++;
			x >>= 1;
		}
	}

	bool ok = true;
	for (auto y: bits) {
		if (y > 0 && y != n * 2 / 3 ) {
			ok = false;
			break;
		}
	}

	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------

signed main(){
    CIN(N);SCIN(s);
    bool flag = true;
    if(N%2==1){
        flag=false;
    }else{
        rep(i,N/2){
            if(s[i]!=s[i+N/2]) flag=false;
            if(!flag) break;
        }
    }
    printf(flag?"Yes\n":"No\n");
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  ll a[n];rep(i,0,n)cin>>a[i];

  set<ll>se;
  vector<ll>s(n+1,0);
  rep(i,0,n){
    s[i+1]=s[i]+a[i];
  }
  map<ll,ll>mp;
  rep(i,0,n+1){
    se.insert(s[i]);
    mp[s[i]]++;
  }

  ll ans=0;
  for(set<ll>::iterator itr=se.begin();itr!=se.end();itr++){
    ans+=mp[*itr]*(mp[*itr]-1)/2;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 25216
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        sc.close();
        if (A%3 == 0 | B%3 == 0 | (A+B)%3 == 0){
            System.out.println("Possible");
        }
        else{
            System.out.println("Impossible");
        }
    }
}

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

int main() {
    long long N;
    cin >> N;
    vector<long long> h(N + 2);
    for (long long i = 1; i <= N; i++) {
        cin >> h[i];
    }
    long long ans = 0;

    if (accumulate(h.begin(), h.end(), 0) == 0) {
        cout << ans << endl;
        return 0;
    }
    while (true) {
        long long beginIndex = -1, endIndex = -1;
        for (long long i = 1; i <= N + 1; i++) {
            if (beginIndex == -1 && h[i] > 0) {
                beginIndex = i;
                continue;
            }
            if (beginIndex != -1 && endIndex == -1 && h[i] == 0) {
                endIndex = i;
                break;
            }
        }
        ans++;
        for (long long i = beginIndex; i < endIndex; i++) {
            h[i]--;
        }
        if (accumulate(h.begin(), h.end(), 0) == 0) {
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int n = ni();
    int x = ni();
    int[] l = na(n);
    int cnt = 1;
    int now = 0;
    for (int v : l) {
      now += v;
      if (now <= x) {
        cnt ++;
      }
    }
    System.out.println(cnt);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

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

  private static long nl() {
    return Long.parseLong(next());
  }

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

  private static char[] ns() {
    return next().toCharArray();
  }

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

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 24916
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int data[]=new int[n];
    int total=0;


    for(int i=0;i<n;i++){
      data[i]=sc.nextInt();
    }
    Arrays.sort(data);


    for(int i=n-1;i>n-k-1;i--){
      
      total=data[i]+total;
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 22868
#include <cstdio>
using namespace std;

int main(){
	for ( int k; scanf( "%d", &k ) != -1 && k != 0; ) {
		int sum = 0;
		for ( int i = 0; i < k * ( k - 1 ) / 2; ++i ) {
			int n;
			scanf( "%d", &n );
			sum += n;
		}
		printf( "%d\n", sum / ( k - 1 ) );
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,a,b;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[400010];//適宜変える(ecnt)
	int id[200010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

ll start,goal;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld%lld%lld",&n,&m,&start,&goal);
	start--,goal--;
	rep(i,0,m){
		ll x,y,a,b;
		scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i].a=a;
		g.e[2*i].b=b;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
		g.e[2*i+1].a=a;
		g.e[2*i+1].b=b;
	}
	g.vcnt=n;
	g.ecnt=2*m;
	qsort(g.e,g.ecnt,sizeof(E),esort);
//	qsort(g.e,g.ecnt,sizeof(E),csort);
//	makeinvedge();

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

//プラキュー（二分ヒープ）（優先度変更ありバージョン）
ll heapN,heap[1<<20],heapinv[1<<20];
int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
void PQchange(int n);
void heap_utod(int n){
	if(2*n>heapN)return;
	int rflag=(2*n+1<=heapN)&&(PQhikaku(2*n,2*n+1));
	if(PQhikaku(n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heapinv[heap[n]]=n;
		heapinv[heap[2*n+rflag]]=2*n+rflag;	
		heap_utod(2*n+rflag);
	}
}
void heap_dtou(int n){
	if(n==1||PQhikaku(n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heapinv[heap[n]]=n;
	heapinv[heap[n/2]]=n/2;
	heap_dtou(n/2);
}
ll PQpop(){
	ll rr=heap[1];
	heapinv[heap[1]]=0;
	heap[1]=heap[heapN--];
	heapinv[heap[1]]=1;
	heap_utod(1);
	return rr;
}
void PQpush(ll n){
	heap[++heapN]=n;
	heapinv[heap[heapN]]=heapN;
	heap_dtou(heapN);
}

ll calc(ll t,ll a,ll b){
	ll l=max(t,sqrt(b)-a-3);
	ll ans=INF;
	rep(i,l,l+5)ans=min(ans,i+(b+i+a-1)/(i+a));
	return ans;
}

//早い方のダイクストラ
//グラフと始点を引いて各点への最短距離・最短経路を返す
//プラキューが必要
//O((E+V)logV)
ll daikusutorappp[1<<21];
void daikusutora2(ll s){
	rep(i,0,g.vcnt)daikusutorappp[i]=i==s?0:INF;
	rep(i,0,g.vcnt)PQpush(i);
	while(heapN){
		ll mv=PQpop();
		for(ll t=g.id[mv];t<g.ecnt&&g.e[t].s==mv;t++){
			ll time=calc(daikusutorappp[mv],g.e[t].a,g.e[t].b);
			if(daikusutorappp[g.e[t].g]>time){
				daikusutorappp[g.e[t].g]=time;
				//daikusutorappp[n+g.e[t].g]=mv;//最短経路がいる場合はこれ
				PQchange(g.e[t].g);
			}
		}
	}
}
int PQhikaku(int i,int j){return daikusutorappp[heap[i]]>daikusutorappp[heap[j]];}
void PQchange(int n){if(heapinv[n])heap_dtou(heapinv[n]);}

int main(){
	readgraph();
	daikusutora2(start);
	printf("%lld\n",daikusutorappp[goal]==INF?-1:daikusutorappp[goal]);
}


Measured memory_bytes: 23472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <class T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
    ll x;
    cin >> x;

    ll ans = 1, sum = x;
    while (sum % 360) {
        ans++;
        sum += x;
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 3608
n = [int(e) for e in input().split()]
a=n[0]
b=n[1]
c=n[2]

if c-a-b <= 0:
	print('No')
elif 4*a*b<(c-a-b)*(c-a-b):
 	print('Yes')
else:
  	print('No')

Measured memory_bytes: 3060