akhauriyash/Code-Regression huggingface dataset:
N = int(input())
maximum = 0
max_sec = 0
A = []
for _ in range(N):
  a = int(input())
  A.append(a)
  if a > maximum:
    max_sec = maximum
    maximum = a
  elif a > max_sec:
    max_sec = a
for i in range(N):
  if A[i] == maximum:
    print(max_sec)
  else:
    print(maximum)

Measured memory_bytes: 12520
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,d;cin>>n>>d;
  int a[n][d];
  int cnt=0;
  for(int i=0;i<n;i++)
  {for(int k=0;k<d;k++)
    {cin>>a[i][k];}}
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      double sum=0;
      for(int k=0;k<d;k++)
      {
        double p=abs(a[i][k]-a[j][k]);
        sum+=p*p;
      }
      double s=sqrt(sum);
      long long p=s;
      if(s==p)cnt++;
    }
  }
  cout<<cnt;
  return 0;
}
          

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define endl '\n'

double dp[3003][3003] = {};

int main()
{
	int n;
	scanf("%d", &n);
	double a[n+1];
	for(int i=1; i<=n; i++)
		scanf("%lf", a+i);
	dp[0][0] = 1;
	for(int i=1; i<=n; i++)
		dp[0][i] = dp[0][i-1] * ( 1 - a[i] );
	for(int h=1; h<=n; h++)
		for(int i=1; i<=n; i++)
			dp[h][i] = a[i] * dp[h-1][i-1] + ( 1 - a[i] ) * dp[h][i-1];
	double p = 0;
	for(int h=n/2+1; h<=n; h++)
		p += dp[h][n];
	printf("%.12lf\n", p);
	return 0;
}

