akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
	ll h;
	cin>>h;

	ll cnt=1;
	while(h>1){
		cnt++;
		h/=2;
	}

	ll ans=pow(2.0,cnt)-1;
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1e6+5;
int p[N],v[N],pn,a[N],cnt[N],n;
bool flag;

void init(int n){
	for(int i=2;i<=n;i++){
		if(!v[i]) p[++pn]=i;
		for(int j=1;j<=pn&&p[j]*i<=n;j++){
			v[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) ++cnt[read(a[i])];
	init(1000000);
	for(int i=1;i<=pn;i++){
		int p=::p[i],cur=0;
		for(int j=p;j<=1000000;j+=p) cur+=cnt[j];
		if(cur==n){
			puts("not coprime");
			return 0;
		}
		flag|=cur>1;
	}
	if(flag) puts("setwise coprime");
	else puts("pairwise coprime");
}

Measured memory_bytes: 15616
from sys import stdin

n,p = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

if all(i%2 == 0 for i in li):
    if p == 0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))

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

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int64_t n;
    cin >> n;
    modint a = 10;
    modint b = 9;
    modint c = 8;
    a = a.pow(n);
    b = b.pow(n);
    b*=2;
    c = c.pow(n);
    modint ans = a - b + c;
    cout << ans << endl;


    // cin >> a;
    // a *= (mod-1);
    // cout << a << endl;
}


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

