akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] ab = new int[m][2];
		for(int i=0;i<m;i++) {
			ab[i][0] = in.nextInt()-1;
			ab[i][1] = in.nextInt()-1;
		}
		long[] ans = new long[m];
		List<long[]> uft = new ArrayList<>();
		for(int i=0;i<n;i++) {
			long[] tmp = new long[2];
			tmp[0] = i;
			tmp[1] = 1;
			uft.add(tmp);
		}
		ans[m-1] = ((long)n*(long)(n-1))/2;
		for(int i=m-2;i>=0;i--) {
			long[] tmp1 = find(uft,ab[i+1][0]);
			long[] tmp2 = find(uft,ab[i+1][1]);
			if(tmp1[0]!=tmp2[0]) {
				ans[i] = ans[i+1] - (long)tmp1[1]*tmp2[1];
				union(uft,ab[i+1][0],ab[i+1][1]);
			}else {
				ans[i] = ans[i+1];
			}
			
		}
		for(int i=0;i<m;i++) {
			System.out.println(ans[i]);
		}
		in.close();
	}
	
	public static long[] find(List<long[]> uft,int idx) {
		long[] node = uft.get(idx);
		if(node[0]==idx) return node;
		else {
			int parentIdx = (int)node[0];
			uft.set(idx, uft.get(parentIdx));
			return find(uft,parentIdx);
		}
	}
	
	public static long[] union(List<long[]> uft,int idx1,int idx2) {
		long[] node1 = find(uft,idx1);
		long[] node2 = find(uft,idx2);
		node1[1] = node1[1] + node2[1];
		node2[0] = node1[0];
		uft.set(idx1, node1);
		uft.set(idx2, node2);
		return node1;
	}

}


Measured memory_bytes: 102352
def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":res=(res*a) %p
  return res

N = int(input())
a = list(map(int,input().split()))
b = set()
for c in a:
    if c in b:b.remove(c)
    else:b.add(c)

