akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define all(c) (c).begin(),(c).end()
#define curr(P,i) P[(i)%P.size()]
#define next(P,i) P[(i+1)%P.size()]
#define prev(P,i) P[(i+P.size()-1)%P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  //bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
bool operator < (Point p)const{return (p.y!=y)?y<p.y:x<p.x;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

//a -> b -> c
int ccw(Point a, Point b, Point c) {
  b = b-a; c = c-a;

  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;    // a--b--c on line
  return 0;                              // a--c--b on line
}

struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}

  bool on(Point c){return abs(ccw(a,b,c))!=1;}
  Real dist(Point c){return abs((b-a).cross(c-a))/(b-a).norm();}

  //射影
  Point project(Point p){
    Point base=b-a;
    Real t=(p-a).dot(base)/base.dot(base);
    return a+base*t;
  }
};


struct Polygon{
  //頂点。反時計回りに順番で与えられていること。
  vector<Point>v;
  
  Polygon(){}
  Polygon(int n){v.resize(n);}

  vector<Point>convexHull(){
    vector<Point>v1=v;
    sort(all(v1));
    int k=0;
    vector<Point> qs(v1.size()*2);
    
    for(int i=0;i<v1.size();i++){
      while(k>1 && (qs[k-1]-qs[k-2]).cross(v1[i]-qs[k-1])<0)k--;
      qs[k++]=v1[i];
    }
    
    for(int i=v1.size()-2,t=k;i>=0;i--){
      while(k>t && (qs[k-1]-qs[k-2]).cross(v1[i]-qs[k-1])<0)k--;
      qs[k++]=v1[i];
    }
    qs.resize(k-1);
    return qs;
  }
};

int main(void){

  int n;
  cin >> n;
  Polygon p(n);

  for(int i=0;i<n;i++)
    cin >> p.v[i].x >> p.v[i].y;
  
  vector<Point>res=p.convexHull();

  cout << res.size() << endl;
  for(int i=0;i<res.size();i++)
    cout << res[i].x << " " << res[i].y << endl;

  return 0;
}

Measured memory_bytes: 7340
#include <iostream>
#include <utility>
#include <queue>

using namespace std;

