akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

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

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    void execute() throws IOException {
        int a = ni();
        int b = ni();
        out.println(a * b);

        out.close();
    }

    boolean input() throws IOException {
        return true;
    }

}


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

int main(int arvc, char** argv){
  int N, K;
  cin >> N >> K;
  int h[N];
  for(int cnt0=0; cnt0 < N; cnt0++){
    cin >> h[cnt0];
  }
  sort(h, h+N);
  int diff[N-1];
  for(int cnt0=0; cnt0 < N-1; cnt0++){
    diff[cnt0] = h[cnt0+1]-h[cnt0];
  }
  /*
  for(int cnt0=0; cnt0 < N-1; cnt0++){
    cout << diff[cnt0] << " ";
  }
  return 0;
  */
  long long tmpsum=0;
  for(int cnt1=0; cnt1 < K-1; cnt1++){
    tmpsum += diff[cnt1];
  }
  /*
  cout << tmpsum << endl;
  return 0;
  */
  long long dis = tmpsum;  
  for(int cnt0=0; cnt0 < N-K; cnt0++){
    tmpsum = tmpsum - diff[cnt0] + diff[cnt0+K-1];
//    cout << "h[" << K+cnt0 << "] to h[" << cnt0+1 << "]: " << tmpsum << endl;
    dis = min(dis, tmpsum);
  }
  printf("%lld", dis);
}

Measured memory_bytes: 1024
def InsertionSort(A, n, g):
    cnt = 0

    for i in range(g, n):
        v = A[i]
        j = i - g

        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1

        A[j + g] = v

    return cnt

def ShellSort(A, n):
    tot_cnt = 0
    G = [1]
    span = 4

    while span < n:
        G.append(span)
        span = span * 3 + 1

    G.reverse()
    m = len(G)

    for g in G:
        tot_cnt += InsertionSort(A, n, g)

    return m, G, tot_cnt


n = int(input())
A = []

for i in range(n):
    A.append(int(input()))

m, G, tot_cnt = ShellSort(A, n)

print(m)
print(*G)
print(tot_cnt)
print(*A, sep = "\n")

Measured memory_bytes: 63000
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n,a,b;
ll gs(ll x)
{
        ll ret = 0;
        while(x > 0)
        {
                ret += x%10;
                x = x / 10;
        }
        return ret;
}
int main()
{
        cin >> n;
        ll x = gs(n);
        if(n%x == 0) cout << "Yes\n";
        else cout << "No\n";
        return 0;
}


Measured memory_bytes: 256
#define CIN_ONLY 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const double PI = 3.14159265358979323846;

int main()
{
	if (CIN_ONLY) {
		ios::sync_with_stdio(0);
		cin.tie(0);
	}
	ll n, a, b;
	cin >> n >> a >> b;
	if (a == b) {
		cout << 1 << endl;
	} else if (a > b) {
		cout << 0 << endl;
	} else if (n == 1) {
		cout << 0 << endl;
	} else {
		cout << (b - a) * (n - 2) + 1 << endl;
	}
	return 0;
}



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

using namespace std;

