akhauriyash/Code-Regression huggingface dataset:
let cnt = ref 0
let (g : int list ref) = ref []
let n_g = ref 0

let insertion_sort (a : int array) n g =
  for i = g to n - 1 do
    let v = a.(i) in
    let j = ref (i - g) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+g) <- a.(!j);
      j := !j - g;
      incr cnt;
    done;
    a.(!j+g) <- v;
  done

let generate_g n =
  let new_g = ref 1 in
  incr n_g;
  while !new_g <= n do
    g := !new_g :: !g;
    new_g := int_of_float (4.**(float_of_int !n_g) +. 3.*.2.**(float_of_int (!n_g - 1)) +. 1.);
    incr n_g;
  done;
  decr n_g

let shell_sort (a : int array) n =
  cnt := 0;
  generate_g n;
  List.iter (fun g -> insertion_sort a n g) !g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  shell_sort a n;
  Printf.printf "%d\n" !n_g;
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12620
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
void solve() {
    int n, m;
    cin >> n >> m;
    cout << n * m << endl;
}
int main() {
    init();
    solve();
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
using namespace std;
vector<int> num;
int nums;
int sum,ave;
int calc_ans(vector<int> ve,int average){
	int ans = 0;
	for(int i = 0;i < ve.size();i++){
		ans += (ve[i]-average) * (ve[i]-average);
	}
	return ans;
}
void solve(){
	for(int i = 0;i < nums;i++){
		ave += num[i];
	}

	if(ave%nums != 0){
		sum = min(calc_ans(num,ave/nums),calc_ans(num,ave/nums+1));
		sum = min(sum,calc_ans(num,ave/nums-1));
	}else{
		sum = calc_ans(num,ave/nums);
	}
	
	cout << sum << endl;
}
int main(){
	cin >> nums;
	int input;
	while(cin >> input){
		num.push_back(input);
	}
	solve();
	return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> v(N);
  rep(i,N) cin >> v[i];
  sort(v.begin(),v.end());
  float ans=v[0];
  rep(i,N-1){
    ans = (ans + v[i+1])/2;
  }
  cout << ans << endl;
}

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

int main(){
  
  int n;
  cin>>n;
  
  vector<int >s,d;
  int x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    s.push_back(x+y);
    d.push_back(x-y);
  }
  
  sort(s.begin(),s.end());
  sort(d.begin(),d.end());
  
  int ans = max(s[n-1]-s[0] , d[n-1]-d[0]);
  cout<<ans;
  
}

Measured memory_bytes: 5080
#include<iostream>
#include<algorithm>
using namespace std;
int n,maxn,ans;
char x;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x=='I')++ans;
		if(x=='D')--ans;
		maxn=max(maxn,ans);
	}
	cout<<maxn<<endl;
}

Measured memory_bytes: 256
N = int(input())
W = map(int, input().split())
W = list(W)

diffs = []
for n in range(1,N):
  w1 = W[:n]
  w2 = W[n:]
  
  su_w1 = sum(w1)
  su_w2 = sum(w2)
  
  diff = abs(su_w1 - su_w2)
  diffs.append(diff)
  
print(min(diffs))

Measured memory_bytes: 9196
s = int(input())
L = [0]*1000001
a = s
t = 1
while True:
    if L[a]==1:
        break
    else:
        L[a] = 1
    if a%2==0:
        a = a//2
    else:
        a = 3*a+1
    t+=1
print(t)


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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a)a, rreps(i,  0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

const string YES_STR = "YES";
const string NO_STR = "NO";

void solve(long long N, std::vector<long long> p) {
	int cnt = 0;
	rep(i, N) {
		if (p[i] != i + 1) {
			cnt++;
		}
	}
	YES(cnt == 0 || cnt == 2);
}

signed main() {
	long long N;
	scanf("%lld",&N);
	std::vector<long long> p(N);
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&p[i]);
	}
	solve(N, std::move(p));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;
const int MOD = 100000;

struct BIT{
	vi dat;
	int size;
	BIT(int s):size(s+1){
		dat.resize(size);
	}

	void add(int n, int x){
		while(n < size){
			dat[n] += x;
			n += n&-n;
		}
	}

	int dist(int l, int r){
		return abs(sum(r)-sum(l));
	}