Measured memory_bytes: 70656
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, Q; cin >> N >> Q;
	vector<long long int>as(N);
	for (int i = 0; i < N; ++i)cin >> as[i];
	while (Q--) {
		auto it = as.begin(); auto jt = as.begin();
		long long int S; cin >> S;
		long long int sum = 0;
		long long int ans = 0;
		while (jt != as.end()) {
			sum += *jt;
			jt++;
			while (sum > S) {
				
				sum -= *it;
				it++;
			}
			ans += jt - it;
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

int main() {
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;
	long long answer = 0;
	if(p == 2) {
		for(int i = 0; i < n; ++i)
			if((s[i] - '0') % 2 == 0)
				answer += i + 1;
	}
	else if(p == 5) {
		for(int i = 0; i < n; ++i)
			if((s[i] - '0') % 5 == 0)
				answer += i + 1;
	}
	else {
		map<int, int> suffix;
		++suffix[0];
		int power = 1, cur = 0;
		for(int i = n - 1; ~i; --i) {
			cur = (cur + power * (s[i] - '0')) % p;
			answer += suffix[cur];
			++suffix[cur];
			power = power * 10 % p;
		}
	}
	cout << answer;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    char N;
    cin >> N;
    int a = N - '0';
    a = a + 1;

    cout << char(a + '0') << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

for line in sys.stdin:
    array = [float(x) for x in line.split()]
    ar1 = array[0:3]
    ar2 = array[3:]
    i = ar1[0]
    ar1 = [x*ar2[0] for x in ar1]
    ar2 = [x*i for x in ar2]
    y = (ar1[2] - ar2[2])/(ar1[1]-ar2[1])
    ar1 = array[0:3]
    x = (ar1[2]-ar1[1]*y)/ar1[0]
    print('%.3f %.3f' % (round(x,3), round(y,3)))

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

ll n;

int main() {
    cin >> n;
    ll i = 1;
    for(i=1; ; ++i){
        ll sum = (i * (i+1)) / 2;
        if(sum > n) break;
    }

    //dbg(sum[i]);
    for(int k=1; k<=i; ++k){
        if((i*(i+1))/2 - n == k) continue;
        cout << k << "\n";
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,62)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

ll A, B, C, D;
map<ll, ll> res;

ll dfs(ll N) {
  if (res.count(N)) return res[N];
  ll result = LLINF;

  if (N%2==0) result = min(result, dfs(N/2)+A);
  else if (N%2==1) result = min(result,min(dfs(N/2)+A+D, dfs(N/2+1)+A+D));

  if (N%3==0) result = min(result, dfs(N/3)+B);
  else if (N%3==1) result = min(result,dfs(N/3)+B+D);
  else if (N%3==2) result = min(result,dfs(N/3+1)+B+D);

  if (N%5==0) result = min(result, dfs(N/5)+C);
  else if (N%5==1) result = min(result,dfs(N/5)+C+D);
  else if (N%5==2) result = min(result,dfs(N/5)+C+D*2);
  else if (N%5==3) result = min(result,dfs(N/5+1)+C+D*2);
  else if (N%5==4) result = min(result,dfs(N/5+1)+C+D);

  if (N<=pow(2,63)/D) result = min(result,D*N);
  // cout << N << "->" << result << endl;
  return res[N] = result;

}

int main() {
  ll T; cin >> T;
  rep(i,T) {
    ll N; cin >> N >> A >> B >> C >> D;
    res.clear();
    res[0] = 0; res[1] = D;
    ll result = dfs(N);
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 4404
import sys

for s in sys.stdin:
  p,q=map(int,s[:-1].split())
  F={}
  X=[]
  c=0
  p%=q
  while 1:
    if p in F or p==0: break
    F[p]=c
    a,p=divmod(p*10,q)
    X.append(a)
    c+=1
  F[0]=c
  i=F[p]
  print "".join(map(str,X))
  if c!=i: print " "*i+"^"*(c-i)

Measured memory_bytes: 4216
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#define int long long
#define maxn 100001
#define inf 20000000000011

using namespace std;

int n,m,dis[maxn],head[maxn],cnt;
bool vis[maxn];
int use[maxn];

int read()
{
	int ans;char c;bool o=false;
	while((c=getchar())<'0' || c>'9') if(c=='-') o=true ; ans=c-48;
	while((c=getchar())>='0' && c<='9') ans=(ans<<1)+(ans<<3)+c-48;
	return o==true?-ans:ans;
}

struct node
{
	int son,val,nxt;
}edge[maxn<<2];

void add(int x,int y,int z)
{
	edge[++cnt].son=y;
	edge[cnt].val=z;
	edge[cnt].nxt=head[x];
	head[x]=cnt;
}

bool spfa(int x)
{
	vis[x]=1;
	use[x]=1;
	for(int i=head[x];i;i=edge[i].nxt)
	{
		int y=edge[i].son,z=edge[i].val;
		if(dis[y]>dis[x]+z)
		{
			dis[y]=dis[x]+z;
			if(vis[y] || spfa(y)) return 1;
		}
	}
	vis[x]=0;
	return 0;
}

signed main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read(),z=read();
		add(x,y,z);
		add(y,x,-z);
	}
	bool ok=0;
    for(int i=1;i<=n;i++)
    {
        if(!use[i])
        {
            dis[i]=0;
            if(spfa(i))
                ok=1;
        }
    }
    if(ok)printf("No\n");
    else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 13952
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aizu
{
	class Program
	{
		static void Main(string[] args)
		{
			var numbers = new List<int>();
			while(true)
			{
				var value = int.Parse(ReadLine());
				if (value == 0)
				{
					break;
				}
				numbers.Add(value);
			}

			var max = numbers.Max();

			var counts1 = new int[max + 1];
			for(var i = 0; i <= max; i++)
			{
				counts1[i] = int.MaxValue - 1;
			}
			counts1[0] = 0;

			var counts2 = new int[max + 1];
			for (var i = 0; i <= max; i++)
			{
				counts2[i] = int.MaxValue - 1;
			}
			counts2[0] = 0;

			var sums = new List<int>();
			var index = 1;
			while(true)
			{
				var sum = index * (index + 1) * (index + 2) / 6;
				if(sum > max)
				{
					break;
				}
				sums.Add(sum);
				index++;
			}

			for(var i = 1; i <= max; i++)
			{
				for(var j = 0; j < sums.Count; j++)
				{
					if(i >= sums[j])
					{
						counts1[i] = Min(counts1[i], counts1[i - sums[j]] + 1);

						if(sums[j] % 2 == 1)
						{
							counts2[i] = Min(counts2[i], counts2[i - sums[j]] + 1);
						}
					}
				}
			}

			numbers.ForEach(value => WriteLine($"{counts1[value]} {counts2[value]}"));
		}
	}
}



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

int main()
{
    int n, m, h;
    cin >> n >> m;
    vector<string> p[n];
    string ver;

    for (int i = 0; i < m; i++) {
        cin >> h >> ver;
        p[h - 1].push_back(ver);
    }
    int ac, pa;
    ac = pa = 0;
    for (int i = 0; i < n; i++) {
        bool getac = false;
        int x = 0;
        for (auto ele : p[i]) {
            if (ele == "AC") {
                getac = true;
                ac++;
                break;
            }
            x++;
        }
        if (getac) pa += x;
    }
    cout << ac << " " << pa << "\n";
}


Measured memory_bytes: 10368
#include<stdio.h>

int main(){
    int a, b, i, ans;
    scanf("%d %d", &a, &b);
    for(i=0;i<2;i++){
        if(a>b){
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		String s = sc.nextLine();
		int[] i = ArrconvAtoi(s);
		i[0]++;
		s = sc.nextLine();
		int[] pc = ArrconvAtoi(s);
		
		int cakesum = 0;
		
			for (int c : pc) {
				cakesum += c;
			}
			
		System.out.println(cakesum % i[0] == 0 ? cakesum / i[0] : cakesum / i[0]  + 1);

	}
	
    private static int[] ArrconvAtoi(String s) {
        String[] strs = s.split(" ");
        int[] ints = new int[strs.length];
        int i = 0;
 
        for (String st : strs) {
            ints[i] = Integer.parseInt(st);
            i++;
        }
 
        return ints;
    }
}


Measured memory_bytes: 26192
from itertools import chain

l = [[] for _ in range(11)]
l[0] = list(map(str, range(1, 10)))
for i in range(10):
    for x in l[i]:
        last = int(x[-1])
        for m in {max(0, last-1), last, min(9 ,last+1)}:
            m = str(m)
            l[i+1].append(x+m)

q = list(map(int, chain(*l)))
q.sort()
# print(len(q))
K = int(input())

print(q[K-1])

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

int main(){
    long N;
    long A[100005]={};
    long long int summoney=0;
    long long int ans;

    cin >> N;
    for(long i=1;i<=N;i++){
        cin >> A[i];
        summoney += abs(A[i]-A[i-1]);
    }
    summoney+=abs(A[N]-0);

    for(long i=1;i<=N;i++){
        ans = summoney - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i+1]-A[i-1]);
        cout << ans << "\n";
    }
    

    return 0;
}

Measured memory_bytes: 2048
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, k, x, c = 0;
    cin >> n >> k;
    rep(i, n){
        cin >> x;
    }
    ll j = 0, f = 0;
    while(j < n){
        j += (k-1);
        if(j >= n)  break;
        c++;
        if(j == n-1){
            f = 1;
            break;
        }
    }
    if(f){
        cout << c << endl;
    }
    else{
        cout << c + 1 << endl;
    }
    return 0;
}



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

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

		sArray = S.split("");
		Arrays.sort(sArray);

		if (sArray[0].equals(sArray[1]) && sArray[2].equals(sArray[3]) && !sArray[1].equals(sArray[2])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 21716
N = int(input())
str = input()
str_list=list(str)
num_list=[]
ans_list=[]
num=0
for i in range (N):
  if str_list[i]=="E":
    num=num+1
    num_list.append(num)
  else:
    num_list.append(num)
   
for i in range (N):
  if i==0:
    ans=num_list[N-1]-num_list[i]
    ans_list.append(ans)
  else:
    ans=num_list[N-1]-num_list[i]+i-num_list[i-1]
    ans_list.append(ans)

print(min(ans_list))

Measured memory_bytes: 29828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        B.at(i) = A.at(i);
    }
    sort(B.begin(),B.end());
    for(int i=0; i<N; i++){
        int ans;
        if(B.at(N-1)==A.at(i)){
            ans = B.at(N-2);
        }else{
            ans = B.at(N-1);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3200
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong() - (long)(i + 1);
    }
    Arrays.sort(a);
    long ans = 0;
    if((n % 2) == 1) {
      int t = n / 2;
      for(int i = 0; i < n; i++) {
        ans += (Math.abs(a[i] - a[t]));
      }
    } else {
      int t = n / 2;
      long s = 0;
      for(int i = 0; i < n; i++) {
        s += (Math.abs(a[i] - a[t]));
      }
      ans = s;
      s = 0;
      for(int i = 0; i < n; i++) {
        s += (Math.abs(a[i] - a[t - 1]));
      }
      ans = Math.min(ans, s);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 88852
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	lint n,k,q;
	cin>>n>>k>>q;
	vector<lint>a(q),p(n);
	rep(i,q)cin>>a.at(i);
	rep(i,n)p.at(i)=0;
	rep(i,q)p.at(a.at(i)-1)++;
	rep(i,n){
		if(0<p.at(i)-(q-k)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
}


Measured memory_bytes: 2176
# -*- coding: utf-8 -*-
def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    X, N = list(map(int, input().split()))
    p = list(map(int, input().split()))

    return X, N, p


def main(X: int, N: int, p: list) -> None:
    """
    求解処理を行う.

    Args:\n
        X (int): 整数
        N (int): 長さ
        p (list): 整数列
    """
    # 求解処理
    ans = 0
    diff = 0
    while True:
        # Xとの差がdiffのうち小さいほう
        x_minus = X - diff
        if x_minus not in p:
            ans = x_minus
            break
        # Xとの差がdiffのうち大きいほう
        x_plus = X + diff
        if x_plus not in p:
            ans = x_plus
            break

        diff += 1

    # 結果出力
    print(ans)


if __name__ == "__main__":
    X, N, p = get_input()
    main(X, N, p)


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

using namespace std;

#define  input freopen("in.txt","r",stdin)
#define  output freopen("out.txt","w",stdout)

int main()
{
	//input;
	//output;

	string s;
	cin >> s;
	int n = s.size();
	s = "#"+s;

	if(s[1]!='1' || s[n]!='0')
	{
		cout << -1 << '\n';
		return 0;
	}
	for(int i = 1; i < n; i++)
	{
		if(s[i]!=s[n-i])
		{
			cout << -1 << '\n';
			return 0;
		}
	}
	s[n] = '1';
	queue<int>q;
	for(int i = 1; i <= n; i++)
		if(s[i]=='1') q.push(i);

	for(int i = 1; i < n; i++)
	{
		if(i==q.front()) q.pop();
		cout << i << ' ' << q.front() << '\n';
	}
	return 0;
}

Measured memory_bytes: 1916
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n;
const ll MOD = 1e9 + 7;
int a[1200];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		a[i] = i + 1;
	ll ans = 1;
	for (int i = 2; i <= n; ++i) {
		int cnt = 0;
		for (int j = 0; j < n; ++j) {
			while (a[j] % i == 0)
				a[j] /= i, ++cnt;
		}
		ans = (ans * (cnt + 1)) % MOD;
	}
	cout << ans << "\n";
	return 0;
}




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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
int num[110000];
int main()
{
	int N, M;
	cin >> N >> M;
	pairs(A)
	pairs(B)
		map<pair<int, int>, string> K;
	fx(M) {
		pairsp(A)
		pb(B,make_pair(bb,aa))
	}

	sorts(B)
	fx(M) {
		num[B.at(x).second]++;
		std::ostringstream sout;
		sout << std::setfill('0') << std::setw(6) << B.at(x).second;
		sout << std::setfill('0') << std::setw(6) << num[B.at(x).second];
		string sum = sout.str();
		K[B.at(x)] = sum;
	}
	fx(M) {
		ce(K[make_pair(A.at(x).second, A.at(x).first)])
	}
    return 0;
}



Measured memory_bytes: 14444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, D;
		N = sc.nextInt();
		D = sc.nextInt();
		int[][] X = new int[N][D];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				X[i][j] = sc.nextInt();
			}
		}

		int cnt = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				int sum = 0;
				for (int k = 0; k < D; k++) {
					sum += Math.abs(X[i][k] - X[j][k]) * Math.abs(X[i][k] - X[j][k]);
				}
				if (Math.sqrt(sum) % 1 == 0) {
					cnt++;
				}
			}
		}

		System.out.println(cnt);
	}
}