int main(){
    long W, H;
    long p[100000];
    long q[100000];
    cin >> W >> H;
    for(int i = 0; i < W; i++){
        cin >> p[i];
    }
    for(int i = 0; i < H; i++){
        cin >> q[i];
    }
    sort(p, p+W);
    sort(q, q+H);
    long cnt_w = 0;
    long cnt_h = 0;
    long ans = 0;
    for(int i = 0; i < H+W; i++){
        //cout << cnt_w << ' ' << cnt_h << endl;
        if(cnt_w == W){
            ans += q[cnt_h];
            cnt_h++;
        }else if(cnt_h == H){
            ans += p[cnt_w];
            cnt_w++;
        }
        else if(p[cnt_w] < q[cnt_h]){
            ans += p[cnt_w]*(H+1-cnt_h);
            cnt_w++; 
        }else{
            ans += q[cnt_h]*(W+1-cnt_w);
            cnt_h++; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int D;
vi C, S[370], T, V, cost;

int calc_minus(int day){
    int res = 0;
    rep(i, 26){
        res += C[i] * (day - cost[i]); 
    }
    return res;
}

int calc_S(vi t){
    ll ans = 0;
    cost.resize(26, 0);

    rep(i, D){
        ans += S[i][t[i]-1];
        cost[t[i]-1] = i+1;
        ans -= calc_minus(i+1);
    }

    return ans;
}

int get_max_c(int day){
    int res = -1, tmp = 0;

    rep(i, 26){
        if(tmp < S[day][i] + C[i]){
            res = i;
            tmp = S[day][i] + C[i];
        }
    }

    return res;
}

void solve(){
    rep(i, D){
        T[i] = get_max_c(i) + 1;
    }
    // cout << calc_S(T) << endl;

    rep(i, D) cout << T[i] << endl;
}

int main(){
    cin >> D;
    C.resize(26);
    T.resize(D, 1);
    
    
    rep(i, 26){
        cin >> C[i];
    }   

    rep(i, D){
        S[i].resize(26);
        rep(j, 26) cin >> S[i][j];
    }

    solve();
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
using namespace std;
int n,dis[41],t[41],maxball,ans;

void saiki(int x,int now,int ball,int sum,int kai){
  if(ans<sum)return;
  maxball=max(maxball,kai);
  if(kai==n&&!ball)ans=min(ans,sum);
  if(ball)saiki(0,now+x*(1+ball),0,sum+x,kai);
  if(ball==3 || kai==n) return;
  
  int nx=dis[kai];
  int nsum=sum+abs(x-dis[kai]);
  int nnow=now+abs(x-dis[kai])*(1+ball);
  if(nnow<=t[kai])saiki(nx,t[kai],ball+1,nsum,kai+1);
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++)cin >>dis[i]>>t[i];
    sort(t,t+n);
    maxball=0,ans=100000000;
    saiki(0,0,0,0,0);
    if(maxball==n)cout <<"OK "<<ans<<endl;
    else cout<<"NG "<<maxball+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }
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){
  int n,m; cin >> n >> m;
  int dis[n][m];
  int a[n],b[n];
  FOR(i,0,n-1) {
    cin >> a[i] >> b[i];
  }
  int c[m],d[m];
  FOR(i,0,m-1){
    cin >> c[i] >> d[i];
  }

  FOR(i,0,n-1){
    FOR(j,0,m-1){
      dis[i][j] = abs(a[i]-c[j]) + abs(b[i]-d[j]);
    }
  }

  FOR(i,0,n-1){
    int naverdis = 1001001001;
    int naver = -1;
    FOR(j,0,m-1){
      if(naverdis>dis[i][j]){
        naverdis = dis[i][j];
        naver = j;
      }
    }
    cout << naver + 1 << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;


int main() {

		int n, k;
		cin >> n >> k;

		int a;
		vector<int> tmp(n);

		for (int i = 0; i < n; i++) {

			cin >> a;
			tmp[a] ++;
		}

		sort(tmp.begin(), tmp.end(), greater<int>());

		int ans = n;

		for (int i = 0; i < k; i++) {
			ans -= tmp[i];
		}

		cout << ans << endl;

		return 0;

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] sheets = new int[r + 1][c + 1];

		int sum = 0;
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				int n = sc.nextInt();
				sheets[i][j] = n;
				sheets[r][j] += n;
				sheets[i][c] += n;
				sum += n;
			}
		}

		sheets[r][c] = sum;
		for (int i = 0; i <= r; i++) {
			for (int j = 0; j <= c; j++) {
				System.out.printf(j < c ? "%d " : "%d%n", sheets[i][j]);
			}
		}
	}
}



Measured memory_bytes: 62268
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long 
#define N 100100
#define M 10000000
using namespace std;

ll n, cnt, p[N];
struct Edge {
    ll u, v, w;
}edge[M];
struct point {
	ll x, y, order;
}a[N], b[N];
void addEdge(ll u, ll v, ll w) {
    edge[cnt].u = u;
    edge[cnt].v = v;
    edge[cnt].w = w;
    cnt++;
}
bool cmp(Edge a, Edge b) {
    return a.w < b.w;
}
bool comx(point x1, point x2) {
	if(x1.x == x2.x)
		return x1.y < x2.y; 
	return x1.x < x2.x;
}
bool comy(point y1, point y2) {
	if(y1.y == y2.y)
		return y1.x < y2.x;
	return y1.y < y2.y;
}
ll find(ll x) {
    return p[x] == x ? x : p[x] = find(p[x]);
}
ll Kruskal() {
    ll ans = 0, sum = 0, u, v, w;
    for(ll i = 0; i <= n; i++)
        p[i] = i;
    sort(edge, edge + cnt, cmp);
    for(int i = 0; i < cnt; i++) {
    	u = edge[i].u, v = edge[i].v, w = edge[i].w;
        ll fa = find(u), fb = find(v);
        if(fa != fb) {
            ans += w;
            p[fa] = fb;
            sum++;
        }
        if(sum == n-1) break;
    }
    return ans;
}