	int sum(int n){
		int s = 0;
		while(n > 0){
			s += dat[n];
			n -= n&-n;
		}
		return s;
	}
};

int main(){
	int n, m;
	while(cin >> n >> m){
		BIT bit(n);
		rep(i, n-1){
			int s;
			cin >> s;
			bit.add(i+1, s);
		}		
		//rep(i, bit.size){
		//	cout << i << ":";
		//	cout << bit.dat[i] << endl;
		//	cout << "sum:";
		//	cout << bit.sum(i) << endl;
		//}

		int ans = 0;
		int pos = 0;
		rep(i, m){
			int a;
			cin >> a;
			ans += bit.dist(pos, pos+a);
			ans %= MOD;
			pos += a;
		}
		cout << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 1532
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int a = sc.nextInt();
    static int b = sc.nextInt();
    static int c = sc.nextInt();

    public static void main(String[] args) {
        if (a < b && b < c && a < c)
            System.out.println("Yes");
        else 
            System.out.println("No");
    }
}



Measured memory_bytes: 26128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll A[100010];

int main() {
	int N, V, P;
	ll M;
	cin >> N >> M >> V >> P;
	for(int i=0; i<N; ++i) cin >> A[i];
	sort(A, A+N, greater<ll>());
	int ok=P-1, ng=N;
	while(ok+1<ng){
		int mid=(ok+ng)/2;
		ll T=A[mid]+M;
		int now=mid-1;
		ll sum=0;
		bool flag=false;
		while(now>=0){
			if(A[now]>T) break;
			sum += T-A[now];
			if(now<P){
				if(sum>=M*(V-N+mid-now)){
					flag=true;
					break;
				}
			}
			--now;
		}
		if(flag) ok=mid;
		else ng=mid;
	}
	cout << ng << endl;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

int gcd(int x, int y){
	return y ? gcd(y, x%y) : x;
}

void Main()
{
	int n, T;
  	cin >> n >> T;
  	vi t(n);
  	ll ans = 0;
  	rep(i,n) {
      	cin >> t[i];
      	if(i==0) continue;
      	if(t[i]-t[i-1]<T) ans += t[i]-t[i-1];
      	else ans += T;
    }
  	ans += T;
  	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e18
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> r;
    rep(i, n) {
        int ext = -1;
        for (int j = a.size() - 1; j >= 0; j--) {
            if (a[j] == j + 1) {
                ext = j;
                break;
            }
        }
        if (ext == -1) {
            cout << -1 << endl;
            return 0;
        }
        a.erase(a.begin() + ext);
        r.push_back(ext + 1);
    }
    reverse(r.begin(), r.end());
    for (auto q : r) {
        cout << q << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    *A, = map(int, input().split())

    money = 1000

    low = A[0]
    p = A[0]
    for x in A:
        if p > x:
            money += (p - low) * (money // low)
            low = x
        p = x

    money += (p - low) * (money // low)

    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9028
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		
		Node[] nodeArray = new Node[N];
		for (int i=0; i<N; i++) {
			nodeArray[i] = new Node();
		}
		for (int i=0; i<N - 1; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			nodeArray[a-1].children.add(nodeArray[b-1]);
			if (a != 1) {
				nodeArray[b-1].children.add(nodeArray[a-1]);
			}
		}
		
		for (int i=0; i<Q; i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			nodeArray[p-1].count += x;
		}
		
		count(nodeArray[0], 0);
		
		StringBuilder sb = new StringBuilder();
		sb.append(nodeArray[0].count);
		for (int i=1; i<N; i++) {
			sb.append(" " + nodeArray[i].count);
		}
		System.out.println(sb);
	}
	
	static void count(Node n, long cnt) {
		if (n.visited) {
			return;
		}
		n.count += cnt;
		n.visited = true;
		for (Node c : n.children) {
			count(c, n.count);
		}
	}
	
	static class Node {
		List<Node> children = new ArrayList<>();
		long count = 0;
		boolean visited = false;
	}
}

Measured memory_bytes: 216996
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//
//using namespace __gnu_pbds;
using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
tree<
       int,
     null_type,
     less<int>,
     rb_tree_tag,
     tree_order_statistics_node_update>t;
*/
int main()
{
    fast_in_out

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

    int mid=a[n/2];
    int ager=a[n/2-1];

    int ans=mid-ager;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxx = 10000;
int read(){int k;cin>>k;return k;}
int lin[maxx],len,k,ans;
int Max,P1,P2;
struct edge{int y,next;}e[maxx];
void init(int x,int y){e[++len].y=y;e[len].next=lin[x];lin[x]=len;}
int mx1[maxx],mx2[maxx],p1[maxx],p2[maxx];
int flag[maxx];
int X;
int a[maxx][maxx];
void dfs(int x,int fa,int deep){
	a[X][x]=a[x][X]=deep;
	for(int i=lin[x];i;i=e[i].next){
		int y=e[i].y;
		if(y==fa)continue;
		dfs(y,x,deep+1);
	}	
	return ;
}	
int n;
int lenx[maxx];
int main(){	
	n=read();k=read();
	for(int i=1;i<n;i++){
		int x=read();int y=read();
		init(x,y);init(y,x);
	}	
	for(int i=1;i<=n;i++)dfs(X=i,0,0);
	for(int i=1;i<=n;i++){	
		for(int j=1;j<=n;j++)if(a[i][j]>k)lenx[i]++;
	}	
	while(1){
		int p=0;
		int Max=0;
		for(int i=1;i<=n;i++){
			if(lenx[i]>Max)Max=lenx[i],p=i;
		}	
		if(Max==0)break;
		for(int i=1;i<=n;i++){
			a[p][i]=0;
			lenx[i]-=(a[i][p]>k);
			a[i][p]=0;
		}
		lenx[p]=0;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
} 	

Measured memory_bytes: 78848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
    int N,W;
    cin >> N >> W;
    vector<int> dp(W+1,0);
     
    for(int i=0; i<N; i++) {
    int v,w,m;
    cin >> v >> w >> m;
 
    for(int k=0; m>0; k++) {
        int num = min(m, (1<<k));
        m -= num;
        for(int j=W; j >= num*w; j--) 
        dp[j] = max(dp[j], dp[j-num*w] + num*v);
    }
    }
 
    int ans = 0;
    for(int x : dp) ans = max(ans,x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int M=1e5+5;
int n;
int a[M];
struct node{
	ll s;
	int flag;
}b[M];
ll res[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	b[1].s=0,b[1].flag=1;
	for(int i=2;i<=n;i++){
		b[i].s=-b[i-1].s+2*a[i-1];
		b[i].flag=-b[i-1].flag;
	}
	res[1]=(2*a[n]-b[n].s)/2;
	for(int i=2;i<=n;i++)res[i]=a[i-1]*2-res[i-1];
	for(int i=1;i<=n;i++)printf("%lld ",res[i]);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  int lighten = 1;
  vector<int> route;
  while (lighten != 2) {
    route.push_back(lighten);
    lighten = a.at(lighten - 1);
    if (route.size() > N) break;
  }
  if (route.size() > N) {
    cout << -1;
  }
  else {
    cout << route.size();
  }
}


Measured memory_bytes: 4320
#include <iostream>
#include<algorithm>
#include<stack>
#include<string>
#include<cstdlib>
#include<stdio.h>
using namespace std;
int n,a[50];
int solve(int i){
    if(i==1||i==0)return 1;
    return solve(i-1)+solve(i-2);
}
int main(){
    int n;
    cin>>n;
    int ans[50];
    ans[0]=1,ans[1]=1;
    for(int i=2; i<=n; i++){
        ans[i]=ans[i-1]+ans[i-2];
    }
    cout<<ans[n]<<endl;
    return 0;
}

Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static int[] S ;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int a = Integer.parseInt(W);
		 W = in.readLine();

		int b = Integer.parseInt(W);
		 W = in.readLine();

		int h = Integer.parseInt(W);

		System.out.println((a+b)*h/2);
	}
}


Measured memory_bytes: 21076
using AtCoderBeginnerContest150.Questions;
using AtCoderBeginnerContest150.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest150.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var kx = inputStream.ReadIntArray();
            var k = kx[0];
            var x = kx[1];

            yield return 500 * k >= x ? "Yes" : "No";
        }
    }
}


namespace AtCoderBeginnerContest150
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest150.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest150.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11348
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        const int Max = 100010;
        static int[] dp = new int[Max];
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            dp = dp.Select(z => z = N).ToArray();
            dp[0] = 0;

            for (var i = 1; i <= N; i++)
            {
                for (var six = 1; six <= i; six *= 6)
                {
                    dp[i] = Math.Min(dp[i], dp[i - six] + 1);
                }
                for (var nine = 1; nine <= i; nine *= 9)
                {
                    dp[i] = Math.Min(dp[i], dp[i - nine] + 1);
                }
            }
            Console.WriteLine(dp[N]);
        }
    }
}