int main() {
    int N, M;
    cin >> N; cin >> M;
    priority_queue <pair <int, int>, vector <pair <int, int> >, greater <pair<int, int> > > queue;
    priority_queue <int> reward;
    for (int i = 0; i < N; i++) {
        int d, r;
        cin >> d;
        cin >> r;
        queue.push(make_pair(d, r));
    }
    int r = 0;
    for (int d = 1; d <= M; d++) {
        while ((!queue.empty()) && queue.top().first <= d) {
            reward.push(queue.top().second);
            queue.pop();
        }
        if (!reward.empty()) {
            r += reward.top();
            reward.pop();
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1908
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    n,m = mi()
    tree = [[] for _ in range(n)]
    for i in range(m):
        s,t = mi()
        tree[s-1].append(t-1)
    dp = [0]*n
    for i in reversed(range(n-1)):
        size = len(tree[i])
        for k in tree[i]:
            dp[i] += dp[k] 
        dp[i] /= size
        dp[i] += 1
    ans = dp[0]
    
    def func(ss,tt):
        tmp = 0
        for l in tree[ss]:
            if l == tt:
                continue
            tmp += dp[l]
        tmp = tmp/(len(tree[ss])-1) + 1
        if tmp > dp[ss]:
            return dp[0]
        else:
            dp[ss] = tmp
        
        for a in reversed(range(ss)):
            tmp = 0
            for b in tree[a]:
                tmp += dp[b]
            dp[a] = tmp/len(tree[a]) + 1
        
        return dp[0]
    
    for i in range(n-1):
        if len(tree[i]) == 1:
            continue
        for k in tree[i]:
            ans = min(ans,func(i,k))
    print(ans)

main()

Measured memory_bytes: 60760
#include <iostream>
#include <utility>
#include <cstdio>
using namespace std;

void insertionSort(int A[], const int n, const int g, int *cnt)
{
    for( int i = g; i < n; ++i ){
        int tmp = A[i];
        int j = i - g;
        while( -1 < j && tmp < A[j] ){
            //cout << A[j+g] << "<-->" << A[j] << endl;
            A[j+g] = A[j];
            j = j - g;
            ++*cnt;
        }
        A[j+g] = tmp;
    }
}

void shellSort(int A[], const int n)
{
    int cnt = 0;
    int m;
    int G[100];
    for( int i = 0; i < 100; ++i ){
        if( i == 0 ) G[i] = n / 2 + 1;
        else G[i] = G[i-1] / 2 - 1;
        if( G[i] < 0 ){
            G[i-1] = 1;
            G[i] = 0;
            m = i;
            break;
        }
    }

    for( int i = 0; i < m; ++i )
        insertionSort(A, n, G[i], &cnt);

    printf("%d\n", m);
    for( int i = 0; i < m; ++i ){
        if( i ) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for( int i = 0; i < n; ++i )
        printf("%d\n", A[i]);
}

int main()
{
    int n;
    scanf("%d", &n);
    int A[n];
    for( int i = 0; i < n; ++i )
        scanf("%d", &A[i]);

    shellSort(A, n);

    return 0;
}

Measured memory_bytes: 5096
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 5e4+10;
int a[maxn];
string str;
bool cmp(int a,int b)
{
    return a > b;
}
int main()
{
    ll n,x,k;
    cin>>n>>x>>k;
    if(n%x == 0)cout<<n/x*k<<endl;
    else cout<<(n/x+1)*k<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int  n,k,q,b,i,j,sum=0,player;
    cin>>n;
    long long int a[n+2],c[n+2];
    for(i=0;i<n;i++)
    {
        cin>>a[i];


    }
    for(i=1;i<=n;i++)
    {
        cin>>b;
        sum+=b;

    }
    for(i=0;i<n-1;i++)
    {
        cin>>c[i];
    }

    for(i=0;i<n-1;i++)
    {
        if(a[i+1]==a[i]+1)
        sum+=c[a[i]-1];

    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

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

  int n;
  cin >> n;
  vector<int> a(n);
  long x = 0, y = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    y += a[i];
  }
  y -= a[0];
  x += a[0];
  long ans = abs(x-y);
  for(int i = 1; i < n - 1; i++){
    ans = min(ans,abs(x-y));
    x += a[i];
    y -= a[i];
  }
  cout << ans << endl;
}

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

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    if(a<=x && a+b >= x) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc143/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
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 N;
vector<int> L;
void solve() {
  cin >> N;
  L.resize(N);
  loop(n,0,N) cin >> L[n];
  sort(L.begin(), L.end());

  ll count = 0;
  for (int a=0; a<N-2; a++) {
    for (int b=a+1; b<N-1; b++) {
      int min_c = L[b]-L[a]+1;
      int max_c = L[a]+L[b]-1;
      count += upper_bound(L.begin()+b+1, L.end(), max_c) - lower_bound(L.begin()+b+1, L.end(), min_c);
    }
  }
  cout << count << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
 
int main(){
 int64_t N, K, A, B, C;
 string S;
 cin >> N >> S;
 S.at(1) = '0';
 int64_t L = stoi(S);
 C = L % 10;
 B = (L % 100 - C) / 10;
 A = (L - 10 * B - C) / 1000;
 K = N * 100 * A + N * 10 * B + N * C;
 cout << K / 100 << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
struct node
{
	int x,y;
}t;
char a[1005][1005];
int inq[1005][1005];
int n,m;
deque<node>q;
bool check(int x,int y,int w)
{
	return !(x<1||x>n||y<1||y>m||inq[x][y]<=w);
}
signed main()
{
	int i,j,sx,sy,ex,ey;
	string s;
	cin>>n>>m>>sx>>sy>>ex>>ey;
	for(i=1;i<=n;i++)
	{
		cin>>s;
		for(j=1;j<=m;j++)
		{
			a[i][j]=s[j-1];
			if(a[i][j]=='#')
				inq[i][j]=-1;
			else
				inq[i][j]=2147483647;
		}
	}
	q.push_front((node){sx,sy});
	inq[sx][sy]=0;
	while(q.size())
	{
		t=q.front();
		q.pop_front();
		if(t.x==ex&&t.y==ey)
		{
			cout<<inq[ex][ey];
			while(q.size())
				q.pop_front();
			return 0;
		}
		for(i=0;i<4;i++)
			if(check(t.x+dx[i],t.y+dy[i],inq[t.x][t.y]))
			{
				inq[t.x+dx[i]][t.y+dy[i]]=inq[t.x][t.y];
				q.push_front((node){t.x+dx[i],t.y+dy[i]});
			}
		for(i=-2;i<3;i++)
			for(j=-2;j<3;j++)
				if(check(t.x+i,t.y+j,inq[t.x][t.y]+1))
				{
					inq[t.x+i][t.y+j]=inq[t.x][t.y]+1;
					q.push_back((node){t.x+i,t.y+j});
				}
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 12524
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a,b,c;
cin >> a >> b >> c;
if (a==b){ cout << c;}else if(b==c){
cout << a;}else{
cout << b;}
cout << "\n";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const int MOD=1e9+7;
const int MAXN=5e5+7;

int ans=0;
int n,m,k,q;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    int x=n/500;
    ans=x*1000;
    n-=x*500;
    x=n/5;
    ans+=x*5;
    cout<<ans<<"\n";
    return 0;
}


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


int main() {
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2) cout << "Odd" << endl;
    else cout << "Even" << endl;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int s=n;
			int count=0;
			int ma=0,mb=0,mc=0;
			if(n>9)	ma=9;
			else	ma=n;
			for(int a=ma;a>=0;a--){
				int sa=s-a;
				if(sa>9)	mb=9;
				else		mb=sa;
				for(int b=mb;b>=0;b--){
					int sb=sa-b;
					if(sb>9)	mc=9;
					else		mc=sb;
					for(int c=mc;c>=0;c--){
						int sd=sb-c;
						if(sd>=0&&sd<10){
							count++;
							//System.out.printf("%d %d %d %d\n",a,b,c,sd);
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 26244
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

template<class T>
struct Combination{
	vector<T> fact,factinv;
	Combination(int n) : fact(n + 1),factinv(n + 1){
		fact[0] = 1;
		for(int i = 1;i <= n;i++) fact[i] = fact[i - 1] * T(i);
		factinv[n] = ~fact[n];
		for(int i = n;i >= 1;i--) factinv[i - 1] = factinv[i] * T(i);
	}
	T nCr(int n,int r){
		if(r < 0 || n < r) return 0;
		return fact[n] * factinv[r] * factinv[n - r];
	}
};

signed main(){
	int n,k;
	cin >> n >> k;
	if(n == k){
		for(int i = 1;i <= k;i++){
			if(i == 1) cout << 1 << endl;
			else cout << 0 << endl;
		}
		return 0;
	}
	Combination<modint<>> comb(2010);
	for(int i = 1;i <= k;i++){
		modint<> ans = comb.nCr(n - k - 1,i - 1) * modint<>(2) + comb.nCr(n - k - 1,i);
		if(i != 1) ans += comb.nCr(n - k - 1,i - 2);
		cout << comb.nCr(k - 1,i - 1) * ans << endl;
	}
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

input=sys.stdin.readline

N,M,Q=map(int,input().split())
rail=defaultdict(int)
for i in range(0,M):
    l,r=map(int,input().split())
    rail[(l,r)]+=1

#dp[i][j]:i+1<=l,r==j+1となるものの個数
dp=[[0 for i in range(0,N)] for j in range(0,N)]
for i in range(0,N):
    dp[i][i]=rail[(i+1,i+1)]

for j in range(0,N):
    for i in range(0,j):
        k=j-1-i
        dp[k][j]=dp[k+1][j]+rail[(k+1,j+1)]

ans=[[0 for i in range(0,N)] for j in range(0,N)]

for i in range(0,N):
    ans[i][i]=dp[i][i]

for i in range(0,N):
    for j in range(i+1,N):
        ans[i][j]=ans[i][j-1]+dp[i][j]

x=[]
for i in range(0,Q):
    p,q=map(int,input().split())
    x.append(ans[p-1][q-1])

for i in range(0,Q):
    print(x[i])


Measured memory_bytes: 72540
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

import math

def is_prime(n):
        if n == 1:
            return False
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

def main():
    x = int(input())

    for i in range(x,100004):
        if is_prime(i)==True:
            print(i)
            break

if __name__=="__main__":
    main()

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
#endif

	int a[5];
	int ans=-1;
	for(int i=0;i<5;i++)
	{
		int x;
		cin>>x;
		if(x==0)
		{
			ans=i+1;
		}
	}

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

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    int t = 0;
    while (a >= b) t++, b *= 2;
    while (b >= c) t++, c *= 2;
    printf("%s\n", t <= k ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3760
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    double dp[2][k+1];
    int cur = 0;
    int nxt = 1;

    for(int i=0;i<2;++i)
    {
        for(int j=0;j<k+1;++j)
        {
            dp[i][j] = 0;
        }
    }

    for(int i=1;i<=n;++i){
        dp[cur][min(i, k)] += 1.0 / n;
    }

    while(true)
    {
        // printf("====================\n");
        // for(int i=0;i<=k;++i)
        // {
        //     printf("%lf\n", dp[cur][i]);
        // }
        // printf("====================\n");

        double remaining = 0;
        for(int i=1;i<k;++i)
        {
            remaining += dp[cur][i];
        }

        if(remaining < 1e-12)
        {
            break;
        }
        dp[nxt][0] += dp[cur][0];
        dp[nxt][k] += dp[cur][k];
        for(int i=1;i<k;++i)
        {
            int next_score = min(i * 2, k);
            dp[nxt][next_score] += 0.5 * dp[cur][i];
            dp[nxt][0] += 0.5 * dp[cur][i];
        }
        
        for(int i=0;i<=k;++i)
        {
            dp[cur][i] = 0;
        }

        cur = 1 - cur;
        nxt = 1 - nxt;
    }

    printf("%.12lf\n", dp[cur][k]);
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        ans += a-1;
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3688
// Working program with FastReader
import java.io.BufferedReader; 

import java.io.IOException; 
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner; 
import java.util.StringTokenizer;
import java.lang.*;
public class Main
{ 
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} 

	long gcd(long a, long b) {
		if(b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int n=ob.nextInt(),t=ob.nextInt();
		boolean   arr[] = new boolean[n+1];
		long p[] = new long[n+1];
		long count=0;
		for (int i1 = 0; i1 < t; i1++) {
			int k = ob.nextInt();
			String s = ob.next();
			if(!arr[k] && s.compareTo("AC")==0) {
				arr[k]=true;
				count++;
			}
			else if(!arr[k]) {
				p[k]++;
			}

		}
		long p1=0;
		for (int i = 1; i < p.length; i++) {
			if(arr[i]) {
				p1+=p[i];
			}
		}
		System.out.println(count+" "+p1);
		
	}
} 


Measured memory_bytes: 45252
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 300001;
const ll M = 1;
struct point {
    ll x, y;
    ll i;
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        ll n, m, x = 0, y = 0, ans = 0, k;
        cin >> k;
        n = 400;
        ll a[n + 1] = {};
        for(int i = 1; i <= 200; i++)
        {
            y = i;
            m = y * y;
            m = m * m * y;
            a[i + 200] = m;
        }
        for(int i = 1; i <= 200; i++)
        {
            y = i;
            m = y * y;
            m = m * m * y;
            m = -m;
            a[i] = m;
        }
        x = -1, y = -1;
        for(int i = 0; i <= n; i++)
        {
            for(int j = 0; j <= n; j++)
            {
                if(a[i] - a[j] == k)
                {
                    if(i > 200)
                        x = i - 200;
                    else x = -i;
                    if(j > 200)
                        y = j - 200;
                    else y = -j;
                    break;
                }
            }
        }
        cout << x << " " << y << "\n";
    }
    return 0;
}


Measured memory_bytes: 3612
import numpy as np
N, M = map(int, input().split(' '))
suc_list = np.zeros(N, dtype=np.uint8)
fai_count = np.zeros(N, dtype=np.int32)
for i in range(M):
    p, s = input().split(' ')
    p = int(p) - 1
    if suc_list[p] == 0:
        if s == 'WA':
            fai_count[p] += 1
        else:
            suc_list[p] = 1

print('{} {}'.format(np.sum(suc_list), np.sum(fai_count[suc_list == 1])))

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

int main () {
  int n, d, x;
  cin >> n >> d >> x;
  int a[n], date[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    date[i] = (d - 1) / a[i];
  }  
  int sum = x;
  for (int i = 0; i < n; i++) {
    sum = sum + date[i] + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 300111
#define inf 1000000000000000007

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s,t="YAKI";
	cin>>s;
	if(s.size() < 4)cout<<"No";
	else{
		for(int i =0 ; i < 4 ; i++){
			if(s[i]!=t[i]){
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
	}
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=15;

vector <string> ans;
int n;

void dfs(int pos,string s){
//	cout<<s<<endl;
	if(pos==n){
		ans.pb(s);
		return;
	}
	vector <char> v;
	for(int i=0;i<s.size();i++) v.pb(s[i]);
	sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0;i<v.size();i++) dfs(pos+1,s+v[i]);
	dfs(pos+1,s+char(v[v.size()-1]+1));
}

int main(){
	cin>>n;
	dfs(1,"a");
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 9588
##### 解けた #####

dic={"a":0,"b":1,"c":2} # 文字→数字
dicr={0:"a",1:"b",2:"c"} # 数字→文字

Sa=input()
Sb=input()
Sc=input()
S=[Sa,Sb,Sc] # リストにしておく
i=0 # 最初はA

while True:
    if len(S[i])==0: # 空になったら表示して終了
        print(dicr[i].upper()) # 表示
        break

    card=S[i][0] # カードを取得
    S[i]=S[i][1:] # 先頭を削る
    i=dic[card] # 番を更新

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

int main() {
  ll n;
  cin>>n;
  ll a[n];
  for(int i = 0;i < n;i++)
    cin>>a[i];
  ll s[n+1];
  s[n] = 0;
  for(int i = n-1; i>=0;i--) {
    s[i] = (s[i+1] + a[i])%mod;
  }
  
  ll ans = 0;
  for(int i = 0;i < n;i++) {
    ans = (ans + ((a[i] % mod) * (s[i+1] % mod)))%mod;
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 6712
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

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

$L = [];
$L[0] = $A[0];
for ($i = 1; $i < $n; ++$i) {
    $L[$i] = gcd($L[$i - 1], $A[$i]);
}

$R = [];
$R[$n - 1] = $A[$n - 1];
for ($i = $n - 2; $i >= 0; --$i) {
    $R[$i] = gcd($R[$i + 1], $A[$i]);
}

$max = 0;
for ($i = 0; $i < $n; ++$i) {
    switch ($i) {
    case 0:
        $max = max($R[1], $max);
        break;
    case $n - 1:
        $max = max($max, $L[$n - 2]);
        break;
    default:
        $max = max($max, gcd($L[$i - 1], $R[$i + 1]));
    }
}
echo $max;


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

    if (b > n*a)    cout << n*a << endl;
    else cout << b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char op[3];
long long a[100010],b[100010];
long long sum[100010];
int main()
{
	int n;
	scanf("%d",&n);
	int N=1;
	scanf("%d",&a[N]);
	for(int i=2;i<=n;i++)
	{
		scanf("%s",&op);
		int x;scanf("%d",&x);
		if(op[0]=='-'){
			N++;b[N]=x;
		}
		a[N]+=x;
	}
	for(int i=1;i<=N;i++)
		sum[i]=sum[i-1]+a[i]-2*b[i];
	long long ans=sum[N];
	long long cur=0;
	for(int i=N;i>1;i--)
	{
		ans=max(ans,sum[i-1]+cur-a[i]);
		cur+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
### constant

ALEN = 8

R_P = 0
R_D = 1

### subroutines

def adr_match?(adr, pat)
  for i in (0...ALEN)
    return false if pat[i] != '?' && adr[i] != pat[i]
  end
  true
end

def filter(n, rules, packet)
  sadr, dadr = packet

  (n - 1).downto(0) do |i|
    op, spat, dpat = rules[i]
    if adr_match?(sadr, spat) && adr_match?(dadr, dpat)
      return op
    end
  end

  R_D
end

### main

loop do
  n, m = gets.split.map(&:to_i)
  break if (n | m) == 0

  rules = []
  n.times do
    op, spat, dpat = gets.strip.split
    rules << [op == 'permit' ? R_P : R_D, spat, dpat]
  end
  #p rules

  packets = []

  m.times do
    packet = gets.strip.split

    if filter(n, rules, packet) == R_P
      packets << packet
    end
  end

  puts packets.length
  packets.each{|pkt| puts pkt.join(' ')}
end

Measured memory_bytes: 6124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n;
  int ans[4] = {};
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "AC") ans[0]++;
    if (s == "WA") ans[1]++;
    if (s == "TLE") ans[2]++;
    if (s == "RE") ans[3]++;
  }
  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

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

    vector<char> v;
    rep(i,s.size()){
        if(v.empty()) v.emplace_back(s[i]);
        else if(v.back() == '(' && s[i] == ')'){
            v.pop_back();
        }else v.emplace_back(s[i]);
    }

    int l = 0, r = 0;
    rep(i,v.size()){
        if(v[i] == ')') l++;
        else r++;
    }

    rep(i,l) cout << '(';
    cout << s;
    rep(i,r) cout << ')';
    cout << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import defaultdict
from collections import deque


def solve(N: int, K: int, T: "List[int]", D: "List[int]"):
    ml = []

    for t,d in zip(T,D):
        ml.append((t,d))
    ml.sort(key=lambda x: x[1],reverse=True)

    mli = ml[0:K]
    mlo = deque(ml[K:])
    mli.reverse()

    tdic = defaultdict(int)
    for i in mli:
        tdic[i[0]] += 1
    
    max_score = sum(map(lambda x:x[1],mli)) + len(tdic)**2
    prev_score = max_score
    for i,p in enumerate(mli):
        if tdic[p[0]] > 1:
            while len(mlo) > 0:
                q = mlo.popleft()
                if q[0] not in tdic:
                    tdic[p[0]] -= 1
                    tdic[q[0]] += 1
                    mli[i] = q
                    tdic_len  = len(tdic)
                    new_score = prev_score - p[1] + q[1] - (tdic_len-1)**2 + (tdic_len)**2
                    max_score = max(max_score,new_score)
                    prev_score = new_score
                    break

    print(max_score)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]" 
    d = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        t[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, K, t, d)

if __name__ == '__main__':
    main()


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
class Graph{

public:
  vector<vector<int>> graphs;
  vector<bool> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS

  Graph(int n){
    graphs.resize(n);
    init(n);
  }
  ~Graph(){}

  void addedge(int u, int v){
    u--; v--;
    graphs[u].push_back(v);
    graphs[v].push_back(u);
  }

  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }

  void init(int n){
    check.resize(n, false);
    dist.resize(n, -1);
  }

  void reset(){
    rep(i,check.size()){
      check[i]=false;
      dist[i]=-1;
    }
  }

  void dfs(int v)
  {
    check[v] = true;

    for(auto next_v : graphs[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }

  void bfs(int v)//----------------------
  {
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graphs[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }//-----------------------

};

int main(void) {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  g.addedge_cin(m);

  g.bfs(0);
  if(g.dist[n-1]==2){
    prt("POSSIBLE");
  } else {
    prt("IMPOSSIBLE");
  }
}


Measured memory_bytes: 13936
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int X[N];
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    
    sort(X, X + N);

    int min = 1000000000;
    for (int i = X[0]; i <= X[N - 1]; i++)
    {
        int sum = 0;
        for (int j : X)
        {
            sum += (j - i) * (j - i);
        }
        if (sum < min)
        {
            min = sum;
        }

    }

    cout << min << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

#define ll long long

int main(){

  ll t;
  cin >> t;

  for(ll tt = 0; tt < t; tt++){
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    for(ll i = 0; i < n; i++){
      cin >> x[i];
    }
    if(n < k){
      cout << 0 << '\n';
    }else{
      sort(x.begin(), x.end());
      vector<ll> a(n-1);
      for(ll i = 0; i < n-1; i++){
	a[i] = x[i+1] - x[i];
      }
      sort(a.begin(),a.end());
      ll ans = x[n-1] - x[0];
      for(ll i = 0; i < k - 1; i++){
	ans -= a[n - 2 - i];
      }
      cout << ans << '\n';
    }
  }
}

Measured memory_bytes: 4288
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int INF=(1<<24);
int dy[6]={0,-1,-1,0,1,1};
int dx[2][6]={
  {-1,-1,0,1,0,-1},{-1,0,1,1,1,0}
};
int W,H,n,m,I;
int ty[100],tx[100];
int uy[100],ux[100];
int v[100][100];

queue <int> Qy;
queue <int> Qx;
queue <int> Qcnt;
queue <int> Qid;

bool input();
void init(int);
void solve();
int bfs();

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

int bfs(){
  int y,x,ny,nx,cnt,id,res=0;
  while(!Qy.empty()){
    y=Qy.front();Qy.pop();
    x=Qx.front();Qx.pop();
    cnt=Qcnt.front();Qcnt.pop();
    id=Qid.front();Qid.pop();


    if(id==n+I)res++;

    for(int i=0;i<6;i++){
      ny=y+dy[i];
      nx=x+dx[y%2][i];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(cnt+1>=v[ny][nx])continue; 
      v[ny][nx]=cnt+1;
      Qy.push(ny);
      Qx.push(nx);
      Qcnt.push(cnt+1);
      Qid.push(id);
    
    }
  }
  return res;
}

void solve(){
  int ans=0;
  for(I=0;I<m;I++){
    init(I);
    ans=max(ans,bfs());
  }
  cout<<ans<<endl;
}

bool input(){
  cin>>W>>H;
  if(W==0&&H==0)return false;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tx[i]>>ty[i];
    ty[i]--;
    tx[i]--;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>ux[i]>>uy[i];
    uy[i]--;
    ux[i]--;
  }
  return true;
}

void init(int s){
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      v[i][j]=INF;
    }
  }
  while(!Qy.empty()){
    Qy.pop();
    Qx.pop();
    Qcnt.pop();
    Qid.pop();
  }
  

  for(int i=0;i<n;i++){
    Qy.push(ty[i]);
    Qx.push(tx[i]);
    Qcnt.push(0);
    Qid.push(i);
    v[ty[i]][tx[i]]=0;
  }
  Qy.push(uy[s]);
  Qx.push(ux[s]);
  Qcnt.push(0);
  Qid.push(n+s);
  v[uy[s]][ux[s]]=0;
}

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

void showClassification(double w);

int main()
{
    double w;
    while(cin >> w)
    {
        showClassification(w);
    }
    return 0;
}

void showClassification(double w)
{
    if(islessequal(w, 48.00))
    {
        cout << "light fly" << endl;
    }
    else if(isgreater(w, 48.00) && islessequal(w, 51.00))
    {
        cout << "fly" << endl;
    }
    else if(isgreater(w, 51.00) && islessequal(w, 54.00))
    {
        cout << "bantam" << endl;
    }
    else if(isgreater(w, 54.00) && islessequal(w, 57.00))
    {
        cout << "feather" << endl;
    }
    else if(isgreater(w, 57.00) && islessequal(w, 60.00))
    {
        cout << "light" << endl;
    }
    else if(isgreater(w, 60.00) && islessequal(w, 64.00))
    {
        cout << "light welter" << endl;
    }
    else if(isgreater(w, 64.00) && islessequal(w, 69.00))
    {
        cout << "welter" << endl;
    }
    else if(isgreater(w, 69.00) && islessequal(w, 75.00))
    {
        cout << "light middle" << endl;
    }
    else if(isgreater(w, 75.00) && islessequal(w, 81.00))
    {
        cout << "middle" << endl;
    }
    else if(isgreater(w, 81.00) && islessequal(w, 91.00))
    {
        cout << "light heavy" << endl;
    }
    else
    {
        cout << "heavy" << endl;
    }
}

Measured memory_bytes: 3156
import itertools
import numpy as np

n = int(input())
a = list(map(int,input().split()))
ac = list(itertools.accumulate(a))

def getNearestValue(list, num):
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

sum = ac[-1]
half = sum/2
near = getNearestValue(ac,half)
dif = abs(ac[near]-half)
print(int(dif * 2))
   


    
    


Measured memory_bytes: 34200
# coding: utf-8
D, G = map(int, input().split())
pc = []
for i in range(D):
    p, c = map(int, input().split())
    pc.append([p, c])
ans = 10**7
for i in range(2**D):
    tmp = 0
    cnt = 0
    rest = list(range(1, D+1))
    for j in range(D):
        if (i >> j) & 1 == 1:
            tmp += pc[j][0] * 100 * (j+1) + pc[j][1]
            cnt += pc[j][0]
            rest.remove(j+1)
    # print(rest)
    if tmp < G:
        plus = max(rest)
        n = min(pc[plus-1][0], -(-(G-tmp) // (plus * 100)))
        cnt += n
        tmp += n * plus * 100
    if tmp >= G:
        ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
unittest
{
	assert( [ "2" ].parse.expand.solve == 9 );
	assert( [ "200" ].parse.expand.solve == 10813692 );
}



import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.to!( long );
	return tuple( k );
}

auto solve( long k )
{
	auto ans = 0L;
	foreach( a; 1L .. k + 1 )
	{
		foreach( b; 1L .. k + 1 )
		{
			foreach( c; 1L .. k + 1 )
			{
				ans += gcd( gcd( a, b ), c );
			}
		}
	}
	return ans;
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,sum = -100,m;
    map<long long int,long long int>mp;

    vector<long long int>v;
    cin>>n;
    for(i = 0; i < n; i++)
    {
        cin>>m;
      if(mp[m]==0)
        v.push_back(m);

        mp[m]++;


    }
    sort(v.begin(),v.end());
    for(i = 0; i < v.size(); i++)
    {

        if(mp[v[i]]>=2)
        {
            for(int j = v.size()-1; j > i; j--)
            {
                if(mp[v[j]]>=2)
                {

                    if(v[i]*v[j]>sum)
                        sum = v[i]*v[j];
                    break;
                }

            }
        }

    }
    for(i = v.size()-1; i >= 0; i--)
    {

        if(mp[v[i]]>=4 && v[i]*v[i]>sum)
        {
            sum = v[i]*v[i];
            break;
        }

    }

    if(sum<0)
        sum = 0;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 7284
#include <bits/stdc++.h>
using i64 = long long;

i64 gcd(i64 a, i64 b) { return b ? gcd(b, a % b) : a; }

int main() {
    i64 n, m;
    std::cin >> n >> m;
    std::vector<i64> v(n);
    for (auto &e : v) std::cin >> e;

    i64 l = v.front();
    for (int i = 1; i < n; i++) {
        l = l / gcd(l, v[i]) * v[i];
        if (l > 2000000000) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    bool flg = true;
    i64 a = l / 2;
    for (auto e : v) {
        if (a / (e / 2) % 2 == 0) flg = false;
    }

    std::cout << (flg ? m / l + (m % l >= a) : 0) << std::endl;

    return 0;
}


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

int main() {
	ll x;
	cin >> x;
	int year = 0;
	ll yokin = 100;
	while (yokin<x) {
		yokin *= 1.01;
		year++;
	}
	cout << year << endl;
	return 0;
}


Measured memory_bytes: 3580
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
ans = 0
n = ii()

for i in range(n):
    x,u = ism()
    if u == 'JPY':
        ans += int(x)
    else:
        ans += float(x)*380000
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  
  vector <int> a(m);
  
  for (int i; i < m; i++){
    cin >> a.at(i);
  }
  
  for (int i; i < m; i++){
    n -= a.at(i);
  }
  
  if (n < 0){
    cout << -1 << endl;
  }
  else{
    cout << n << endl;
  }
}

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

using namespace std;

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

    int before = atoi(s.substr(0,2).c_str());
    int after = atoi(s.substr(2,2).c_str());

    bool before_b = (before > 12) || (before == 0);
    bool after_b = (after > 12) || (after == 0);

    if (before_b && after_b) {
        cout << "NA" << endl;
    } else if((!before_b) && after_b) {
        cout << "MMYY" << endl;
    } else if(before_b && !after_b) {
        cout << "YYMM" << endl;
    } else {
        cout << "AMBIGUOUS" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define int long long

int p = 0;

struct TNode
{
	int data;
	struct TNode *left, *right;
};

typedef struct TNode *Tree;

Tree insert(Tree T, int x)
{
	if (T == NULL)
	{
		T = (Tree)malloc(sizeof(struct TNode));
		T->data = x;
		T->left = T->right = NULL;
	}
	if (x < T->data)
		T->left = insert(T->left, x);
	if (x > T->data)
		T->right = insert(T->right, x);
	return T;
}

void inorder(Tree T)
{
	if (T)
	{
		inorder(T->left);
		printf(" %lld", T->data);
		inorder(T->right);
	}
}

void preorder(Tree T)
{
	if (T)
	{
		printf(" %lld", T->data);
		preorder(T->left);
		preorder(T->right);
	}
}

void print(Tree T)
{
	inorder(T);
	printf("\n");
	preorder(T);
	printf("\n");
}

int main()
{
	int n, x;
	char s[20];
	Tree T;
	T = NULL;

	scanf("%lld", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%s", s);
		if (s[0] == 'i')
		{
			scanf("%lld", &x);
			T = insert(T, x);
		}
		if (s[0] == 'p')
			print(T);
	}
}


Measured memory_bytes: 17336
#include <stdio.h>

struct Team
{
	char name;
	int win;
	int lose;
};

int main(void)
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		struct Team result[10];
		int i, j;
		
		for (i = 0; i < n; i++){
			scanf("%*c%c", &result[i].name);
			result[i].win = result[i].lose = 0;
			for (j = 0; j < n - 1; j++){
				int t;
				
				scanf("%d", &t);
				if (t == 0){
					result[i].win++;
				}
				else if (t == 1){
					result[i].lose++;
				}
			}
		}
		for (i = 0; i < n - 1; i++){
			for (j = 0; j < n - i - 1; j++){
				if (result[j].win < result[j + 1].win){
					struct Team tmp = result[j];
					result[j] = result[j + 1];
					result[j + 1] = tmp;
				}
				else if (result[j].win == result[j + 1].win && result[j].lose > result[j + 1].lose){
					struct Team tmp = result[j];
					result[j] = result[j + 1];
					result[j + 1] = tmp;
				}
			}
		}
		for (i = 0; i < n; i++){
			printf("%c\n", result[i].name);
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
from sys import stdin


def main() -> None:
    n = int(next_str())

    for i in range(1, n + 1):
        if not judge(i + 1, n):
            print(i ** 2)
            break


def judge(i: int, n: int) -> bool:
    if i ** 2 <= n:
        return True
    return False


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

int main(){
  string A,B;
  int i;
  cin >> A >> B;
  for(i = 0; i < B.size(); i++){
    cout << A.at(i) << B.at(i);
  }
  if(A.size() != B.size()){
    cout << A.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256