if N%2==1:
    if b == {0}:print(power_func(2,N//2,10**9+7))
    else:print(0)
else:
    if len(b) == 0:print(power_func(2,N//2,10**9+7))
    else:print(0)

Measured memory_bytes: 13812
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, Y = MAP()

for i in range(N+1):
	for j in range(N+1-i):
		remain = Y - 10000*i - 5000*j
		k = N - i - j
		if k >= 0 and remain >= 0 and k*1000 == remain:
			print(i, j, k)
			exit()

print(-1, -1, -1)


Measured memory_bytes: 23568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
    string s;
    cin>>s;
    if('A'<=s[0] && s[0]<='Z'){
        cout<<'A'<<endl;
    }
    if('a'<=s[0] && s[0]<='z'){
        cout<<'a'<<endl;
    }
    return 0;
}

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

int l[2005][2005];
int r[2005][2005];
int u[2005][2005];
int b[2005][2005];

int main(){
	int H,W;
	cin >> H >> W;
	
	vector<string> field(H);
	
	rep(i,H){
		cin >> field[i];
	}
	
	rep(i,H){
		rep(j,W){
			if (field[i][j] == '#'){
				l[i][j] = 0;
			}else if(j == 0){
				l[i][j] = 1;
			}else {
				l[i][j] = l[i][j - 1] + 1;
			}
		}
	}
	
	rep(i,H){
		for (int j = W-1; j >= 0 ; --j) {
			if(field[i][j] == '#'){
				r[i][j] = 0;
			}else if (j == W-1){
				r[i][j] = 1;
			}else{
				r[i][j] = r[i][j+1] + 1;
			}
		}
	}
	
	rep(j,W){
		rep(i,H){
			if(field[i][j] == '#'){
				u[i][j] = 0;
			}else if(i == 0){
				u[i][j] = 1;
			}else{
				u[i][j] = u[i-1][j] +1;
			}
		}
	}
	
	rep(j,W){
		for (int i = H-1; i >=0 ; --i) {
			if(field[i][j] == '#'){
				b[i][j] = 0;
			}else if (i == H-1){
				b[i][j] = 1;
			}else{
				b[i][j] = b[i+1][j] + 1;
			}
		}
	}
	
	ll ans[1005][1005];
	
	ll res = 0;
	
	rep(i,H){
		rep(j,W){
			ans[i][j] = l[i][j] + r[i][j] + u[i][j] + b[i][j] - 3;
			res = max(res, ans[i][j]);
		}
	}
	
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 67072
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll sum = accumulate(begin(a), end(a), 0LL);
    vector<ll> ans(n);
    ans[0] = sum;
    for(int i = 1; i < n; i += 2){
        ans[0] -= a[i] * 2;
    }
    for(int i = 1; i < n; i++){
        ans[i] = a[i - 1] * 2 - ans[i - 1];
    }
    cout << ans[0];
    for(int i = 1; i < n; i++){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		
		for(int i=2;i<100;i++){
//			println(i+":"+phi(i));
		}
		
		for(;;){
			int a1=sc.nextInt();
			int m1=sc.nextInt();
			int a2=sc.nextInt();
			int m2=sc.nextInt();
			int a3=sc.nextInt();
			int m3=sc.nextInt();
			if(a1==0&&m1==0&&a2==0&&m2==0&&a3==0&&m3==0)
				break;
			// ans=lcm(Ó(m1),Ó(m2),Ó(m3))
//			println(phi(m1)+"");
//			println(phi(m2)+"");
//			println(phi(m3)+"");
			
			long r;
			long n1,n2,n3;
			for(r=a1,n1=1;r!=1;n1++)
				r=(r*a1)%m1;
			for(r=a2,n2=1;r!=1;n2++)
				r=(r*a2)%m2;
			for(r=a3,n3=1;r!=1;n3++)
				r=(r*a3)%m3;
//			println(n1+"");
//			println(n2+"");
//			println(n3+"");
			
			long lcm1=lcm(n1, n2);
			long lcm2=lcm(lcm1, n3);
//			println("");
//			println(lcm1+"");
			println(lcm2+"");
//			println("");
		}
		sc.close();
	}

	long lcm(long m, long n){
		return m/gcd(m, n)*n;
	}

	long gcd(long m, long n){
		for(; n!=0;){
			long r=m%n;
			m=n;
			n=r;
		}
		return m;
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int a, b;
  cin >> a >> b;

  if (a % 3 == 0) cout << "Possible" << endl;
  else if (b % 3 == 0) cout << "Possible" << endl;
  else if ((a + b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;


  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        int max = 0;
        for(int i = 0; i < n; i++) {
        	int tmp = sc.nextInt();
        	sum += tmp;
        	max = Math.max(max, tmp);
        }
        if( max < (sum-max) ) {
            System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
	}
}


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

int main() {
  int N,d,i,count=0,dist[110]={0};
  
  cin >> N;
  
  for(i=0;i<N;i++) {
    cin >> d;
    dist[d]++;
  }
  
  for(i=0;i<110;i++) {
    if(dist[i]!=0) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(void)
{
	int n;
	
	scanf("%d",&n);
	
	int A[n];
	int i,j,temp=0,c=0;
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	
	for(i=0;i<n;i++)
	{
		for(j=n-1;j>=i+1;j--)
		{
			if(A[j]<A[j-1])
			{
				temp=A[j];
				A[j]=A[j-1];
				A[j-1]=temp;
				c++;
			}
		}
	}
	
	for(i=0;i<n;i++)
	{
	    if(i>=1)
	    {
	        printf(" ");
	    }
		printf("%d",A[i]);
	}
	printf("\n");
	
	printf("%d\n",c);
	
	return 0;
}


Measured memory_bytes: 2100
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
bool solve(void){
	int n,i,j;cin>>n;
	if(n==0){return false;}
	vector<int>ta(n+1);
	for(i=0;i<n;i++){string s;cin>>s;ta[i]=s.size();}
	ta[n]=9999999;
	int tanka[5]={5,7,5,7,7};
	for(i=0;i<n;i++){
		int bas=0,num=0;
		for(j=i;;j++){
			num+=ta[j];
			if(num>tanka[bas]){break;}
			if(num==tanka[bas]){bas++;num=0;}
			if(bas==5){cout<<i+1<<endl;return true;}
		}
	}
	
	return true;
}
int main(void){
	while(solve()){}
}


Measured memory_bytes: 3188
def main():
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  if 0 in nums:
    print(0)
    return
  else:
    for i in nums:
      result *= i
      if result > 1000000000000000000:
        print(-1)
        return
    print(result)
    return


if __name__ == "__main__":
  main()

Measured memory_bytes: 21652
#include<stdio.h>

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

  int tmp = n;
  int www;
  int sum = 0;
  while( n > 0 ){
    www = n % 10;
    sum += www;
    n = n / 10;
  }

  if( tmp % sum == 0 ) puts("Yes");
  else puts("No");

  return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#define ll unsigned long long
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll int t;
  cin>>t;
  if(t%1000==0)cout<<0<<endl;
  else
  cout<<1000-(t%1000)<<endl;
  return 0;
} 


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
    int n,x;
    int l[100];
    int total=0;
    int ans=1;

    scanf("%d",&n);
    scanf("%d",&x);

    for(int i=0;i<n;i++){
      scanf("%d",&l[i]);
      total += l[i];
      if(total>x){
        break;
      } else {
        ans++;
      }
    }
    printf("%d",ans);
}
    

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN=1e5+5;
int tot,head[MAXN];
bool mark[MAXN];
int ans1,ans2;
int n;
int num;
int slit;
int father;
struct Edge
{
    int from,to;
    int next;
}e[MAXN*2];
void add(int u,int v)
{
    e[tot].from=u;
    e[tot].to=v;
    e[tot].next=head[u];
    head[u]=tot++;
}
bool dfs(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        if(to==n) return true;
        if(dfs(to,rt))
        {
            mark[to]=true;
            return true;
        }
    }
    return false;
}
int dfs2(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        if(!mark[to]) continue;
        else
        {
            num++;
            if(num==slit)
            {
                father=rt;
                return to;
            }
            else
                return dfs2(to,rt);
        }
    }
}
void dfs3(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        ans1++;
        dfs3(to,rt);
    }
}
void dfs4(int rt,int fa)
{
    for(int i=head[rt];i!=-1;i=e[i].next)
    {
        int to=e[i].to;
        if(to==fa) continue;
        ans2++;
        dfs4(to,rt);
    }
}
int main()
{
    while(cin>>n)
    {
        memset(head,-1,sizeof(head));
        memset(mark,false,sizeof(mark));
        tot=0;
        int u,v;
        for(int i=1;i<=n-1;i++)
        {
            cin>>u>>v;
            add(u,v);add(v,u);
        }
        dfs(1,0);
        mark[1]=true;mark[n]=true;
        int cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(mark[i])
            {
                cnt++;
            }
        }
        if(cnt&1)
            slit=cnt/2+1;
        else slit=cnt/2;
        num=1;
        int id=dfs2(1,0);
        int child;
        for(int i=head[id];i!=-1;i=e[i].next)
        {
            int to=e[i].to;
            if(mark[to]&&to!=father)
                child=to;
        }
        ans1=0;ans2=0;
        dfs3(id,child);
        dfs4(child,id);
        if(ans1>ans2)
            cout<<"Fennec"<<endl;
        else
            cout<<"Snuke"<<endl;
    }
    return 0;
}

Measured memory_bytes: 7808
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)

int main(void)
{
    int count = 0;
    char s[32] = {0} ;
    cin >> s ;
    //cout << s << endl;
    REP(i,3)
    {
        if(s[i] == 'o')
        {
            count ++ ;
        }
    }
    
    printf("%d", 700 + 100 * count);
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
	int i,j;

	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N,M,K;
	cin >> N >> M >> K;
	vector<ll>a(N),b(N);
	for(i=0;i<N;i++) cin >> a[i];
	for(i=0;i<N;i++) cin >> b[i];

	vector<P>c(N);
	for(i=0;i<N;i++) c.push_back(P(a[i],b[i]));
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());

	ll ans=0;
	for(i=0;i<(1<<N);i++){
		ll x=0;
		int m=M,k=K;
		if(__builtin_popcount(i)==K){
			for(j=0;j<N;j++){
				if(i&(1<<j)){
					if(m>=c[j].second){
						x+=(c[j].first)*(c[j].second);
					    m-=c[j].second;
						k--;
						if(k==0) break;
					}else{
						x+=(c[j].first)*m;
						m=0;
						break;
					}
			    }
		    }

			ans=max(ans,x+m);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1208
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

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


template <typename T>
class segment_tree{
    private:
        static int calc_size(int n){
            int m = 1;
            while(m < n){
                m *= 2;
            }
            return m;
        }

        T query(int s, int t, int i, int l, int r) const {
            if(r <= s || t <= l){
                return init;
            }

            if(s <= l && r <= t){
                return node[i];
            }

            int m = l + (r - l) / 2;
            T vl = query(s, t, i * 2 + 1, l, m);
            T vr = query(s, t, i * 2 + 2, m, r);
            return f(vl, vr);
        }

    public:
        int n;
        vector<T> node;
        T init;
        function<T(T, T)> f;

        segment_tree(int n, T init, function<T(T, T)> f)
            : n(calc_size(n)), node(calc_size(n) * 2, init), init(init), f(f){}

        void update(int i, const T& x){
            i += (n - 1);
            node[i] = x;
            while(i > 0){
                i = (i - 1) / 2;
                node[i] = f(node[2*i+1], node[2*i+2]);
            }
        }

        //[s, t)
        T query(int s, int t) const {
            return query(s, t, 0, 0, n);
        }
};

signed main(){
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        a[i] -= k;
    }

    vector<int> s(n+1);
    rep(i, n){
        s[i+1] = s[i] + a[i];
    }

    vector<int> t = s;
    sort(t.begin(), t.end());
    map<int, int> encode;
    vector<int> decode;
    int m = 0;
    rep(i, n+1){
        if(encode.find(t[i]) == encode.end()){
            encode.emplace(t[i], m++);
            decode.push_back(t[i]);
        }
    }

    int ans = 0;
    //Range Sum Query
    segment_tree<int> st(m+1, 0, [](int a, int b){return a+b;});
    for(int i = n; i >= 0; i--){
        int x = encode[s[i]];
        int cnt = st.query(x, x+1);
        ans += st.query(x, m);
        st.update(x, cnt+1);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int a,b,c;cin>>a>>b>>c;
    bool res=0;
    for(int i=1;i<b;i++){
        if(a*i%b==c)res=1;
    }
    if(res)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3632
A = int(input())
B = int(input())
C = int(input())
X = int(input())
var = 0
for i in range(A+1):
  if (X-500*i) >= 0:
    Y = X-500*i
    for j in range(B+1):
      if ((Y-100*j) >= 0) and (((Y-100*j)//50) <= C):
        var = var+1
print(var)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){return a%1000000007;};
typedef pair<int,int> i_i;

#define N 100005
int n;
vector<int>map[N];
bool already[N];
stack<int> s;

int main(){
    cin>>n;
    for(int i=1;i<=n-1;i++){
        int a,b;cin>>a>>b;
        map[a].push_back(b);
        map[b].push_back(a);
    }
    for(int i=1;i<=n;i++)already[i]=false;
    s.push(1);already[1]=true;
    while(true){
        int t=s.top();
        int i=-10;
        for(i=0;i<=map[t].size()-1;i++){
            if(already[map[t][i]]==false)break;
        }
        if(i!=map[t].size())s.push(map[t][i]),already[map[t][i]]=true;
        else s.pop();
        
        if(s.top()==n)break;
    }
    int mid=s.size()/2;
    for(int i=1;i<=mid-1;i++){
        s.pop();
    }
    int mida=s.top();s.pop();
    int midb=s.top();
    
    vector<int>p,q;
    for(int i=0;i<=map[mida].size()-1;i++){
        if(map[mida][i]!=midb)p.push_back(map[mida][i]);
    }map[mida].clear();
    if(!p.empty())for(int i=0;i<=p.size()-1;i++)map[mida].push_back(p[i]);
    
    
    for(int i=0;i<=map[midb].size()-1;i++){
        if(map[midb][i]!=mida)q.push_back(map[midb][i]);
    }map[midb].clear();
    if(!q.empty())for(int i=0;i<=q.size()-1;i++)map[midb].push_back(q[i]);
    
    queue<int>F,S;
    int f=1,s=1;
    for(int i=1;i<=n;i++)already[i]=false;
    F.push(1);S.push(n);
    already[1]=true;already[n]=true;
    
    while(!F.empty()){
        int t=F.front();
        if(!map[t].empty())for(int i=0;i<map[t].size();i++){
            if(already[map[t][i]]==false){
                F.push(map[t][i]);
                f++;
                already[map[t][i]]=true;
            }
        }
        F.pop();
    }
    while(!S.empty()){
        int t=S.front();
        if(!map[t].empty())for(int i=0;i<map[t].size();i++){
            if(already[map[t][i]]==false){
                S.push(map[t][i]);
                s++;
                already[map[t][i]]=true;
            }
        }
        S.pop();
    }
    
    if(f>s)cout<<"Fennec";
    else cout<<"Snuke";
    
    
    
    
    /*for(int i=1;i<=n;i++){
        cout<<i<<":";
        if(!map[i].empty()){
        for(int j=0;j<=map[i].size()-1;j++){
            cout<<map[i][j]<<" ";
        }
        }
        cout<<endl;
     }*/
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n, m;
  cin >> n >> m;
  set<i64> fs;
  for (int i = 2; i * i <= m; ++i) {
    if (m % i == 0) {
      fs.insert(i);
      fs.insert(m / i);
    }
  }
  fs.insert(m);
  auto find = [&]() -> i64 {
    for (auto it = fs.rbegin(); it != fs.rend(); ++it) {
      i64 g = *it;
      if (n <= m / g) return g;
    }
    return 1;
  };
  cout << find() << endl;
}


Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static long[][] dp;
    static int ind=1;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    int m=gi();
	    int[] P=new int[m];
	    int[] Y=new int[m];
	    ArrayList<Integer>[] li=new ArrayList[n+1];

        for (int i=0; i< m;i++) {
        	P[i]=gi();
        	Y[i]=gi();
            if(li[P[i]]!=null) {
            	li[P[i]].add(Y[i]);
            } else {
            	ArrayList<Integer> l=new ArrayList<Integer>();
            	l.add(Y[i]);
            	li[P[i]]=l;
            }
        }

        for(int i=1; i<=n;i++) {
        	List<Integer> ll=li[i];
        	if(ll!=null &&ll.size()>1) Collections.sort(ll);
        }

        StringBuilder sb=new StringBuilder();
        for (int i=0; i<m;i++) {
        	int p=P[i];
        	List<Integer> yl=li[p];
            int y=Collections.binarySearch(yl, Y[i])+1;
        	sb.append(String.format("%06d%06d",p, y));
        	sb.append(System.getProperty("line.separator"));
        }
        System.out.println(sb);

        //System.out.println(max);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 78772
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int r=0;
    int maxm=-2000000000;
    cin >> n;
    cin >> r;
    int minm=r;
    for(int i=1;i<n;i++){
        cin >> r;
        maxm=max(maxm,r-minm);
        minm=min(minm,r);
    }
    cout << maxm << endl;
    return 0;
}


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

void main_()
{
    ll N;
    cin >> N;

    map<ll, ll> m; // 棒の長さ、本数
    for (ll i = 0; i < N; ++i) {
        int A;
        cin >> A;
        m[A]++;
    }

    vector<pair<ll, ll>> v; // 棒の長さ、本数
    copy_if(begin(m), end(m), back_inserter(v), [](auto&& m) { return m.second >= 2; });

    ll ans;
    if (v.empty()) {
        ans = 0;
    } else if (v.size() == 1) {
        ans = (v[0].second < 4) ? 0 : v[0].first * v[0].first;
    } else {
        auto v1 = v.back();
        auto v2 = v[v.size() - 2];
        if (v1.second >= 4) {
            ans = v1.first * v1.first;
        } else {
            ans = v1.first * v2.first;
        }
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
string add_0(string s) {
	while (s.size() != 6)
		s = '0'+s;
	return s;
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int, int>> mp;
	vector<pair<int, string>> id;
	for (int i = 0; i < m; i++)
	{
		int a,b,c=i+1;
		cin >> a >> b;
		mp.push_back(make_tuple(a, b, c));
	}
	sort(mp.begin(), mp.end());
    int cnt=1;
    int currx=0;
	for (tuple<int, int, int> t:mp)
    {   string s,up,down;
		int x, y, z;
		tie(x, y, z) = t;
        if(currx==x)
          cnt++;
        else
          cnt = 1;
		up = to_string(x);
		down = to_string(cnt);
		s = add_0(up) + add_0(down);
		id.push_back(make_pair(z, s));
     	currx = x;
	}
    sort(id.begin(),id.end());
	for (pair<int, string> t : id) {
		int x;
		string y;
		tie(x, y) = t;
		cout << y << endl;
	}
}


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

typedef long long ll;
#define rep1(i, n) for(int i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(int i = 0; i <=(ll)(n); i++)

int main(){
    int n;
    cin >> n;
    int x[20][20];
    int y[20][20];
    int a[20];
    bool all_not_told = true;
    rep1(i, n){
        cin >> a[i];
        if(a[i] > 0) all_not_told = false;
        rep1(j,a[i]) cin >> x[i][j] >> y[i][j];
    }
    
    if(all_not_told){
        cout << n << endl;
        return 0;
    }

    if(n == 1) cout << 1 << endl;

    int max_honest_count = 0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for(int bit = 1; bit < (1<<n); ++bit){        
        int honest_count = 0;
        bool contradiction = false;
        rep1(i, n){
            if(bit & (1<<(i-1))) { // i が bit に入るかどうか
                honest_count++;
                rep1(j, a[i]){
                    if( ((bit >> (x[i][j]-1) ) & 1) ^ y[i][j]){
                        contradiction = true;
                        break;
                    }
                }
            }
        }
        if(!contradiction) max_honest_count = max(honest_count, max_honest_count);
    }
    cout << max_honest_count << endl;
    return 0;
}

Measured memory_bytes: 3124
s,t = input(),input()
n,m=len(s),len(t)
dp = [[0]*(n+1) for _ in range(m+1)]

for i in range(m):
    for j in range(n):
        if s[j] == t[i]:
            dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1])
        
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j], dp[i][j+1])

ans = ""
count = 0
while count != dp[-1][-1]:
    if dp[m][n] == dp[m-1][n]:
        m -= 1
    elif dp[m][n] == dp[m][n-1]:
        n -= 1
    else:
        ans += t[m-1]
        count += 1
        m -= 1
        n -= 1

print(ans[::-1])

Measured memory_bytes: 113244
#include <iostream>

using namespace std;

int main()
{
    char c;
    cin >> c;

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string a,b; cin>>a>>b;
	if(a.size()>b.size()) return cout<<"GREATER"<<endl,0;
	else if(a.size()<b.size()) return cout<<"LESS"<<endl,0;
	else{
		rep(i,a.size()){
			if(a[i]>b[i]) return cout<<"GREATER"<<endl,0;
			else if(a[i]<b[i]) return cout<<"LESS"<<endl,0;
			else{
				if(i==a.size()-1) return cout<<"EQUAL"<<endl,0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
d=input().split()
for _ in range(int(input())):
 t,f=[d.index(s)for s in input().split()]
 n=[(1,2,4,3,1),(0,3,5,2,0),(0,1,5,4,0),(1,0,4,5,1),(0,2,5,3,0),(1,3,4,2,1)][t]
 print(d[n[n.index(f)+1]])


Measured memory_bytes: 5600
N = int(input())

result = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0,
}

for _ in range(N):
    t = input()
    result[t] += 1

print("AC x {}".format(result['AC']))
print("WA x {}".format(result['WA']))
print("TLE x {}".format(result['TLE']))
print("RE x {}".format(result['RE']))


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

int n;
int m[101][101];
int p[101];

int main() {
    cin >> n;
    int count = n - 1, temp, i, j, k;

    cin >> p[0] >> p[1];
    for ( i = 2; i <= n; i++ ) {
        cin >> temp >> p[i];
    }

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

    for ( i = 1; i <= n-1; i++ ) {
        for ( j = 1; j <= n - i; j++ ) {
            temp = p[j - 1] * p[j] * p[j + i] + m[j + 1][j + i] + m[j][j];
            for ( k = j + 2; k <= i + j; k++ ) {
                temp = min(temp, p[j - 1] * p[k - 1] * p [j + i] + m[k][j + i] + m[j][k - 1]);
            }
            m[j][j + i] = temp;
        }
    }

    cout  <<  m[1][n] <<endl;

    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
vector<int>par;
void init(int N) {
  par.resize(N + 3);
  for(int i = 0; i <= N; i ++) {
    par[i] = i;
  }
}
int root(int v) {
  if (v == par[v]) return v;
  return par[v] = root(par[v]);
}
bool merge(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return false;
  par[b] = a;
  return true;
}
int main () {
  int N, M;
  cin >> N >> M;
  init(N);
  int ans = N - 1;
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    if (merge(a, b)) ans --;
  }
  cout << ans << endl;
}


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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ld long double

#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
#define Fit(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define Fitd(i,v) for(__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))

using namespace std;

const int nm = 210;

int n;
char a[nm][nm];
int v[nm];

int bfs(int i) {
	memset(v, -1, sizeof(v));
	queue<int> q;
	q.push(i);
	v[i] = 1;
	int res = 1;
	while (!q.empty()) {
		int i = q.front();
		q.pop();
		for (int j = 0; j < n; ++j) {
			if (a[i][j] == '1') {
				if (v[j] == -1) {
					v[j] = v[i] + 1;
					res = max(res, v[j]);
					q.push(j);
				} else if (v[j] == v[i] - 1 || v[j] == v[i] + 1)
					continue;
				else
					return -1;
			}
		}
	}
	return res;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    cin >> n;
    for (int i = 0; i < n; ++i) {
    	cin >> a[i];
    }
    int res = -1;
    for (int i = 0; i < n; ++i) {
    	res = max(res, bfs(i));
    }
    cout << res << "\n";
#ifdef LOCAL
    cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 256
//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

const int maxn=100100;

int n;

int a[maxn];

void bad()
{
  cout<<"No"<<endl;
  exit(0);
}

void good()
{
  cout<<"Yes"<<endl;
  exit(0);
}

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

  cin>>n;

  for(int i=0;i<n;i++)
    cin>>a[i];

  sort(a,a+n);

  if(a[n-1]>=n)
    bad();

  if(a[n-1]-a[0]>1)
    bad();

  if(a[0]==a[n-1])
    {
      if(a[0]==n-1)
	good();
      if(a[0]<=n/2)
	good();
      bad();
    }
  
  int x=0,y=0;
  
  for(int i=0;i<n;i++)
    if(a[i]==a[0])
      x++;

  y=n-x;

  int mn=x+(y>0);
  int mx=x+y/2;
  
  if(mn<=a[n-1] and a[n-1]<=mx)
    good();
  else
    bad();
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;
 
void solve() {
 
    ll n, k, s;
    cin >> n >> k >> s;
 
    rep(i, n)
    {
        if(i != 0) cout << " ";
        if(i < k) cout << s;
        ll other = (s == 1e9)? 1 : (s+1);
        if(i >= k) cout << other; 
    }
    return;
}
 
int main() {
    solve();
    return 0;
 
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
ll dp[402][402];
int main()
{
	ll n;
	cin>>n;
	ll a[n+1];
	ll sum[n+1];
	memset(sum,0,sizeof(sum));
	for (ll i=1;i<=n;i++)
	{
		cin>>a[i];
		if (i==1)
			sum[i]=a[i];
		else
			sum[i]=sum[i-1]+a[i];
	}
	for (ll i=0;i<=n;i++)
		dp[i][i]=0;
	for (ll l=2;l<=n;l++)
	{
		for (ll i=1;i<=n-l+1;i++)
		{
			ll j=i+l-1;
			dp[i][j]=1e18;
			for (ll k=i;k<j;k++)
			{
				ll ans=dp[i][k]+dp[k+1][j]+(sum[k]-sum[i-1]+sum[j]-sum[k]);
				dp[i][j]=min(dp[i][j],ans);
			}
		}
	}
	// for (ll i=1;i<=n;i++)
	// {
	// 	for (ll j=1;j<=n;j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[1][n];
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll ans=0;


void Main() {
  ll n;
  R n;
  vector<ll> v[n];
  rep(i,n-1) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  ll c[n],d[n];
  rep(i,n) R c[i];
  sort(c,c+n,greater<ll>());
  queue<int> que;
  que.push(0);
  memset(d,-1,sizeof(d));
  ll k=0,ans=0;
  d[0]=c[k++];
  while(!que.empty()) {
    ll x=que.front();que.pop();
    rep(i,v[x].size()) {
      ll y=v[x][i];
      if(d[y]!=-1) continue;
      d[y]=c[k++];
      ans+=d[y];
      que.push(y);
    }
  }
  pr(ans);
  PR(d,n);
}

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


Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main() {
	int n,sum,sc[1000];
	double ave,S;
	while(1){
		cin >> n;
		if(n == 0)break;
		S = 0;
		sum = 0;
		for(int i = 0; i < n; i++){
			cin >> sc[i];
			sum += sc[i];
		}
		ave = 1.0*sum/n;
 
		for(int i = 0; i < n; i++){
			S += pow(sc[i]-ave,2)*1.0;
		}
		cout  << setprecision(10) << sqrt(S/n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
#include<cstdio>
int main()
{
    int a[]={1,3,5,7,8,10,12};
    int b[]={4,6,9,11};
    int x,y;
    while (scanf("%d %d",&x,&y)==2)
    {
        if (x==2||y==2)printf("No\n");
        else
        {
            int ok1=1,ok2=1;
            for (int i=0;i<7;i++)
            {
                if (a[i]==x)ok1=0;
                if (a[i]==y)ok2=0;
            }
            if (ok1&&ok2)printf("Yes\n");
            else if ((!ok1)&&(!ok2))printf("Yes\n");
            else printf("No\n");
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    ll r = 0, g = 0, b = 0;
    rep(i, n){
        if(s[i]=='R'){
            r++;
        }
        if (s[i] == 'G'){
            g++;
        }
        if (s[i] == 'B')
        {
            b++;
        }
    }
    ll sum = r * b * g;


    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n-j+i; j++)
        {
            int k = j + j - i;
            if(s[i-1]!=s[j-1]&&s[i-1]!=s[k-1]&&s[k-1]!=s[j-1]){
                sum--;
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n; lint t;
    scanf("%d%lld", &n, &t);
    lint h[n];
    rep(i, n) scanf("%lld", &h[i]);

    lint lim[n], sum = 0, a = h[0];
    rep(i, n){
        sum += h[i];
        if(sum > t) lim[i] = 0;
        else{
            chmax(a, h[i]);
            lim[i] = 1 + (t-sum) / a;
        }
    }
    rep(i, n) printf("%lld\n", lim[i] + 1);
}


Measured memory_bytes: 4796
n, k = io.read('n'), io.read('n')
bucket = {}
coll = {}

for i = 1, n do
    local a_i = io.read('n')
    bucket[a_i] = (bucket[a_i] or 0) + 1
end

for _, v in pairs(bucket) do    -- > <
    coll[#coll + 1] = v
end

table.sort(coll)

ans = n
for i = 1, math.min(k, #coll) do
    ans = ans - coll[#coll - i + 1]
end

print(ans)


Measured memory_bytes: 10208
N = int(input())
a_b_c = [list(map(int, input().split())) for i in range(N)]

#dp[i+1][j]:i日目までの活動履歴のうち、最終日である i 日目には活動 j (0: A, 1: B, 2: C) を選んだ場合の、得られる幸福度の最大値

dp = [[0 for j in range(3)] for i in range(N+1)]

for i in range(N):
    dp[i+1][0] = max(dp[i][1],dp[i][2]) + a_b_c[i][0]
    dp[i+1][1] = max(dp[i][0],dp[i][2]) + a_b_c[i][1]
    dp[i+1][2] = max(dp[i][0],dp[i][1]) + a_b_c[i][2]

print(max(dp[N]))

Measured memory_bytes: 47364
def solve(N, A):
    ret = 1
    upper = 10**18
    if 0 in A:
      return 0
    for a in A:
        ret *= a
        if upper < ret:
          return -1
    return ret
 
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))

Measured memory_bytes: 21648
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n;

  while (cin >> n,n){
    int x[100];
    int y[100];

    int gem[25][25] = {0};

    REP(i,n){
      cin >> x[i] >> y[i];
      gem[x[i]][y[i]] = 1;
    }
    int m;

    cin >> m;

    char d[100];
    int l[100];

    int nowx=10;
    int nowy=10;

    REP(j,m){
      cin >> d[j] >> l[j];
      if (d[j]=='E'){
	REP(k,l[j]){
	  nowx ++;
	  gem[nowx][nowy]=0;
	}
      }else if(d[j]=='W'){
	REP(k,l[j]){
	  nowx --;
	  gem[nowx][nowy]=0;
	}
      }else if(d[j]=='S'){
	REP(k,l[j]){
	  nowy --; 
	  gem[nowx][nowy]=0;
	} 
      }else if(d[j]=='N'){
	REP(k,l[j]){
	  nowy ++;
	  gem[nowx][nowy]=0;
	}
      }
      //      cout << nowx << "," << nowy << endl; //
    }
    int tf=0;


    /*  
	REP(piyo,25){
	REP(are,25){
	cout << gem[piyo][are] << ",";
	}}
    */


    REP(hoge,25){
      REP(huga,25){
	tf += gem[hoge][huga];
      }
    }

    if(tf){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
    }
  }
}

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

int main(){
  int a[4];
  scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]);
  sort(a,a+4);
  if(a[0] == a[1] && a[2] == a[3]){
    printf("yes\n");
  } else{
    printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 3144
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
      N:usize, A:[i64;N]
    }
    let mut ans = 0;
    for i in 1..=N {
        if i % 2 == 1 && A[i - 1] % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main() {
  ll n;
  cin>>n;
  ll power=1;
  for(int i=1;i<=n;i++){
    power*=i;
    power%=1000000007;
  }
  cout<<power<<endl;
  return 0;
}


Measured memory_bytes: 256
INF = -float('inf')

def bellmanford(n,e,r):
  costs = [INF]*n
  costs[r] = 0
  for i in range(n):
    for u,v,c in e:
      if costs[u]+c > costs[v] and costs[u]!=INF:
        costs[v] = costs[u]+c
        if i==n-1 and v==n-1:
          return 'inf'
  return costs[n-1]

n,m = map(int, input().split())
edge = []
for i in range(m):
  a,b,t = map(int, input().split())
  edge.append((a-1,b-1,t))

print(bellmanford(n,edge,0))


Measured memory_bytes: 9348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int count = 0;
		
		if(N <= 2) {
			System.out.println(count);
		} else {
			count = (N - N % 3) / 3 ;
			System.out.println(count);
		}
		
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
#include <cmath>
int main() {
    static const double pi = acos(-1);
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double x = (H*60 + M)   /720.0;
    double y = (H*30 + M/2.0) /360.0;
    //ここの部分で 30H + M/2とすると桁落ちする？
    //printf("%.20f\n",x);
    //printf("%.20f\n",y);

    double th = 2 * pi * y;
    double tm = 2 * pi * M / 60;
    double theta  = th - tm;
    double ans;
    ans = sqrt(A * A + B * B - 2 * A * B * cos(theta));

    printf("%.10f\n",ans);
      
    return 0;
}

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

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

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

int charN(char c) {
    return static_cast<int>(c) - static_cast<int>('a');
}
int main() {
    string s; cin >> s;
    int N = (int)s.size();
    long long K; cin >> K;
    repp(i, 0, N - 1) {
        char c = s[i];
        if (c == 'a') continue;
        if (26 - charN(c) > K) continue;
        K -= 26 - charN(c);
        s[i] = 'a';
    }
    if (K > 0) {
        s[N-1] = static_cast<char>((charN(s[N-1]) + K) % 26 + static_cast<int>('a'));
    }
    cout << s << endl;
}



Measured memory_bytes: 512
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))


query :: Int -> [Int] -> Int
query n ais = sum $ map (abs . subtract mid) diffs 
 where
   diffs = sort $ zipWith (-) ais [1..]
   mid = diffs !! ((n-1) `div` 2)

main :: IO ()
main = do
  n <- read <$> getLine
  ais <- unfoldr (B.readInt . B.dropWhile (==' ')) <$> B.getLine
  putStrLn $ show $ query n ais

Measured memory_bytes: 32124
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    String s=sc.next();
    if (a<3200) {
      System.out.println("red");
    }else{
      System.out.println(s);
    }
  }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
ll atk_num(ll x){
    if(x==1) return 1;
    return 1+2*atk_num(x/2);
}

int main(){
    ll h;
    cin >> h;
    ll ans=atk_num(h);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	long long a,b,k,i;
	scanf("%lld %lld %lld",&a,&b,&k);
	if(a-k<=0){
		k-=a;
		a=0;
		if(b-k<=0)	b=0;
		else	b-=k;
	}
	else	a-=k;
	printf("%lld %lld\n",a,b);
	return 0;
}


Measured memory_bytes: 1728
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;


ll a[202020];
int solve()
{
   ll n;
   cin >> n;
   map<ll, ll> m;
   for (int i = 0; i < n; i++){
      cin >> a[i];
      m[a[i]] = i + 1;
   }

   set<ll> se;
   se.insert(0);
   se.insert(n + 1);
   ll ans = 0;
   for(ll i=1; i <= n; i++){
      ll l, r;
      auto it = se.lower_bound(m[i]);
      r = *it;
      it--;
      l = *it;
      ans += (m[i] - l) * (r - m[i])*i;
      se.insert(m[i]);
   }

   cout << ans << endl;

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

   solve();
}

Measured memory_bytes: 23680