int main() {
	ll ans;
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld %lld", &a[i].x, &a[i].y);
		a[i].order = i;
		b[i].x = a[i].x, b[i].y = a[i].y, b[i].order = a[i].order;
	}
	sort(a+1, a+1+n, comx);
	sort(b+1, b+1+n, comy);
	for(int i = 1; i < n; i++) {
		ll cost = fabs(a[i].x - a[i+1].x);
		addEdge(a[i].order, a[i+1].order, cost);
	}
	for(int i = 1; i < n; i++) {
		ll cost = fabs(b[i].y - b[i+1].y);
		addEdge(b[i].order, b[i+1].order, cost);
	}
	ans = Kruskal();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 12672
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int N = input[0];
        int K = input[1];
        int count1 = 0;
        int count2 = 0;
        long sum = 0;

        // Kの倍数である数値の個数を数える
        
        for(int i = 1; i <= N; i++) 
        {
            if(i % K == 0)
            {
                count1 += 1;
            }
        }
        
        
        
        // 余りがKの半分となる数値の個数を数える
        for(int i = 1; i <= N; i++)
        {
            if(i % K == K/2)
            {
                count2 += 1;
            }
        }
        
        sum += (long)count1 * count1 * count1;
        
        if(K % 2 == 0)//Kが偶数のとき
        {
            sum += (long)count2 * count2 * count2;
        }
        
        
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, K;
    cin >> N >> K;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
    }

    //点灯数を求める
    //自分の右側にいくつ有るか
    vector<ll > r_T(N, 0);
    for(ll i = 0; i < N; i++){
        for(ll j = i + 1; j < N; j++){
            if(vec[i] > vec[j]) r_T[i]++;
        }
    }
    //自分の左側にいくつ有るか
    vector<ll > l_T(N, 0);
    for(ll i = N - 1; i >= 0; i--){
        for(ll j = i - 1; j >= 0; j--){
            if(vec[i] > vec[j]) l_T[i]++;
        }
    }

    ll sum = 0;
    for(ll i = 0; i < N; i++){
        sum += r_T[i] * K % MOD;
        sum %= MOD;
        //cout << r_T[i] + l_T[i] << endl;
        sum += (r_T[i] + l_T[i]) * (((K-1) * K) / 2 % MOD) % MOD;
        //sum += l_T[i] * (K-1) % MOD;
        sum %= MOD;
    }

    cout << sum << endl;

}

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

