akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, L, A):

    for i in range(N-1):
        if A[i] + A[i+1] >= L:
            print('Possible')
            for j in range(i):
                print(j+1)
            for j in reversed(range(i+1, N-1)):
                print(j+1)
            print(i+1)
            return

    else:
        print('Impossible')


def main():
    N, L = read_int_n()
    A = read_int_n()
    slv(N, L, A)


if __name__ == '__main__':
    main()


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

P=list(map(int,input().split()))

probability=[]
sums=[0]
total=0
for i in range(N):
    num=0
    prob=1/P[i]
    for j in range(1,P[i]+1):
        num+=j*prob
    probability.append(num)
    total+=num
    sums.append(total)

ans=0
for j in range(N-K+1):
    if ans<sums[j+K]-sums[j]:
        ans=sums[j+K]-sums[j]

print('{:.012f}'.format(ans))

Measured memory_bytes: 115016
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    string N;
    cin >> N;
    int S = 0;
    for(int i = 0; i < N.size(); i++) S += N.at(i) - 48;
    if (stoi(N) % S == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
const int MOD = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

double dp[310][310][310] = {0.0};
bool visited[310][310][310] = {false};

double rec(int i, int j, int k, int n){
  if(visited[i][j][k]) return dp[i][j][k];
  double ret = n;
  if(i) ret += i * rec(i-1, j, k, n);
  if(j) ret += j * rec(i+1, j-1, k, n);
  if(k) ret += k * rec(i, j+1, k-1, n);
  ret /= (double) i+j+k;
  dp[i][j][k] = ret;
  visited[i][j][k] = true;
  return ret;
}

int main() {
  int N;
  cin >> N;
 
  vector<int> b(4, 0);
  REP(i, N){
    int a;
    cin >> a;
    b[a] += 1;
  }
  visited[0][0][0] = true;
  cout << fixed << setprecision(13);
  cout << rec(b[1], b[2], b[3], N) << endl;

}


Measured memory_bytes: 256256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;



class Node {
public:
    int x, y, d;
    Node(int a, int b, int c) {
        x = a;
        y = b;
        d = c;
    }
};

bool operator>(const Node &lhs, const Node &rhs) {
    return lhs.d > rhs.d;
}

bool operator<(const Node &lhs, const Node &rhs) {
    return lhs.d < rhs.d;
}

int f(int x, int y, int w, int h, int k) {
    int ww = ((x) > (w - x - 1)) ? (w  - x - 1) : (x);
    int hh =((y) > (h - y - 1)) ? (h  - y - 1) : (y);
    
    ww = (ww + k - 1)/k;
    hh = (hh + k - 1)/k;
    return (ww > hh) ? hh : ww;
}

int main() {
    int hx[4] = {0, 0, 1, -1};
    int hy[4] = {-1, 1, 0, 0};
    vector<string> s;
    
    int w, h, k;
    cin >> h >> w >> k;
    s.resize(h);
    for(int i = 0; i < h; i++) {
        cin >> s[i];
    }
    int x, y;
    for (int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == 'S') {
                s[i][j] = '#';
                x = j;
                y = i;
            }
        }
    }
    
    multiset<Node> q;
    
    
    Node node(x, y, 1);
    
    int ans = f(x, y, w, h, k) + 1;
    
    q.insert(node);
    
    
    while(q.size() > 0) {
        Node now = *q.begin();
        q.erase(q.begin());
        if(now.x < 0 || now.x >= w || now.y < 0 || now.y >= h) {
            ans = 0;
            break;
        }
        if(f(now.x, now.y, w, h, k) + 1 < ans) {
            ans = f(now.x, now.y, w, h, k) + 1;
        }
        if(now.d - 1 == k) {
            continue;
        }
        for(int i = 0; i < 4; i++) {
            if(s[now.y + hy[i]][now.x + hx[i]] == '.') {
                if(now.x + hx[i] == 0 || now.x + hx[i] == w - 1 || now.y + hy[i] == 0 || now.y + hy[i] == h - 1) {
                    ans = 1;
                    continue;
                }
                s[now.y + hy[i]][now.x + hx[i]] = '#';
                Node next(now.x + hx[i], now.y + hy[i], now.d + 1);
                q.insert(next);
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
int n, a, b;
int main()
{
	cin >> n >> a >> b;
	for (int i = n; i < b + 1; i += n)
	{
		if (i >= a)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int main(){
    int a, b, c, d, e, f;
    while(cin>>a>>b>>c>>d>>e>>f){
        double det = a*e-b*d;
        double x = (c*e-b*f)/det;
        double y = (a*f-c*d)/det;
        x = (int)(x*1000)/1000.0;
        y = (int)(y*1000)/1000.0;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

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

int area(int x,int y){
    int area = x * y;
    return area;
}

int length(int x, int y){
    int length = 2 * x + 2 * y;
    return length;
}

int main(int argc, const char * argv[]) {
    int a, b;
    int x, y;
    cin >> a >> b;
    x = area(a, b);
    y = length(a, b);
    cout << x << " " << y << endl;
    return 0;
}



Measured memory_bytes: 3104
import math

n= int(input())
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

res  = []
if is_prime(n):
    res.append(n - 1)
else:
    for t in range(1, int(math.sqrt(n)) + 1):
        if n % t == 0:
                res.append(n//t + t - 2)


print(min(res))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 50;
const int mod = 1e9 + 7;
ll fac[maxn];
ll qpow(ll a,ll b){
    ll ans = 1;a %= mod;
    for(ll i = b;i;i >>= 1,a = a * a % mod)
        if(i & 1) ans = ans * a % mod;
    return ans % mod;
}
ll C(ll n,ll m){
    if(m > n || m < 0) return 0;
    ll s1 = fac[n],s2 = fac[n - m] * fac[m] %mod;
    return s1 * qpow(s2,mod - 2) % mod;
}
void init(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++)
    fac[i] = fac[i-1] * i % mod;
}
int main()
{
    std::ios::sync_with_stdio(false);
    ll n;
    init();
    cin >> n;
    ll k = n / 3;
    ll cnt = n % 3;
    ll ans = 0;
    while(k >= 1){
        ans += C(cnt + k - 1, k - 1);
        ans %= mod;
        cnt += 3;
        k--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11460
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
mod = 10**9 + 7

#maincode-------------------------------------------------

n = ini()
a = inl()
b = a[::]
ans = 0
for i in range(n-2,0,-1):
    a[i] += a[i+1]%mod

for i in range(n-1):
    ans += a[i+1] * b[i]
    ans = ans % mod
    
print(ans)

Measured memory_bytes: 32068
S=input()
l=len(S)-1

s=0
for i in range(2**l):
    t=format(i,"b")
    t=t.zfill(l)
    k=S[0]
    for j in range(l):
        if(t[j]=="0"):
            k=k+S[j+1]
        else:
            s+=int(k)
            k=S[j+1]
    s+=int(k)
 
print(s)

Measured memory_bytes: 40048
'''A - Biscuit Generator
https://atcoder.jp/contests/abc125/tasks/abc125_a

>>> main(3,5,7)
10
>>> main(3,2,9)
6
>>> main(20,20,19)
0'''


def main(a: int, b: int, t: int):
    print(t//a * b)


if __name__ == "__main__":
    a, b, t = map(int, input().split(' '))
    main(a, b, t)


Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 500000 + 9;
ll d,s,t;

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>d>>t>>s;
        if(d <= t * s)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;









return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <tuple>
#include <stack>
using namespace std;
typedef long long ll;

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

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

int main(){
    ll d,e,m,n,o1=0,o2=0,o3=0,p,q,r,x,y,z,max1=0,ans=0,o=1,a1,b1;
    string s,t,u;
    cin>>n;
    ll b[n+1],a[n];
    for(ll i=0;i<n;i++){
       cin>>a[i];
        b[i+1]=0;
    }
    b[0]=3;
    for(ll i=0;i<n;i++){
       o*=b[a[i]];
        b[a[i]]--;
        b[a[i]+1]++;
        o%=1000000007;
    }
    cout<<o%1000000007<<endl;
}






Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define  ll long long
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    ll xx=a+b;
    if(xx%2==0)
        cout<<xx/2<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;

    return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    S, T = map(str, open(0).read().split())

    if S == T:
        print('Yes')
    else:
        for i in range(0, len(S)):
            tmp = S[-1] + S[0:-1]
            S = tmp
            if S == T:
                print('Yes')
                exit()
        print('No')


main()

Measured memory_bytes: 2940
N, K = map(int, input().split())
p = list(map(int, input().split()))
  
# 「和の期待値」は「期待値の和」なので、先に期待値を求める
for i in range(N):
  p[i] = (1+p[i])/2

# 累積和
S = [0]*N
S[0] = p[0]
for i in range(N-1):
  S[i+1] = S[i] + p[i+1]

ans = S[K-1]
for i in range(N-K):
  ans = max(ans, S[i+K] - S[i])

print(ans)

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

int main(){
  string S;
  cin >>S;
  int check=1;
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)!='U'&& S.at(i)!='D'){
      if(i%2==0 && S.at(i)!='R'){check=0;break;}
      if(i%2==1 && S.at(i)!='L'){check=0;break;}
    }
  }
  if(check==0){cout <<"No"<<endl;}
    else{cout <<"Yes"<<endl;}
}

Measured memory_bytes: 256
#include<stdio.h>

#define INF 1000000000

int matrixChainOrder(int*,int);
int min(int,int);

int main(){

  int n,r[101],c[101],p[102],i,answer;

  
  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d%d",&r[i],&c[i]);

  }
  
  for(i=0;i<=n;i++){

    if(i==n)p[i]=c[n-1];
    else   p[i]=r[i];
  }

  /* for(i=0;i<=n;i++){

    printf("%d ",p[i]);
  }
  printf("\n");*/

  answer=matrixChainOrder(p,n);

  printf("%d\n",answer);

  return 0;

}

int matrixChainOrder(int p[],int n){

  int i,m[102][102],l,j,k,q; 

  //printf("%d\n",n);
  
 

  for(i=1;i<=n;i++){
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){

      j=i+l-1;

      m[i][j]=INF;

      for(k=i;k<=j-1;k++){

	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];

	//printf("compare: %d %d\n",m[i][j],q);
	
	m[i][j] = min(m[i][j],q);

      }

    }
  }

  //  printf("wa-i\n");

  // printf("%d",n);
  
  /*for(i=1;i<n;i++){
    for(j=n-i+1;j>0;j--){
      
      //      printf("wa-i2\n");
      
      printf("%d ",m[i][j]);
      
    }
    printf("\n");
    }*/
  
  // printf("%d\n",m[1][n]);
  
  return m[1][n];
}

int min(int a,int b){

  if(a>b) return b;
  else return a;

}
  

Measured memory_bytes: 636
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>

using namespace std;


int main(){
  long long n, k;
  cin >> n >> k;
  long long subt = 0;
  long long a, b;
  vector<pair<int, int>> p;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    p.push_back(make_pair(a,b));
  }
  sort(p.begin(),p.end());
  for(int i = 0; i < n; i++){
    subt += p[i].second;
    if(subt >= k){
      cout << p[i].first << endl;
      return 0;
    }
  }

  return 0;
} 


Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
from itertools import *
from collections import *

INF = float('inf')

weather = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']


def main():
    S = input().rstrip()
    index = weather.index(S)
    print(weather[index + 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
def main():
    n = int(input())
    A = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        while A[i]%2 == 0:
            A[i] = A[i]//2
            ans += 1
    print(ans)


if __name__ =='__main__':
    main()


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----


----解説ここまで---- */


int main() {

	int X, Y, Z; cin >> X >> Y >> Z;
	
	int ans = 0;
	int sub = Z;
	FOR(_, 0, 1000000) {
		sub += Z + Y;
		if (sub <= X) {
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

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

    int n;
    cin >> n;

    int a;
    vector<long> as;
    long c = 0;
    long odd_c = 0;
    long even_c = 0;
    while (c < n && cin >> a){
        as.push_back(a);
        if (a % 2 == 0){
            ++even_c;
        }else{
            ++odd_c;
        }
        ++c;
    }

    if(odd_c % 2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
vector<int> g[10101];
char s[10101];
int n,x[10101],ans;
int fa[10101],szz[10101],sz[10101],dep[10101];
void dfs(int u,int faa){
	fa[u]=faa,dep[u]=dep[faa]+1,sz[u]=x[u],szz[u]=dep[u]*x[u];
	for (auto v:g[u]){
		if (v==faa) continue;
		dfs(v,u);
		sz[u]+=sz[v];
		szz[u]+=szz[v];
	}
}
void dfs2(int u,int faa){
	int ma=0,_=0;
	szz[u]=0;
	for (auto v:g[u]){
		if (v==faa) continue;
		dfs2(v,u);
		if (szz[v]>ma) ma=szz[v];
		_+=szz[v];
	}
	if (ma*2<=_) szz[u]=sz[u];
	else{
		szz[u]=_-2*(_-ma)+sz[u];
	}
}
signed main(){
	n=read();
	ans=0x3f3f3f3f;
	scanf("%s",s+1);
	for (int i=1;i<n;i++){
		int x=read(),y=read();
		g[x].push_back(y),g[y].push_back(x);
	}
	dep[0]=-1;
	for (int id=1;id<=n;id++){
		int T=0,ma=0,maid=0;
		for (int i=1;i<=n;i++) x[i]=s[i]-'0';
		dfs(id,0);
		if (szz[id]%2) continue;
		int ___=szz[id]/2;
		for (auto v:g[id]){
			if (szz[v]>ma){
				ma=szz[v],maid=v;
			}
		}
		if (ma*2<=szz[id]){
			ans=min(ans,___);
		}else{
			int tmp=szz[maid],ned=2*ma-szz[id];
			dfs2(maid,id);
			if (tmp-szz[maid]>=ned)
				ans=min(ans,___);
//			szz[id]-=tmp-szz[maid];
//			ma=0,maid=0;
//			for (auto v:g[id]){
//				if (szz[v]>ma){
//					ma=szz[v],maid=v;
//				}
//			}
//			if (ma*2<=szz[id]){
//				ans=min(ans,___);
//			}
		}
	}
	cout<<(ans==0x3f3f3f3f?-1:ans);
	return 0;
}



Measured memory_bytes: 4280
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    S = Scanner.string()
    print("NYoe s"[S[2] == S[3] and S[4] == S[5]::2])


if __name__ == "__main__":
    main()


Measured memory_bytes: 60268
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pb push_back

using LL = long long;
using namespace std;

typedef pair<int, int> pii;

int main() {
	int n;
	while (cin >> n,n) {
		int cnt[26] = {},ans = -1;
		char ac;
		for (int i = 1; i <= n; i++) {
			char c;
			cin >> c;
			cnt[c - 'A']++;
			vector<pii> vec;
			for (int j = 0; j < 26; j++) vec.pb(mp(cnt[j], j));
			sort(vec.begin(),vec.end(),greater<pii>());
			if (vec[0].first > vec[1].first + n - i && ans == -1) {
				ans = i;
				ac = vec[0].second;
			}
		}
		if (ans == -1) cout << "TIE" << endl;
		else cout << (char)(ac + 'A') << " " << ans << endl;
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n,m,ans = 0;
  string s,ss,sss;
  cin>>s;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int A, B, C, D; cin >> A >> B >> C >> D;
    cout << (A != C ? 1 : 0) << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
import math
def main():
	n , p = map(int , input().split())
	i = 2
	if n==1:
		print(p)
		exit()
	ans = 1
	while (i<=math.sqrt(p)):
		if p%i==0:
			cnt = 0
			while p%i==0:
				p = p//i
				cnt = cnt+1
			u = cnt//n
			for j in range(0 , u):
				ans = ans*i
		i = i+1
	print(ans)
if __name__=="__main__":
	main()

Measured memory_bytes: 63388
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
    cout << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, q;
    cin >> n >> q;
    vector<int> a[n + 1];
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        a[u].pb(v);
    }

    int b[n + 1];
    memset(b, 0, sizeof b);
    while (q--) {
        int p, x;
        cin >> p >> x;
        b[p] += x;
    }

    queue<int> qu;
    qu.push(1);
    while (!qu.empty()) {
        int fir = qu.front();
        qu.pop();
        for (int e : a[fir]) {
            b[e] += b[fir];
            qu.push(e);
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << b[i] << ' ';
    }




}



Measured memory_bytes: 14080
N = int(input())
A = list(map(int, input().split()))

if N % 2 == 0:
    B = []
    for i in range(int(N/2)):
        B.append(i*2 + 1)
        B.append(i*2 + 1)
else:
    B = [0]
    for i in range(int(N/2)):
        B.append(i*2 + 2)
        B.append(i*2 + 2)

if sorted(A) == B:
    print((2 ** int(N/2)) % (10**9 + 7))
else:
    print(0)


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

int main(){
	string s, t;

	cin >> s >> t;

	for(int i=0; i<s.size(); i++){
		if(s[i] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3620
using System;

namespace ABC075
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int H = int.Parse(input[0]);
            int W = int.Parse(input[1]);

            int[,] S = new int[H, W];
            string s = "";
            for (int i = 0; i < H; i++)
            {
                s = Console.ReadLine();
                for (int j = 0; j < W; j++)
                {
                    if (s[j] == '.') S[i, j] = 0;
                    if (s[j] == '#') S[i, j] = -1;
                }
            }

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (0 <= S[i, j])
                    {
                        // 上下
                        if (0 <= i - 1 && S[i - 1, j] == -1) S[i, j]++;
                        if (i + 1 < H && S[i + 1, j] == -1) S[i, j]++;

                        // 左右
                        if (j + 1 < W && S[i, j + 1] == -1) S[i, j]++;
                        if (0 <= j - 1 && S[i, j - 1] == -1) S[i, j]++;

                        // 右上、右下
                        if (j + 1 < W && 0 <= i - 1 && S[i - 1, j + 1] == -1) S[i, j]++;
                        if (j + 1 < W && i + 1 < H && S[i + 1, j + 1] == -1) S[i, j]++;

                        // 左上、左下
                        if (0 <= j - 1 && 0 <= i - 1 && S[i - 1, j - 1] == -1) S[i, j]++;
                        if (0 <= j - 1 && i + 1 < H && S[i + 1, j - 1] == -1) S[i, j]++;
                    }
                }
            }

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (S[i, j] == -1) Console.Write('#');
                    else Console.Write(S[i, j]);
                }
                Console.WriteLine();
            }
        }
    }
}


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

int swap(int* a, int* b) {
  int tmp;
  tmp = *b;
  *b = *a;
  *a = tmp;
}

int main () {
  int a, b, c, tmp = 0;
  cin >> a >> b >> c;
  if (a >= b) {
    swap(&a, &b);
  }
  if (a >= c) {
    swap(&a, &c);
  }
  if (b >= c) {
    swap(&b, &c);
  }
  
  cout << a << " " << b << " " << c << "\n";
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    if (S[1] == 'R') {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        cout << "x";
    }
    cout << endl;
}

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

int main(void){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  rep(i,n-1)cin >> c[i];
  int ans=0;
  rep(i,n){
    ans+=b[a[i]-1];
    if(i>0 && a[i-1]+1 == a[i]){
      ans+=c[a[i-1]-1];
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
  int n;cin >> n;
  map<string, int> m;
  string prev="";
  rep(i,n){
    string w; cin >> w;
    if(i>0&&prev[prev.length()-1]!=w[0]){
      cout << "No" << endl;
      return 0;
    }
    m[w]++;
    if(m[w]>1){
      cout << "No" << endl;
      return 0;      
    }
    prev=w;
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin >> N >> M;
    int A[N];
    double threshold;
    int sum = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    threshold =  double(sum)/(4*M);
    int count = 0 ;
    for(int i=0;i<N;i++){
        if(double(A[i]) >= threshold)
            count ++ ;
    }
    if(count >= M)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    
    return 0;
}

Measured memory_bytes: 384
# numpyだとTLE。よって普通の2次元リストで。
# import numpy as np

N = int(input())
# dp = np.array([ [0] * (N+1), [0] * (N+1), [0] * (N+1) ])
dp = [ [0] * (N+1), [0] * (N+1), [0] * (N+1) ]

for i in range(1, N+1):
	a, b, c = map(int, input().split())
	dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a
	dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b
	dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c
	# dp[0, i] = dp[1:, i-1].max() + a
	# dp[1, i] = dp[::2, i-1].max() + b
	# dp[2, i] = dp[:2, i-1].max() + c	
	# print('i, dp[i] =',i, dp[:, i])

#print(dp[:, N].max())
print(max(dp[0][N], dp[1][N], dp[2][N]))


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

int main() {
	int N, p[30];
    cin >> N;
    for (int i = 0; i < N; ++i){
    	cin >> p[i];
    }

    int ans = 0;
    for (int i = 1; i < N-1; ++i){
    	if (   (p[i-1] < p[i] && p[i] < p[i+1]) 
    		|| (p[i-1] > p[i] && p[i] > p[i+1]) ) ans++;
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string b;
int a,c;
double d;
stringstream ss;
int main(){
    cin>>a>>b;
    ss<<b;ss>>c;
    d=sqrt(a*pow(10,b.length())+c);
    if(d-(int)d==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans = 0;
    rep(i,k) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

string solve1(void)
{
    string s;
    cin >> s;

    if (s == "AAA" || s == "BBB")
    {
        return "No";
    }
    else
    {
        return "Yes";
    }
}

int main(void)
{
    cout << solve1() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

long long v[3100][3100], dp[3100][3100][5];
int main() {
    int R, C, K;
    cin >> R >> C >> K;
    memset(v, 0, sizeof(v));
    for (int i = 0; i < K; ++i) {
        long long r, c, t;
        cin >> r >> c >> t;
        v[r][c] = t;
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i <= R; ++i) {
        for (int j = 0; j <= C; ++j) {
            for (int k = 0; k <= 3; ++k) {
                // 上へ行く
                if (i-1 >= 0) {
                    chmax(dp[i][j][0], dp[i-1][j][k]);
                    chmax(dp[i][j][1], dp[i-1][j][k] + v[i][j]);
                }
 
                // 右へ行く
                if (j-1 >= 0) {
                    chmax(dp[i][j][k], dp[i][j-1][k]);
                    if (k-1 >= 0)
                        chmax(dp[i][j][k], dp[i][j-1][k-1] + v[i][j]);
                }
            }
        }
    }
    long long res = 0;
    for (int k = 0; k <= 3; ++k) chmax(res, dp[R][C][k]);
    cout << res << endl;
}

Measured memory_bytes: 454104
#include <cstdio>

int main()
{
  int n,x;
  scanf("%d%d",&n,&x);
  if(x!=1&&x!=2*n-1){
    puts("Yes");
    int c=(x==2?5:x==3?5:1);
    int g=(x==2?-1:1);
    for(int i=0;i<2*n-1;i++){
      int k;
      if(i<n-2||n+1<i){
	k=c;
	c++;
	if(c==x-2){
	  c=x+2;
	}
      }
      else{
	k=(i==n-2?x-1*g:i==n-1?x:i==n?x+1*g:x-2*g);
      }
      printf("%d\n",k);
    }
  }
  else{
    puts("No");
  }
  return 0;
}


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

typedef pair<int, int> P;
int main(void){
    int N;
    cin >> N;
    
    vector<P> vp;
    
    for (int i=0; i<N; i++){
        int x, l;
        cin >> x >> l ;
        vp.push_back({x+l, x-l});
    }
    sort(vp.begin(), vp.end());
    
    int ans = 0;
    int t = -(1<<30);
    
    for (int i=0; i<N; i++){
        // cout << vp[i].second << " " << vp[i].first << endl;
        if(t <= vp[i].second){
            
            ans++;
            t = vp[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4296
using System;

namespace ABC111_a
{


    class Plogram
    {
        static void Main()
        {
            

            string array = Console.ReadLine();
            int[] answer = new int[array.Length];
            
            for(int i = 0; i < array.Length; i++)
            {
                char ch = array[i];
                if(ch == '1')
                {
                    answer[i] = 9;
                }
            }
            for(int i = 0; i < array.Length; i++)
            {
                char ch = array[i];
                if(ch == '9')
                {
                    answer[i] = 1;
                    
                }
            }
            Console.WriteLine(answer[0] * 100 + answer[1] * 10 + answer[2]);

        }
    }
}

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


int main(){
    ll n;  cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    rep(i,n) a[i] = a[i] - (i+1);
    sort(a.begin(), a.end());
    ll b = a[n/2];
    ll ans = 0;
    rep(i,n){
        ans += abs(a[i]-b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))


ans=0
i=0

while i!=n:
    s=[a[i],b[i]]
    a[i]=a[i]-min(s)
    b[i]=b[i]-min(s)
    ans+=min(s)

    s = [a[i+1], b[i]]
    a[i+1]=a[i+1]-min(s)
    ans+=min(s)
    i+=1
print(ans)

Measured memory_bytes: 19156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	char y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,x,y;
int main(){
	n=read();
	for(int i=1;i<=n;i++)
		x=read(),y+=x==i?0:1;
	if(y==0 or y==2)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define QS ios_base::sync_with_stdio(false);
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9+7;
using namespace std;

int dp[6003];
int a[3003], b[3003];
int main(){
//freopen("output.txt", "w", stdout);
    QS
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> vp(n);
    for(int i = 0; i < n; ++i){
        cin >> vp[i].first >> vp[i].second;
    }
    sort(vp.begin(), vp.end());
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 6002; j >= 0; --j){
            if(j >= vp[i].first && j < t + vp[i].first){
                dp[j] = max(dp[j], dp[j-vp[i].first]+vp[i].second);
                ans = max(dp[j], ans);
            }

        }
    }
    cout << ans << '\n';
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = INF;
    rep(i, (int)S.length() - 2) {
        int tmp = 0;
        rep(j, 3) {
            tmp += (S[i + j] - '0') % 10;
            tmp *= 10;
        }
        //cout << tmp /10 << endl;
        ans = min(abs(tmp / 10 - 753), ans);
    }
    cout << ans << endl;
    return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

#ifndef __SOULTCH
#define endl '\n'
#define debug(x) 
#else
#define debug(x) cout << " [+] " << #x << " = " << x << endl
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << pai.first << ' ' << pai.second;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> s) {
    for (T p : s) cout << p << ' ';
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> s) {
    for (auto p : s) cout << '(' << p << ") ";
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

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

    cout << (min({A, B, C})==max({A, B, C})?"Yes":"No") << endl;
}






Measured memory_bytes: 256
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long u = sc.nextLong();
        // long D = sc.nextLong();
        // long K = sc.nextLong();

        int N = sc.nextInt();
        int X = sc.nextInt();

        int[] L = new int[N + 1];

        for (int i = 1; i < N + 1; i++) {
            L[i] = sc.nextInt();
        }

        int boundCnt = 1;
        int distance = 0;
        for (int i = 1; i < N + 1; i++) {
            distance += L[i];
            if (distance > X) break;
            boundCnt++;
        }


        System.out.println(boundCnt);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
bool isprime(int a)
{
    for(int i=2;i<=sqrt(a);i++)
    {
        if(a%i==0)
            return false;
    }
    return true;
}
bool comp(int a,int b)
{
    return a>b;
}
bool prop(string s,string t)
{
    if(s.size()!=t.size()-1)
        return false;
    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i])
        return false;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
        cout<<k;
    else if(k<=a+b)
        cout<<a;
    else
        cout<<a-(k-(a+b));
    return 0;
}


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

int main() {
  string strin;
  string strout;

  cin >> strin;
  int len = strin.length();
  for(int i=0; i<len; i++) {
    strout += strin[len-i-1];
  }
  cout << strout << endl;

  return 0;
}

Measured memory_bytes: 1176
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32
    }
    println!("{}", a * a);
}


Measured memory_bytes: 4352
local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  return (x * y) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local fact = {1}
local invs = {1}
local invfact = {1}
for i = 2, 2000000 do
  fact[i] = bmul(fact[i - 1], i)
  invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])
  invfact[i] = bmul(invfact[i - 1], invs[i])
end

local function getCombQ(n, k)
  if k == 0 or k == n then return 1 end
  return bmul(fact[n], bmul(invfact[k], invfact[n - k]))
end

local pow25 = {1}
local pow26 = {1}
for i = 2, 1000010 do
  pow25[i] = bmul(pow25[i - 1], 25)
  pow26[i] = bmul(pow26[i - 1], 26)
end

local k = io.read("*n", "*l")
local s = io.read()
local n = #s
local ret = 0
for j = 0, k do
  local z = getCombQ(n + j - 1, n - 1)
  z = bmul(z, pow25[j + 1])
  local rem = k - j
  z = bmul(z, pow26[rem + 1])
  ret = badd(ret, z)
end
print(ret)


Measured memory_bytes: 135472
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const int M = pow(10,9)+7;
class mll {
public:
	long long x;
public:
	mll(long long x = 0) : x((x% M + M) % M) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= M) x -= M;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= M;
	}
	mll operator + (const mll& a) {
		*this += a;
		return *this;
	}
	mll operator * (const mll& a) {
		*this *= a;
		return *this;
	}
};

bool IsOneBit(long long bits, int i) {
	return (bits & (1ll << i)) > 0;
}
int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	long long AMax = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		AMax = max(A[i], AMax);
	}
	int digit = log2(AMax);
	mll ans=0;
	for (int i = 0; i <= digit; i++) {
		long long one = 0, zero = 0;
		for (long long a : A) {
			if (IsOneBit(a, i)) one++;
			else zero++;
		}
		ans += mll(1ll << i) * one * zero;
	}
	cout << ans.x << endl;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vvi edges(n, vi(n));
    function<void(int, int, int)> div = [&](int l, int r, int d) {
        if (r - l <= 1)
            return;
        int mid = (l + r) / 2;
        for (int i = l; i < mid; ++i) {
            for (int j = mid; j < r; ++j) {
                edges[i][j] = d;
            }
        }
        div(l, mid, d + 1);
        div(mid, r, d + 1);
    };
    div(0, n, 1); // [0, n)
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            cout << edges[i][j];
            if (j == n - 1)
                cout << endl;
            else
                cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 1536
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

c = 0
for i in range(n):
  c += min(A[i],B[i])
  if A[i] < B[i]:
    c += min(A[i+1],B[i]-A[i])
    A[i+1] -= min(A[i+1],B[i]-A[i])

print(c)


Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    int upto = 1<<n;
    vector<int> dp(upto);
    for(int mask=0;mask<upto;mask++)
    {
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if((mask&(1<<i))&&(mask&(1<<j)))
                    dp[mask]+=a[i][j];
            }
        }
    }
    for(int mask=0;mask<upto;mask++)
    {
        for(int submask=mask;submask>0;submask=mask&(submask-1))
        {
            dp[mask] = max(dp[mask],dp[submask]+dp[mask^submask]);
        }
    }
    cout<<dp[upto-1];
    return 0;
}

Measured memory_bytes: 768