Measured memory_bytes: 14260
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define All(x) (x).begin(),(x).end()
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
const double PI=acos(-1.0);
const double eps=1e-6;
const long long mod=1e9+7;
const int inf=0x7fffffff;
const int maxn=100005;
ll qpow(ll x,ll y,ll Mod) {ll ans=1,base=x%Mod; while(y){if(y&1)ans=(ans*base)%Mod;base=(base*base)%Mod;y>>=1;} return ans;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// fast read
template<class T> void read(T &x) {
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9'){f|=(ch=='-');ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=f?-x:x;
	return;
}

ll n,cnt,ans;
pair<ll,int> yin[maxn];

int main(){
	//freopen("test.in","r",stdin);
	read(n);
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			yin[++cnt].first=i;
			while(n%i==0) n/=i,yin[cnt].second++;
		}
	}
	if(n!=1) yin[++cnt].first=n,yin[cnt].second++;
	for(int i=1;i<=cnt;i++){
		int dd=1;
		for(int j=1;j<=yin[i].second;j+=++dd){
			ans++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
const int mod = 1e9+7,inv2 = 5e8+4;
int n,siz[maxn],ans,pw[maxn];
vector<int>G[maxn];
void dfs(int u){
	siz[u]=1;
	for(int v:G[u]) if(!siz[v]) dfs(v),siz[u]+=siz[v];
}
int main()
{
	scanf("%d",&n),pw[0]=1;
	for(int i=1;i<=n;i++) pw[i]=1ll*pw[i-1]*inv2%mod;
	for(int i=1,x,y;i<n;i++) scanf("%d%d",&x,&y),G[x].push_back(y),G[y].push_back(x);
	dfs(1);
	for(int i=1;i<=n;i++){
		int s=0;
		for(int v:G[i]) ans=(ans-pw[n-(siz[v]<siz[i]?siz[v]:n-siz[i])])%mod,s++;
		ans=(ans+inv2+1ll*(s-1)*pw[n])%mod;
	}
	printf("%d\n",(ans+mod)%mod);
}

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

int main() {
   int a,b,c;
   cin>>a>>b>>c;
   if(b/a<=c){
       cout<<b/a;
   }
   else
   {
       cout<<c<<endl;
   }  
}



Measured memory_bytes: 256
#include<cstdio>

int main(){
	int n;
	int x;
	char c;
	char m[] = {'S', 'H', 'C', 'D'};

	int cards[4][14];

	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 14; j++){
			cards[i][j] = 0;
		}
	}

	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf(" %c %d", &c, &x);
		cards[(c - 53) % 6][x] = 1;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 1; j < 14; j++){
			if(!cards[i][j]){
				printf("%c %d\n", m[i], j);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
  val words = listOf("dream", "dreamer", "erase", "eraser")
  val s = readLine()!!
  val sb = StringBuilder(s)
  while (sb.isNotEmpty()) {
    var deleted = false
    for (word in words) {
      if (sb.endsWith(word)) {
        sb.delete(sb.length - word.length, sb.length)
        deleted = true
      }
    }
    if (!deleted) break
  }
  println(if (sb.isEmpty()) "YES" else "NO")
}


Measured memory_bytes: 38548
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

vector<ll> ban;
vector<ll> ten;
ll n;
signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	cin >> n;
	ll tmp;
	REP(i, n) {
		cin >> tmp;
		ban.push_back(tmp);
		cin >> tmp;
		ten.push_back(tmp);
	}

	ll maxban=LINF;
	ll lowerNum=LINF;
	ll lowerindex;


	REP(i, ten.size()) {
		if (ten[i] < lowerNum) {
			lowerNum = ten[i];
			lowerindex = ban[i];
		}
	}

	cout << lowerNum + lowerindex << endl;

	return 0;

}




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