int main() 
{
    int m, n, o, i, j;
    j = 0;
    cin >> m;
    cin >> n;
    cin >> o;
    if (m >= n){
        for(i=m;;i--){
            if(i == 0){
                break;
            }
            if(m%i == 0 && n%i == 0){
                j = j + 1;
                if (j == o){
                    cout << i;
                }
            }
        }
    }
    else {
        for(i=n;;i--){
            if(i == 0){
                break;
            }
            if(m%i == 0 && n%i == 0){
                j = j + 1;
                if (j == o){
                    cout << i;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

struct Node{int parent,left,right;};
Node T[100001];
int D[100001],H[100001];
void setDepth(int u,int p)
{
	D[u] = p;
	if(T[u].right != -1)
	{
		setDepth(T[u].right,p+1);
	}
	if(T[u].left != -1)
	{
		setDepth(T[u].left,p+1);
	}
}

int setHeight(int u)
{
	int h1,h2;
	h1=h2=0;
	if(T[u].left!=-1)h1 = setHeight(T[u].left)+1;
	if(T[u].right!=-1)h2 = setHeight(T[u].right)+1;
	return H[u] = max(h1,h2);
}


int getSibling(int u)
{
	if(T[u].parent==-1)return -1;
	int p = T[u].parent;
	int l = T[p].left;
	int r = T[p].right;
	if(l==u&&r==-1)return -1;
	if(l==-1&&r==u)return -1;
	if(l==u)return r;
	return l;
}



int main()
{
	int n;
	cin >> n;
	for(int i = 0;i<n;i++)
	{
		T[i].left=T[i].right=T[i].parent = -1;
	}
	for(int i = 0;i<n;i++)
	{
		int now;
		cin >> now;
		int l ,r;
		cin >> l >> r;
		T[now].left = l;
		T[now].right = r;
		if(l!=-1)T[l].parent = now;
		if(r!=-1)T[r].parent = now;
	}
	for(int i = 0;i<n;++i)
	{
		if(T[i].parent==-1)
		{
			setHeight(i);
			setDepth(i,0);
			break;
		}
	}
	for(int i = 0;i<n;i++)
	{
		int p = getSibling(i);
		int d =0;
		if(T[i].left!=-1)d++;
		if(T[i].right!=-1)d++;
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].parent,p,d,D[i],H[i]);
		if(T[i].parent==-1)
		{
			cout<<"root\n";
		}
		else if(T[i].left==-1&&T[i].right==-1)
		{
			cout<<"leaf\n";
		}
		else
		{
			cout<<"internal node\n";
		}
	}

	return 0;
}


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

int main()
{
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);

	if (abs(x - a) > abs(b - x)) {
		printf("B\n");
	} else {
		printf("A\n");
	}
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
ans_index = []

def get_index(s):
    a = ""
    for ans in ans_index:
        a += s[ans]
    return a

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        s = input()
        if s != "." * W:
            A.append(s)

    for w in range(W):
        add = True
        for h in range(len(A)):
            if A[h][w] != ".":
                add = False
                break
        if not add:
            ans_index.append(w)

    #print(A, ans_index)

    for line in map(get_index, A):
        print("".join(line))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e3+5, M=1e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

int n, m;
ll mem[N][N];
char arr[N][N];

int dr[] = {0, 1};
int dc[] = {1, 0};

bool valid(int r, int c){
    return r<n && c<m && arr[r][c]!='#';
}
ll solve(int i, int j){
    if(i == n-1 && j == m-1) return 1;
    if(mem[i][j] != -1) return mem[i][j];
    ll ret = 0;
    for(int k=0; k<2; k++){
        if(valid(i+dr[k], j+dc[k])){
            ret = (solve(i+dr[k], j+dc[k])%mod + ret%mod)%mod;
        }
    }
    return mem[i][j] = ret;
}

int main()
{
    _69e27
    memset(mem, -1, sizeof mem);
    cin >> n >> m;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++)
            cin >> arr[i][j];
    }
    cout  << solve(0, 0);
    return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
 
#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(int i=x;i<y;i++)
#define foreI(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sl "\n";
#define ii pair<ll,ll>
#define mk make_pair
 
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
string a,b;
const int MAXN = 3005;
ll dp[MAXN][MAXN];
int n,m;
string ans;
ll solve(int i,int j){
    if(i==n)return 0;
    if(j==m)return 0;
    ll &r = dp[i][j];
    if(r!=-1)return r;
    if(a[i]==b[j]){r=solve(i+1,j+1)+1;}
    else r=max(solve(i+1,j),solve(i,j+1));
    return r;
}
void build(int i,int j){
    if(i==n)return;
    if(j==m)return;
    ll answer = solve(i,j);
    if(a[i]==b[j]&&answer==solve(i+1,j+1)+1){ans.pb(a[i]);build(i+1,j+1);}
    else if(answer==solve(i+1,j)){build(i+1,j);}
    else if(answer==solve(i,j+1)){build(i,j+1);}
    return;
}
int main() {FIN;
   
    cin>>a>>b;
    n=a.size();
    m=b.size();
    memset(dp,-1,sizeof(dp));
    solve(0,0);
    build(0,0);
    cout<<ans<<sl;
    return 0;
}
 


Measured memory_bytes: 74424
chomp (my $s = <STDIN>);
my ($f, $c) = (0, 0);
my @p;
for my $i (0..length($s)-1) {
  if (substr($s, $i, 1) eq 'R') {
    if ($f == 1) {
      push @p, $c;
      $f = 0;
      $c = 0;
    }
    $c++;
  } else {
    if ($f == 0) {
      push @p, $c;
      $f = 1;
      $c = 0;
    }
    $c++;
    push @p, $c if $i == length($s) - 1;
  }
}
my $ans;
while (@p) {
  my $x = shift @p;
  my $y = shift @p;
  $ans .= "0 " x ($x - 1);
  if (($x + $y) % 2 == 0) {
    $ans .= ($x + $y) / 2;
    $ans .= ' ';
    $ans .= ($x + $y) / 2;
    $ans .= ' ';
  } elsif ($x % 2 == 0) {
    $ans .= int(($x + $y) / 2);
    $ans .= ' ';
    $ans .= int(($x + $y) / 2) + 1;
    $ans .= ' ';
  } else {
    $ans .= int(($x + $y) / 2) + 1;
    $ans .= ' ';
    $ans .= int(($x + $y) / 2);
    $ans .= ' ';
  }
  $ans .= "0 " x ($y - 1);
}
print substr($ans, 0, length($ans) - 1);


Measured memory_bytes: 4424
n, m = gets.split.map(&:to_f)
a = gets.split.map(&:to_f)
b = 0
all = a.inject(:+)
a.each do |i|
    if (i / all) >= 1 / (4 * m) 
        b += 1
    end
end

 if b >= m
     puts 'Yes'
 else
     puts 'No'
 end

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll 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(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k,x;
  cin >> k >> x;
  ll minX = x - k + 1;
  ll maxX = x+k - 1;
  for(int i = minX; i < maxX+1; i ++){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	ll x[101],y[101],h[101];
	ll mah=0;
	for(ll i=0;i<n;i++){
		cin>>x[i]>>y[i]>>h[i];
		mah=max(mah,h[i]);
	}
	for(ll i=0;i<101;i++){
		for(ll j=0;j<101;j++){
			for(ll k=mah;k<=mah+210;k++){
				bool ch=true;
				for(ll l=0;l<n;l++){
					ll ma=max(ll(0),k-abs(x[l]-i)-abs(y[l]-j));
					if(ma!=h[l]){
						ch=false;
					}
				}
				if(ch){
					cout <<i<<" "<<j<<" "<<k;
					return 0;
				}
			}
		}
	}
	// your code goes here
	return 0;
}

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

int main() {

	int n; cin >> n;
	
	if (n == 1) {
		int ans; cin >> ans;
		cout << ans << endl;
		return 0;
	}

	vector<int> h(n);
	int max_h = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		max_h = max(max_h, h[i]);
	}

	vector<vector<int>> c(max_h, vector<int>(n, 0));
	for (int j = 0; j < n; j++) {
		for (int i = 0; i < max_h; i++) {		
			if (i < h[j]) {
				c[i][j] = 1;
			}
			
		}
	}

	int ans = 0;
	for (int i = 0; i < max_h; i++) {
		for (int j = 0; j < n - 1; j++) {
			if (c[i][j + 1] == 0 && c[i][j] == 1) {
				ans++;
			}

			if (j== n - 2 && c[i][j + 1] == 1) {
				ans++;
			}
		}
	}

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

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

int main(){
  int N,Q;
  cin >> N >> Q;
  vector<int> a(N-1),b(N-1),p(Q),x(Q);
  vector<int> adj[N];
  for(int i = 0; i < N-1; ++i){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    adj[a[i]].push_back(b[i]);
    adj[b[i]].push_back(a[i]);
  }
  vector<int> cnt(N-1);
  for(int i = 0; i < Q; ++i){
    cin >> p[i] >> x[i];
    p[i]--;
    cnt[p[i]] += x[i];
  }
  deque<int> q;
  q.push_back(0);
  vector<int> vis(N);
  vis[0] = 1;
  while(!q.empty()){
    int u = q.front();
    q.pop_front();
    for(int i = 0; i < adj[u].size(); ++i){
      int t = adj[u][i];
      if(vis[t] == 1) continue;
      vis[t] = 1;
      cnt[t] += cnt[u];
      q.push_back(t);
    }
  }
  for(int i = 0; i < N-1; ++i){
    cout << cnt[i] << " ";
  }
  cout << cnt[N-1] << endl;
}


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

int main(void){
	int i, n, m; //入力数：n, m
	int *a, *b;
	int x, y;		//仮の変数

	scanf("%d %d", &n, &m);
	a = (int*)calloc(n, sizeof(int));
	b = (int*)calloc(n, sizeof(int));

	for(i= 0; i < m; i++){
		scanf("%d %d", &x, &y);
		++a[x - 1];
		++b[y-1];
	}

	printf("\n");
	for(i = 0; i < n; i++){
		printf("%d\n", a[i] + b[i]);
	}

	free(a);
	free(b);

	printf("\n");
}

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

int IsPrime(int);

int main() {
	int *A;
	int n, count = 0;
	int i;

	scanf("%d", &n);
	A = (int *)malloc(n * sizeof(int));

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

	for (i = 0; i < n; i++) {
		if (IsPrime(A[i]) == 1)
			count++;
	}

	printf("%d\n", count);

	free(A);
	return 0;
}

int IsPrime(int n) {
	int i;

	if (n == 2)
		return 1;

	if (n % 2 == 0)
		return 0;

	for (i = 3; i <= n / i; i += 2) {
		if (n%i == 0)
			return 0;
	}

	return 1;
}


Measured memory_bytes: 2124
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // math.factorial(r) // math.factorial(n-r)

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")

def main():
    R, C, K = LI()
    rcv = LIR1(K)

    # dp = make_list(R+1, C+1, 4)
    dp = make_list(C+1, 4)
    table = make_list(R, C)

    for r, c, v in rcv: table[r][c] = v + 1

    for r in range(R):
        newdp = [[max(p), 0, 0, 0] for p in dp]
        for c in range(C):
            for i in range(1, 4)[::-1]:
                newdp[c][i] = max(newdp[c][i], newdp[c][i - 1] + table[r][c])
                newdp[c + 1][i] = max(newdp[c + 1][i], newdp[c][i])
            newdp[c + 1][0] = max(newdp[c + 1][0], newdp[c][0])
        dp = newdp

    print(max(dp[C-1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 275464
n,k,q = map(int,input().split())
#参加者のライフをPでリストに
P = [k-q]*n

for _ in range(q):
  A = int(input())
  P[A-1] += 1
  
for i in range(n):
  if P[i]<=0:
    print("No")
  else:
    print("Yes")


Measured memory_bytes: 6596
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: i64,
    }
    let mut ans = 0;
    let d = n.to_string().len();
    for m in (1..d + 1).step_by(2) {
        if m < d {
            ans += 10i64.pow((m - 1) as u32) * 9;
        } else {
            ans += n - 10i64.pow((d - 1) as u32) + 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2192
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;
LL MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N, vector<int>());
    vector<int> to(N, 0), tmp(N, 0);
    for(int i=0; i<M; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        to[y]++;

    }
    vector<int> cnt(N, 0);
    vector<int> data;
    for(int i=0; i<N; i++)
        if(to[i] == 0 ) {
            data.push_back(i);
            cnt[i] = 0;
        }
    int ans = 0;
    
    for(int i=0; i<data.size(); i++) {
        int cur = data[i];
    //    cout << cur << " " << cnt[cur] << endl;
        ans = max(ans, cnt[cur]);
        for(auto v: G[cur]) {
            //if(cnt[v] >= 0) continue; 
            cnt[v] = max(cnt[v], cnt[cur] + 1);
            tmp[v]++;
            if(to[v] == tmp[v])
                data.push_back(v);

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


Measured memory_bytes: 7548
import java.util.*;
import java.io.*;
import java.lang.*;
// ArrayList<Integer>[] arr=new ArrayList[n];
public class Main{    
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
         StringBuilder sb=new StringBuilder();
         BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
         int n=s.nextInt(),m=s.nextInt();
         if(n<=9&&m<=9){
            System.out.println(n*m);
         }
         else{System.out.println("-1");}
       // System.out.println(sb);
    }
}

Measured memory_bytes: 23892
/*input
24
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 
#define INF 0x3f3f3f3f

int t , a , b , c , d;
int32_t main(){
	IOS;
	cin >> t;
	REP(times , 0 , t){
		cin >> a >> b >> c >> d;
		if(a < b || b > d) cout << "No" << endl;
		else {

			if(c + 1 >= b) cout << "Yes" << endl;
			else {
				a = a % b;
				if(a > c) cout << "No" << endl;
				else {
					if(b == d) cout << "Yes" << endl;
					else {
						int tmp = __gcd(b , d);
						int ql = c + 1 - a;
						int qr = b - 1 - a;
						if(ql % tmp == 0 || qr % tmp == 0) cout << "No" << endl;
						else if(ql / tmp != qr / tmp) cout << "No" << endl;
						else cout << "Yes" << endl;
						// cout << "?" << endl;
						// DB4(a , b , c , d);
						
					}
				}
			}
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,k,q,a[N];
int main()
{
    scanf("%d%d%d",&n,&k,&q);
    while(q--)
    {
        int x;scanf("%d",&x);
        if(x>1) a[1]--,a[x]++;
        if(x<n) a[x+1]--,a[n+1]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        a[i]+=a[i-1];
        if(a[i]+k>0) printf("Yes\n");
        else printf("No\n");
    }
}


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

int n, m;
int c[32];
int dp[65536];

const int INF = (1 << 30);

int main() {
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; ++i) {
    scanf("%d", &c[i]);
  }
  for(int& I : dp) I = INF;

  dp[0] = 0;
  for(int i = 0; i < m; ++i) {
    for(int j = c[i]; j <= n; ++j) {
      dp[j] = std::min(dp[j], dp[j-c[i]] + 1);
    }
  }

  printf("%d\n", dp[n]);
  
  
  return 0;
}

Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
#define int long long

int n[1000010];

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

  int s; cin >> s;
  n[1] = s;
  for(int i = 2; i < 1000001; i++){
    if(n[i-1]%2 == 0){
      n[i] = n[i-1] / 2;
    }
    else {
      n[i] = 3 * n[i-1] + 1;
    }

    for(int j = 1; j < i; j++){
      if(n[j] == n[i]){
        cout << i << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	int W = s.nextInt();
	int H = s.nextInt();
	int x = s.nextInt();
	int y = s.nextInt();
	int r = s.nextInt();

	int flag = 0;

	if(x-r >= 0 && x+r <= W){
	    if(y-r >= 0 && y+r <= H) flag = 1;
	}

	if(flag == 1) System.out.println("Yes");
	else System.out.println("No");
    }
}



Measured memory_bytes: 26276
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;


ll n;
ll m;
vll k(10);
vvll s(10,vll (10,0));
vll p(10);
vll u(10,0);

ll solve(ll t){
        ll a=0;
        ll d=0;
        ll l=1;
        if(t==n){
                FOR(i,0,m-1){
                        d=0;
                        FOR(j,0,k[i]-1){
                                if(u[s[i][j]-1]==1) d++;
                        }
                        if(d%2!=p[i]){
                                l=0;
                                break;
                        }
                }
                return l;
        }else{
                u[t]=0;
                a+=solve(t+1);
                u[t]=1;
                a+=solve(t+1);
                return a;
        }
}

signed main(){
        cin >>n;
        cin >>m;
        FOR(i,0,m-1){
                cin >>k[i];
                FOR(j,0,k[i]-1){
                        cin >>s[i][j];
                }
        }
        FOR(i,0,m-1){
                cin >>p[i];
        }
        sal(solve(0))
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	string s;int n,i,j;cin>>n>>s;
	vi d(n+1,0),p(n+1,1);p[0]=0;for(i=1;i<n;i++){
		for(j=1;j<=i+1;j++){
			if(s[i-1]=='<') d[j]=p[j-1];
			else d[j]=(p[n]-p[j-1]+mod)%mod;
		}for(j=1;j<=n;j++) p[j]=(p[j-1]+d[j])%mod;
	}ll c=0;for(auto i:d) c=(c+i)%mod;cout<<c<<endl;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
l = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(m)]
# n,m = 3,2
# l = [5,1,4]
# s = [[2,3],[1,5]]
# l = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
l.sort()
s.sort(key=lambda x: x[1], reverse=True)
idx = 0
for i in range(m):
    for j in range(idx, min(n, idx + s[i][0])):
        if l[j] < s[i][1]:
            l[j] = s[i][1]
        else:
            break
    idx += s[i][0]
print(sum(l))

Measured memory_bytes: 32968
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, T;
	cin >> N >> T;
	vector<int> t(N);
	for (int i = 0; i < N; ++i) {
		cin >> t[i];
	}

	long long last = 0;
	long long ans = 0;
	
	for (int i = 0; i < N; ++i) {
		if (t[i] <= last) {
			ans += T - (last - t[i]);
		}
		else {
			ans += T;
		}
		last = t[i] + T;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int lcm(int a, int b){return(a*b)/gcd(a, b);}  


int32_t main()
{
	string s;
	cin >> s;
	int n = sz(s);
	int cnt= 0 ;
	for(int i=0;i<n / 2;i++)
	{
		if(s[i] != s[n-1-i])
			cnt++;
	}
	cout <<cnt<<endl;
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[99][99];
double x[99];
int idx[99];

int c(const void*a,const void*b){
	if(x[*(int*)a]>x[*(int*)b])return -1;
	if(x[*(int*)a]<x[*(int*)b])return 1;
	return strcmp(s[*(int*)a],s[*(int*)b]);
}

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		rep(i,0,n){
			ll a[9];
			scanf(" %s",s[i]);
			rep(k,0,9)scanf("%lld",a+k);
			x[i]=(double)(a[8]*a[7]*a[6]-a[0])/(a[1]+a[2]+a[3]+(a[4]+a[5])*a[8]);
			idx[i]=i;
		}
		qsort(idx,n,sizeof(int),c);
		rep(i,0,n)printf("%s\n",s[idx[i]]);
		puts("#");
	}
}


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

int main() {
  int n;cin>>n;
  long an[n];rep(i,n)cin>>an[i];
  cout << an[n-1];
  if (n%2==0) {
    rep(i,n/2-1) cout << " " << an[n-3-i*2];
    rep(i,n/2) cout << " " << an[i*2];
  } else {
    rep(i,n/2) cout << " " << an[n-3-i*2];
    rep(i,n/2) cout << " " << an[1+i*2];
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll dp[3005][3005];
ll n,k,l;
ll a[3005];
ll solve(ll i,ll j)
{
    if(i==j)
    {
        if(n%2)
            return a[i];
        else
            return -a[i];
    }
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll x;
    x=n-j+i-1;
    ll p;
    ll b=x%2;
    ll c;
    if(b)
        c=-1;
    else
        c=1;
    if(b)
        p=min((c*a[i]+solve(i+1,j)),(c*a[j]+solve(i,j-1)));
    else
        p=max((c*a[i]+solve(i+1,j)),(c*a[j]+solve(i,j-1)));
    /*if(b)
    {
        p=p*(-1);
    }*/
    dp[i][j]=p;
    return p;
}
/*ll dp[100005];a
ll n,i,j,K;
ll a[105];
set<ll> s;
ll solve(ll k)
{
    if(k<0)
        return -1;
    if(k==0)
        return 0;
    if((s.find(k))!=(s.end()))
        return 1;
    if(dp[k]!=-1)
        return dp[k];
    ll f=0;
    ll x=1;
    for(i=1;i<=n;i++)
    {
        x=1+solve(k-a[i]);
        if((x%2)==1)
            f=1;
    }
    dp[k]=f;
    return f;
}*/

int main()
{
    for(k=0;k<3005;k++)
        for(l=0;l<3005;l++)
            dp[k][l]=-1;
    /*for(i=0;i<100005;i++)
            dp[i]=-1;
    cin>>n>>K;
    for(i=1;i<=n;i++)
        {cin>>a[i];
        s.insert(a[i]);
        }
    ll ppp=solve(K);
    if(ppp)
        cout<<"First";
    else
        cout<<"Second";*/
    cin>>n;
    for(k=0;k<n;k++)
        cin>>a[k];
    cout<<solve(0,n-1);
    return 0;
}






Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <numeric>

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

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c_i(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c_i[i];
    int ans = accumulate(b.begin(), b.end(), 0);
    rep(i, n-1){
        if (a[i]+1 == a[i+1]){
            ans += c_i[a[i] - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int Euler_Phi(int n) {
	int res = n;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			res = res / i * (i - 1);
			while (n /= i, n % i == 0);
		}
	}
	if (n != 1) res = res / n * (n - 1);
	return res;
}

int main()
{
	int n;
	cin >> n;
	cout << Euler_Phi(n) << endl;
	return 0;
}

Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC045A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, h;

            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            h = int.Parse(Console.ReadLine());

            Console.WriteLine((a + b) * h / 2);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
A, B, C, X, Y = map(int, input().split())

min_total = float("inf")
for i in range(max(X, Y) + 1):
    sum_C = 2 * C * i
    sum_A = A * max(0, X - i)
    sum_B = B * max(0, Y - i)
    total = sum_C + sum_A + sum_B
    if total < min_total:
        min_total = total

print(min_total)

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int n;
    cin >> n;
    vector<double> v(n);
    for(int i=0; i<n; i++)
        cin >> v[i];
    int n2=n-1;
    while(n2--){
        sort(all(v));
        if(v.back() > 1000)
            v.pop_back();
        double temp = (v[0]+v[1])/2;
        
        v[1]=temp;
        v[0]=1001;
    }
    cout << v[1];
}

Measured memory_bytes: 256
import java.util.Scanner;

//Flick Input
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		String[] s = {"a","i","u","e","o"};
		String[] b = {"w","a","k","s","t","n","h","m","y","r"};
		char[] r = sc.next().toCharArray();
		StringBuilder res = new StringBuilder();
		for(int i=0;i<r.length;i+=2){
			int id = r[i]-'0';
			int x = r[i+1]=='T'?0:r[i+1]=='L'?1:r[i+1]=='U'?2:r[i+1]=='R'?3:4;
			if(id==1)res.append(s[x]);
			else if(id==0){
				if(x==0)res.append("wa");
				else if(x==2)res.append("nn");
				else res.append("wo");
			}
			else res.append(b[id]+s[x]);
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int F1[100010], F2[100010];
int main() {
        int n; cin >> n;

        int mx1 = 0, mx2 = 0, x1 = 0, x2 = 0;
        priority_queue < pair <int, int> > Q1, Q2;
        for(int i = 1; i <= n; i++) {
                int x; cin >> x;
                if(i & 1) {
                        F1[x]++;
                }else{
                        F2[x]++;

                }
        }
        for(int i = 1; i <= 100000; i++) {Q1.push({F1[i], i}); Q2.push({F2[i], i});}
        int mn = INT_MAX;

        if(Q1.top().second == Q2.top().second) {
                int a1 = Q1.top().first;
                Q1.pop();
                int a2 = Q1.top().first;
                int b1 = Q2.top().first;
                Q2.pop();
                int b2 = Q2.top().first;
                mn = min(mn, min(n - a1 - b2, n - a2 - b1));
        }else mn = min(mn, n - Q1.top().first - Q2.top().first);

        cout << mn << endl;
}


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

int main() {
    i64 n, k;
    std::cin >> n >> k;
    std::vector<i64> h(n);
    for (auto &e : h) std::cin >> e;
    std::sort(h.begin(), h.end());
    i64 ret = 0;
    for (int i = 0; i < n - k; i++) ret += h[i];
    std::cout << ret << std::endl;

    return 0;
}


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

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

Measured memory_bytes: 3916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124 {
	class ABC124_C {
		static void Main(string[] args) {
			var input = Console.ReadLine();
			var N = input.Length;

			var start0 = CreateNBinary(N, 0);
			var start1 = CreateNBinary(N, 1);

			var sum0 = 0;
			var sum1 = 0;
			for (int i = 0; i < N; i++) {
				if (input[i] != start0[i]) sum0++;
				if (input[i] != start1[i]) sum1++;
			}

			Console.WriteLine(sum0 > sum1 ? sum1 : sum0);
		}

		private static string CreateNBinary(int n, int start) {
			var sb = new StringBuilder(start.ToString());
			for (int i = 0; i < n-1; i++) {
				if(sb[i] == '0') {
					sb.Append('1');
					continue;
				}

				if(sb[i] == '1') {
					sb.Append('0');
					continue;
				}
			}

			return sb.ToString();
		}
	}
}


Measured memory_bytes: 12128