akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		char last = input.charAt(input.length()-1);
		if (last == '2' || last == '4' || last == '5' || last == '7' || last == '9') {
			System.out.println("hon");
		} else if (last == '0' || last == '1' || last == '6' || last == '8') {
			System.out.println("pon");
		} else {
			System.out.println("bon");
		}
		sc.close();
	}

}

Measured memory_bytes: 35648
x=int(input())
m=10**6

def segment_sieve(a,b):
    ass = []
    is_prime_small = [True] * (int(b**0.5)+1)
    is_prime = [True] * (b-a)
    for i in range(2,int(b**0.5)):
        if is_prime_small[i]:
            j = 2*i
            while j**2 < b:
                is_prime_small[j] = False
                j += i
            j = max(2*i,((a+i-1)//i)*i)
            while j < b:
                is_prime[j-a] = False
                j += i
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(a+i)
    if ass[0] == 1:
        del ass[0]
    return ass

print(min(segment_sieve(x,m)))

Measured memory_bytes: 20292
#include <iostream>

using namespace std;

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

    switch (x) {
        case 3:  // fall through
        case 5:  // fall through
        case 7:
            cout << "YES\n";
            break;
        default:
            cout << "NO\n";
            break;
    }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(m)]
ab.sort()
l,r=ab[0]
ans=1
for a,b in ab[1:]:
  if r<=a:
    ans+=1
    l,r=a,b
  else:
    l=max(l,a)
    r=min(r,b)
print(ans)

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L, R;
  L = A + B;
  R = C + D;
  
  if ( L > R ){
    cout << "Left" << endl;
  }
  
  else if ( L == R ){
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long pow_mod(long long a, long long b, long long p){
    long long ret = 1;
    while(b){
        if(b & 1) ret = (ret * a) % p;
        a = (a * a) % p;
        b >>= 1;
    }
    return ret;
}
long long Fermat(long long a, long long p){
        return pow_mod(a, p-2, p);
}
int main(){
    
    int n;cin>>n;
    vector<long long> arr(n);
    vector<long long> ct(60,0);
    for(int i=0;i<n;++i){
        long long curr;cin>>curr;
        arr[i]=curr;
        for(long long j=0;j<60;++j){
            if(((1LL<<j)&curr)>0){
                ct[j]++;
            }
        }
    }
    long long res = 0;
    for(int i=0;i<n;++i){
        long long curr = arr[i];
        for(long long j=0;j<60;++j){
            if(((1LL<<j)&curr)>0){
                res += 1LL *(1LL<<j)% mod * (n - ct[j])% mod ;
                res %= mod;
            }else{
                res += 1LL *(1LL<<j)% mod * ct[j]% mod;
                res %= mod;
            }
        }                   
    }
    long long md = 1e9+7;
    res *= Fermat(2,md);
    res %= mod;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 2560
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var sum int
	for i := 1; ; i++ {
		sum += i
		if sum >= N {
			fmt.Println(i)
			break
		}
	}
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = 1000000007;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

void solve(){
	ll n;
	cin >> n;
	ll a;
	map < ll , ll > m1,m2;
	set < ll > st;
	f1(n){
		cin >> a;
		if(i&1) m1[a]++;
		else m2[a]++;
		st.in(a);
	}
	if(st.size() == 1){
		cout << n/2 << '\n';
		return;
	}
	if(n == 2){
		cout << 0;
		return;
	}
	vector < pair < ll , ll > > v1,v2; 
	for(auto u : m1) v1.pb({ ( (n/2) - u.ss) , u.ff});
	for(auto u : m2) v2.pb({ ( (n/2) - u.ss) , u.ff});
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	if(v1[0].ss != v2[0].ss) cout << v1[0].ff+v2[0].ff;
	else cout << min( v1[1].ff+v2[0].ff , v1[0].ff+v2[1].ff) << '\n';
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 13556
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    int H, W, M;
    io >> H >> W >> M;

    vi hs(H), ws(W);
    vector<pair<int,int>> targets;
    for (int i = 0; i < M; i++)
    {
        int h, w;
        io >> h >> w;
        --h; --w;
        ++hs[h];
        ++ws[w];
        targets.push_back({h,w});
    }

    vector<pair<int,int>> hps(H), wps(W);
    for (int i = 0; i < H; i++)
        hps[i] = {hs[i],i};
    for (int j = 0; j < W; j++)
        wps[j] = {ws[j],j};
    

    using cmp_t = greater<pair<int,int>>;
    sort(begin(hps), end(hps), cmp_t());
    sort(begin(wps), end(wps), cmp_t());
    sort(begin(targets), end(targets));


    auto hp2 = partition_point(begin(hps), end(hps), [&hps](pair<int,int> v){ return v.first == hps[0].first;}); 
    auto wp2 = partition_point(begin(wps), end(wps), [&wps](pair<int,int> v){ return v.first == wps[0].first;}); 

    int ans = hps[0].first + wps[0].first;
    bool found = true;
    for (auto ih = hps.begin(); ih != hp2; ++ih)
    {
        for (auto iw = wps.begin(); iw != wp2; ++iw)
        {
            if (!binary_search(begin(targets), end(targets), make_pair(ih->second, iw->second)))
            {
                found = false;
                goto ans;
            }
        }
    }

ans:
    if (found) ans--; 
    io << ans << BR;
}

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

using namespace std;

int main() {
  string A, B;
  cin >> A >> B;
  if (A.size() > B.size()) {
    printf("GREATER\n");
  } else if (A.size() < B.size()) {
    printf("LESS\n");
  } else {
    for (int i = 0; i < A.size(); ++i) {
      if (A[i] < B[i]) {
        printf("LESS\n");
        return 0;
      } else if (A[i] > B[i]) {
        printf("GREATER\n");
        return 0;
      }
    }
    printf("EQUAL\n");
  }
}

Measured memory_bytes: 3044
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  	int N;
  	cin >>N;
	vector<int> A(N);
	vector<int> vec(N);
  	for(int i=0;i < N; i++){
		cin >> A[i];
  	}
  	int cnt = 0;
  	long long sum = 0;
  	for(int i=0;i < N; i++){
      	int b;
		cin >> b;
      	vec[i] = A[i]-b;
      	sum += vec[i];
  	}
  	if (sum < 0){
      	cout << -1 <<endl;
      	return 0;
    }
  	sort(vec.begin(), vec.end());
  	sum = 0;
  	for(auto v:vec){
      	if (v < 0){
          	cnt++;
        	sum-=v;
        }
    }
  	for(int i=N-1;i >=0; i--){
      if (sum <= 0)
        	break;
      cnt++;
      sum -= vec[i];
  	}
  	cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main(void)
{
	int n,y;
	int b[51],r,t;
	int i,j;
	long long int g[10001];
	double fg,q;
	int max,bmax;
	
	scanf("%d",&n);
	while(n!=0){
		scanf("%d",&y);
		for(i=0;i<n;i++){
			scanf("%d %d %d",&b[i],&r,&t);
			if(t==1){
				q=(double)(100+y*r)/100;
				g[i]=10000*q;
	//			printf("A 単利=%lf\n",g[i]);
			}
			else if(t==2){
				fg=1.00;
				q=(double)(100+r)/100;
				for(j=0;j<y;j++){
					fg=fg*q;
	//				printf("q=%lf\n",q);
				}
	//			printf("B=%lf\n",fg);
				g[i]=10000*fg;
	//			printf("B 複利=%lf\n",g[i]);
			}
		}
		max=g[0];
		bmax=b[0];
		for(i=0;i<n;i++){
			if(max<g[i]){
				max=g[i];
				bmax=b[i];
			}
		}
		printf("%d\n",bmax);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 604
#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 RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

bool check(int N, vector<int> D){
    while(N > 0){
        int t = N % 10;
        REP(i, D.size()){
            if(t == D[i]){
                return false;
            }
        }
        N /= 10;
    }
    return true;
}

int main()
{
    int N, K;
    scanf("%d %d", &N, &K);
    vector<int> D(K);
    REP(i, K) scanf("%d", &D[i]);
    while(1){
        if(check(N, D)){
            printf("%d\n", N);
            return 0;
        }
        N++;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    string s;
    stack<int> st;
    while (cin>>s) {
        if (s == "+" || s == "-" || s == "*") {
            int op2 = st.top(); st.pop();
            int op1 = st.top(); st.pop();
            if (s == "+") st.push(op1 + op2);
            else if (s == "-") st.push(op1 - op2);
            else if (s == "*") st.push(op1 * op2);

            continue;
        }

        st.push(stoi(s));
    }

    cout<<st.top()<<endl;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,n;
    cin>>h>>w>>n;
    if(h>w){
        if(n%h==0){
            cout<<n/h<<'\n';
        }
        else{
            cout<<n/h+1<<'\n';
        }
    }
    else{
        if(n%w==0){
            cout<<n/w<<'\n';
        }
        else{
            cout<<n/w+1<<'\n';
        }
    }
    return(0);
}

Measured memory_bytes: 256
def main():
    mod=1000000007
    n,k=map(int,input().split())
    ans=0
    for i in range(k,n+2):
        l=i*(i+1)//2
        r=i*(2*n-i+3)//2
        ans+=r-l+1
        ans%=mod
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 63296
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;
LD dp[3005];
bool vis[3005];
int main(){
    int n;
    scanf("%d", &n);
    vis[0] = 1;
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        LD p1, p2;
        scanf("%Lf", &p1);
        p2 = 1-p1;
        for(int j=n;j>=0;j--){
            if(!vis[j]) continue;
            dp[j+1] = (dp[j+1] + dp[j]*p1);
            dp[j] = (dp[j]*p2);
            vis[j] = 1;
            vis[j+1] = 1;
        }
    }
    LD ans = 0;
    for(int i=(n+1)/2;i<=n;i++){
        ans += dp[i];
    }
    printf("%.10Lf\n", ans);
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
ans = []

max_a, min_a = (-10**6, 10**6)
max_i, min_i = 0, 0
for i in range(N):
    if max_a <= a[i]:
        max_a, max_i = a[i], i
    if min_a >= a[i]:
        min_a, min_i = a[i], i

if max_a + min_a >= 0:
    for i in range(N):
        a[i] += a[max_i]
        ans.append((max_i, i))
    for j in range(N - 1):
        a[j + 1] += a[j]
        ans.append((j, j + 1))
else:
    for i in range(N):
        a[i] += a[min_i]
        ans.append((min_i, i))
    for j in range(N - 1, 0, -1):
        a[j - 1] += a[j]
        ans.append((j, j - 1))

# print(a)
print(len(ans))
for (x, y) in ans:
    print(x + 1, y + 1)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    string S;
	cin >> S; 
	int temp=0;
	for(size_t i=1;i<S.length();i++)
	    if(S[i]==S[i-1]) temp++;
	if(temp+2*K<N-1) 
	    cout << temp+2*K;
	else 
	    cout << N-1;
	return 0;
} 

Measured memory_bytes: 512
package main

import "fmt"

func getMax(nums ...int) (max int){
  max = 0
  for i:=0; i<len(nums); i++{
    if nums[i] > max{
      max = nums[i]
    }
  }
  return
}

func main(){
  var a, b, c int
  fmt.Scan(&a, &b, &c)
  fmt.Println(a+b+c-getMax(a,b,c))
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;


public class Main{
	Scanner sc;
	double[][] A;
	double[][] B;
	
	/* Game
	 * すべての接触パターンについて、共通の部分を抜き出す。共通なのでAND
	 */
	boolean solve(double[][] a, double[][] b){
		return a[0][0]<=b[1][0] && b[0][1]<=a[1][1] && b[0][0]<=a[1][0] && a[0][1]<=b[1][1];
	}
	
	void io(){
		sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			A = new double[2][];
			B = new double[2][];
			for(int i=0; i<2; ++i){
				A[i] = new double[]{nd(), nd()};
			}
			for(int i=0; i<2; ++i){
				B[i] = new double[]{nd(), nd()};
			}
			
			System.out.println((solve(A, B)) ? "YES" : "NO");
		}
		
		sc.close();
	}
	
	double nd(){
		return sc.nextDouble();
	}
	
	public static void main(String[] args){
		new Main().io();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

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

using namespace std;

int func(int n) {
    int sum = 0;
    while(n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int r = func(n);

    if(n % r == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
 
my $stdin = <STDIN>;
chomp($stdin);
my @sides = split(/ /, $stdin);
print is_include_even(\@sides) ? 0 : count_diff_block(\@sides), "\n";
 
 
 
sub count_diff_block{
  my ($sides) = @_;
  @$sides = sort {$a <=> $b} @$sides;
  my $diff_num = $sides->[0] * $sides->[1];
  return $diff_num;
}
 
 
sub is_include_even{
  my ($array) = @_;
  for my $var (@$array) {
    return 1 if $var % 2 == 0;
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void solve() {
        int e, o; cin >> e>> o;
        cout << (e)* (e- 1)/ 2+ o* (o- 1)/ 2<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) solve();
return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
let _ = 
  let read n =
    let rec iter n = if n = 0 then [] else Scanf.scanf "%d\n" (fun x -> x) :: iter (n - 1) in
    List.rev @@ iter n in
  let max_sseq = function
    | [] -> (min_int,min_int)
    | hd :: tl -> List.fold_left (fun (c,m) x -> let mx = max (c + x) x in (mx, max mx m)) (hd, hd) tl in
  let rec loop () = 
    let n = Scanf.scanf "%d\n" (fun x -> x) in
    if n = 0 then ()
    else let lst = read n in
         Printf.printf "%d\n" (snd @@ max_sseq lst);
         loop () in
  loop ()

Measured memory_bytes: 3700
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  Bint a, b;
  cin >> a >> b;
  cout << a / b << endl;

  return 0;
}



Measured memory_bytes: 3260
import math

t8 = [[] for _ in range(130)]
t10 = [[] for _ in range(130)]
for i in range(1251):
    t8[math.floor(i * 0.08)].append(i)
    t10[math.floor(i * 0.1)].append(i)

a, b = map(int, input().split())
if min(t8[a]) > max(t10[b]) or max(t8[a]) < min(t10[b]):
    print(-1)
else:
    print(max(min(t8[a]), min(t10[b])))


Measured memory_bytes: 64180
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#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;

vector<vector<Int>> graph;
vector<Int> d;
Int N, M, S, T;
const Int INF = 100000000;

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

    cin >> N >> M;
    graph.assign(N*3, vector<Int>());
    d.assign(N*3, INF);
    rep(i, 0, M) {
        Int u, v; cin >> u >> v;
        --u; --v;
        graph[u].emplace_back(v+N);
        graph[u+N].emplace_back(v+2*N);
        graph[u+2*N].emplace_back(v);
    }
    cin >> S >> T;
    --S, --T;

    queue<Int> q;
    for(auto next : graph[S]) {
        q.emplace(next);
        d[next] = 1;
    }

    while(!q.empty()) {
        auto now = q.front();
        q.pop();

        for(auto next : graph[now]) {
            if (d[next] < INF) continue;
            d[next] = d[now]+1;
            q.emplace(next);
        }
    }

    Int res = d[T];
    if (res == INF) res = -1;
    else res /= 3;

    cout << res << endl;
}


Measured memory_bytes: 19072
#include<iostream>
using namespace std;
int main(){
 	int N,ans,i,a,b;
	cin >> N;
	b = N;
	ans = 0;	
	a = 0;
	if (N==10||N==100||N==1000||N==10000)ans=10;
	else{ 
		for (i= 10000;i>1/10;i=i/10){
			a=b/i;
			ans=ans+a;
		
			b=b - a*i;
	}	}
	cout << ans<< endl;
	}

Measured memory_bytes: 256
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b<a)
	{
		if(c>=(a-b))
		cout<<(c-(a-b));
		else
		cout<<0;
	}
	else
	cout<<c;
	return 0;
}











Measured memory_bytes: 256
#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

bool check(string s)
{
    string r;
    reverse_copy(s.begin(),s.end(),back_inserter(r));
    return s==r;
}

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

    string s;
    cin>>s;
    int n=s.size();
    cout<<(check(s)&&check(s.substr(0,n/2))?"Yes":"No");
}


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

class Main {

    void solve(){

	Scanner sc = new Scanner(System.in);

	int n = sc.nextInt();
	int[] A = new int[n];
	int[] B = new int[n];
	int[] C = new int[n];
	for ( int i=0; i<n; ++i ) A[i] = B[i] = C[i] = 0;
	
	int x = sc.nextInt();
	for ( int i=0; i<x; ++i ) A[sc.nextInt()-1] = 1;
	int y = sc.nextInt();
	for ( int i=0; i<y; ++i ) B[sc.nextInt()-1] = 1;
	int z = sc.nextInt();
	for ( int i=0; i<z; ++i ) C[sc.nextInt()-1] = 1;

	int ans = 0;
	for ( int i=0; i<n; ++i ) {
	    if ( (A[i] == 0 && C[i] == 1) || (B[i] == 1 && C[i] == 1) ) ++ans;
	}

	System.out.println( ans );
    }

    public static void main(String[] a) {new Main().solve(); }
}



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

int main() {
	int n;
	int a;

	double t=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		t += 1.0 / a;
	}
	cout << 1/t<< endl;
	
	return 0;
}

Measured memory_bytes: 256
import heapq
import sys
N = int(input())
K = list(input())
W = []
R = []
for i in range(N):
    if K[i] == "W":
        W.append(i)
    else:
        R.append(-i)

if len(W) == 0 or len(R) == 0:
    print(0)
    sys.exit()
heapq.heapify(W)
heapq.heapify(R)
c = 0
while(True):
    a = heapq.heappop(W)
    b = heapq.heappop(R)
    b *= -1
    if a > b:
        break
    heapq.heappush(W, b)
    heapq.heappush(R, -a)
    c += 1
print(c)

Measured memory_bytes: 90804
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<double,double>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////

double dist(P a,P b){return sqrt( (a.fi-b.fi)*(a.fi-b.fi) +(a.se-b.se)*(a.se-b.se) );}

void solve(){
  ini(N);   
  vp v(N); in(v);

  vi ord(N); iota(all(ord) , 0);
  double ans = 0.0;
  do{
    rep(i , N - 1) ans += dist(v[ord[i]] , v[ord[i + 1]]);
  }while( next_permutation( all(ord) ) );

  rep1(i , N) ans /= i;
  out(ans);
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) cin >> s[i];
  vector<vector<int>> trie(1, vector<int>(26, -1));
  vector<int> sz(1, 0);
  vector<int> pos(n, -1);
  vector<int> fa(1, -1);
  vector<bool> ed(1, false);
  const int kRoot = 0;
  int ptr = 1;
  for (int i = 0; i < n; ++i) {
    int x = kRoot;
    for (int j = 0; j < s[i].size(); ++j) {
      if (trie[x][s[i][j] - 'a'] == -1) {
        trie[x][s[i][j] - 'a'] = ptr++;
        trie.emplace_back(26, -1);
        fa.push_back(x);
        sz.push_back(0);
        ed.push_back(false);
      }
      x = trie[x][s[i][j] - 'a'];
      sz[x]++;
    }
    pos[i] = x;
    ed[x] = true;
  }

  constexpr int kB = 500;
  vector<int> arb(n, 0);
  vector<vector<vector<int>>> cnt(n, vector<vector<int>>(26, vector<int>(26)));

  for (int i = 0; i < n; ++i) {
    if (s[i].size() <= kB) continue;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      int a = -1, b = -1;
      for (int k = 0; k < s[i].size() && k < s[j].size(); ++k) {
        if (s[i][k] != s[j][k]) {
          a = s[j][k] - 'a';
          b = s[i][k] - 'a';
          break;
        }
      }
      if (a == -1 && b == -1) {
        if (s[i].size() > s[j].size()) arb[i]++;
      } else {
        cnt[i][a][b]++;
      }
    }
  }

  int q;
  cin >> q;
  while (q--) {
    int k;
    cin >> k;
    string p;
    cin >> p;
    k--;
    if (s[k].size() > kB) {
      int res = arb[k];
      for (int i = 0; i < p.size(); ++i) {
        for (int j = i + 1; j < p.size(); ++j) res += cnt[k][p[i] - 'a'][p[j] - 'a'];
      }
      cout << res + 1 << "\n";
    } else {
      vector<int> rnk(26);
      for (int i = 0; i < 26; ++i) rnk[p[i] - 'a'] = i;
      int res = 0;
      for (int i = s[k].size() - 1, x = pos[k]; i >= 0; --i) {
        if (ed[x]) res++;
        for (int j = 0; j < rnk[s[k][i] - 'a']; ++j) {
          if (trie[fa[x]][p[j] - 'a'] == -1) continue;
          res += sz[trie[fa[x]][p[j] - 'a']];
        }
        x = fa[x];
      }
      cout << res << "\n";
    }
  }
  return 0;
}


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

int main() {
  int A , B ; 
  cin >> A >> B ; 
  int64_t N = A*B ; 
  int64_t M = min(A,B) ; 
  int64_t L = max(A,B) ; 
  
  for(int64_t i = 1 ; i <= L ; i++){
    int64_t T = M*i ; 
    
    if( T%L == 0 ){
      cout << T << endl ; 
      return 0 ; 
    }
  }
  
  
}

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

long long int N, im[101010], l, r, A;


int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", &l, &r);
        A += r - l + 1;
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, m, l; cin >> n >> m >> l;

    vector<ll> a(m), b(m), c(m);
    vector<vector<ll>> d(n, vector<ll>(n, INF));
    REP(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        if (c[i] <= l) {
            d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
        }
    }

    ll q; cin >> q;
    vector<ll> s(q), t(q);
    REP(i, q) {
        cin >> s[i] >> t[i];
        s[i]--; t[i]--;
    }
    
    // ワーシャルフロイド
    REP(k, n) REP(i, n) REP(j, n) {
        chmin(d[i][j], d[i][k] + d[k][j]);
    }
    
    vector<vector<ll>> dp(n, vector<ll>(n, INF));
    REP(i, n) REP(j, n) if (i != j) {
        if (d[i][j] <= l) {
            dp[i][j] = 1;
        }
    }

    // ワーシャルフロイド
    REP(k, n) REP(i, n) REP(j, n) {
        chmin(dp[i][j], dp[i][k] + dp[k][j]);
    }

    REP(i, q) {
        if (dp[s[i]][t[i]] == INF) {
            cout << "-1" << endl;
        } else {
            cout << dp[s[i]][t[i]] - 1 << endl;
        }
    }

    
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
visited = {i:False for i in range(N)}
visited[0] = True
ans = 0

def DFS(x):
#  print(visited)
  global ans
  nextx = []
  if False not in visited.values():
    ans += 1
    return
  for i in range(M):
    if x in ab[i]:
      xcol = ab[i].index(x)
      if visited[ab[i][1-xcol]-1]:
        continue
      else:
        nextx.append(ab[i][1-xcol])
#  print(nextx)
  for i in nextx:
    visited[i-1] = True
    DFS(i)
    visited[i-1] = False
  return

DFS(1)
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())
S = input()
T = input()

import sys

def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)


g = gcd(N, M)
sn = N//g
sm = M//g

ok = True
for k in range(0, g):
    a = k * sn
    b = k * sm
    if S[a] != T[b]:
        ok = False
        break

if ok:
    print(N*M//g)
else:
    print(-1)

Measured memory_bytes: 3316
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, k) = i.read2::<usize, usize>();

    writeln!(o, "{}", solve(n, k)).unwrap();
}
fn solve(n: usize, k: usize) -> f64 {
    let mut ans = 0.0;
    for x in 1..n + 1 {
        let coin = if x >= k {
            0.0
        } else {
            (k as f64 / x as f64).log2().ceil()
        };
        ans += (1.0 / n as f64) / (2.0f64).powf(coin);
    }
    ans
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4476
#include <stdio.h>

int main(void) {
	// your code goes here
	int a, b, x;
	
	scanf("%d %d %d", &a, &b, &x);
	
	if(x-a>=0&&x-a<=b)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

int main() {
	in(ll, N);
	vector<ll> x(N), y(N), h(N);
	loop(i, N) {
		cin >> x[i] >> y[i] >> h[i];
	}
	auto isValid = [&](ll xc, ll yc, ll hc) {
		if (hc < 1)
			return false;
		loop(i, N) {
			if (h[i] != std::max<ll>(hc - abs(x[i] - xc) - abs(y[i] - yc), 0ll))
				return false;
		}
		return true;
	};
	ll x0 = x[0], y0 = y[0], h0 = h[0];
	loop(i, N) {
		if (h[i] != 0) {
			x0 = x[i];
			y0 = y[i];
			h0 = h[i];
			break;
		}
	}
	loop(yc, 101) {
		loop(xc, 101) {
			ll hc = abs(x0 - xc) + abs(y0 - yc) + h0;
			if (isValid(xc, yc, hc)) {
				out(xc, yc, hc);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
// Binary indexed tree supporting binary search.
 
 
#define x first
#define y second

#define forn(i, n) for(int i = 0; i < int(n); ++i)

typedef pair<int, int> pii;
//#define forn(i, a,b) for (int i = (int) a; i <= (int) b; ++i)
const int MAXN = 101;


int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int S,W;
    cin>>S>>W;
    if(W>=S){
    	cout<<"unsafe"<<endl;
	}
	else{
		cout<<"safe"<<endl;
	}
		
	

	return 0;	
}

Measured memory_bytes: 3652
import sys

def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0.0
    bunbo = 0.0
    for a in A:
        bunbo += (1.0/a)
    ans = 1 / bunbo
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int INF = 1 << 30;
int main(){
	int N;
	ll A[300][300];
	ll B[300][300];

	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			B[i][j] = INF;
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			scanf("%d", &A[i][j]);
			B[i][j] = A[i][j];
		}
	}

	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
			}
		}
	}
	bool def = true;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(B[i][j] < A[i][j]) def = false;
		}
	}

	ll ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			bool nukemichi = false;
			for(int k = 0; k < N; k++){
				if(i == k || j == k) continue;
				if(B[i][j] == B[i][k] + B[k][j]){
					nukemichi = true;
				}
			}
			if(nukemichi == false) ans += B[i][j];
		}
	}
	if(def == false) printf("-1\n");
	else printf("%lld\n", ans / 2);
	return 0;
}


