akhauriyash/Code-Regression huggingface dataset:
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

use std::cmp::*;

fn main() {
    let n: usize = read();
    let mut a: Vec<u64> = Vec::new();

    for _ in 0..n
    {
        let ai: u64 = read();
        a.push(ai);
    }

    let mut winner: u64 = max(a[0], a[1]);
    let mut runner_up: u64 = min(a[0], a[1]);
    let mut winner_index: u32 = if winner == a[0] { 0 } else { 1 };

    for i in 2..n
    {
        // 該当の値がwinner以上である場合
        if a[i] >= winner
        {
            runner_up = winner;
            winner = a[i];
            winner_index = i as u32;
            continue;
        }

        // 該当の値がwinner未満runner_up以上である場合
        if a[i] >= runner_up
        {
            runner_up = a[i];
        }
    }

    // winner_indexの時だけrunner_upの値を表示すればOK
    for i in 0..n
    {
        if i == winner_index as usize { println!("{}", runner_up); continue; }
        println!("{}", winner);
    }
}


Measured memory_bytes: 7676
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt;ll ans;
char c[200010];
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	for(rt i=1,tot=0;i<=n;i++){
		tot+=c[i]=='B';
		ans+=(c[i]=='W')*tot;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	bool ok = true;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (a % 2 == 1) { continue; }
		if (a % 3 != 0 && a % 5 != 0) { ok = false; }
	}

	cout << (ok ? "APPROVED" : "DENIED") << endl;

	return 0;
}


Measured memory_bytes: 256
// B - 0 or 1 Swap
#include <stdio.h>

int main(void){
    int n, cnt=0, tmp;
    int p[51];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &p[i]);
    int k=0;
    for(int i=0; i<n; i++){
        if(p[i]!=i+1)k++;
    }
    if(k<=2) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,head[MN+5],cnt=0,a[MN+5],b[MN+5],H[MN*4+5],dep[MN+5];
int dfn[MN+5],top[MN+5],size[MN+5],mx[MN+5],Fa[MN+5],dn=0,vis[MN+5];
struct edge{int to,next;}e[15000005];
struct data{pair<int,int> mn,mn2;
	data operator + (const data&b)
	{
		data c;
		if(mn.first==b.mn.first) c.mn=mn,c.mn2=min(mn2,b.mn2);
		else if(mn<b.mn) c.mn=mn,c.mn2=min(mn2,b.mn);
		else c.mn=b.mn,c.mn2=min(mn,b.mn2);
		return c;
	} 
};
struct Tree{int l,r,val;data x;}T[MN*4+5];
inline void ins(int*h,int f,int t){e[++cnt]=(edge){t,h[f]};h[f]=cnt;}
void Pre(int x,int fa)
{
	size[x]=1;mx[x]=0;Fa[x]=fa;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			dep[e[i].to]=dep[x]+1;
			Pre(e[i].to,x);
			size[x]+=size[e[i].to];
			if(size[e[i].to]>size[mx[x]]) mx[x]=e[i].to;
		}
}
void Dfs(int x,int tp)
{
	top[x]=tp;dfn[x]=++dn;
	if(mx[x]) Dfs(mx[x],tp);
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=Fa[x]&&e[i].to!=mx[x])
			Dfs(e[i].to,e[i].to);
}
void Build(int x,int l,int r)
{
	if((T[x].l=l)==(T[x].r=r)){T[x].x=(data){make_pair(0,l),make_pair(1e9,0)};return;}
	int mid=l+r>>1;	
	Build(x<<1,l,mid),Build(x<<1|1,mid+1,r);
	T[x].x=T[x<<1].x+T[x<<1|1].x;
}
inline void Mark(int x,int v){T[x].val+=v;T[x].x.mn.first+=v;T[x].x.mn2.first+=v;}
inline void pushdown(int x){Mark(x<<1,T[x].val),Mark(x<<1|1,T[x].val),T[x].val=0;}
void Modify(int x,int l,int r,int v,int fr)
{
	if(T[x].l==l&&T[x].r==r)
	{
		if(v>0) ins(H,x,fr);
		return Mark(x,v);;
	}
	if(T[x].val) pushdown(x);
	int mid=T[x].l+T[x].r>>1;
	if(r<=mid) Modify(x<<1,l,r,v,fr);
	else if(l>mid) Modify(x<<1|1,l,r,v,fr);
	else Modify(x<<1,l,mid,v,fr),Modify(x<<1|1,mid+1,r,v,fr);
	T[x].x=T[x<<1].x+T[x<<1|1].x;
}
int Get(int x,int k)
{
	while(H[x]&&vis[e[H[x]].to]) H[x]=e[H[x]].next;
	if(H[x]) return e[H[x]].to;
	if(T[x].l==T[x].r) return printf("what a fuck?\n");
	int mid=T[x].l+T[x].r>>1;
	if(T[x].val) pushdown(x);
	return Get(x<<1|(k>mid),k);
}
void Solve(int x,int y,int v,int i)
{
	for(;top[x]!=top[y];x=Fa[top[x]])
	{
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		Modify(1,dfn[top[x]],dfn[x],v,i);
	}
	if(dfn[x]>dfn[y]) swap(x,y);
	if(dfn[x]<dfn[y]) Modify(1,dfn[x]+1,dfn[y],v,i);	
}
int main()
{
	n=read();
	for(int i=1;i<n;++i)
	{
		int x=read(),y=read();
		ins(head,x,y);ins(head,y,x);
	}
	Pre(1,0);Dfs(1,1);Build(1,1,n);
	for(int i=1;i<n;++i)
	{
		a[i]=read();b[i]=read();
		Solve(a[i],b[i],1,i);
	}
	for(int i=1;i<n;++i)
	{
		int fr=T[1].x.mn.first==1?T[1].x.mn.second:(T[1].x.mn2.first==1?T[1].x.mn2.second:0);
		if(!fr) return 0*puts("NO");
		int res=Get(1,fr);vis[res]=1;
		Solve(a[res],b[res],-1,i);
	}
	puts("YES");
	return 0;
}