Measured memory_bytes: 21972
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += min(a[i],b[i])
  b[i] -=  min(a[i],b[i])
    
  ans += min(a[i+1],b[i])
  a[i+1] -= min(a[i+1],b[i])
print(ans)



Measured memory_bytes: 24196
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;

long long p3(long long n) {
	return n * n * n;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	if (k % 2 != 0) {
		printf("%lld\n", p3(n/k));
	}else {
		printf("%lld\n", p3(n/k) + p3(n/(k/2)-n/k));
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,j;
	char str[20];
	scanf("%s",&str);
	for(i=0;str[i]!='\0';i++){
	}
	for(j=i-1;j>=0;j--){
		printf("%c",str[j]);
	}
	printf("\n");
	return 0;
} 


Measured memory_bytes: 2032
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    string S;
    bool answer = false;

    cin >> S;
    rep(i, 3) if (S[i] == S[i + 1]) answer = true; 

    if (answer) cout << "Bad" << endl;
    else cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    // fast_io();
    cin >> N;
}
vector<char> seat;


void query(int idx){
    string q;
    cout << idx << endl;
    cin >> q;
    seat[idx] = q[0];
}

int solve(){
    seat.resize(N);
    
    int le = 0, ri = N-1;
    query(le);
    query(ri);
    int n=0;
    while(n<20){
        int mid = (le+ri)/2;
        query(mid);
        if(seat[mid]=='V') break;
        if(seat[le]==seat[mid] && ((mid-le+1)%2)==0 ) ri=mid;
        else if(seat[le]!=seat[mid] && ((mid-le+1)%2) ) ri=mid;
        else le=mid;
        n++;
    }
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
typedef long double ll;
int main(){
    int a,b; cin>>a>>b;
    int h,m; cin>>h>>m;
    int time = h*60+m;
    ll theta1 = (6*time);
    ll theta2 = (0.5*time);
    ll theta = abs(theta1 - theta2)*M_PI/180;
    ll ans = sqrt(a*a + b*b - 2*a*b*cos(theta));
    cout<<std::setprecision(20)<<ans; 
    

}

Measured memory_bytes: 4080
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(n - 1):
    if a[i + 1] == a[i] + 1:
        ans += c[a[i] - 1]
print(ans)

Measured memory_bytes: 3064
/*betaでやろう*/
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = 1e17;
const ll NEGA=-INF; 

ll ans = 0;
int cnt=0;

ll a[200000];
int used[1001];
ll dp[1001][1001];
ll sumx,sumy,sumz;
ll sx,sy,sz;
ll pa[200000];
int main() 
{ 
 string S;
 cin>>S;
 int w;
 cin>>w;
 rep(i,S.length()){
     if(i%w) continue;
     cout<<S[i];
 }
 cout<<endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long l = in.nextLong();
		long r = in.nextLong();
		if(r-l+1>=2019) System.out.println(0);
		else {
			long min = Long.MAX_VALUE;
			for(long i=l;i<=r;i++) {
				for(long j=i+1;j<=r;j++) {
					long tmp = ((i%2019)*(j%2019))%2019;
					if(tmp<min) min = tmp;
				}
			}
			System.out.println(min);
		}
		
		in.close();

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a=0;
    cin >> a;
 
    int pertu,perthr,perfiv;
    int count=0;
   
   vector<int> vec(a);
    for (int i = 0; i < a; i++) {
     cin >> vec.at(i);
     pertu=vec.at(i)%2;
     if(pertu==0){
      perthr=vec.at(i)%3;
      perfiv=vec.at(i)%5;
      if(perthr!=0&&perfiv!=0){
          cout << "DENIED"<< endl;
          count++;
          i=a;
      }
    }
    
    }
    if(count==0){
        cout << "APPROVED"<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

enum HinaArareColor {
    PINK,
    WHITE,
    GREEN,
    YELLOW,
    NUM_OF_HINA_ARARE_COLORS
};
    

int main() {
    int numOfArares = 0;
    std::cin >> numOfArares;
    char* hinaArareBag = new char[numOfArares];
    
    bool hinaArareColors[NUM_OF_HINA_ARARE_COLORS] = {false, false, false, false};
    int numOfColors = 0;
    for (int i = 0; i < numOfArares; i++) {
        std::cin >> hinaArareBag[i];
        switch (hinaArareBag[i]) {
            case 'P':
                hinaArareColors[PINK] = true;
                break;
            case 'W':
                hinaArareColors[WHITE] = true;
                break;
            case 'G':
                hinaArareColors[GREEN] = true;
                break;
            case 'Y':
                hinaArareColors[YELLOW] = true;
                break;
        }
        numOfColors = 0;
        for (int indexOfColor = 0; indexOfColor < NUM_OF_HINA_ARARE_COLORS; indexOfColor++) {
            if (hinaArareColors[indexOfColor]) {
                numOfColors++;
            }
        }
        if (numOfColors == NUM_OF_HINA_ARARE_COLORS) {
            break;
        }
    }
    if (numOfColors == 3) {
        std::cout << "Three" << std::endl;
    } else if (numOfColors == 4) {
        std::cout << "Four" << std::endl;
    }
    
    delete[] hinaArareBag;
}


Measured memory_bytes: 3128
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))

ans = [[0 for i in range(w)] for j in range(h)]
for i, row in enumerate(s):
    for j, index in enumerate(row):
        if i == j == 0:
            if s[i][j] == "#":
                ans[i][j] = 1
        elif i == 0:
            if s[i][j] == s[i][j - 1]:
                ans[i][j] = ans[i][j - 1]
            else:
                ans[i][j] = ans[i][j - 1] + 1
        elif j == 0:
            if s[i][j] == s[i - 1][j]:
                ans[i][j] = ans[i - 1][j]
            else:
                ans[i][j] = ans[i - 1][j] + 1
        else:
            if s[i][j] == s[i - 1][j]:
                a1 = ans[i - 1][j]
            else:
                a1 = ans[i - 1][j] + 1
            if s[i][j] == s[i][j - 1]:
                a2 = ans[i][j - 1]
            else:
                a2 = ans[i][j - 1] + 1
            ans[i][j] = min(a1, a2)

print((ans[-1][-1] + 1) // 2)
        

Measured memory_bytes: 3316
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
char A[110][110];
int f[110][110];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),m=gi();
	for(int i=1;i<=n;++i)scanf("%s",A[i]+1);
	memset(f,63,sizeof f);f[1][1]=A[1][1]=='#';
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(i>1||j>1)
				f[i][j]=std::min(f[i-1][j]+(A[i][j]=='#'&&A[i-1][j]=='.'),f[i][j-1]+(A[i][j]=='#'&&A[i][j-1]=='.'));
	printf("%d\n",f[n][m]);
	return 0;
}


