akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  ll A,B,C;
  cin >> A >> B >> C;
  if(A == B && B == C){
    if(A%2) cout << 0 << endl;
    else cout << -1 << endl;
  }
  else{
    if(A%2 == 1 || B%2 == 1 || C%2 == 1) cout << 0 << endl;
    else{//A==B==Cでなく、全て偶数の時
      vector<ll> v = {A,B,C};
      ll k = 1;
      while(1){
        ll a = v[0];
        ll b = v[1];
        ll c = v[2];
        v[0] = (b + c)/2;
        v[1] = (a + c)/2;
        v[2] = (a + b)/2;
        if(v[0]%2 || v[1]%2 || v[2]%2){
          cout << k << endl;
          break;
        }
        k++;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int s,i,p[30],t=0;
  string a;
  char b[105];
  cin>>a;
  s=a.size();
  for(i=1;i<=26;i++){
    p[i]=0;
  }
  for(i=0;i<s;i++){
    if(a[i]=='a')
        p[1]++;
    else if(a[i]=='b')
        p[2]++;
    else if(a[i]=='c')
        p[3]++;
    else if(a[i]=='d')
        p[4]++;
    else if(a[i]=='e')
        p[5]++;
    else if(a[i]=='f')
        p[6]++;
    else if(a[i]=='g')
        p[7]++;
    else if(a[i]=='h')
        p[8]++;
    else if(a[i]=='i')
        p[9]++;
    else if(a[i]=='j')
        p[10]++;
    else if(a[i]=='k')
        p[11]++;
    else if(a[i]=='l')
        p[12]++;
        else if(a[i]=='m')
        p[13]++;
        else if(a[i]=='n')
        p[14]++;
        else if(a[i]=='o')
        p[15]++;
        else if(a[i]=='p')
        p[16]++;
        else if(a[i]=='q')
        p[17]++;
        else if(a[i]=='r')
        p[18]++;
        else if(a[i]=='s')
        p[19]++;
        else if(a[i]=='t')
        p[20]++;
        else if(a[i]=='u')
        p[21]++;
        else if(a[i]=='v')
        p[22]++;
        else if(a[i]=='w')
        p[23]++;
        else if(a[i]=='x')
        p[24]++;
        else if(a[i]=='y')
        p[25]++;
        else
        p[26]++;
  }
   for(i=1;i<=26;i++){
    if(p[i]%2==1){
        t=1;
        break;
    }
  }
  if(t==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;



return 0;
}


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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 2e3 + 10;
const int M = (int) 6e5 + 10;
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const int mod1 = 998244353;
const int mod2 = INF;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;


int n, m, ans;
int a[N][N];
pii h[2][N][N], p[N];

const pii operator - (pii x, pii y) {
  x.f -= y.f;
  x.s -= y.s;
  if (x.f < 0) 
    x.f += mod1;
  if (x.s < 0) 
    x.s += mod2;
  return x;
}

const pii operator + (pii x, pii y) {
  x.f += y.f;
  x.s += y.s;
  if (x.f >= mod1) 
    x.f -= mod1;
  if (x.s >= mod2) 
    x.s -= mod2;
  return x;
}

pii get_hash(int tr, int x, int l, int r) {
  return h[tr][x][r] - (l ? h[tr][x][l - 1] : mp(0, 0));
}

bool ok(int i, int j, int l, int r) {
  return get_hash(0, i, l, r) == get_hash(0, j, l, r)
        || get_hash(1, i, l, r) == get_hash(0, j, l, r);
}

int lo[N], hi[N];

void recalc(vec v) {
  stack<int> st;
  for (int i = 0; i < sz(v); i++) {
    while (!st.empty() && v[st.top()] >= v[i]) {
      hi[st.top()] = i;
      st.pop();
    }
    lo[i] = (st.empty() ? -1 : st.top());
    st.push(i);
  }
  while (!st.empty()) {
    hi[st.top()] = sz(v);
    st.pop();
  }
  for (int i = 0; i < sz(v); i++) {
    ans = max(ans, (hi[i] - lo[i]) * v[i]);
  }
}

void calc() {
  for (int l = 0; l < m; l++) {
    vec cur;
    for (int i = 1; i < n; i++) {
      int lo = 0, hi = m - 1 - l, f;
      while (lo <= hi) {
        int mid = (lo + hi) / 2;
        if (ok(i, i - 1, l, l + mid)) {
          f = mid + 1;
          lo = mid + 1;
        } else {
          hi = mid - 1;
        }
      }
      cur.pb(f);
    }
    recalc(cur);
  }
}

pii mult(int x, pii y) {
  return mp(y.f * 1ll * x % mod1, y.s * 1ll * x % mod2);
}

int main() {
  #define fn "combination"
  #ifdef witch
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #else
     // freopen(fn".in", "r", stdin);
     // freopen(fn".out", "w", stdout);
  #endif
  srand(time(0));
  cin >> n >> m;
  ans = max(n, m);
  p[0] = mp(1, 1);
  for (int j = 1; j < m; j++) {
    p[j] = mult(3, p[j - 1]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char x;
      cin >> x;
      a[i][j] = (x == '#');
      h[0][i][j] = (j ? h[0][i][j - 1] : mp(0, 0)) + mult(a[i][j] + 1, p[j]);
      h[1][i][j] = (j ? h[1][i][j - 1] : mp(0, 0)) + mult(2 - a[i][j], p[j]);
    }
  }
  calc();
  cout << ans;
  return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define dbg cerr << "HU" << endl;
#define NACHO {ios::sync_with_stdio(0); cin.tie(NULL);}
 
typedef long long tint;
typedef long double ld;
 
const int INF = 190000000;
const int MOD = 1e9+7;
const int MAXN = 100001;

tint dp[100001];

int main(){
	NACHO;
	tint n, w; cin >> n >> w;
	tint a, b; cin >> a >> b;
	if(a <= w) dp[a] = b;
	forsn(i, 1, n){
		cin >> a >> b;
		for(int j=w;j>=0;j--){
			if(a+j <= w) dp[a+j] = max(dp[a+j], dp[j]+b);
		}
	}
	tint maxi = 0;
	forn(i, w+1){
		maxi = max(maxi, dp[i]);
	}
	cout << maxi << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>

using namespace std;

int p;
bool check(int *a, int n)
{
  for(int i = 0; i < n; i++){
    if(a[i] >= 0){
      p = i;
      return true;
    }
  }

  return false;
}

int main(int argc, char **argv)
{
  int *a, n, s, t, q;

  while(1){
    cin >> n;
    if(n == 0){
      break;
    }
    
    a = (int *)calloc((n+1)*(n+1), sizeof(int));
    for(int i = 0; i < n*n; i++){
      cin >> s >> t;
      a[i] = s + t*n;
    }

    s = 0;
    t = -1;
    while(check(a, n*n)){
      q = a[p];
      a[p] = t;
      p = q;
      while(1){
	if(a[p] == t){
	  s++;
	  break;
	} else if(a[p] < 0 && a[p] > t){
	  break;
	}
	q = a[p];
	a[p] = t;
	p = q;
      }
      t--;
    }
    cout << s << endl;
    free(a);
  }


  return 0;
}

Measured memory_bytes: 940
import java.util.*;
public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveB();
    }
    
    private void solveA() {
	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
	int ans = 0;

	for (int i=0;i < 4;i++){
	    if (s.charAt(i) == '+'){
		ans++;
	    }
	    else{
		ans--;
	    }
	}
    	System.out.println(ans);
    }

    private void solveB() {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int m = n;
	int s = 0;

	while(n != 0){
	    s += n%10;
	    n /= 10;
	}

	if (m%s == 0){
	    System.out.println("Yes");
	}
	else{
	    System.out.println("No");
	}
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
int main(){
  int a,b;
  char c;

  while(1){
    scanf("%d %c %d",&a,&c,&b);
    if(c == '?') break;
    else if(c=='+') printf("%d\n",a+b);
    else if(c=='-') printf("%d\n",a-b);
    else if(c=='*') printf("%d\n",a*b);
    else if(c=='/') printf("%d\n",a/b);
    else if(c=='%') printf("%d\n",a%b);
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

class Point{
	private :
	int x; //X point of grid
	int y; //Y point of grid
	int path; //number of path
	bool roadWork; //roadWork flag

	public : 
	Point() : x(), y(), path(), roadWork() {}
	~Point() = default;
	void setX(int i) { x = i; }
	void setY(int i) { y = i; }
	void setPath(int i) { path = i; }
	void setRoadWork(bool b) { roadWork = b; }
	int getX() { return x; }
	int getY() { return y; }
	int getPath() { return path; }
	int getRoadWork() { return roadWork; }
};

std::vector<Point> getRWPList(int i);
std::vector<Point> getPointList(std::vector<Point> v, int a, int b);

int main(void){
	int a; //number of road from south to north
	int b; //number of road from east to west 

	while(std::cin >> a >> b){ //input number of road
		if(a == 0 && b == 0){ //end input
			break;
		}

		size_t num; //number of dataset
		std::cin >> num; //input number of dataset

		std::vector<Point> pointList = getPointList(getRWPList(num), a, b); //array of point

		for(size_t i = 0; i < pointList.size(); ++i){ //set path of all road
			if(pointList.at(i).getRoadWork() == true){
				pointList.at(i).setPath(0);
			}else{
				if(i == 0){
					pointList.at(i).setPath(1);
				}else if(i < b){
					pointList.at(i).setPath(pointList.at(i - 1).getPath()); //add number of path at west point 
				}else if(i % b == 0){
					pointList.at(i).setPath(pointList.at(i - b).getPath()); //add number of path at south point 
				}else{
					pointList.at(i).setPath(pointList.at(i - 1).getPath() + pointList.at(i - b).getPath()); //add number of path at west and south point 
				}
			}
		}

		std::cout << pointList.back().getPath() << std::endl; //output result
	}

	return 0;
}

std::vector<Point> getRWPList(int i){
	std::vector<Point> v; //array of road work point

	for(size_t j = 0; j < i; ++j){ //input grid of road work point
		int tmp1, tmp2;
		std::cin >> tmp1 >> tmp2;
		Point p;
		p.setX(tmp1);
		p.setY(tmp2);
		v.push_back(p);
	}

	return v;
}

std::vector<Point> getPointList(std::vector<Point> v, int a, int b){ //v is RWPList, a is number of road from south to north, b is number of road from west to north
	std::vector<Point> w;

	for(size_t i = 0; i < a; ++i){
		for(size_t j = 0; j < b; ++j){
			Point p;
			p.setX(i + 1);
			p.setY(j + 1);

			for(size_t k = 0; k < v.size(); ++k){
				if(p.getX() == v.at(k).getX() && p.getY() == v.at(k).getY()){
					p.setRoadWork(true);
				}
			}

			w.push_back(p);
		}
	}

	return w;
}

Measured memory_bytes: 2972
import java.util.Scanner;

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

        int c = Integer.parseInt(a + b);
        int sq = (int)Math.sqrt(c);

        if (c == sq * sq) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cis(s);
    cis(t);
    int ans = 0;
    rep(i, 3){
        if (s[i]==t[i]) ans++;
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
	int x;
	cin >> x;
	cout << x * x * x << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=203,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S,T;cin>>S>>T;
    int a=0,b=0,cnt=0;
    bool ok=false;
    
    while(1){
        while(a<S.size()&&S[a]!=S[cnt]) a++;
        if(a==S.size()) break;
        
        cnt++;
        a++;
        
        if(cnt==S.size()) break;
        
        while(b<T.size()&&T[b]!=S[cnt]) b++;
        if(b==T.size()) break;
        
        cnt++;
        b++;
        
        if(cnt==S.size()) break;
    }
    
    if(cnt==S.size()) ok=true;
    
    a=0;b=0;cnt=0;
    
    while(1){
        while(b<T.size()&&T[b]!=S[cnt]) b++;
        if(b==T.size()) break;
        
        cnt++;
        b++;
        
        if(cnt==S.size()) break;
        
        while(a<S.size()&&S[a]!=S[cnt]) a++;
        if(a==S.size()) break;
        
        cnt++;
        a++;
        
        if(cnt==S.size()) break;
    }
    
    if(cnt==S.size()) ok=true;
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3236
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }


    int N;
    public bool calc2(long[] A)
    {
        long sum = 0;
        for (int i = 0; i < N; i++)
        {
            sum += A[i];
        }
        if ((sum - N) % 2 == 1) return true;
        if (N % 2 == 0) return false;

        int oddcnt = 0;
        int oddpos = -1;
        for (int i = 0; i < N; i++)
        {
            if(A[i] % 2 == 1)
            {
                oddpos = i;
                oddcnt++;
            }
        }

        if (oddcnt != 1) return false;
        if (A[oddpos] == 1) return false;
        A[oddpos]--;

        long g = A[0];
        for (int i = 1; i < N; i++)
        {
            g = gcd(A[i], g);
        }
        for (int i = 0; i < N; i++)
        {
            A[i] /= g;
        }

        return !calc2(A);
    }

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

    public void calc()
    {
        long[] A;
        N = cin.nextInt();
        A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextLong();
        }
        if (calc2(A)) Console.WriteLine("First");
        else Console.WriteLine("Second");
    }
    
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 16472
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}



// min
int main(void){

  int r;
  int ans = 0;

  scanf("%d", &r);

  ans = 3 * r * r;
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
from collections import deque

INF = float("inf")

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

Si, Sj = (0, 0)
for i, a in enumerate(A):
    if "S" in a:
        Si, Sj = (i, a.index("S"))
        break

distance = INF

Q = deque([(0, Si, Sj)])
while Q:
    dist, i, j = Q.popleft()
    if dist > K:
        break

    distance = min(distance, i, j, H - i - 1, W - j - 1)

    for di, dj in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and A[ni][nj] == ".":
            A[ni][nj] = "#"
            Q.append((dist + 1, ni, nj))

print(-(-distance // K) + 1)


Measured memory_bytes: 9332
#include <iostream>
using namespace std;long long i=0,n,q,x,r,l,m,a[100000],t[100001],s[100001];int main(){cin>>n>>q;for(;i<n;i++){cin>>a[i];s[i+1]=s[i]+a[i];t[i+1]=(i?t[i-1]:0)+a[i];}while(q--){cin>>x;l=0;r=n+1;while(r-l>1){m=(r+l)/2;(abs(a[n-m]-x)>abs(a[n-(m+1)/2]-x)?r:l)=m;}cout<<s[n]-s[n-(l+1)/2]+t[max(n-l-(l&1),0LL)]<<endl;}}


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

int main(){
    int n;
    vector<int> values;
    bool repetido = false;
    cin>>n;
    if(2<=n<=200000){
        for(int i =0;i<n;i++){
            int numero;
            cin>>numero;
            values.push_back(numero);
        }
        sort(values.begin(),values.end());
            int temporal = 0;
           for (int k = 0; k < values.size(); k++)
           {
               (temporal!=values[k]) ?temporal = values[k] : repetido = true;
           }
           
            if(repetido)
                cout<<"NO";
             else
                cout<<"YES";         
    }else
        return 0;
}

Measured memory_bytes: 1400
#define ENABLE_DEBUG 1
// hidden common codes{{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;
template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

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

    auto fifth=[&](lint x){
        return x*x*x*x*x;
    };

    lint n=input;
    for(lint i=1;fifth(i)-fifth(i-1)<=n;i++){
        for(lint j=0;j<=i;j++){
            if(fifth(i)+fifth(j)==n){
                std::cout<<i<<' '<<-j<<'\n';
                return 0;
            }
            if(fifth(i)-fifth(j)==n){
                std::cout<<i<<' '<<j<<'\n';
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3644
#include <iostream>
#define int long long
using namespace std;

typedef long long ll;

ll mod=1e9+7;

ll mod2x(ll n,ll k){
    ll ans=n;
    for(ll i=0;i<k;i++){
      ans=(ans*ans)%mod;
    }
    return ans;
}
 
string by_x(ll n,ll x){
    string ans="";
    while(n>0){
        char c=n%x+'0';
        ans=ans+c;
        n/=x;
    }
    return ans;
}
 
ll modpow(ll n,ll k){
    ll ans=1;
    string s=by_x(k,2);
    ll t=s.size();
    for(ll i=0;i<t;i++){
      if(s[i]=='1'){
        ans=(ans*mod2x(n,i))%mod;
      }
    }
  return ans;
}

signed main(){
  string s;
  cin >> s;
  ll n=s.size();
  ll a[n+5];
  a[1]=2;
  for(ll i=2;i<n+5;i++){
    a[i]=(a[i-1]*3)%mod;
  }
  ll sum[n+5];
  sum[0]=1;
  for(ll i=1;i<n+5;i++){
    sum[i]=(sum[i-1]+a[i])%mod;
  }
  ll ans=sum[n-1];
  ll count=0;
  ll dig=n-1;
  for(ll i=1;i<n;i++){
    dig--;
    if(s[i]=='1'){
      count++;
      //cout << count << " " << dig << endl;
      ans=(ans+modpow(2,count)*sum[dig])%mod;
    }
  }
  ans=(ans+modpow(2,count+1))%mod;
  if(s=="0") cout << 1 << endl;
  else cout << ans << endl;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (2e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, z, w;
    cin >> n >> z >> w;
    vi a(n);
    rep(i, n) cin >> a[i];
    if (n==1) cout << abs(a[0]-w) << endl;
    else cout << max(abs(a[n-1]-w), abs(a[n-2]-a[n-1])) << endl;
    return 0;
}


Measured memory_bytes: 3644
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=100005;


void solve()
{
    string s;
    cin>>s;
    int f[2]={0};
    for(int i=0;i<3;i++)
        f[s[i]-'A']++;
    if(f[0]&&f[1])
        cout<<"Yes";
    else
        cout<<"No";
        cout<<endl;
    
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    
    int t;
    t=1;
     //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
def solve(m,k):
    if m==0:
        if k==0:
            return [0,0]
        return [-1]
    if m==1:
        if k==0:
            return [0,0,1,1]
        return [-1]
    if k>2**m-1:
        return [-1]
    n=2**m
    if k==0:
        Ret=[]
        for i in range(n):
            Ret.append(i); Ret.append(i)
        return Ret
    Used=[False]*n
    Used[0]=True; Used[k]=True
    Pair=[]
    for i in range(1,n):
        if Used[i]:
            continue
        Pair.append([i,k^i])
        Used[i]=True; Used[k^i]=True
    A=[]
    for a,b in Pair:
        A.append(a); A.append(b)
    Ret=A+[0,k,0]+A[::-1]+[k]
    return Ret

m,k=map(int,input().split())
Ans=solve(m,k)
print(*Ans)

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main() {
  int N;
  cin >> N;
  if(N%2==0) cout<<0.5<<endl;
  else{
    double M=N/2+1;
    double L=N;
    cout<<fixed<<setprecision(6)<<M/L;
  }
}
  



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int K, X;
    cin >> K >> X;
    for(int i = -K + 1; i < K; i++) {
        cout << X + i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int adder = 0;
        int counter=0;
        Scanner scan = new Scanner(System.in);

        int hako[] = new int[3];
        for (int i = 0; i < 3; i++) {
            hako[i]=scan.nextInt();
        }
        int hako1[]=new int[3];
        hako1[0]=hako[1];
        hako1[1]=hako[0];
        hako1[2]=hako[2];
        int hako2[]=new int[3];
        hako2[0]=hako1[2];
        hako2[1]=hako1[1];
        hako2[2]=hako1[0];
        System.out.print(hako2[0]+" ");
        System.out.print(hako2[1]+" ");
        System.out.print(hako2[2]+" ");
        }


}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int N = 1e5+5;

ll sum[N],ss[N];

int main()
{
	int n,k,cnt = 0;
	string s;
	scanf("%d%d",&n,&k);
	cin >> s;s += '2';ss[0] = 0;
	
	int len = 1;
	for(int i = 1;i < s.size();++i){
		if(s[i] != s[i-1]) sum[++cnt] = len,ss[cnt] = ss[cnt-1] + sum[cnt],len = 1;
		else len++;
	}
	
	int key = s[0] == '1' ?cnt/2 :(cnt+1)/2;
	int st = s[0] == '1' ?1 :2;
	ll ans = s[0] == '1' ?0 :ss[k << 1];
		
	if(key <= k) printf("%lld\n",ss[cnt]);
	else{
		ans = ss[k << 1];
		for(int i = st;(k << 1)+i-1 <= cnt;i += 2) ans = max(ans,ss[min(cnt,i+(k << 1))]-ss[i-1]);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (c >= a && c <= a + b ? "YES" : "NO") << endl;
	return 0;
}
 

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


bool p[N];
int num[N];

int main(){

  for(int i=0;i<N;i++)p[i] = true;
  p[0] = p[1] = false;

  for(int i=2;i*i<N;i++){
    if(p[i]){
      for(int j=2*i;j<N;j+=i)p[j] = false;
    }
  }

  int sum = 0;
  for(int i=0;i<N;i++){
    if(p[i])sum++;
    num[i] = sum;
  }

  int n;
  while(cin >> n ,n)cout << num[2*n] - num[n] << endl;
  
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    char s[3];
    scanf("%s",s);
    int value=700;
    for(int i=0; i<3; i++){
        if(s[i]=='o'){
            value+=100;
        }
    }
    cout << value << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  string a,b,c;
  int n;
  int m;
  n = 0 ; m = 0;
  cin>>a>>b>>c;
  while (a[n] != '\0'){
    n++;
  }
  while(b[m] != '\0'){
    m++;
  }
  if((a[n-1] == b[0]) && (b[m-1] == c[0])){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
const int N=3e4+5;
int a[N],k[N];
bool vis[10][10];
int cal(int x){
	int res=0;
	while(x){
		x-=(x&(-x));
		res++;
	}
	return res;
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%1d",&a[i]);
	int t=0;
	for(int i=n;i>=1;i--){
		t|=(1<<a[i]);
		k[i]=t;
	}
	int ans=0;
	for(int i=1;i<=n-2;i++){
		for(int j=i+1;j<=n-1;j++){
			if(vis[a[i]][a[j]])continue;
			vis[a[i]][a[j]]=1;
			ans+=cal(k[j+1]);
		}
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int p=31;
const int m=1e9+7;
typedef long long ll;
typedef int in;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");} 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// #define int ll

in main (){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=-2e18;
    if(b<0){
    	if(c>0){
    		ans=max(b*c,ans);
    	}
    	else{
    		ans=a*c;
    		if(d>=0)ans=max((ll)0,ans);
    		
    	}
    }
    else if(b==0){
    	if(c>=0)ans=max((ll)0,ans);
    	else
    		ans=max(ans,a*c);
    }
    else{
    	if(d<=0){
    		if(a<=0)ans=max({(ll)0,ans,a*c});
    		else ans=max(ans,d*a);
    	}	
    	else
    	ans=max({(ll)0,a*c,b*d,b*c,a*d,ans});
    }
    cout<<ans;

}
    


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int d = sc.nextInt();
		int n = sc.nextInt();
		int ans = 0;
		if (n == 100) {
			ans = (int) Math.pow(100, d) * (n + 1);
		} else {
			ans = (int) Math.pow(100, d) * n;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

int halfCount(int x){
    int cnt = 0;
    while(x>1 && x%2==0){
        x /= 2;
        cnt++;
    }
    return cnt;
}

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

    int n;cin >> n;
    int ans = 1;
    int count = 0;
    gnr(i,1,n+1){
        int hc = halfCount(i);
        if(hc > count){
            count = hc;
            ans = i;
        }
    }

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

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

#define size_t int

using namespace std;

int main(int argc, char const *argv[]) {
  char n[1000];
  scanf("%s", n);
  for (size_t i = 0; n[i] != 0; i++) {
    if (n[i] == '9') {
      printf("1");
    } else if (n[i] == '1') {
      printf("9");
    } else {
      printf("%c", n[i]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
b = [(a[i],i+1) for i in range(n)]
b.sort(reverse=True)
cntf = 0
cntb = n-1
dp = [[0 for i in range(n+1)] for j in range(n+1)]
dp[0][1] = -10**18
for i in range(1,n+1):
  x,ind = b[i-1]
  dp[i][0] = dp[i-1][0]+abs(n-i-ind+1)*x
  for j in range(1,i+1):
    dp[i][j] = max(dp[i-1][j-1]+abs(j-ind)*x,dp[i-1][j]+abs(n-(i-j)+1-ind)*x)
print(max(dp[n]))

Measured memory_bytes: 107132
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = (int(x)-1 for x in input().split())
  graph[a].append(b)
  graph[b].append(a)

from collections import deque
def bfs(s:int)->list:
  dist = [-1]*n
  dist[s] = 0
  que = deque([s])
  while que:
    u = que.popleft()
    for v in graph[u]:
      if dist[v] != -1: continue
      dist[v] = dist[u] + 1
      que.append(v)
  return dist

dfen = bfs(0)
dsnu = bfs(n-1)
pfen = 0
psnu = 0
for i in range(n):
  if dfen[i] <= dsnu[i]: pfen += 1
  else: psnu += 1
ans = 'Fennec' if pfen > psnu else 'Snuke'
print(ans)


Measured memory_bytes: 33848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u=sc.next();
		if(s.equals(u)) {
			a--;
		}else {
			b--;
		}
		System.out.println(a+" "+b);
		sc.close();
	}
}


Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	a := readInt()
	b := readInt()
	p := make([]int, n)
	for i := range p {
		p[i] = readInt()
	}
	var x, y, z int
	for _, v := range p {
		if v <= a {
			x++
		} else if v <= b {
			y++
		} else {
			z++
		}
	}
	println(min(x, min(y, z)))
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - The Number of Even Pairs
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  printf("%d\n", n * (n - 1) / 2 + m * (m - 1) / 2);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        String[] s = new String[n];
        for(int i=0;i<s.length;i++)
        {
            s[i] = scan.next();
        }
        
        int m = scan.nextInt();
        String[] t = new String[m];
        for(int i=0;i<t.length;i++)
        {
            t[i] = scan.next();
        }
        
        int max = 0;
        for(int i=0;i<s.length;i++)
        {
            int tmp = 0;
            for(int j=0;j<s.length;j++)
            {
                if(CheckSame(s[i],s[j]))
                {
                    tmp++;
                }
            }
            for(int j=0;j<t.length;j++)
            {
                if(CheckSame(s[i],t[j]))
                {
                    tmp--;
                }
            }
            if(tmp>max)
            {
                max = tmp;
            }
        }
        
        System.out.println(max);
    }
    
    
    static Boolean CheckSame(String a,String b){
        if(a.length() != b.length())
        {
            return false;
        }
        for(int i=0;i<a.length();i++)
        {
            if(a.charAt(i) != b.charAt(i))
            {
                return false;
            }
        }
        return true;
    } 
}

Measured memory_bytes: 22868
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> d(n + 1);
    d[0] = 0;
    rep(i, n) {
      int l; cin >> l;
      d[i + 1] = d[i] + l;
    }
    int count = 0;
    rep(i, n + 1) {
      if (d[i] <= x) {
        count++;
      }
    }

    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// Prioridade
typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (int)(b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)
#define W(x) cerr << "\033[31m"<<  #x << " = " << x << "\033[0m" << endl;
// fim da Prioridade
int dp[11][10][2][2];
int seen[11][10][2][2];
int timer = 0;
string s;
inline int solve(){
	int idx = 0, last = 0, can = 0, put = 0;
	
	for(last = 0; last <= 9; last++){
		for(can = 0; can <= 1; can++){
			dp[s.size()][last][can][0] = 0;
			dp[s.size()][last][can][1] = 1;
		}
	}
	
	for(idx = s.size()-1; idx >= 0; idx--){
		for(last = 0; last <= 9 ; last++){
			for(can = 0; can <= 1; can++){
				for(put = 0; put <= 1; put++){
					int ans = 0;
					if(!idx || !put){
						int num = can ? 9 : s[idx] - '0';
						for(int i = 0; i <= num ; i++){
							ans += dp[idx + 1][i][can | (i != num)][put | (i != 0)];
						}
					}else{
						int num = can ? 9 : s[idx] - '0';
						for(int i = -1; i <= 1; i++){
							if(0 <= last + i and last + i <= num){
								ans += dp[idx + 1][last + i][can | ((last + i) != num)][1];
							}
						}
					}
					dp[idx][last][can][put] = ans;
				}
			}
		}
	}
	return dp[0][0][0][0];
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll lo = 1LL, hi = 3234566670LL, mid;
	int k;	
	cin >> k;
	while(lo <= hi){
		mid = (lo + hi)>>1;
		s = to_string(mid);
		timer++;
		if(solve() < k){
			lo = mid + 1;
		}else{
			hi = mid - 1;
		}
	}
	cout << hi + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
     
    public class Main{
        public static Scanner scan  = new Scanner(System.in);
        public static void main(String[]args){
            float n;
            n=nextFloat();
            print(n*2.0*3.141592);
        }
     
     
     
        public static int nextInt(){
            return Integer.parseInt(scan.next());
        }
        public static long nextLong(){
            return Long.parseLong(scan.next());
        }
        public static String next(){
            return scan.next();
        }
        public static double nextDouble(){
            return Double.parseDouble(scan.next());
        }
        public static float nextFloat(){
            return Float.parseFloat(scan.next());
        }
     
        //Yes or No
        public static void yesNo(boolean flag){
            if(flag) System.out.println("Yes");
            else System.out.println("No");
        }
        public static void print(Object a){
            System.out.println(a);
        }
    }

Measured memory_bytes: 36000
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN=55;
int n;
string s[MAXN];
int t[MAXN];
string x;
int main(){
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>s[i]>>t[i],t[i]+=t[i-1];
	cin>>x;
	for(int i=1; i<=n; i++)
		if(x==s[i]){
			cout<<t[n]-t[i]<<endl;
			break;
		}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"sort"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // Use Fprintf

	// CODE
	A, B, C := nextInt(), nextInt(), nextInt()
	ans := minInt(A+B+1, C)
	ans += B
	fmt.Fprintf(out, "%d\n", ans)
}

// Template

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(nextStr())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(nextStr(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = nextStr()
	}
	return ret
}

func maxInt(x int, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInt(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

func dummy() {
	fmt.Fprintf(out, "Hello, World\n")
	fmt.Fprintf(out, "%v", reflect.TypeOf(0))

	arr := []int{10, 9, 8, 7, 1}
	sort.Ints(arr)
	fmt.Fprintln(out, arr)
}


Measured memory_bytes: 640