Measured memory_bytes: 40960
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
int main()
{
    //freopen("in.txt","r",stdin);
    mint val;
    cin >> val;
    mint lo = 1, hi = 10000000;
    while(lo < hi)
    {
        mint mid = (lo + hi) / 2;
        mint d = (mid*(mid + 1)) / 2;
        if(d >= val)
        {
            hi = mid;
        }
        else
        {
            lo = mid + 1;
        }
    }
    cout << lo << endl;
    return 0;
}



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

int main(){
    int N, ans=0, left=-1, right, tmp=0;
    string S;
    cin >> N;
    cin >> S;
    for(int i=0; i<N; i++){
	if(S[i]=='I')
	    tmp++;
	else if(S[i]=='D')
	    tmp--;
	ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ALL = 0

for j,k in enumerate(A):
    len_A = len(A)
    ALL += B[k-1]
    if j + 1 == len_A:
        pass
    else:
        if A[j+1] - k == 1:
            ALL += C[k-1]
print(ALL)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n,a,result=0;
cin >>n;
  for(int i=1;i<=n;i++){
    cin>>a;
    if(i*a%2!=0){
     
     
       result++;

     
    }
  }
cout <<result;
return 0;
}






ll gcd(ll a, ll b){

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

}


Measured memory_bytes: 3592
inputs = input().split(' ')

taka_hp = int(inputs[0])
taka_at = int(inputs[1])
aoki_hp = int(inputs[2])
aoki_at = int(inputs[3])

while True:
  aoki_hp -= taka_at
  if aoki_hp <= 0:
    print('Yes')
    break
  taka_hp -= aoki_at
  if taka_hp <= 0:
    print('No')
    break

Measured memory_bytes: 9124
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    Arrays.sort(a);
    reverse(a);
    for(int i = 0; i < n; i++){
      alice += (i % 2 == 0) ? a[i] : -a[i];
    }
    System.out.println(alice);
  }
  
  public static int[] reverse(int[] array){
    for(int i = 0; i < array.length/2; i++){
      int tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> w(N), d(N);
  REP(i, N) { cin >> w[i] >> d[i]; }

  ll ok = 2e18 + 1, ng = 0;
  while (ng + 1 < ok) {
    ll m = (ok + ng) / 2;
    ll cnt = 0;
    REP(i, N) {
      if (m >= w[i]) {
        cnt += 1 + (m - w[i]) / d[i];
      }
    }
    (cnt >= K ? ok : ng) = m;
  }
  cout << ok << endl;
}

Measured memory_bytes: 1792
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//Use these for recursive solution
const int mod=1e9+7;
//int dp[1005][1005];
//bool vis[1005][1005];

/*
int recursive(int row, int col, vector<vector<char>>&matrix)
{
	//cout<<row<<col<<endl;
	if(row<0 || col<0)
		return 0;
	if(matrix[row][col]=='#')
		return 0;
	if(row==0 && col==0)
		return dp[row][col]=1;

	//i do my work
	int left=0;
	int up=0;
	//if i already visited this cell return the ans from the dp table
	if(vis[row][col])
		return dp[row][col];
	//else find the answer form the children and mark the cell as visisted 
	else
	{
		vis[row][col]=true;
		//get the answers from childern and do the work;
		 left=recursive(row,col-1,matrix);
		 up=recursive(row-1,col,matrix);
	}
	return dp[row][col]=(left+up)%mod;
}
*/
int bottomup(vector<vector<char>>&matrix)
{
	int row=matrix.size();
	int col=matrix[0].size();
	int dp1[row][col];

	//fill the first col
	dp1[0][0]=1;
	for(int i=1;i<row;i++)
	{
		if(matrix[i][0]=='#')
			dp1[i][0]=0;
		else
			dp1[i][0]=dp1[i-1][0];
	}
	//fill the first row
	for(int i=1;i<col;i++)
	{
		if(matrix[0][i]=='#')
			dp1[0][i]=0;
		else
			dp1[0][i]=dp1[0][i-1];
	}
	for(int i=1;i<row;i++)
	{
		for(int j=1;j<col;j++)
		{
			if(matrix[i][j]=='#')
				dp1[i][j]=0;
			else
				dp1[i][j]=(dp1[i-1][j]+dp1[i][j-1])%mod;
		}
	}
	//for(int i=0;i<row;i++)
	//{
	//	for(int j=0;j<col;j++)
	//		cout<<dp1[i][j]<<" ";
	//		cout<<endl;
	//}
	return dp1[row-1][col-1];
}
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int row,col;
	cin>>row>>col;
	vector<vector<char>>matrix(row,vector<char>(col));
	for(int i=0;i<row;i++)
		for(int j=0;j<col;j++)
			cin>>matrix[i][j];

	//cout<<recursive(row-1,col-1,matrix)<<endl;
	//for(int i=0;i<row;i++)
	//{
	//	for(int j=0;j<col;j++)
	//		cout<<dp[i][j]<<" ";
	//	cout<<endl;
	//}
	cout<<bottomup(matrix);
	
}

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

