akhauriyash/Code-Regression huggingface dataset:
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
//int h,w;
const int MOD=1e9+7;
LL fact[200000+2],invfact[200000+2];
LL quick(LL A,LL B){
	if(!B) return 1ll;
	LL res=quick(A,B>>1);
	res*=res;
	res%=MOD;
	if(B&1)
	res*=A;
	return res%MOD;
}
LL c(int A,int B){
	return fact[B]*invfact[A]%MOD*invfact[B-A]%MOD;
}
mp wall[3002];
bool cmp(mp A,mp B){
	if(A.FIR!=B.FIR){
		return A.FIR<B.FIR;
	}
	return A.SEC<B.SEC;
}
LL f[3003];
int main(){
	fastio;
	fact[0]=invfact[0]=1;
	rb(i,1,200000)
		fact[i]=fact[i-1]*i,fact[i]%=MOD;
	invfact[200000]=quick(fact[200000],MOD-2);
	rl(i,200000,1)
		invfact[i-1]=invfact[i]*i,invfact[i-1]%=MOD;
	int H,W,N;
	cin>>H>>W>>N;
	rb(i,1,N){
		cin>>wall[i].FIR>>wall[i].SEC;
	}
	sort(wall+1,wall+1+N,cmp);
	rb(i,1,N){
		f[i]=c(wall[i].FIR-1,wall[i].FIR-1+wall[i].SEC-1);	
//		cout<<f[i]<<"$"<<endl;	
	}
//	cout<<f[2]<<endl;
	rb(i,1,N){
		rb(j,i+1,N){
//			cout<<i<<" "<<j<<<endl;
			if(wall[i].FIR<=wall[j].FIR&&wall[i].SEC<=wall[j].SEC){
				f[j]-=
				f[i]*
				c(wall[j].FIR-wall[i].FIR,wall[j].FIR-wall[i].FIR+wall[j].SEC-wall[i].SEC)
				%MOD;
//				cout<<i<<" "<<j<<endl;
//				cout<<" "<<f[i]<<" "<<c(wall[j].FIR-wall[i].FIR,wall[j].FIR-wall[i].FIR+wall[j].SEC-wall[i].SEC)<<endl;
				f[j]+=MOD;
				f[j]%=MOD;
			}		
		}
//		cout<<f[i]<<endl;
		f[i]*=c(H-wall[i].FIR,H-wall[i].FIR+W-wall[i].SEC);
		f[i]%=MOD;
	}	
//	cout<<N<<endl;
//	cout<<f[2]<<endl;
	LL res=c(H-1,H-1+W-1);
	rb(i,1,N)
		res-=f[i],res+=MOD,res%=MOD;
	cout<<res<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
map<int,int>mp;
const int N=2e5+100;
int dp[50][500][500];///前n个a有i，b有j的最小花费
int a[50],b[50],c[50];
int inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m1,m2;
    cin>>n>>m1>>m2;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,0x3f,sizeof dp);
    dp[0][0][0]=0;
    for(int i=0;i<n;i++){
       for(int j=0;j<=400;j++){
        for(int k=0;k<=400;k++){
            if(dp[i][j][k]==inf) continue;
           dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
           dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
       }
     }
    }
    int ans=inf;
    for(int i=1;i<=400;i++){
        if(i*m1<=400&&i*m2<=400){
            ans=min(ans,dp[n][i*m1][i*m2]);
        }
    }
    if(ans!=inf)
    cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}


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