Measured memory_bytes: 1664
//abc150A
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int k, x, i;
  scanf("%d %d", &k, &x);
  if(k * 500 >= x) printf("Yes");
  else printf("No");
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val mod = 1000000007L

    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!.split(' ').map { it.toInt() }
    val t = readLine()!!.split(' ').map { it.toInt() }

    val dp = Array(s.size + 1) { LongArray(t.size + 1) }

    for (i in (0 until n))
        for (j in (0 until m)) {
            val x1 = (dp[i + 1][j] + dp[i][j + 1] + mod - dp[i][j]) % mod
            val x2 = if (s[i] == t[j]) {
                dp[i][j] + 1 % mod
            } else {
                0
            }
            dp[i + 1][j + 1] = (x1 + x2) % mod
        }

    println(dp[n][m] + 1)
}


Measured memory_bytes: 90280
#include<stdio.h>



void trace(int A[],int N);
void insertsort(int A[],int N);




int main(void){

 
  
  int N,i,j;
  
  scanf("%d",&N);

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

  
  trace(A,N);
  insertsort(A,N);

    return 0;
}





void trace(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");


}





void insertsort(int A[],int N){
  int j,i,v;
  int k;
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while((j>=0)&&(A[j]>v)){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}



Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdlib>

typedef long long ll;

int main() {
    ll a, b, k;
    std::cin >> a >> b >> k;
    for(int i = 1; i <= k; ++i) {
        if(i & 1) {
            b += a / 2;
            a /= 2;
        } else {
            a += b / 2;
            b /= 2;
        }
    }
    std::cout << a << ' ' << b << '\n';
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
A = [[] for i in range(N)]

for i in range(N):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        A[i].append((x - 1, y))

for i in range(N):
    B = itertools.combinations(range(N), i)
    for b in B:
        state = [1] * N
        for bb in b:
            state[bb] = 0
        flag = True
        for j in range(N):
            if j in b:
                continue
            for (x, y) in A[j]:
                if state[x] != y:
                    flag = False
        if flag:
            print(N - i)
            exit()
print(0)


Measured memory_bytes: 3064
#include<stdio.h>

void insertionSort(int*, int[]);

int main(){
  int i,j,n,v,k;
  int a[1000];

  insertionSort(&n,a);

  for(k = 0; k < n; k++){
    if(k == n - 1)  printf("%d",a[k]);
    else printf("%d ",a[k]);
  }
  printf("\n");

  for(i = 1; i <= n - 1; i++){
    v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
   for(k = 0; k < n; k++){
     if(k == n - 1)  printf("%d",a[k]);
     else printf("%d ",a[k]);
       }
       printf("\n");
  }
  
  return 0;
}

void insertionSort(int *n, int a[]){
  scanf("%d",n);
  for(int i = 0; i < *n; i++){
    scanf("%d",&a[i]);
  }
}



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

int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = min(n%k, abs(n%k - k));
  cout << ans << endl;
}


Measured memory_bytes: 3608