int n, a[200009], b[200009];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; b[i] = a[i];
	}
	sort(b, b + n);
	int G1 = b[n / 2 - 1], G2 = b[n / 2];
	for (int i = 0; i < n; i++) {
		if (G2 <= a[i]) cout << G1 << endl;
		else cout << G2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
n,m,q=map(int,input().split())
abcd=[]
for _ in range(q):
	a,b,c,d=map(int,input().split())
	abcd.append((a,b,c,d))
ans=0
p=[]
import sys
sys.setrecursionlimit(10**6)
def dfs(x):
	if len(x)==n:
		p.append(x)
	else:
		for i in range(m-x[-1]+1):
			dfs(x+[x[-1]+i])
dfs([1])
# import itertools
# p=itertools.combinations_with_replacement(range(1,m+1),n)
for x in p:
	r=0
	for i in range(q):
		if x[abcd[i][1]-1]-x[abcd[i][0]-1]==abcd[i][2]:
			r+=abcd[i][3]
	ans=max(ans,r)
print(ans)

Measured memory_bytes: 16132
#include<stdio.h>
#define INT_MAX 0x7f7f7f7f
int n, m, dis[105][105];
bool floyd()
{
    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++){
            dis[i][i] = 0;
            for(int j = 0; j < n; j++)
                if(dis[i][k] != INT_MAX && dis[k][j] != INT_MAX)
                    if(dis[i][j] > dis[i][k] + dis[k][j])
                        dis[i][j] = dis[i][k] + dis[k][j];
            if(dis[i][i] < 0) return false;
        }
    return true;
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            dis[i][j] = INT_MAX;
    for(int i = 1; i <= m; i++)
    {
        int x, y, t;
        scanf("%d%d%d", &x, &y, &t);
        dis[x][y] = t;
    }
    if(floyd())
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++){
                if(dis[i][j] != INT_MAX) printf("%d", dis[i][j]);
                else printf("INF");
                putchar(" \n"[j == n-1]);
        }
    else printf("NEGATIVE CYCLE\n");
    return 0;
}