int main()
{
  int A,B,C;
  int sum=0;
  cin>>A>>B;
  for(int i=0;i<B;i++){
    cin>>C;
    sum+=C;
  }
  if(A>sum)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func gcd(a int64, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a int64, b int64) int64 {
	return a / gcd(a, b) * b
}
func main() {
	n, _ := strconv.Atoi(nextLine())
	var ret int64
	ret = 1
	for i := 0; i < n; i++ {
		t, _ := strconv.ParseInt(nextLine(), 10, 64)
		ret = lcm(ret, t)
	}
	fmt.Println(ret)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a[200000],ans[200000];
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n-1;i>=0;i--){
        if((n-i)%2)ans[(n-i)/2]=a[i];
        else ans[n-((n-i)/2)]=a[i];
    }
    for(int i=0;i<n;i++){
        if(i!=n-1)cout<<ans[i]<<" ";
        else cout<<ans[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3712
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int X = ni();
		if(X >= 1800) {
			System.out.println(1);
		} else if(X >= 1600) {
			System.out.println(2);
		} else if(X >= 1400) {
			System.out.println(3);
		} else if(X >= 1200) {
			System.out.println(4);
		} else if(X >= 1000) {
			System.out.println(5);
		} else if(X >= 800) {
			System.out.println(6);
		} else if(X >= 600) {
			System.out.println(7);
		} else {
			System.out.println(8);
		} 
	}


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25428
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;

int flag[3000][3000];

ll solve(int i, int j, vector <vector<ll>> &dp, vector<int> &a) {
  if (flag[i][j] != 0) {
    return dp[i][j];
  }
  if (i == j) {
    dp[i][j] = a[i];
  } else {
    dp[i][j] = max(a[i] - solve(i+1, j, dp, a), a[j] - solve(i, j-1, dp, a));
  }
  flag[i][j] = 1;
  return dp[i][j];
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<ll>> dp(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << solve(0, n-1, dp, a) << endl;
}


Measured memory_bytes: 105856
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();
    long K = sc.nextLong();

    sc.close(); 

    String[] S = S_.split("");

    long result = 1;
    long i = 0;

    while (i < K) {
      if (!S[(int)i].equals("1")) {
        result = Integer.valueOf(S[(int)i]);
        break;
      }
      i++;
    }

    System.out.println(result);

  }

}

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

int main(){
	int n;cin >> n;
	vector<int> dp(110000,n);
	dp.at(0)=0;
	for(int i=0;i<=n;++i){
		for(int j=1;i+j<=n;j*=6){
			dp.at(i+j)=min(dp.at(i+j),dp.at(i)+1);
		}
		for(int j=1;i+j<=n;j*=9){
			dp.at(i+j)=min(dp.at(i+j),dp.at(i)+1);
		}
	}
	cout << dp.at(n) << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"strings"
)

type xy struct {
	x int
	y int
}

type route struct {
	path []xy
	now  xy
}

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	s := make([]string, H)
	visited := make([][]bool, H)

	count := 0
	for i := 0; i < H; i++ {
		visited[i] = make([]bool, W)
		fmt.Scan(&s[i])
		count += strings.Count(s[i], ".")
	}

	routes := make([]route, 1)
	routes[0] = route{[]xy{xy{0, 0}}, xy{0, 0}}
	i := 0
	for len(routes) > 0 {
		i++
		if i > H*W+10000 {
			break
		}
		r := routes[0]

		if r.now.x == W-1 && r.now.y == H-1 {
			fmt.Println(count - len(r.path))
			return
		}

		if r.now.y < H-1 && s[r.now.y+1][r.now.x] == '.' && !visited[r.now.y+1][r.now.x] {
			rc := r
			rc.now.y++
			visited[rc.now.y][rc.now.x] = true
			rc.path = append(rc.path, rc.now)
			routes = append(routes, rc)
		}
		if r.now.y > 0 && s[r.now.y-1][r.now.x] == '.' && !visited[r.now.y-1][r.now.x] {
			rc := r
			rc.now.y--
			visited[rc.now.y][rc.now.x] = true
			rc.path = append(rc.path, rc.now)
			routes = append(routes, rc)
		}
		if r.now.x < W-1 && s[r.now.y][r.now.x+1] == '.' && !visited[r.now.y][r.now.x+1] {
			rc := r
			rc.now.x++
			visited[rc.now.y][rc.now.x] = true
			rc.path = append(rc.path, rc.now)
			routes = append(routes, rc)
		}
		if r.now.x > 0 && s[r.now.y][r.now.x-1] == '.' && !visited[r.now.y][r.now.x-1] {
			rc := r
			rc.now.x--
			visited[rc.now.y][rc.now.x] = true
			rc.path = append(rc.path, rc.now)
			routes = append(routes, rc)
		}

		if len(routes) > 1 {
			routes = routes[1:]
		}
	}
	fmt.Println("-1")
}