int main(){
    string N;
    cin >> N;
    if((N[0]==N[1]&&N[1]==N[2])||(N[1]==N[2]&&N[2]==N[3])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
m=sum(B)
for i in range(n):
    c=min(A[i],B[i])
    A[i]-=c
    B[i]-=c
    d=min(A[i+1],B[i])
    A[i+1]-=d
    B[i]-=d
m-=sum(B)
print(m)

Measured memory_bytes: 18476
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N= 200005;
const ll lmod = 1e9+7;

int N,K;
int a[MAX_N];
ll b[MAX_N];

int main(){
  cin >> N >> K ;
  rep(i,N) scanf("%d%lld",a+i,b+i);
  ll ans = 0;
  rep(i,N){
    if((K|a[i])==K) ans += b[i];
  }
  REP(i,0,31){
    int stand = 1<<i;
    if((stand&K) == 0) continue;
    int arbiturary = (1<<i) - 1; //1でも0でもいいところ
    int temp = (K|arbiturary)^stand;
    ll tempA = 0LL;
    rep(i,N){
      if((temp|a[i]) == temp){
        tempA += b[i];
      }
    }
    ans = max(ans,tempA);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
using namespace std;

struct UnionFind {
    vector<int> par, weight;
    UnionFind(int n) :par(n,-1), weight(n) {}
    void unite(int x, int y, int w = 0) {
        w += get_weight(x); w -= get_weight(y);
        x = root(x); y = root(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y), w = -w;
        par[x] += par[y];
        par[y] = x;
        weight[y] = w;
        return;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) {
        if(par[x] < 0) return x;
        int r = root(par[x]);
        weight[x] += get_weight(par[x]);
        return par[x] = r;
    }
    int sizeOf(int x) { return -par[root(x)]; }
    int get_weight(int x) { root(x); return weight[x]; }
    int diff(int x, int y) { return get_weight(y) - get_weight(x); }
};

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M;cin>>N>>M;
    UnionFind uf(N);
    int L,R,D;
    for(int i=0;i<M;++i){
        cin>>L>>R>>D;
        --L;--R;
        if(!uf.same(L,R)){
            uf.unite(L,R,D);
        } else {
            if(uf.diff(L,R)!=D){
                cout << "No" << '\n';
                return 0;
            }
        }
    }
    cout << "Yes" << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  ll p[a], q[b], r[c];
  rep(i, a){
    cin >> p[i];
  }
  rep(i, b){
    cin >> q[i];
  }
  rep(i, c){
    cin >> r[i];
  }
  sort(p, p+a, greater<>());
  sort(q, q+b, greater<>());
  sort(r, r+c, greater<>());
  vector<ll> tmp;
  ll cnt = 0, ans = 0;
  rep(i, x){
    tmp.push_back(p[i]);
    ans+=p[i];
  }
  rep(j, y){
    tmp.push_back(q[j]);
    ans+=q[j];
  }
  sort(tmp.begin(), tmp.end());
  rep(i, tmp.size()){
    if(tmp[i]<r[cnt] && cnt<c){
      ans+=(r[cnt] - tmp[i]);
      cnt++;
    }
  }
  cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    ll count = 0;
    cin >> N >> M;
    if(abs(N - M) <= 1) {
        count = 1;
        repi2(i, 2, N) {
            count *= i;
            count %= MOD;
        }
        repi2(i, 2, M) {
            count *= i;
            count %= MOD;
        }
        if(abs(N - M) == 0) {
            count *= 2;
            count %= MOD;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define vector ve
#define priority_queue pq
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;


int main()
{
    int N;cin>>N;
    int a=1,b=2;
    while (a<N) {
        a+=b;
        b++;
    }
    if(a!=N){
        out("No");
        return 0;
    }
    
    out("Yes");
    out(b);
    int c=1,d=0,e=0;
    rep(i,b){
        cout << b-1 <<" ";
        d=1;
        int cc = c;
        rep(j,e){
            cout << c << " ";
            if(j==e-1){
                d++;
                c+=d;
                break;
            }
            c++;
            d++;
        }
        reps(j,e,b-1){
            cout << c << " ";
            c+=d;
            d++;
        }
        c = cc;
        c+=e;
        e++;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
from collections import deque

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

G = [[] for _ in range(N+1)]
m = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in m:
    G[a].append(b)
    G[b].append(a)

par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])

while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)
print('Yes')
print(*par[2:], sep='\n')
    

Measured memory_bytes: 50704
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
B = [A[i][:] for i in range(N)]
C = [A[i][:] for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if k == i or k == j: continue
            if B[i][k]+B[k][j] <= B[i][j]:
                A[i][j] = -1
                B[i][j] = B[i][k]+B[k][j]

ans = 0
for i in range(N):
    for j in range(N):
        if B[i][j] != C[i][j]:
            print(-1)
            exit()
        if A[i][j] != -1:
            ans += A[i][j]
            A[i][j] = -1
            A[j][i] = -1
print(ans)

Measured memory_bytes: 76480
n=int(input())
t,a=map(int,input().split())
for i in range(1,n):
    ti,ai=map(int,input().split())
    if ti<=t or ai<=a:
        k=max((t+ti-1)//ti,(a+ai-1)//ai)
        t=k*ti
        a=k*ai
    else:
        t=ti
        a=ai
    #print(t,a)
print(t+a)




Measured memory_bytes: 38768
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.BitAll
{
    class AtTemplate
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string input = Console.ReadLine();
            int a = input[0] - '0';
            int b = input[1] - '0';
            int c = input[2] - '0';
            int d = input[3] - '0';

            int result;
            string [] opr = new string[3];
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {

                    for (int k = 0; k < 2; k++)
                    {
                        result = 0;
                        if (i == 0)
                        {
                            result = a + b;
                            opr[0] = "+";
                        }
                        else
                        {
                            result = a - b;
                            opr[0] = "-";
                        }
                        if (j == 0)
                        {
                            result += c;
                            opr[1] = "+";
                        }
                        else
                        {
                            result -= c;
                            opr[1] = "-";
                        }
                        if (k == 0)
                        {
                            result += d;
                            opr[2] = "+";
                        }
                        else
                        {
                            result -= d;
                            opr[2] = "-";
                        }
                        if (result == 7)
                        {
                            string resultStr = input.Insert(1, opr[0]);
                            resultStr = resultStr.Insert(3, opr[1]);
                            resultStr = resultStr.Insert(5, opr[2]);
                            resultStr += "=7";
                            Console.WriteLine(resultStr);
                            return;
                        }
                    }
                }
            }
        }
    }
}


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

using namespace std;
#define int long long
#define endl '\n'



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (i + 1) * (n - i);
    }
    // cout << ans << endl;
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        if (a > b) swap(a, b);
        ans -= a * (n - b + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
from collections import defaultdict

N, M = map(int, input().split())
PY = defaultdict(dict)
for i in range(M):
    temp = list(map(int, input().split()))
    PY[temp[0]][temp[1]] = i
PY_sort = sorted(PY.items(), key=lambda x: x[0])

city = {}
for n, ms in PY_sort:
    ms_sort = sorted(ms.items(), key=lambda x: x[0])
    k = 1
    for m, i in ms_sort:
        city[i] = "".join([str(n).zfill(6), str(k).zfill(6)])
        k += 1
city_sort = sorted(city.items(), key=lambda x: x[0])
for i in range(M):
    print(city_sort[i][1])


Measured memory_bytes: 122456
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,i,a,b;
    bool A = false,B = false,C,ans = false;
    cin >> N;
    for(i = 0;i < N;i++){
        cin >> a >> b;
        C = a == b;
        if(A && B && C){
            ans = true;
            break;
        }
        A = B;
        B = C;
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int sum=0;
	char head=s[0],tail=s[s.length()-1];
	for(int i=1;i<s.length()-1;++i)
	{
		sum++;
	}
	cout<<head<<sum<<tail<<endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val Array(n, m, x) = readInts

  case class Book(price: Int, rikaido: Array[Int]) {
    def +(that: Book): Book =
      Book(
        this.price + that.price,
        rikaido.zipWithIndex.map(r => r._1 + that.rikaido(r._2))
      )
  }

  val books = for {
    _ <- 1 to n
  } yield {
    val sankosho = readInts
    Book(sankosho.head, sankosho.tail)
  }

  var min = -1
  for (i <- 1 to n) {
    books.toSeq
      .combinations(i)
      .foreach { b =>
        val sum =
          b.foldLeft(Book(0, (for { _ <- 1 to m } yield { 0 }).toArray))(_ + _)
        if (sum.rikaido.forall(_ >= x)) {
          if (min == -1) {
            min = sum.price
          } else if (min > sum.price) {
            min = sum.price
          }
        }
      }
  }
  println(min)
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


Measured memory_bytes: 57260
#include<stdio.h>

int main(void){

int i, temp, k, temp2;
int remain[5];
int T[5];
int N[5];
int count = 0;
int sum = 0;

for(i = 0; i < 5; i++){
    scanf("%d", &T[i]);
}

for(i = 0; i < 5; i++){
    N[i] = i;
    remain[i] = T[i] % 10;
    if(remain[i] == 0){
        count += 1;
    }
}

for(i = 0; i < 5; i++){
  for(k = i + 1; k < 5; k++)
    if(remain[i] < remain[k]){
        temp = remain[i];
        remain[i] = remain[k];
        remain[k] = temp;
        temp2 = N[i];
        N[i] = N[k];
        N[k] = temp2;

    }
}

if(count == 5 || count == 4){
    sum = T[0] + T[1] + T[2] + T[3] + T[4];
}

else{
    for(i = 0; i < 5 - count - 1; i++){
        sum += T[i] + 10 - remain[i];
        }
    for(i = 5 - count - 1; i < 5; i++){
        sum += T[i];
    }

}

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

return 0;
}


Measured memory_bytes: 128
//Ojas Kumar Dubey //
// el_freki //
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define v1 vector<int>
#define mapp map<int,int>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int modulo=1000000007;
#define deb(x) cout << #x << "=" << x << endl
#define test int t;cin>>t;while(t--)
#define f(i,j,n) for(int i=j;i<n;i++)
#define r(i,j,n) for(int i=j-1;i>=n;i--)
#define minn INT_MIN
#define maxx INT_MAX
#define all(container) container.begin() , container.end()
#define sz(container) (int)container.size()
#define pii pair <int , int>
#define pll pair <long long int , long long int>
#define setp(x) setprecision(x)
int power(int a,int n){
    a%=modulo;
    n%=modulo;
    int var=a,ans=1;
    while(n){
        if(n&1)
            ans=((ans%modulo)*(var%modulo))%modulo;
        var=((var%modulo)*(var%modulo))%modulo;
        n=n>>1;
    }
    return ans;
}
// ------------------------------------Template End------------------------------ //
void solve(){
    string n,m ;
    cin>>n>>m;
    int mi = modulo;
    int i=0;
    while(i<(n.size()-m.size()+1)){
        string s = n.substr(i,m.size());
        //cout<<s;
        int a=0;
        f(j,0,m.size()){
            if(m[j]!=s[j])
                a++;
        }
        mi = min(mi,a);
        i++;
    }
    cout<<mi;
       
}
signed main(){
	fast;
    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt",
    #endif
	solve();
}

			
	



Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int n;
	std::cin >> n;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	std::map<lnt,lnt> map;
	lnt sum=0;
	rep(i,n) {
		map[a[i]]++;
		sum+=a[i];
	}
	int q;
	std::cin >> q;
	rep(qq,q) {
		lnt b,c;
		std::cin >> b >> c;
		sum+=(c-b)*map[b];
		map[c]+=map[b];
		map.erase(b);
		print(sum);
	}
}


Measured memory_bytes: 7948
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
    const numbers = line.split(' ').map(Number);

    // Edit from here
    let a = numbers[0];
    let b = numbers[1];

    if ( a === 0 && b === 0 ) { break; }

    if ( a > b ) {
        const tmp = a;
        a = b;
        b = tmp;
    } 

    const output = a + ' ' + b;
    // to here
    
    console.log(output);
    
}


Measured memory_bytes: 18836
#include <stdio.h>

int main(void)
{
	int a,b,c,f;

	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		f=a;
		a=b;
		b=f;
	}
	if(a>c){
		f=a;
		a=c;
		c=f;
	}
	if(b>c){
		f=b;
		b=c;
		c=f;
	}
	printf("%d %d %d\n",a,b,c);

	return 0;

}

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

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

int main(int argc, char *argv[]) {
  int N;
  int X;
  cin >> N >> X;
  int x[N];
  for(int i = 0; i < N; i++) {
    cin >> x[i];
  }
  vector<int> v;
  for(int i = 0; i < N; i++) {
    v.push_back(x[i]);
  }
  v.push_back(X);
  sort(v.begin(), v.end());
  vector<int> v2;
  for(int i = 0; i < N; i++) {
    v2.push_back(v[i+1] - v[i]);
  }
  sort(v2.begin(), v2.end());
  int ans = v2[0];
  for(int i = 0; i < N; i++) {
    if(gcd(ans, v2[i]) < ans) {
      ans = gcd(ans, v2[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1784
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define st first
#define sc second
#define arr array
#define yes cout << "Yes" <<"\n"
#define no cout << "No" <<"\n"
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false)
#define out cin.tie(nullptr)
#define task "A"
#define open(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout);}
#define open_to_check(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin);}
#define int64 long long

const int maxn = 1e5 + 2;
const int maxN = 1e5 + 5;
const ll mod = 998244353;

using namespace std;

/// Count : 1


int main()
{
    //if(fopen(task".inp", "r")){
        //freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    //}
    ll s, t, d;
    cin >> d >> t >> s;
    if(s*t >= d) yes;
    else no;

}


Measured memory_bytes: 3628
S = list(map(int,input().split()))
N = S[0]
K = S[1]
if K % 2 == 1 :
    x = N // K
    answer = x**3
else:
    x = N // K
    y = (N + K//2) // K
    answer = x**3 + y**3
print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>

using namespace std;

double sum10(double a){
  double sum=0;
  for(int i=0;i<10;i++){
    sum+=a;
    if(i%2)
      a/=3.0;
    else
      a*=2.0;
  }
  return sum;
}
int main(){
  double a;
  while(cin>>a){
    cout<<setprecision(10)<<sum10(a)<<endl;
  }
}

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

int main() {
  int n,m; cin>>n>>m;
  graph v(n+1);
  int a,b;
  rep(i,m){
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vector<int> vec(n+1,0);
  set<int> s{1};
  rep(i,n){
    if(i==0){continue;}
    set<int>s_=s;
    s.clear();
    for(int j:s_){ 
      for(int k:v[j]){
        if(vec[k]==0){
          vec[k]=j;
          s.insert(k);
        }
      }
    }
  }
  
  if(count(vec.begin()+2,vec.end(),0)!=0){
    cout<<"No";
  }
  else{
    cout<<"Yes"<<endl;
    rep(i,n+1){
      if(i<=1){continue;}
      cout<<vec[i]<<endl;
    }
  }
}

Measured memory_bytes: 19032
n1, n2, n3, n4, n5 = map(int, input().split())

if n1 == 0:
  print(1)
elif n2 == 0:
  print(2)
elif n3 == 0:
  print(3)
elif n4 == 0:
  print(4)
else:
  print(5)

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

using namespace std;

int f(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3* n + 1;
    }
}

int main(){
    int s;
    cin >> s;
    vector<int> a;
    a.push_back(s);
    int ai=0;
    for(int i=1; i<=1000000; i++){
        ai = f(a[i-1]);
        auto result = find(a.begin(), a.end(), ai);
        if(result == a.end()){
            a.push_back(ai);
        }else{
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	char s;
	cin>>s;
	if(s>='a'&&s<='z')
	cout<<'a';
	else
	cout<<"A";
}

 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

const int mod=998244353;

struct node
{
	int len;
	unsigned long long l,r;
};

bool operator <(node a,node b) {return a.len<b.len||(a.len==b.len&&a.l<b.l)||(a.len==b.len&&a.l==b.l&&a.r<b.r);}

int n;
char s[110];
map<node,int> F;
map<node,int>::iterator it;

node getnode(int *nw,int l,int r)
{
	node B=(node){r-l+1,0,0};
	for (int i=l; i<=r-64; i++) B.l=(B.l<<1)+nw[i];
	for (int i=max(r-63,l); i<=r; i++) B.r=(B.r<<1)+nw[i];
	return B;
}

int solve(node A)
{
	if (A.len==0) return 1;
	if ((it=F.find(A))!=F.end()) return (*it).second;
	int ans=0,len=A.len,nw[110],nww[110];
	for (int i=1; i<=len-64; i++) nw[i]=(A.l>>(len-64-i)&1);
	for (int i=max(len-63,1); i<=len; i++) nw[i]=(A.r>>(len-i)&1);
	ans=1ll*(nw[1]+1)*solve(getnode(nw,2,len))%mod;
	for (int i=1; i<=len; i++)
	{
		for (int k=1; k<=i; k++) nww[k]=nw[k];
		for (int j=2; i*j<=len; j++) 
		{
			for (int k=1; k<=i; k++) nww[k]&=nw[i*(j-1)+k];
			ans=(ans+1ll*solve(getnode(nww,1,i))*solve(getnode(nw,i*j+1,len)))%mod;
		}
	}
	F.insert(make_pair(A,ans));
	return ans;
}

int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	node A=(node){n,0,0};
	for (int i=1; i<=n-64; i++) A.l=(A.l<<1)+(s[i]-'0');
	for (int i=max(n-63,1); i<=n; i++) A.r=(A.r<<1)+(s[i]-'0');
	printf("%d\n",solve(A));
	return 0;
}

Measured memory_bytes: 3840
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
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


inf = 10 ** 18
mod = 10 ** 9 + 7

s = sr()
st = []
for c in s:
    if c == '0':
        st.append('0')
    elif c == '1':
        st.append('1')
    else:
        if st:
            st.pop()
print(''.join(st))

Measured memory_bytes: 72788
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define testcases() int t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
 //----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
	cin>>n;
	vector<float> v(n);
	priority_queue<float,vector<float>,greater<float>> q;
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
		q.push(v[i]);
	}
	for(int i=1;i<=n-1;i++)
	{
		float x=q.top();
		q.pop();
		float y=q.top();
		q.pop();
		q.push((x+y)/2);
	}
	cout<<q.top();
	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7

class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )

X, Y =  map(int, input().split())

if (2*X-Y)%3!=0 or (2*Y-X)%3!=0:
    print(0)
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    if a<0 or b<0:
        print(0)
    else:
        fact = [1]
        for n in range(1,a+b+1):
            fact.append(fact[-1]*n%MOD)
        print(ModInt(fact[a+b])/ModInt(fact[a])/ModInt(fact[b]))



 

Measured memory_bytes: 86320
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
const double PI = acos(-1.0);

bool ans[1000001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k;
    cin >> n >> m >> k;

    REP(i, n*m+1){
        ans[i] = false;
    }
    REP(j, n+1){
        REP(i, m+1){
            ans[(n-j)*i+(m-i)*j] = true;
        }
    }
    cout << (ans[k] ? "Yes":"No") << "\n";
    return 0;
}


Measured memory_bytes: 1280
N = int(input())
b = list(map(int, input().split(" ")))

a = []
possible = True
while(len(b) > 0 and possible):
    possible = False
    for i in range(len(b)-1, -1, -1):
        if b[i] == i + 1:
            a = [b.pop(i)] + a
            possible = True            
            break

if possible:
    for a_ in a:
        print(a_)
else:
    print(-1)

Measured memory_bytes: 3316
#include<stdio.h>

//??????????????¢???????????\??£?????????????????§??????????????¢??°
int isInRect(int W, int H, int x, int y, int r) {
	if (0 <= x - r && 0 <= y - r && x + r <= W && y + r <= H) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int W, H, x, y, r;

	//????????¢???????????????(W,H)?????????????????????(x,y)??¨??????r?????\???
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	//??????????????¢???????????\??£???????????°Yes,??\??£?????????????????°No?????????
	if (isInRect(W, H, x, y, r) == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        String P = scanner.next().toLowerCase();
        char p[] = P.toCharArray();
 
        String tmp;
        int ans = 0;
        boolean FLG;
 
        while(!(tmp = scanner.next()).equals("END_OF_TEXT")){
 
            char line[] = tmp.toLowerCase().toCharArray();
 
            if(line.length != p.length)continue;
 
            FLG = true;
            for(int i = 0; i < P.length(); i++){
                if(p[i] != line[i]){
                    FLG = false;
                    break;
                }
            }
            if(FLG)ans++;
        }
 
        System.out.println(ans);
    }
}


Measured memory_bytes: 26264
#include<stdio.h>
int max(int x,int y){
  int max;
  if(x>y){
    max=x;
  }else{
    max=y;
  }
  return max;
}
int main(void){
  int a,b,ans;
  scanf("%d %d",&a,&b);
  ans=max(0,a-2*b);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        ll a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  string s;
  cin >> s;
  int n=s.size();
  
  bool ok=true;
  rep(i,n/2){
    if(s[i]!=s[n-1-i])ok=false;
  }
  string t=s.substr(0,n/2);
  string u=s.substr(n/2+1);
  int nt=t.size();
  int nu=u.size();
  rep(i,nt){
    if(t[i]!=t[nt-1-i])ok=false;
  }
  rep(i,nu){
    if(u[i]!=u[nu-1-i])ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString             as B
import           Data.List
import qualified Data.Set                    as S
import           Data.STRef
import qualified Data.Vector                 as V
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM


readInt :: IO [Int]
readInt = map read . words <$> getLine

readIntlines :: Int -> IO [[Int]]
readIntlines n = map (map read . words) <$> replicateM n getLine

main :: IO ()
main = do
    n <- readInt
    a <- readInt
    putStrLn . unwords . map show $ solve a

solve :: [Int] -> [Int]
solve xs = let t = foldl1' (\acc x -> xor acc x) xs
            in map (\x -> xor t x) xs


Measured memory_bytes: 89796
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };



int main() {
	int n, m,Q;
	cin >> n >> m>>Q;
	whei(char) a(n, hei(char)(m, '.'));
	rep(i, 0, Q) {
		int x, y, s;
		cin >> x >> y >> s;
		if (s == 1) {
			rep(i, 0, x)rep(j, 0, m)a[i][j] = '#';
		}
		if (s == 2) {
			rep(i, x, n)rep(j, 0, m)a[i][j] = '#';
		}
		if (s == 3) {
			rep(i, 0, n)rep(j, 0, y)a[i][j] = '#';
		}
		if (s == 4) {
			rep(i, 0, n)rep(j, y, m)a[i][j] = '#';
		}
	}
	int ans = 0;
	rep(i, 0, n)rep(j, 0, m)if (a[i][j] == '.')ans++;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];
    ll ans = 1;
    ll now = 0;
    rep(i, N) {
        now += L[i];
        if (now <= X) ans++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    int64_t a,res = 0;
    rep(i,n){
        cin >> a;
        res += a-1;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1, mod = 1000000007;

int n;
int pri[N], tot, zs[N];
bool vis[N];

int main()
{
	//File("");
	n = gi <int> ();
	for (int i = 2; i <= n; i+=1)
	{
		if (!vis[i]) pri[++tot] = i;
		for (int j = 1; j <= tot && pri[j] <= n / i; j+=1)
		{
			vis[i * pri[j]] = true;
			if (i % pri[j] == 0) break;
		}
	}
	for (int i = 2; i <= n; i+=1)
	{
		int x = i;
		for (int j = 2; j * j <= x; j+=1)
			if (x % j == 0)
			{
				while (x % j == 0) ++zs[j], x /= j;
			}
		if (x > 1) ++zs[x];
	}
	LL ans = 1;
	for (int i = 1; i <= tot; i+=1)
		ans = (ans * (1 + zs[pri[i]])) % mod;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3772
#include<iostream>
#include<cmath>
using namespace std;
#define MOD 1000000007
long long f[1000005];
long long g[100005];
long long inv[1000005];

long long q_pow(long long n,long long m)
{
	int res=1;
	while(m)
	{
		if(m&1)
		{
			res=(res*n)%MOD;
		}
		n=(n*n)%MOD;
		m=m>>1;
	}
	return res;
} 

void fac()
{
	f[0]=1;
	inv[0]=1;
	for(long long i=1;i<=1000000;i++)	
	{
		f[i]=(f[i-1]*i)%MOD;
	}
	inv[1000000]=q_pow(f[1000000],MOD-2);
	for(long long i=1000000-1;i>0;i--)
	{
		inv[i]=(inv[i+1]*(i+1))%MOD;
	}
}
long long c(long long n,long long m)
{
	long long res=((f[n]*inv[n-m])%MOD*inv[m])%MOD;
	return res;
}
int main()
{
	fac();
	long long n,m;
	cin>>n>>m;
	long long p=0;
    long long lim=sqrt(m);
	for(int i=2;i<=lim;i++)
	{
		if(m%i==0)
		{
			g[p]=0;
			while(m%i==0)
			{
				g[p]++;
				m=m/i;
			}
			p++;
		}
	}	
//	cout<<g[1]<<' '<<g[0]<<endl;
	long long ans=1;
	for(int i=0;i<p;i++)
	{
		ans=(c(g[i]+n-1,n-1)*ans)%MOD;
	}
	if(m!=1) ans=(ans*n)%MOD;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll a, b;
    cin>>a>>b;
    int i;
    ll ans = 0;
    FOR0(i, 40)
    {
        ll n2 = pow(2, i+1);
        ll n = pow(2, i);
        ll x = a%n2;
        ll y = (b-a);
        ll temp = 0;
        ll sum = (x+y)%n2;
        if(i==0)
        {
            if((y+1)%2!=0)
                temp += x;
            if(((y+1)/2)%2!=0)
            {
                temp += ((y+1)/2)%2;
            }
        }
        else 
        {
            if(sum < x)
            {
                if(x >= n)
                    temp += (n2 - x);
                if( sum >= n )
                    temp += (sum-n+1);   
            }
            else 
            {
                if(x > n)
                    temp -= (x-n);
                if(sum >= n)
                    temp += (sum - n + 1);
            }
        }
        ans += (temp%2)*n;
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

map<string, int> weights;

bool capital(const char c) { return c >= 'A' && c <= 'Z'; }
bool small(const char c) { return c >= 'a' && c <= 'z'; }

int number(const string &s, int &idx) {
  if (isdigit(s[idx])) {
    int p = s[idx++] - '0';
    if (idx < s.length() && isdigit(s[idx])) {
      p *= 10;
      p += s[idx++] - '0';
    }
    return p;
  }
  return 0;
}

int atom(const string &s, int &idx) {
  if (capital(s[idx])) {
    string atom(1, s[idx++]);
    while(idx < s.length() && small(s[idx])) atom += string(1, s[idx++]);
    if (weights.find(atom) == weights.end()) {
      return -2;
    } else {
      return weights[atom];
    }
  }
  return -2;
}

int molecule(const string &s, int &idx) {
  if (idx >= s.length() || s[idx] == ')') return 0;
  int v;
  if (s[idx] == '(') {
    v = molecule(s, ++idx);
    v *= number(s, ++idx);
  } else {
    v = atom(s, idx);
    if (v == -2) return -2;
    if (idx < s.length() && isdigit(s[idx])) v *= number(s, idx);
  }
  if (v <= 0) return -2;
  int w = molecule(s, idx);
  if (w == -2) return -2;
  return v + w;
}

int main() {
  int w;
  string m;
  while(cin>>m, m != "END_OF_FIRST_PART") {
    cin>>w;
    weights[m] = w;
  }

  while(cin>>m, m != "0") {
    int i = 0;
    int v = molecule(m, i);
    if (v == -2) cout << "UNKNOWN" << endl;
    else cout << v << endl;
  }
}

Measured memory_bytes: 1232