Measured memory_bytes: 2760
N, A, B = map(int, input().split())

if (B - A)%2 == 0:
    print((B - A)//2)
else:
    if A - 1 > N - B and B - A - 1 != 0:
        print((B - A + 1)//2 + N - B)
    elif  A - 1 <= N - B and B - A - 1 != 0:
        print((B - A + 1)//2 + A - 1)
    elif A - 1 > N - B and B - A - 1 == 0:
        print(N - B + 1)
    else:
        print(A)


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

int main()
 {
 	string s;
 	cin>>s;
 	int n=s.size();
 	if(s[n-1]=='s') cout<<s+"es";
 	else cout<<s+"s";
 }
 
   
 	
 	
 
	 

Measured memory_bytes: 3612
package main

import (
	"fmt"
	"os"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	days := []string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	for i, d := range days {
		if s == d {
			fmt.Printf("%d\n", 7-i)
			os.Exit(0)
		}
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int kiage(int,int);
int main(){
	int x,y,z;
	cin>>x>>y>>z;
	cout<<(x-z)/(y+z)<<endl;
}
int kiage(int rareru,int ru){
	int anser;
	if(rareru%ru==0){
		anser=rareru/ru;
	}
	else anser=rareru/ru+1;
	return anser;
}
//長さ　幅　周りとの距離


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

public class P
{
    public int area { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    public static void print(Stack<P> st)
    {
        var n = st.Count();
        if (n == 0) { Console.WriteLine(0); Console.WriteLine(0); return; }
        var asum = st.Pop().area;
        var ret = asum.ToString();
        for (int i = 1; i < n; i++)
        {
            var w = st.Pop();
            ret = w.area.ToString() + " " + ret;
            asum += w.area;
        }
        Console.WriteLine(asum);
        Console.WriteLine(n.ToString() + " " + ret);
    }
    public static void getAns(string s)
    {
        var st1 = new Stack<int>();
        var st2 = new Stack<P>();
        for (int i = 0; i < s.Length; i++)
            if (s[i] == '\\') st1.Push(i);
            else if (s[i] == '/' && st1.Count() > 0)
            {
                var id = st1.Pop();
                var area = i - id;
                while (st2.Count() > 0 && id <= st2.Peek().id)
                {
                    area += st2.Peek().area;
                    st2.Pop();
                }
                st2.Push(new P { id = id, area = area });
            }
        print(st2);
    }
}



Measured memory_bytes: 10788
#include <iostream>

using namespace std;

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



Measured memory_bytes: 3084
using System;

namespace ABC099A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if (n < 1000)
            {
                Console.WriteLine("ABC");
                return;
            }
            Console.WriteLine("ABD");
        }
    }
}

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

#define jaldi ios_base::sync_with_stdio(false)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define mod 1000000007

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}

ll root(ll a,vll &head)
{
    while(a!=head[a])
    {
        head[a]=head[head[a]];
        a=head[a];
    }
    return a;
}

void merge(ll a,ll b,vll &head, vll &size)
{
    ll p_a = root(a,head);
    ll p_b = root(b,head);
    if(p_a==p_b)
        return;
    
    if(size[p_a]>size[p_b])
    {
        size[p_a]+=size[p_b];
        head[p_b]=head[p_a];
    }
    else
    {
        size[p_b]+=size[p_a];
        head[p_a]=head[p_b];
    }
    
}

ll ans;
void backtrack(ll i,ll cost,vvll &dp,vll &cur,ll x,vll &C)
{
    ll m=dp[0].size();
    if(i==dp.size())
    {
        ll f=0;
        for(ll j=0;j<m;j++)
        {
            if(cur[j]<x)
                f=1;
        }
        if(f==0)
            ans=min(ans,cost);
        return;
    }

    vll newval(m,0);


    for(ll j=0;j<m;j++)
    {
        newval[j]=cur[j]+dp[i][j];
    }
    backtrack(i+1,C[i]+cost,dp,newval,x,C);
    backtrack(i+1,cost,dp,cur,x,C);
}

int main()
{
    jaldi;
    precision(20);
    ll i,j;

    ll n,m,x;
    cin>>n>>m>>x;
    vll C(n);
    vector<vector<ll>> dp(n,vector<ll>(m));
    for(i=0;i<n;i++)
    {
        cin>>C[i];
        for(j=0;j<m;j++)
        {
            cin>>dp[i][j];
        }
    }
    ans=LONG_LONG_MAX;
    vll cur(m,0);
    backtrack(0,0,dp,cur,x,C);
    if(ans==LONG_LONG_MAX)
        cout<<-1<<endl;
    else
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
  ll x; cin >> x;
  ll kane = 100;
  ll count = 0;
  while(kane < x){
    kane = kane + kane * 0.01;
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;

int main() {
	int n, m; cin >> n >> m;
	string t(n, '-');
	for (int i = 0; i < m; i++) {
		int s; char c; cin >> s >> c;
		s--;
		if (t[s] != '-' && t[s] != c) {
			cout << -1 << endl;
			return 0;
		}
		t[s] = c;
	}

	for (int i = 0; i < 1000; i++) {
		string num = to_string(i);
		if (num.size() != n) continue;
		bool flag = true;
		for (int j = 0; j < n; j++) {
			flag &= t[j] == '-' || num[j] == t[j];
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


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

int main(){
	int i,N;
    cin >> N;
	vector<string> siri(N);
    for(i = 0 ; i < N ; i ++){
    	cin >> siri[i];
        if(i && siri[i - 1][siri[i - 1].length() - 1] != siri[i][0]){
        	i = -1;
            break;
        }
      	for(int I = 0 ; I < i ; I ++){
        	if(siri[I] == siri[i]){
          		i = -1;
          		break;
        	}
        }
      	if(i == -1) break;
    }
   	if(i == -1) cout << "No" << endl; else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;

long cnt = 0;
long N;
long num[3];
bool check(long x){
    bool b3 = false, b5 = false, b7 = false;
    while(x){
        if(x % 10 == 3) b3 = true;
        else if(x % 10 == 5) b5 = true;
        else if(x % 10 == 7) b7 = true;
        x = x / 10;
    }
    if(b3 && b5 && b7) return true;
    else return false;
}
void dfs(long rest, long tmpn){
    if(rest == 0){
        if(tmpn <= N && check(tmpn)){
            cnt++;
        }
        return;
    }
        else{
            rep(i, 3){
                dfs(rest-1, tmpn*10+num[i]);
            }
        }
        return;
}




int main(){
cin >> N;
num[0] = 3;
num[1] = 5;
num[2] = 7;

for(long n = 3; n <= 9; n++){
    dfs(n, 0);
}

show(cnt);
return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

ll solve_naive(ll n)
{
	int res=0;
	repi(i,1,n+1) repi(j,i,n+1)
		if(i/__gcd(i,j)*j==n)
			res++;
	return res;
}

ll solve(ll n)
{
	vector<tuple<ll,int>> fs;
	{
		map<ll,int> tmp;
		for(ll i=2;i*i<=n;i++)
			while(n%i==0){
				tmp[i]++;
				n/=i;
			}
		if(n!=1) tmp[n]++;
		for(auto p:tmp) fs.push_back(p);
	}
	int m=fs.size();
	
	set<tuple<ll,ll>> s;
	rep(i,1<<m){
		ll x=1,y=1;
		rep(j,m){
			ll& z=i>>j&1?x:y;
			rep(k,get<1>(fs[j]))
				z*=get<0>(fs[j]);
		}
		s.insert(mt(min(x,y),max(x,y)));
	}
	
	rep(i,m){
		ll pri,cnt; tie(pri,cnt)=fs[i];
		set<tuple<ll,ll>> t=s;
		for(auto p:s){
			ll x,y; tie(x,y)=p;
			ll& z=x%pri?x:y;
			rep(k,cnt){
				z*=pri;
				t.insert(mt(min(x,y),max(x,y)));
			}
		}
		swap(s,t);
	}
	return s.size();
}

int main()
{
	for(ll n;cin>>n && n;)
		cout<<solve(n)<<endl;
}

Measured memory_bytes: 4160
N=gets.to_i
L=gets.split(" ").map(&:to_i)
s=0
m=0
for i in 0..N-1
	s+=L[i]
	m=(L[i]>m) ? L[i] : m
end
if s>2*m
	puts "Yes"
else
	puts "No"
end

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

int main(void){
    string a,b; cin >> a >> b;
    a+=b;
    int n=stoi(a.substr(0, a.size()));

    for(int i=1; i<500; i++){
        if(i*i==n){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int num=s.size()-1;
	if(s[num]=='s') s=s+"es";
	else s=s+"s";
	cout<<s;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,a;
  cin>>n>>a;
  int r = n % 500;
  if(r <= a) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner stdin = new Scanner(System.in);
		double a = 0;
		double b = 0;
		double c = 0;
		double d = 0;
		double e = 0;
		double f = 0;
		double x = 0;
		double y = 0;
		while(stdin.hasNext()) {
			a = stdin.nextDouble();
			b = stdin.nextDouble();
			c = stdin.nextDouble();
			d = stdin.nextDouble();
			e = stdin.nextDouble();
			f = stdin.nextDouble();
			x = (e * c - b * f) / (e * a - b * d);
			y = (a * f - c * d) / (e * a - b * d);
			BigDecimal bdX = new BigDecimal(x);
			BigDecimal bdY = new BigDecimal(y);
			BigDecimal bd1 = bdX.setScale(4, BigDecimal.ROUND_HALF_UP);
			BigDecimal bd2 = bdY.setScale(4, BigDecimal.ROUND_HALF_UP);
			//System.out.printf("%.3f",bd1.doubleValue() + " " + bd2.doubleValue());
			System.out.printf("%.3f %.3f\n",bd1.doubleValue(), bd2.doubleValue());
		}
		
		
	}
}

Measured memory_bytes: 28552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  

ll n;
bool cal(ll x){
  ll left=n-x;
  for(ll i=x-1; 1<=i; i--){
    if(left-i<0) continue;
    left -= i;
  }
  return left==0;
}


int main(){
  cin >> n;

  ll lb=-1, ub=n+1, mid=1e+15;
  while(1<ub-lb){
    mid = (lb+ub)/2;
    if(cal(mid)) ub=mid;
    else lb=mid;
  }
  ll left=n;
  for(ll i=ub; 0<left; i--){
    if(left-i<0) continue;
    left -= i;
    cout << i << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
//#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
  std::for_each(std::begin(c), std::end(c), [&os](typename C::value_type p) { os << '{' << p.first << ',' << p.second << "}, "; });
  os << std::endl;
}



signed main(){
    cin >> n;
    unordered_map<string,int> um;
    int ans = 0;
    REP(i,n){
        string s;
        cin >> s;
        int m = s.size();
        vector<char> x(m);
        REP(j,m){
            x[j] = s[j];
        }
        Sort(x);
        REP(j,m){
            s[j] = x[j];
        }
        if(um.find(s) == um.end()){
            um.emplace(s, 1);
        }
        else{
            int t = um.at(s);
            ans += t;
            um.erase(s);
            um.emplace(s,t+1);
        }
    }
    //print(um);
    cout << ans << endl;
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}





Measured memory_bytes: 10660
n = int(raw_input())
a = [[10**9 for i in range(n)] for j in range(n)]
for i in range(n):
    data = map(int, raw_input().split())
    a[data[0]][data[0]] = 0
    for j in range(data[1]):
        a[data[0]][data[j*2+2]] = data[j*2+3]
ans = [[10**9 for i in range(n)] for j in range(n+1)]
ans[0][:] = a[0][:]
for j in range(1, n+1):
    for k in range(n):
        for l in range(n):
            if ans[j][k] > ans[j-1][l] + a[l][k]:
                ans[j][k] = ans[j-1][l] + a[l][k]
        if ans[j][k] == 10**9:    
            ans[j][k] = ans[j-1][k]
for i in range(n):
    print i, ans[-1][i]

Measured memory_bytes: 6644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
LL A,B,N;

void work(){
    scanf("%lld%lld%lld",&A,&B,&N);
    if(N>=B-1){
        printf("%lld\n",A*(B-1)/B);
    }
    else{
        printf("%lld\n",A*N/B);
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}








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

using namespace std;

bool cmp(int a, int b) {
  return a > b;
}

int main() {
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end(), cmp);
  
  long long ans = a[0];
  for (int i = 2; i  < n; ++i) {
    ans += a[i / 2];
  }

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

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

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin>>n;
    ll ans=n*(n+1)/2;

    vector<set<ll>> ed(n);
    for(int i = 0;i < n-1;++i) {
        int a,b;
        cin>>a>>b;
        --a;--b;
        if(a>b)swap(a,b);
        ed[b].insert(a);
    }

    for(ll i = 0;i < n;++i) {
        ans += i*(n-i);
        //cerr<<ans<<endl;
        for(auto x:ed[i]) {
            ans -= (x+1)*(n-i);
        }

    }

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


Measured memory_bytes: 21924
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define rcin(a,n) rep(i,n)cin >> a[i];
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 111; i < 1000; i += 111) {
        if (n <= i) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
  int N; 
  cin>>N;
  vector<int> low(N);
  for(int i=0; i<N; i++){
    int p;
    cin>>p;
    low.at(i)=p;
  }
  int min=low.at(0);
  int count=0;
  for(int i=0; i<N; i++){
    if(low.at(i)<=min){
      count++;
      min=low.at(i);
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
from bisect import bisect_left,bisect_right
for b in B:
    ida = bisect_left(A,b)
    idc = bisect_right(C,b)
    ans += ida*(N-idc)
print(ans)


Measured memory_bytes: 104084
#define ll long long int

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
ll arr[N];
bool b[N];

int main() {

    ll n;
    cin >> n;
    string temp = "";
    while (n) {
        char c = ((26 + (n % 26) - 1)) % 26 + 'a';
        temp += c;
        n--;
        n /= 26;
    }

    reverse(temp.begin(), temp.end());
    cout << temp << endl;
    return 0;
}

Measured memory_bytes: 3604
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let num : u32 = read();

    let mut count = 0;

    for i in 1 .. num + 1
    {
        eprintln!("({})", i);

        let a : u32 = read();

        if (i % 2 == 1) && (a % 2 == 1)
        {
            count += 1;
        }
    }

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


Measured memory_bytes: 2172
#pragma region Include
#include <bits/stdc++.h>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(digit) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A;
  cin >> N;
  unordered_map<int, int> mp;
  rep(i, N) {
    cin >> A;
    if (mp[A] == 0) {
      mp[A] = 1;
    } else {
      out("NO");
      return 0;
    }
  }
  out("YES");
  return 0;
}

Measured memory_bytes: 8520
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int[] sum = {a,b,c};
        Arrays.sort(sum);

        System.out.println(sum[0]+sum[1]);
    }

}


Measured memory_bytes: 25172
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.List (intercalate)

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  let
    as' = VU.fromList as :: VU.Vector Int
    x1 = VU.sum . VU.zipWith (*) (VU.iterateN n negate 1) $ as' :: Int
    xs = VU.prescanl subtract x1 . VU.map (2 *) $ as' :: VU.Vector Int
  putStrLn . intercalate " " . map show . VU.toList $ xs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=1e4+100;

int f[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    for(int x=1;x<=100;x++)
        for(int y=1;y<=100;y++)
            for(int z=1;z<=100;z++)
            {
                int val=x*x+y*y+z*z+x*y+y*z+z*x;
                if(val<=n)
                    f[val]++;
            }
    for(int i=1;i<=n;i++)
        cout<<f[i]<<"\n";
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

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

	ll n, k, i, ans = 1, j, lp, rp, itr;
	cin >> n >> k;
	vl a(n);
	rep(i, 0, n)
	{
		cin >> a[i];
	}
	sort(all(a));
	// rep(i, 0, n)
	// 	cout << a[i] << " ";
	// cout << endl;

    if (a[n - 1] == 0 && (k & 1))
    {
    	cout << 0 << endl;
    	return 0;
    }

    if (a[n - 1] < 0 && (k & 1))
    {
        for(i = n - 1; i >= n - k; i--)
        {
            ans = (ans * a[i]) % mod;
            while(ans < 0)
            	ans += mod;
            ans %= mod;
        }
        cout << ans << endl;
    	return 0;
    }

    i = 0;
    j = n - 1;
    if (k & 1)
    {
        ans = (ans * a[j]) % mod;
        while(ans < 0)
        	ans += mod;
        ans %= mod;
        j--; 
        k--;
    } 

    k = k / 2LL; 

    for (itr = 0; itr < k; itr++)
    {
        lp = a[i] * a[i + 1];
        rp = a[j] * a[j - 1];
        // pr(lp);
        // pr(rp);
        // cout << endl;
        if (lp > rp)
        { 
            ans = (ans * (lp % mod)) % mod; 
            while(ans < 0)
            	ans += mod;
            ans %= mod;
            i += 2; 
        } 
        else
        { 
            ans = (ans * (rp % mod)) % mod; 
            while(ans < 0)
            	ans += mod;
            ans %= mod;
            j -= 2; 
        } 
    }
    cout << ans << endl;

}

Measured memory_bytes: 4688
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my $ok = -1;
for(my $i=9;$i>=1;$i--){
  my $j = $i . $i . $i;
  $ok = ($j - 0) if $j - 0 >= $n;
}
print "$ok\n";


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	ps := make([]int, n)
	wa := make([]int, n)
	pena := 0
	ac := 0
	for i := 1; i <= m; i++ {
		var p int
		var s string
		fmt.Scan(&p, &s)
		p--
		if ps[p] > 0 {
			continue
		}
		if s == "AC" {
			ps[p] = i
			ac++
			pena += wa[p]
		}
		if s == "WA" {
			wa[p]++
		}
	}
	fmt.Printf("%d %d", ac, pena)
}


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

int main()
{
    int n;
    int m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cstring>

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;

int t[17][17];
int memo[1<<16]; // クリア済みステージだけ持てばおｋ
int n;

int solve(int clear){
	if(memo[clear] != 0) return memo[clear];
	if(clear == (1<<n)-1) return 0;

	int res = 2<<29;
	for(int i = 0; i < n; i++){
		if((clear>>i)&1) continue;
		int time = t[i][0];
		for(int j = 1; j <= n; j++){
			if(clear>>(j-1)&1) time = min(time, t[i][j]);
		}
		res = min( res, time+solve(clear|(1<<i)));
	}

	return memo[clear] = res;
}


int main(){	
	while(cin >> n, n){
		rep(i, n){
			rep(j, n+1){
				cin >> t[i][j];
			}
		}
		memset(memo, 0, sizeof(memo));
		cout << solve(0) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1424
import bisect

N = int(input())
L = sorted(map(int, input().split()))

ans = 0
for m in range(N):
    for s in range(m):
        #このfor文の時点で、時点でs<mを満たす。
        # L[m] <= L[l] < L[s] + L[m]
        # 使用している辺は使えず、sortしてあるので、m<lという条件が加わる。
        # m<lの時点で、L[m] <= L[l]は満たすので、m<l とL[l] < L[s] + L[m]で考える。
        ans += bisect.bisect_left(L,L[s]+L[m]) - (m+1)
        
print(ans)


Measured memory_bytes: 42332
import sys
import itertools

for n in sys.stdin.readlines():
    n = int(n)
    patterns = itertools.product(range(10), range(10), range(10), range(10))
    ans = 0
    for a, b, c, d in patterns:
       if a + b + c + d == n:
           ans +=1
    print(ans)

Measured memory_bytes: 7644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String s = br.readLine();
            String[] sArray = s.split("");
            if (s.length() == 3) {
                for (int i = 2; i >= 0; i--) {
                    System.out.print(sArray[i]);
                }
            } else {
                for (int i = 0; i < 2; i++) {
                    System.out.print(sArray[i]);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 21204
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int N, sum(0); cin >> N;
    VI a(N);
    REP(i, N){
        cin >> a[i];
        sum += a[i];
    }
    int ans = -1, dif(INF);
    REP(i, N){
        if(dif > abs(N*a[i] - sum)){
            dif = abs(N*a[i] - sum);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math as m

def prime(n):
    if n <= 1:
        return False
    for i in range(2,int(m.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

def Goldbach(n):
  x = []
  c = 0
  for i in range(n+1):
    if prime(i):
      x.append(i)
  for j in x:
    for k in x:
      if j > k:
        pass
      elif j + k == n:
            c += 1
      else:
        pass
  print(c)

while 1:
  n = int(input())
  if n == 0:
    break
  Goldbach(n)



Measured memory_bytes: 5684
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int ans=0,n,a,b;
map<int,int> mp;
int main()
{
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++)
	{
        cin>>vec[i];
        mp[vec[i]]++;
    }
    sort(vec.begin(),vec.end(),greater<int>());
    for(int i=0;i<vec.size();i++)
	{
        a=vec[i];
        if(mp[a]==0)  continue;
        for(int j=1;j<=a;b=j-a)  j*=2;
        if(mp[b]==0)  continue;
        if(a==b&&mp[a]==1)  continue;
        ans++;
        mp[a]--;
        mp[b]--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19712