Measured memory_bytes: 1024
def main(N, h):
    dp = [2**31-1] * N
    dp[0] = 0
    for i in range(N):
        if i+1 <= N-1:
            dp[i+1] = min(dp[i+1], dp[i] + (abs(h[i+1] - h[i])))
        if i+2 <= N-1:
            dp[i+2] = min(dp[i+2], dp[i] + (abs(h[i+2] - h[i])))
    return dp[-1]

N =int(input())
h = list(map(int,input().split()))
print(main(N, h))

Measured memory_bytes: 13904
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
typedef vector<int> V;
typedef pair<int, int> pii;

const int N = 1e5;
int a[N];
int main()
{
    int n, ok = 1;
    cin >> n;
    while (n--) {
        int x;
        cin >> x;
        if (x % 2 == 0)
            if (x % 3 && x % 5) {
                ok = 0;
                break;
            }
    }
    if (ok)
        cout << "APPROVED";
    else
        cout << "DENIED";
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    REP1(i,9){
        if(N%i==0&&N/i<10){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3584
n, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]

w0 = wv[0][0]
wv_dict = {w0:[], w0+1:[], w0+2:[], w0+3:[]}
for w, v in wv:
    wv_dict[w].append(v)
for w, vs in wv_dict.items():
    vs = sorted(vs)[::-1]
    wv_dict[w] = [0]
    for v in vs:
        wv_dict[w].append(v + wv_dict[w][-1])
# print(wv_dict)

ans = 0
for i in range(len(wv_dict[w0])):
    for j in range(len(wv_dict[w0+1])):
        for k in range(len(wv_dict[w0+2])):
            for l in range(len(wv_dict[w0+3])):
                w_sum = i*w0 + j*(w0+1) + k*(w0+2) + l*(w0+3)
                if w_sum > W: continue

                ans = max(ans, wv_dict[w0][i]+wv_dict[w0+1][j]+wv_dict[w0+2][k]+wv_dict[w0+3][l])
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int E,Y,a;
	cin>>E>>Y;
	if(E==0){
		if(2016>=Y && Y>=1989){
			a=28-(2016-Y);
			printf("H%d\n",a);
		}
		else if(1988>=Y && Y>=1926){
			a=63-(1988-Y);
			printf("S%d\n",a);
		}
		else if(1925>=Y && Y>=1912){
			a=14-(1925-Y);
			printf("T%d\n",a);
		}
		else{
			a=44-(1911-Y);
			printf("M%d\n",a);
		}
	}
	else if(E==1) cout<<1868+Y-1<<endl;
	else if(E==2) cout<<1912+Y-1<<endl;
	else if(E==3) cout<<1926+Y-1<<endl;
	else cout<<1989+Y-1<<endl;
	return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vector<ll> v(istream_iterator<int>{cin} , istream_iterator<int>());
	vector<ll> sum(n);
	partial_sum(all(v) , sum.begin());
	
	vector<vector<ll>> dp(n , vector<ll>(n , -1LL));
	function<ll(int,int)> rec = [&](int l , int r)
	{
		if(l == r)
			return 0LL;
			
		if(dp[l][r] != -1)
			return dp[l][r];
		
		ll mn = numeric_limits<ll>::max();
		for(int i = l ; i < r ; ++i)
			mn = min(mn , rec(l , i) + rec(i + 1 , r));

		return dp[l][r] = mn + sum[r] - (l > 0 ? sum[l - 1] : 0LL);
	};
	
	cout << rec(0 , n - 1);
	

	return 0;
}

Measured memory_bytes: 1536
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        return s == "ABC" ? "ARC" : "ABC";
    }
}