int main() {
  map<int,int> m;
  m[1] = 1;
  m[2] = 3;
  m[3] = 1;
  m[4] = 2;
  m[5] = 1;
  m[6] = 2;
  m[7] = 1;
  m[8] = 1;
  m[9] = 2;
  m[10] = 1;
  m[11] = 2;
  m[12] = 1;
  int x, y;
  cin >> x >> y;
  if(m.at(x) == m.at(y))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll a,b,n; cin >> a >> b >> n;
  ll x;
  if(n>=b)  x=b-1;
  else x=n;
  ll ans=floor(a*x/b)-a*floor(x/b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


//1


int main(){

ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
long long int res=0;
for(int i=1;i<=n;i++){
if(i%3!=0 && i%5!=0)res+=i;
}

cout<<res<<endl;

}

//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



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

int main(){
  string s;
  cin >> s;
  if (s == "SUN") puts("7");
  if (s == "MON") puts("6");
  if (s == "TUE") puts("5");
  if (s == "WED") puts("4");
  if (s == "THU") puts("3");
  if (s == "FRI") puts("2");
  if (s == "SAT") puts("1");
  return 0;
}

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

vector<int> a;

int main(){
	int n; cin >> n;
	a.resize(n);
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int m = a[n - 1];
	a.pop_back();
	int m1 = m / 2;
	int m2 = m / 2;
	if (m & 1){
		m2 += 1;
	}

	int cand1 = *(lower_bound(a.begin(), a.end(), m1)-1);
	int cand2 = *lower_bound(a.begin(), a.end(), m2);
	if (abs(m1 - cand1) <= abs(m2 - cand2)){
		cout << m << ' ' << cand1;
	}
	else{
		cout << m << ' ' << cand2;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
  int a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;
  if(a == b && b == c)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np


def main():
    n, m = [int(x) for x in input().split()]
    ans = 0
    if m < n and (m >= 0 or n < 0):
        n *= -1
        ans += 1
    ans += abs(abs(m) - abs(n))
    n += abs(abs(m) - abs(n))
    if n != m:
        n *= 1
        ans += 1
    print(ans)


main()


Measured memory_bytes: 12432
#include <iostream>
#define INF 10000000
using namespace std;

int main(){
  int n,x[302][302]={},y[302][302]={};
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>y[i][j],x[i][j]=y[i][j];
  
  for(int i=0;i<n;i++)
    for(int j=n-2;j>=0;j--) {
      x[i][j]+=x[i][j+1];
      y[j][i]+=y[j+1][i];
    }

  int ans=max(y[0][n-1],y[n-1][0]),sum[302][302],K[2][302][302]={},t=0,f=1;
  while(f){
    t++,f=0;
    for(int i=0;i<n;i++) //yoko
      for(int j=i+1;j<n;j++) {//yoko
	int a=K[t%2][i][j],&b=K[(t+1)%2][i][j];
	b=a;
	sum[i][j]=-INF;

	for(int k=a+1;k<n;k++) { //tate
	  int X=(x[a][i]-x[a][j+1])+(x[k][i]-x[k][j+1]);
	  int Y=(y[a+1][i]-y[k][i])+(y[a+1][j]-y[k][j]);
	  if(sum[i][j]<=X+Y)sum[i][j]=X+Y,b=k;
	}
	ans=max(ans,sum[i][j]);

	if(b!=n-1)f=1;
	for(int k=a+1;k<b;k++){//tate
	  sum[i][j]+=(x[k][i+1]-x[k][j])-(x[k-1][i]-x[k-1][j+1]);
	  ans=max(ans,sum[i][j]);
	}
      }
  }
  cout <<ans<<endl;
	  
  return 0; 
}

Measured memory_bytes: 2948
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

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

using namespace std;

typedef long long ll;

ll n, k;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> k;
    
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    cout << n - k << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100005
#define NIL -1

struct Node{
  int p, l, r;
};
struct Node T[N];

int getDepth(int p){
  if(T[p].p == NIL) return 0;
  return getDepth(T[p].p) + 1;
}

int main(){
  int n, i, k, j, c;
  int id, tmp;
  int dep[N];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].l = T[i].p = T[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d", &id, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &c);
      if(j == 0){
	T[id].l = c;
	T[c].p = id;
	tmp = c;
      }else{
	T[tmp].r = c;
	T[c].p = id;
	tmp = c;
      }
    }    
  }
  for(i = 0; i < n; i++){
    dep[i] = getDepth(i);
  }
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].p, dep[i]);
    if(T[i].p == NIL && T[i].l == -1){
      printf("root, []\n");
      continue;
    }
    else if(T[i].p == NIL){
      printf("root, [");
    }else if(T[i].l == NIL){
      printf("leaf, []\n");
    }else{
      printf("internal node, [");
    }
    if(T[i].l != NIL || T[i].p == NIL){
      printf("%d", T[i].l);
      tmp = T[i].l;
      while(1){
	if(T[tmp].r == NIL) break;
	printf(", %d", T[tmp].r);
	tmp = T[tmp].r;
      }
      printf("]\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string s;
  cin >> s;
  int N = s.size();
  
  int firstC = 200;
  int lastF = -200;
  
  for (int i = 0; i < N; i++)
  {
    if (s.at(i) == 'C') 
    {
      firstC = i;
      break;
    }
  }
  
  for (int i = N - 1; i >= 0; i--)
  {
    if (s.at(i) == 'F') 
    {
      lastF = i;
      break;
    }
  }
  
  string ans = "No";
  if (firstC < lastF) ans = "Yes";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
n = int(input())
ps = []
for _ in range(n):
    ps.append(list(map(int,input().split())))


def d(i, j):
    return pow((ps[i][0] - ps[j][0])**2 + (ps[i][1] - ps[j][1])**2, 0.5)

p = itertools.permutations(range(n), n)

c = 0
ss = 0
for k in p:
    c += 1
    for i in range(n-1):
        ss += d(k[i], k[i+1])
print(ss/c)


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

int main(){
  int n;
  cin>>n;
  vector<string> v;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    v.push_back(s);
  }
  map<string,int> mp;
  int count=0;
  int sz=v.size();
  for(int i=0;i<sz;i++){
    if(mp.find(v[i])!=mp.end())
    {
      mp[v[i]]++;
    }
    else{
      mp[v[i]]=1;
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 24988
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, a, b;
  cin >> n >> a >> b;
  if((b - a) % 2 == 0){
    cout << (b - a) / 2 << endl;
  }else{
    cout << min(a-1, n-b) + 1 + (b-a-1)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner sc;

    public Main() {
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();
    }

    private void solve() {
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        show(A);
        for (int i = 1; i < N; i++) {
            int v = A[i];
            int j = i - 1;
            while (j >= 0 && A[j] > v) {
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;
            show(A);
        }
    }

    void show(int[] A) {
        StringBuilder sb = new StringBuilder();
        for (int i : A) {
            sb.append(i);
            sb.append(" ");
        }

        System.out.println(sb.toString().trim());
    }
}

Measured memory_bytes: 28968
def modpow(a,n):
  if n<1:
    return 1
  ans=modpow(a,n//2)
  ans=(ans*ans)%mod
  if n%2==1:
    ans*=a
  return ans%mod

def conb(n,i):
  inv,ans=1,1
  for j in range(1,i+1):
    ans=ans*(n-j+1)%mod
    inv=inv*j%mod
  return (ans*modpow(inv,mod-2))%mod


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)
    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)
    return arr



mod=10**9+7
N,M=[int(x) for x in input().rstrip().split()]
fact=factorization(M)
ans=1

if M==1:
  print(1)
else:
  for i in fact:
    ans*=conb(i+N-1,N-1)
  print(ans%mod)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define pii pair<int,int> 
#define X first
#define Y second
#define MAXN 200000
const int magic = 864197532;

struct Line {
	long long m, k; // y = mx + k
	long long v(int x) {
		return 1ll * m * x + k;
	}
};

struct LiChao {
	int l, r, m;
	Line line;
	LiChao* ch[2];
	LiChao (int l, int r) : l(l), r(r), m(l + r >> 1) {
		line.m = 0;
		line.k = 0;
		if (r - l != 1) {
			ch[0] = new LiChao(l, m);
			ch[1] = new LiChao(m, r);
		}
	}
	void insert(Line seg) {
		if (r - l == 1) {
			if (seg.v(l) < line.v(l)) {
				line = seg;
			}
		} else {
			if (line.m > seg.m) swap(seg, line);
			if (line.v(m) > seg.v(m)) {
				swap(seg, line);
				ch[1]->insert(seg);
			} else {
				ch[0]->insert(seg);
			}
		}
	}
	long long query(int x) {
		if (r - l == 1) return line.v(x);
		if (x < m) return min(ch[0]->query(x), line.v(x));
		else return min(ch[1]->query(x), line.v(x));
	}
};

int main () {
    srand(time(NULL));
	int n;
	long long c;
	cin >> n >> c;
	long long dp[n];
	int tmp;
	/* dp[i] = dp[j] + (h_j - h_i)^2 + c 
			 = dp[j] + h_j^2 - 2 * h_i * h_j + h_i^2 + c
			 = h_i^2 + c + (dp[j] + h_j^2 - 2 * h_j * h_i)*/
	LiChao root(1, 1000001);
	fop (i,0,n) {
		cin >> tmp;
		if (i) dp[i] = root.query(tmp) + (1ll * tmp * tmp) + c;
		else dp[i] = 0;
		Line A;
		A.m = -2 * tmp;
		A.k = (1ll * tmp * tmp) + dp[i];
		root.insert(A);
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 127872
from bisect import bisect_left

N,Q = (int(x) for x in input().split())

stop_arr = [tuple(map(int, input().split())) for _ in range(N)]
Q_arr = [int(input()) for _ in range(Q)]

stop_arr.sort(key=lambda x:x[2])

ans_arr = [-1]*Q
skip_arr = [-1]*(Q+1)

for s,t,x in stop_arr:
    q_start = bisect_left(Q_arr, s-x)
    q_stop = bisect_left(Q_arr, t-x)
    l = q_start
    while l < q_stop:
        if skip_arr[l] == -1:
            skip_arr[l] = q_stop
            ans_arr[l] = x
            l += 1
        else:
            l = skip_arr[l]

print(*ans_arr, sep="\n")


Measured memory_bytes: 57124
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!long;
    auto as = readln.split.to!(long[]);
    foreach (i; 0..N) {
        as[i] -= i+1;
    }
    const cs = as.sort!((a,b) => a < b).array;
    if (cs.length % 2 == 0) {
        [cs[$/2], cs[$/2+1]].map!(c => as.map!(a => abs(a - c)).sum).reduce!min.writeln;
    } else {
        as.map!(a => abs(a - cs[$/2])).sum.writeln;
    }
}



Measured memory_bytes: 11504
def distance(p1, p2):
  (x1, y1) = p1
  (x2, y2) = p2
  return abs(x1 - x2) + abs(y1 - y2)

N, M = map(int, input().split())
stu = [0]*N
point = [0]*M

for i in range(N):
  a, b = map(int, input().split())
  stu[i] = (a, b)
for i in range(M):
  a, b = map(int, input().split())
  point[i] = (a, b)

ans = [-1]*N  # (ind, score)
for j, now in enumerate(stu):
  ans[j] = -1
  score = 1e18
  for i in range(M):
    pos = point[i]
    if distance(now, pos) < score:
      score = distance(now, pos)
      ans[j] = i+1

for e in ans:
  print(e)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }

int L[102];

int main(){
    int N,X,l,sum=0, cnt=1;
    cin >> N >> X;
    rep(i,N){
        cin >> l;
        sum += l;
        if (sum <= X){
            cnt ++;
        }else{
            cout << cnt << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n, t =  map(int, input().split())
index=0
cost1=[]
cost2=[]
time=[]
while index < n:
    c, t2 = map(int, input().split())
    if t2 < t+1:
        cost1.append(c)
        cost2.append(c)
        time.append(t2)
    index+=1
if cost1==[]:
    print("TLE")
else:
    print(min(cost1))

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < k; i++)ans += a[i];
	cout << ans;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <string>
#include <unordered_set>

#define MAX_N 100'000
#define INF 1'000'000'007

typedef long long ll;

using namespace std;

int C[26]{};

int main() {
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N; ++i) {
    ++C[S[i] - 'a'];
  }

  ll res = 1;
  for (int i = 0; i < 26; ++i) {
    if (C[i] > 0) {
      res = (res * (C[i] + 1)) % INF;
    }
  }
  printf("%lld\n", res - 1);
}


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

using namespace std;

int main(){
    int count = 0;
    string S;
    cin >> S;
    for(int i = 0 ; i < 3; i++){
        if (S[i] == S[i + 1]){
            count++;
        }
    }
    if(count == 0){
        cout << "Good";
    }else{
        cout << "Bad";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int count=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]!=i+1) {
            count++;
        }
    }
    if(count<=2)
    {
        cout<<"YES";
    } else
    {
        cout<<"NO";
    }
    

}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String line = br.readLine();
            StringBuffer stringBuffer = new StringBuffer(line);
            line = stringBuffer.reverse().toString();
            System.out.println(line);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 24120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
   ll n;
   cin>>n;
   ll ans=0;
   ll temp=n;
   for(int i=2;i<=sqrt(n);i++)
   {
   	if(temp%i==0)
   	{
   		int cnt=0;
   		while(temp%i==0)
   		{temp/=i;
   			cnt++;
   		}
   		ans+=(sqrt(1+8*cnt)-1)/2;
   	}
   }
   if(temp!=1)
   {
   	ans++;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int arr[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    cin >> n >> m;
    int maxx = 0;
    for (int i = 0; i < m; i++) {
        cin >> arr[i];
    }
    for (int i = 0; i < m; i++) {
        maxx = max(maxx, (arr[(i + 1) % m] - arr[i] + n) % n);
    }
    cout << n - maxx;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> calc_z(string s){
	int n = s.size();
	vector<int> z(n);
	z[0] = n;
	int i = 1, j = 0;
	while(i < n){
		while(i + j < n && s[j] == s[i + j]){ ++j; }
		z[i] = j;
		if(j == 0){
			++i;
			continue;
		}
		int k = 1;
		while(i + k < n && k + z[k] < j){
			z[i + k] = z[k];
			++k;
		}
		i += k;
		j -= k;
	}
	return z;
}

int main(){
	ios::sync_with_stdio(false);
	
	string s, t;
	getline(cin, s);
	getline(cin, t);
	
	string tmp = s + t;
	reverse(tmp.begin(), tmp.end());
	int ls = s.size(), lt = t.size();
	vector<int> z1 = calc_z(t + s);
	vector<int> z2 = calc_z(tmp);
	
	int ans = 0;
	for(int i = 0; i + lt <= ls; ++i){
		ans += z1[i + lt] + z2[ls - i] + 1 == lt;
	}
	cout << ans << '\n';
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, W;
    cin >> n >> W;
    vector<vector<long long> > dp(2, vector<long long>(W + 1));
    vector<int> val(n);
    vector<int> wt(n);
    for (int i = 0; i < n; i++) {
        cin >> wt[i] >> val[i];
    }
    int curr = 0;
    for (int i = 1; i <= n; i++) {
        for (int w = 0; w <= W; w++) {
            dp[curr][w] = dp[1 - curr][w];
            if (w >= wt[i - 1]) {
                dp[curr][w] = max(dp[curr][w], dp[1 - curr][w - wt[i - 1]] + val[i - 1]);
            }
        }
        curr = 1 - curr;
    }
    cout << dp[(n - 1) % 2][W];
    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


int MOD=1000000007;
int N,M,P;
int A[100005];int B[100005];int C[100005];

int ans=0;

struct Bellman_Ford{ //たどり着けないときはLLINF、負の閉路を持つときは-LLINFを返す。
    int N;
    int *d;
    int *pre;
    bool *negative;
    vector< pair< pair<int,int> , int> > edges;
    Bellman_Ford(int N) : N(N){
        d=new int[N];
        pre=new int[N];
        negative=new bool[N];
        rep(i,N){
            d[i]=LLINF;
            pre[i]=-1;
            negative[i]=false;
        }
    }
    void push_nondir(int a,int b, int c){
        edges.pb( mp( mp(a,b),c) );
        edges.pb( mp( mp(b,a),c) );
    }
    void push_dir(int a,int b, int c){
        edges.pb( mp( mp(a,b) ,c) );
    }
    int solve(int start, int end){
        d[start]=0;
        rep(i,N-1){
            rep(j,edges.size()){
                int from=edges[j].first.first;int to=edges[j].first.second;int cost=edges[j].second;
                if(d[from]!=LLINF&d[to]>d[from]+cost){
                    d[to]=d[from]+cost;
                    pre[to]=from;
                }
            }
        }
        //startからendにいく回路の中に負の重みの閉路がある？
        rep(i,N){
            rep(j,edges.size()){
                int from=edges[j].first.first;int to=edges[j].first.second;int cost=edges[j].second;
                if(d[from]!=LLINF&&d[to]>d[from]+cost){
                    d[to]=d[from]+cost;
                    negative[to]=true;
                }
                if(negative[from])negative[to]=true;
            }
        }
        if(negative[end]){return -LLINF;}
        else return d[end];
    }
    bool anywhere_negativeC(){//do after solve()
        rep(i,edges.size()){
            int from=edges[i].first.first;int to=edges[i].first.second;int cost=edges[i].second;
            if(d[to]>d[from]+cost)return true;
        }
        return false;
    }
    void free_BF(){
        delete[] d;
        delete[] pre;
        delete[] negative;
    }
    
};

signed main(){
    scanf("%lld %lld %lld",&N,&M,&P);
    Bellman_Ford BF(N);
    rep(i,M){
        scanf("%lld %lld %lld",&A[i],&B[i],&C[i]);A[i]--;B[i]--;
        BF.push_dir(A[i],B[i],P-C[i]);
    }
    ans=BF.solve(0,N-1);
    if(ans>-LLINF)printf("%lld\n",max((int)0,-ans));
    else printf("-1\n");
    BF.free_BF();
}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

i64 n;
vector<i64> a;
vector<i64> d;
vector<vector<i64>> g;
vector<i64> p;

void dfs(i64 x) {
    i64 idx = lower_bound(begin(p), end(p), a[x]) - begin(p);
    i64 s = p.size();
    if (idx != s) {
        swap(p[idx], a[x]);
    } else {
        p.push_back(a[x]);
    }

    d[x] = p.size();
    for (auto& e : g[x]) {
        if (d[e] == -1) dfs(e);
    }

    if (idx != s) {
        swap(p[idx], a[x]);
    } else {
        p.pop_back();
    }
}

void solve() {
    cin >> n;
    a.resize(n);
    for (auto& e : a) cin >> e;
    g.resize(n);
    for (i64 i = 0; i < n - 1; i++) {
        i64 u, v;
        cin >> u >> v, u--, v--;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    d.resize(n, -1);
    dfs(0);
    for (auto& e : d) cout << e << endl;
}

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


Measured memory_bytes: 34384
N,M=map(int,input().split())
KA=[list(map(int,input().split())) for _ in range(N)]
c=[0]*M
  
for m in range(N):
  a=KA[m][0]+1
  for n in range(1,a):
    c0=KA[m][n]
    c[c0-1]+=1 
print(c.count(N))
    


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		int h,w;
		String[] str;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		while(true){
			str = br.readLine().split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);

			if(h==0 && w==0)break;

			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if((i+j)%2 == 0){
						builder.append("#");
					}else{
						builder.append(".");
					}
				}
				builder.append("\n");
			}
			builder.append("\n");
		}

		builder.delete(builder.length() - 1, builder.length());
		System.out.println(builder);
		br.close();
	}
}

Measured memory_bytes: 25192
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();

        int range = d * 2 + 1;
        int result = n % range == 0 ? n / range : n / range + 1;

        System.out.println(result);
    }
}


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

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────

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

	vi x(n), y(n), b(n), p(n);
	rep(i, n) cin >> x[i] >> y[i] >> b[i] >> p[i];

	vi ans(n);

	rep(i, n) {
		int ans1 = x[i] * b[i] + y[i] * p[i];

		if (b[i] < 5) b[i] = 5;
		if (p[i] < 2) p[i] = 2;

		int ans2 = x[i] * 0.8 * b[i] + y[i] * 0.8 * p[i];

		ans[i] = min(ans1, ans2);
	}
	
	rep(i, n) {
		cout << ans[i] << endl;
	}
}


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