Measured memory_bytes: 892
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

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

	if (B % A)
	{
		cout << B-A << endl;
	}
	else
	{
		cout << A + B << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using ld = long double;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int maxS = 1e5 + 7;
pair<ll, ll> arr[maxS];
ll DP[2][maxS];

int main() {
    fastio();

    ll N, W;
    cin >> N >> W;
    for(int i = 0;i < N;i ++) {
        cin >> arr[i].first >> arr[i].second;
    }
    for(int i = 0;i <= W;i ++) {
        DP[0][i] = 0;
    }
    DP[0][arr[0].first] = arr[0].second;
    int a = 1, b = 0;
    for(int i = 1;i < N;i ++) {
        for(int j = 0;j <= W;j ++) {
            DP[a][j] = DP[b][j];
            if(j-arr[i].first >= 0) {
                DP[a][j] = max(DP[a][j], DP[b][j - arr[i].first] + arr[i].second);
            }
        }
        swap(a, b);
    }
    ll MAX = 0;
    for(int i = 0;i <= W;i ++) {
        MAX = max(DP[b][i], MAX);
    }
    cout << MAX << "\n";
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  double rad = c * M_PI / 180;
  double S = a * b * sin(rad) / 2;
  double h = b * sin(rad);
  double a_dash = a - b * cos(rad);
  double L = a + b + sqrt(h * h + a_dash * a_dash);
  cout << fixed << setprecision(5);
  cout << S << " " << L << " " << h << endl;

  return 0;
}


Measured memory_bytes: 3588
"use strict";
    
const main = arg => {
    const times = arg.split("\n").map(n=>parseInt(n));
    let min = 10;
    
    let sum = 0;
    
    for(let i=0; i<5; i++) {
        let digitOne   = String(times[i]).split("");
        digitOne = parseInt(digitOne[digitOne.length - 1]);
        
        let digitMinus = 10 - digitOne;
        sum += parseInt(times[i]);
        
        if(digitMinus !== 10) {
            sum += digitMinus;
        }
        
        if(digitMinus !== 10 && digitOne < min) {
            min = digitOne;
        }
    }

    console.log(parseInt(sum - (10 - min)));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int N;
  cin >> N;
  long long int B =1;
  long long int C=1;
  for(long long int i=0;i<18;i++){
    C=C*10;
  }
  
  vector<long long int> A(N);
  for(long long int i=0;i<N;i++){
    cin >> A[i];
    if(A[i]==0){
      cout << 0 << endl;
      return 0;
    }
  }
  for(long long int i=0;i<N;i++){
    if(A[i]>C/B){
      cout << -1 << endl;
      return 0;
    }
    else{
      B*=A[i];
    }
  }
  cout << B << endl;
}
  


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll a, ll b){
   if(b == 0) return a;
   return gcd(b, a % b);
}
int main(){
   int h,w; cin >> h >> w;
   char s [h + 2][w + 2];
   rep(i,h){
      rep(j,w){
      cin >> s[i + 1][j + 1];
      //cout << s[i + 1][j + 1];
      }
      //cout << endl;
   }

   bool flag = true;
   _rep(i,1,h + 1)_rep(j,1,w + 1){
      if(s[i][j] == '#')
         if(s[i - 1][j] == '#' || s[i + 1][j] == '#' 
         || s[i][j - 1] == '#' || s[i][j + 1] == '#'){
            continue;
         }else{
            flag = false;
         }
      }
   if(flag)cout << "Yes" << endl;
   else cout << "No" << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll h;
  cin >> h;
  ll ans = 0;
  ll t = 1;
  while(h>0){
    ans += t;
    t*=2;
    h /= 2;
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
sum_jpy = 0
jpy_per_btc = 380000
for _ in range(n):
    x, u = input().split()
    if u == 'JPY':
        sum_jpy += int(x)
    else:
        sum_jpy += float(x) * jpy_per_btc
print(sum_jpy)

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

int main(){
	string s;
	cin >> s;

	if(s.at(0) == s.at(1)) cout << "Bad" << endl;
	else if(s.at(1) == s.at(2)) cout << "Bad" << endl;
	else if(s.at(2) == s.at(3)) cout << "Bad" << endl;
	else cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 1000006, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(4), cout << fixed;

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

    int di = 0;
    int i = 1;
    int ans = 1;
    while (di <= x && i <= n) {
        di = di + l[i - 1];
        ++i;
        if (di <=x)
            ++ans;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstdlib>
using namespace std;

int N,K;
int main (){
    cin >> N >> K;
    int x;
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> x;
        sum += min( abs(K - x) , x) * 2;
    }
    cout << sum << endl;
    return 0;
}


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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    while (true) {
      if (A.at(i) % 2 == 0) {
        cnt++;
        A.at(i) /= 2;
      } else break;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int n,m;
	long long x[100000];
	long long y[100000];

	scanf("%d %d", &n, &m);
	for(int i=0;i<n;i++){
		scanf("%lld", &x[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%lld", &y[i]);
	}

	long long sumx = 0;
	long long sumy = 0;
	for(int i=0;i<n;i++){
		sumx += i*x[i] + (n-1-i)*(-x[i]);
	}
	sumx %= 1000000007;
	for(int i=0;i<m;i++){
		sumy += i*y[i] + (m-1-i)*(-y[i]);
	}
	sumy %= 1000000007;

	long long ans = (sumx * sumy)%1000000007;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 1000010
#define mo 998244353
#define LL long long
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
LL i,j,k,l,n,m,ans,temp;
LL jc[N],ny[N];
LL ksm(LL x,LL y){
	LL res=1;
	for(;y;y>>=1,x=(x*x)%mo)if(y&1)res=(res*x)%mo;
	return res;
}
void prepare(){
	LL i;
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	fo(i,2,N-10)jc[i]=(jc[i-1]*i)%mo;
	ny[N-10]=ksm(jc[N-10],mo-2);
	fd(i,N-11,2)ny[i]=(ny[i+1]*(i+1))%mo;
}
LL C(LL n,LL m){return ((jc[m]*ny[n])%mo*ny[m-n])%mo;}
LL dis(LL n,LL m){return C(n,n+m);}
int main(){
	prepare();
	scanf("%lld%lld",&n,&m);
	if(n<m)swap(n,m);
	fo(i,1,m){
		l=(dis(n-i,m-i)*dis(i,i))%mo;
		temp=(temp+l)%mo;
	}
	l=(ksm(dis(n,m),mo-2)*ny[2])%mo;
	ans=(n+temp*l)%mo; 
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 15872
N = int(input())
rest_dict = {}
city_list = []
for i in range(N):
    city, score = input().split()
    if city not in city_list:
        city_list.append(city)
        rest_dict[city] = [[int(score), i]]
    else:
        rest_dict[city].append([int(score), i])

city_list = sorted(city_list)
for city in city_list:
    rest_list = rest_dict[city]
    rest_list = sorted(rest_list, reverse=True)
    for rest in rest_list:
        print(rest[1]+1)

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

using namespace std;

int main()
{
	int n;
	cin >>n;
	vector<long long> a(3 * n);

	for(int i = 0; i < 3 * n; ++i)
		cin >>a[i];
	sort(begin(a), end(a));
	long long ans = 0;
	for(int i = n; i < 3 * n; i += 2){
		ans += a[i];
	}
	cout <<ans <<'\n';
}


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

int main()
{
  int n;
  int ans = 1e+9;

  cin >> n;

  for(int i = 1; i < n; i++){
    int a = i, b = n - i; 
    int sa = 0, sb = 0;

    while(a != 0){
      sa += a % 10;
      a /= 10;
    }

    while(b != 0){
      sb += b % 10;
      b /= 10;
    }

    ans = min(ans, sa + sb);
  }

  cout << ans << endl;

  return 0;
}


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

void S(){puts("No");exit(0);}
int main()
{
  int N;
  cin >>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >>a[i];
  }
  
  int ans=0;

  for(int i=0;i<N;i++){
    int j=0;
    int x=1;
    while(1){
      if((a[i]&x)==x){
        ans+=j;
        break;
      }
      j++;
      x*=2;
    }
  }
  cout <<ans<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
multiset<pair<int,int>> add,del;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>s;
		int cur=0,mi=0;
		FORR(c,s) {
			if(c=='(') cur++;
			else cur--;
			mi=min(mi,cur);
		}
		
		if(cur>=0) add.insert({-mi,cur});
		if(cur<0) del.insert({-(mi-cur),-cur});
	}
	
	int cur=0;
	FORR(a,add) {
		if(cur-a.first<0) return _P("No\n");
		cur+=a.second;
	}
	x=cur;
	
	cur=0;
	FORR(a,del) {
		if(cur-a.first<0) return _P("No\n");
		cur+=a.second;
	}
	if(x==cur) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 50448
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>


using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007
#define INF INT_MAX/2
#define int long long

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}


int atcoder() {
    int n,k;
    cin >> n >> k;
    Vi a(n);
    REP(i,0,n) cin >> a[i];
    int x=0,cnt=0,ans=0;
    
    int mask;
    for(mask=1; mask<=k; mask = mask<<1){
        REP(i,0,n) if(mask&a[i]) cnt++;
        if(cnt*2<n) x += mask;
        cnt=0;
    }
    
    
    for(;mask!=0;mask=mask>>1){
        if((x&mask) && !(k&mask)) x -= mask;
        else if(!(x&mask) && (k&mask)) break;
    }
    
    REP(i,0,n) ans += x^a[i];
    cout << ans << ENT;
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin>>s>>t;
    int cnt = 0;
    vector<int >v;
    int k = 0;
  //  v.push_back(t.size());
    for(int i = 0; i <s.size()-t.size()+1; i++)
    {
        cnt = 0;
        for(int j = 0; j<t.size();  j++)
        {
            if(s[i+j]!=t[j])
            {
                cnt++;
            }
        }
        v.push_back(cnt);
    }
    sort(v.begin(), v.end());
    cout<<v[0]<<endl;
}


Measured memory_bytes: 3528