Measured memory_bytes: 25792
#include<stdio.h>

int main(void)
{
	unsigned int  a,b;
	double f;
	scanf("%u%u",&a,&b);
	
	f = (double)a / (double)b;
	
	printf("%u %u %.5lf\n",a/b,a%b,f);
	
	return 0;	
	
}

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

int main(){
  int n;
  cin >> n;
  vector<int> arr(n); 
  int i;
  for(i = 0; i < n; i++){
    cin >> arr.at(i);
  }
  int count = 0;
  bool judge = true;
  do{
    for(i = 0; i < n; i++){
      if(arr.at(i) % 2 == 0) arr.at(i) /= 2;
      else judge = false;
    }
    if(judge) count++;
  }while(judge);
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    string ans = "Yay!"; 
    if (A>8||B>8){
        ans = ":(";
    }
    if (A<0||B<0){
        ans = ":(";
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x,a,b;
  cin >> x >> a >> b;
  if(b-a<=0){
    cout << "delicious" << endl;
  }else if(b-a<=x){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
package main

import "fmt"
import "sort"
func main(){
    var N int
    fmt.Scan(&N)

    lines := scanNums(N)

    sort.Sort(sort.Reverse(sort.IntSlice(lines)))
    maxLine := lines[0]
    sum := 0
    for i:=1; i<N; i++{
        sum += lines[i]
    }

    if maxLine < sum {
        fmt.Println("Yes")
    }else{
        fmt.Println("No")
    }

}

/**
 * １行に空白区切りで数字を読み込み
 */
func scanNums(len int) (nums []int) {
	nums = make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&nums[i])
	}
	return
}


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

int main() {
	int n, x[100], s, m;
	cin >> n;
	s = 0;
	for(int i = 0; i < n; i++) {
		cin >> x[i];
		s += x[i];
	}
	s /= n;
	// s or s + 1
	int p = s;
	int v1 = 0;
	for(int i = 0; i < n; i++) {
		int t = x[i] - p;
		v1 += t * t;
	}
	p = s + 1;
	int v2 = 0;
	for(int i = 0; i < n; i++) {
		int t = x[i] - p;
		v2 += t * t;
	}
	cout << (v1 < v2 ? v1 : v2) << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MOD=1e9+7;
int main()
{
	int n, k; cin>>n>>k;
	int a[101];
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	ll dp[101][100001]={};
	dp[0][0]=1;
	ll s[100001];
	fill(s, s+k+1, 1);
	for(int i=1; i<=n; i++){
		for(int j=0; j<=k; j++){
			if(j<=a[i]){
				dp[i][j]=s[j];
			}else{
				dp[i][j]=(s[j]-s[j-a[i]-1]+MOD)%MOD;
			}
		}
		s[0]=dp[i][0];
		for(int j=1; j<=k; j++){
			s[j]=(s[j-1]+dp[i][j])%MOD;
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}

Measured memory_bytes: 79872
object Main extends App {
  val src: Iterator[Int] = io.Source.stdin.getLines.map(_.toInt)
  val weightList: List[Int] = for (i <- List.range(9, -1, -1)) yield (math.pow(2, i).toInt)

  def weightPairs(n: Int) = {
    weightList.reverse.zip(((n, Nil) /:[(Int, List[Int])] weightList) { case ((a, b), c) => (a % c, (a / c) :: b )}._2)
  }

  for (n <- src) {
    val weightPairList = weightPairs(n)
    println(weightPairList.map { case (a, b) => if (b == 1) a else 0 }.filter(_ != 0).mkString(" "))
  }
}

Measured memory_bytes: 44596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

double n,m,sum,ans = 0;
cin >> n >> m;
vi a(n);
rep(i,n) cin >> a[i];

sum = accumulate(a.begin(),a.end(),0);

rep(i,n)  if(a[i] >= sum/4/m) ans++;

if(ans >= m) cout << "Yes" << endl;
else cout << "No" << endl;


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int i=0;
    int n;
    int k=0;
    string s;
    //cin>>n>>k;
    cin >>s;
    if(s[0]=='0'&&s[1]!='0')k=0;
    else if(s[0]=='1'&&(s[1]=='0'||s[1]=='1'||s[1]=='2'))k=0;
    else k=1;
    if(s[2]=='0'&&s[3]!='0')i=0;
    else if(s[2]=='1'&&(s[3]=='0'||s[3]=='1'||s[3]=='2'))i=0;
    else i=1;
    if(k==1&&i==1)std::cout << "NA" << std::endl;
    else if(k==1)std::cout << "YYMM" << std::endl;
    else if(i==1)std::cout << "MMYY" << std::endl;
    else std::cout << "AMBIGUOUS" << std::endl;
   
}


Measured memory_bytes: 256
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, x) = intList()
    val a = intList()
    var remain = x
    var count = 0
    a.sorted().forEach {
        remain -= it
        if (remain >= 0) {
            count++
        } else {
            println(count.toString())
            return
        }
    }
    if (remain == 0) {
        println(count.toString())
    } else {
        println((count - 1).toString())
    }
}

Measured memory_bytes: 37808
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;

template <int M, bool IsPrime = false> class Modulo {
  int n;
  static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
  }

public:
  Modulo() : n(0) { ; }
  Modulo(int m) : n(m) {
    if (n >= M)
      n %= M;
    else if (n < 0)
      n = (n % M + M) % M;
  }
  Modulo(ll m) {
    if (m >= M)
      m %= M;
    else if (m < 0)
      m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo &operator+=(const Modulo &a) {
    n += a.n;
    if (n >= M) n -= M;
    return *this;
  }
  Modulo &operator-=(const Modulo &a) {
    n -= a.n;
    if (n < 0) n += M;
    return *this;
  }
  Modulo &operator*=(const Modulo &a) {
    n = (ll(n) * a.n) % M;
    return *this;
  }
  Modulo operator+(const Modulo &a) const {
    Modulo res = *this;
    return res += a;
  }
  Modulo operator-(const Modulo &a) const {
    Modulo res = *this;
    return res -= a;
  }
  Modulo operator-() const { return Modulo(0) - *this; }
  Modulo operator*(const Modulo &a) const {
    Modulo res = *this;
    return res *= a;
  }

  Modulo operator^(ll m) const {
    if (m == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (m / 2);
    return m % 2 ? res * a : res;
  }
  typename std::enable_if<IsPrime, Modulo>::type
  operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
  typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
    return *this *= inv(ll(a), M);
  }

  friend bool is_zero(const Modulo &x) { return int(x) == 0; }
  friend int abs(const Modulo &x) { return int(x); }

  static Modulo fact(int n, bool sw = true) {
    static std::vector<Modulo> v1 = { 1 }, v2 = { 1 };
    if (n >= (int)v1.size()) {
      const int from = v1.size(), to = n + 1024;
      v1.reserve(to);
      v2.reserve(to);
      for (int i = from; i < to; ++i) {
        v1.push_back(v1.back() * Modulo<M, true>(i));
        v2.push_back(v2.back() / Modulo<M, true>(i));
      }
    }
    return sw ? v1[n] : v2[n];
  }
  static Modulo comb(ll a, ll b) {
    if (b < 0 || b > a) return 0;
    return Modulo::fact(a, true) * Modulo::fact(b, false) *
           Modulo::fact(a - b, false);
  }
};
using Mod = Modulo<1000000007, true>;

int main(void)
{
  ll n,m,k;
  cin >> n >> m >> k;
  Mod answer=0;
  REP(i,n) {
    Mod tmp = (i*(i+1)/2 + (n-i)*(n-i-1)/2);
    tmp *= m;
    tmp *= m;
    answer += tmp;
  }
  REP(i,m) {
    Mod tmp = (i*(i+1)/2 + (m-i)*(m-i-1)/2);
    tmp *= n;
    tmp *= n;
    answer += tmp;
  }
  answer /= 2;
  answer *= Mod::comb(n*m-2,k-2);
  cout << (ll)answer << endl;
  return 0;
}


Measured memory_bytes: 2560