void solve(long long N, long long R){
    if (N < 10)
        cout << R + 100 * (10 - N) << endl;
    else
        cout << R << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long R;
    scanf("%lld",&R);
    solve(N, R);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <bitset>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

int main() {
  int n; cin>>n;
  int a[n]; for(int i=0;i<n;i++) cin>>a[i];
  int an = 1e9;
  for(int x=-200;x<=200;x++) {
    int sm=0;
    for(int i=0;i<n;i++) {
      sm+=(x-a[i])*(x-a[i]);
    }
    an=min(an,sm);
  }
  cout<<an<<endl;
}
// Thank you for making problems and running the contest

Measured memory_bytes: 256
def put_class(n):
  if n <= 48:
    print("light fly")
  elif n <= 51:
    print("fly")
  elif n <= 54:
    print("bantam")
  elif n <= 57:
    print("feather")
  elif n <= 60:
    print("light")
  elif n <= 64:
    print("light welter")
  elif n <= 69:
    print("welter")
  elif n <= 75:
    print("light middle")
  elif n <= 81:
    print("middle")
  elif n <= 91:
    print("light heavy")
  else:
    print("heavy")
 
while True:
  try:
    put_class(float(input()))
  except EOFError:
    break


Measured memory_bytes: 5572
<?php
  list($a,$b,$c) = explode(" ", trim(fgets(STDIN)));
  list($k) = explode(" ", trim(fgets(STDIN)));
  
  $m = max($a,$b,$c);

  $x = $m;
  for($i=0;$i<$k;$i++){
    $x *= 2;
  }

  echo $a+$b+$c+$x-$m;

Measured memory_bytes: 16028
import java.io.*;
import java.util.*;
 
public class Main{
	
 
	public void solve(){
		while(true){
			int R = nextInt();
			int N = nextInt();
			if(R == 0) break;
			int[] build = new int[41];
			for(int i = 0; i < N; i++){
				int l = nextInt();
				int r = nextInt();
				int h = nextInt();
				for(;  l < r; l++){
					build[l + 20] = Math.max(build[l + 20], h);
				}
			}
			double ans = 10000;
			
			for(int i = 0; i <= 20; i++){
				if(i >= R) break;
				int h = build[i + 20];
				ans = Math.min(ans, R + h - Math.sqrt(R * R - i * i));
				
				h = build[20 - 1 - i];
				ans = Math.min(ans, R + h - Math.sqrt(R * R - i * i));
			}
			
			out.println(ans);
		}
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

int main(){
    int h, w;
    cin >> h >> w;
    
    char C[h][w];
    int D[h][w], b = 0;
    REP(i, h){
        REP(j, w){
            cin >> C[i][j];
            if(C[i][j] == '#'){
                b++;
            }
            D[i][j] = 1e9;
        }
    }
    D[0][0] = 0;
    int dx[4] = {-1, 1, 0, 0};
    int dy[4] = {0, 0, -1, 1};
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    while(!(q.empty())){
        pair<int, int> tmp = q.front();
        q.pop();
        REP(i, 4){
            int nx, ny;
            nx = tmp.first + dx[i];
            ny = tmp.second + dy[i];
            if(nx < 0 or ny < 0 or nx >= h or ny >= w or C[nx][ny] == '#'){
                continue;
            }
            if(D[tmp.first][tmp.second] + 1 < D[nx][ny]){
                D[nx][ny] = D[tmp.first][tmp.second] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }
    if(D[h - 1][w - 1] == 1e9) cout << -1 << endl;
    else{
        cout << h * w - b - D[h - 1][w - 1] - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    struct Point {
        double x;
        double y;
    };
    Point p1, p2, p;
    double a, b, X, Y;
    int q;
    cin >> p1.x >> p1.y;
    cin >> p2.x >> p2.y;
    cin >> q;

    if(p1.x == p2.x){
        for(int i = 0; i < q; i++){
            cin >> p.x >> p.y;
            /*もしp1とp2のx座標が等しければ、点pと点Xは一致するため、
            点Xのx座標は線分p1p2の中点でy座標は点pのy座標である*/
            cout << fixed << setprecision(8) << 2 * p1.x - p.x << " ";
            cout << fixed << setprecision(8) << p.y << endl;
        }
    }
    else{
        double l = (p2.y - p1.y) / (p2.x - p1.x); //直線p1p2の傾き
        for(int i = 0; i < q; i++){
            cin >> p.x >> p.y;
            a = l * ((p.y - p1.y) - l * (p.x - p1.x)) / (1 + l * l) + p.x;
            b = (l * (l * p.y + p.x - p1.x) + p1.y) / (1 + l * l);
            X = 2 * a - p.x;
            Y = 2 * b - p.y;

            cout << fixed << setprecision(8) << X << " ";
            cout << fixed << setprecision(8) << Y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3300
#include<stdio.h>
int main(void){
	int n;
	int i;
	int sum = 1;
	int p;
	char str[10000];
	int dice[6];
	for(i = 0;i < 6;i++){
		dice[i] = i + 1;
	}
	while(scanf("%d",&n)){
		if(n == 0){
			break;
		}
		for(i = 0;i < n;i++){
			scanf("%s",str);
			if(str[0] == 'N'){
				p = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = p;
				sum += dice[0];
			}
			else if(str[0] == 'E'){
				p = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = p;
				sum += dice[0];
			}
			else if(str[0] == 'W'){
				p = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = p;
				sum += dice[0];
			}
			else if(str[0] == 'S'){
				p = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = p;
				sum += dice[0];
			}
			else if(str[0] == 'R'){
				p = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[3];
				dice[3] = p;
				sum += dice[0];
			}
			else{
				p = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[4];
				dice[4] = dice[2];
				dice[2] = p;
				sum += dice[0];
			}
		}
		printf("%d\n",sum);
		sum = 1;
		for(i = 0;i < 6;i++){
		dice[i] = i + 1;
	}
	}
	return 0;
}

Measured memory_bytes: 608
#include<stdio.h>

#define MAX 1000

int main(void)
{
  
  char input[MAX];
  char output[MAX];
  int i;
  int j = 0;

  scanf("%s",input); 

  for(i=0;input[i]!='\0';i+=2){
    
    if(input[i] == '2'){
      output[j] = 'k';
      j++;
    }
    
    else if(input[i] == '3'){
      output[j] = 's';
      j++;
    }

    else if(input[i] == '4'){
      output[j] = 't';
      j++;
    }

    else if(input[i] == '5'){
      output[j] = 'n';
      j++;
    }
  
    else if(input[i] == '6'){
      output[j] = 'h';
      j++;
    }
  
    else if(input[i] == '7'){
      output[j] = 'm';
      j++;
    }  

    else if(input[i] == '8'){
      output[j] = 'y';
      j++;

	if(input[i+1] == 'T'){
	  output[j] = 'a';
	  j++;
	  continue;
	}
	else if(input[i+1] == 'U'){
	  output[j] = 'u';
	  j++;
	  continue;
	}
	else if(input[i+1] == 'D'){
	  output[j] = 'o';
	  j++;
	  continue;
	}
    }

    else if(input[i] == '9'){
      output[j] = 'r';
      j++;
    }

    else if(input[i] == '0'){
      if(input[i+1] == 'U'){
	output[j] = 'n';
	output[j+1] = 'n';
	j+=2;
	continue;
      }

      else{
	output[j] = 'w';
	j++;

	if(input[i+1] == 'T'){
	  output[j] = 'a';
	  j++;
	  continue;
	}
	else if(input[i+1] == 'D'){
	  output[j] = 'o';
	  j++;
	  continue;
	}
      }
    }


    if(input[i+1] == 'T'){
      output[j] = 'a';
      j++;
    }

    else if(input[i+1] == 'L'){
      output[j] = 'i';
      j++;
    }

    else if(input[i+1] == 'U'){
      output[j] = 'u';
      j++;
    }

    else if(input[i+1] == 'R'){
      output[j] = 'e';
      j++;
    }

    else if(input[i+1] == 'D'){
      output[j] = 'o';
      j++;
    }
    
  }
    
  output[j] = '\0';

  printf("%s\n",output);

  return 0;
  
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctype.h>
using namespace std;
int main() {
    string a,b; cin >> a >> b;
    string ans="EQUAL";
    if (a.size()>b.size()) ans = "GREATER";
    else if (a.size()<b.size()) ans = "LESS";
    else{
        for (int i=0;i<a.size();i++){
            if (a[i]>b[i]) {
                ans = "GREATER";
                break;
            }
            else if (a[i]<b[i]) {
                ans = "LESS";
                break;
            }
            else continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int len[2005];
char s[2005][10005];
bitset<10005> can[2005];
pair<int,int> dp[10005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>s[i];
		len[i]=strlen(s[i]);
	}
	for(int i=0;i<n;i++){
		can[i].reset();
	}
	can[n]=1;
	for(int i=n-1;i>=0;i--){
		can[i]=can[i+1]|(can[i+1]<<len[i]);
	}
	int cnt=0,ii=0;
	for(int i=0;i<n;i++){
		if(can[i+1][k-len[i]]) dp[cnt++]=make_pair(i,0);
	}
	string res;
	for(int i=1;i<=k;i++){
		char mi='z';
		int cnt2=0;
		for(int j=0;j<cnt;j++){
			mi=min(s[dp[j].first][dp[j].second],mi);
		}
		res+=mi;
		int miid=1e9;
		for(int j=0;j<cnt;j++){
			int fi=dp[j].first,se=dp[j].second;
			if(s[fi][se]==mi){
				if(se+1==len[fi]) miid=min(miid,fi);
				else{
					dp[cnt2++]=make_pair(fi,se+1);
				}
			}
		}
		for(int j=miid+1;j<n;j++){
			if(k-len[j]-i>=0&&can[j+1][k-len[j]-i]) dp[cnt2++]=make_pair(j,0);
		}
		cnt=cnt2;
	}
	cout<<res;
}

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

#define rep(i,s,n) for(int i=s; i<n; ++i)
#define per(i,s,n) for(int i=n-1; i>=s; --i)
#define mset(a,n) memset(a, n, sizeof(a))
#define veci vector<int>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sc(a) scanf("%d", &a)
#define prt(a,c) printf("%d%c", a, (c ? '\n' : ' '))

typedef long long LL;

#define INF 0x7fffffff
#define EPS 1e-15
const int N = 3;

char s[N];

int main() {
	bool f = 0;
	scanf("%s", s);
	rep(i,0,N) {
		if(s[i]=='7') {
			printf("Yes\n");
			f = 1;
			break;
		}
	}
	if(!f)
		printf("No\n");
	return 0;
}

Measured memory_bytes: 3764
from collections import deque
 
n,m = map(int,input().split())
 
root = [[] for i in range(n)]
for _ in range(m):
    a, b ,c = (int(x) for x in input().split())
    root[b-1].append(a-1)
    root[a-1].append(b-1) 

check = [-1]*n

ans = 0

for j in range(n):
  if check[j] != -1: continue
  ans += 1
  check[j] = 1
  stack=deque([j])
  check[0] = 0
  while len(stack)>0:
      v = stack.popleft()
      for i in root[v]:
          if check[i] == -1:
              check[i] = 1
              stack.append(i)
for i in check:
  if i == -1:
    ans += 1
print(ans)

Measured memory_bytes: 68768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    if(n%2){
      if (!(i % 2)) cin >> a[n/2 - i/2];
      else cin >> a[n/2 + (i+1)/2];      
    } else {
      if (i % 2) cin >> a[n/2 - (i+1)/2];
      else cin >> a[n/2 + i/2];
    }
  }
  rep(i, n) cout << a[i] << " ";
  cout << endl;
}


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

long long knapsack[100007];
long long int N,W;

int main(){

	cin >> N >> W;
    knapsack[0]=0;
    for(int i=1;i<100007;i++)
    knapsack[i]=10000000000003;
    long long int w[1000];
    int v[1000];
    int V=0;
    for(int i=1;i<=N;i++)
    {
        cin>>w[i]>>v[i];
        V+=v[i];
    }
    //cout<<V<<"\n";
    for(int i=1;i<=N;i++)
    {
        int w2=w[i];
        int v2=v[i];
        for(int j=V;j>=v2;j--)
        knapsack[j]=min(knapsack[j],knapsack[j-v2]+w2);
    }
	for(int i=V;i>=0;i--)
	{
	    if(knapsack[i]<=W)
	    {
	        cout<<i<<"\n";
	        break;
	    }
	}
}

Measured memory_bytes: 1152
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

vector<int> e[100005];
int D[100005][2];

void dfs(int cur, int from, int d, int id)
{
  D[cur][id] = d;
  for(auto v: e[cur]){
    if(v!=from) dfs(v, cur, d+1, id);
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,a,b;
  cin >> n >> a >> b;
  a--,b--;
  REP(i,n-1){
    int s,t;
    cin >> s >> t;
    s--,t--;
    e[s].push_back(t);
    e[t].push_back(s);
  }
  dfs(a,a,0,0);
  dfs(b,b,0,1);

  int ans = 0;
  REP(i,n) {
    if(D[i][0]<D[i][1]) ans = max(ans, D[i][1]-1);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 11648
from collections import Counter

n=int(input())
d=list(map(int,input().split()))

mod=998244353

c=Counter(d)
max_key=max(d)

if d[0]!=0 or c[0]!=1:
  print(0)
  exit()

ans=1
patterns=1
for i in range(max_key+1):
  p_num=c[i]
  ans*=patterns**p_num
  ans%=mod
  patterns=p_num

print(ans)

Measured memory_bytes: 24324