akhauriyash/Code-Regression huggingface dataset:
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  2e6+5;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, a[N], basis[64];
string s;

bool check(ll x){
	for(int j = 0; j < 60; j++){
		if(((1ll<<j)&x) == 0) continue;
		if(!basis[j]) return false;
		x ^= basis[j];
	}
	return true;
}

void insert(ll x){
	for(int j = 0; j < 60; j++){
		if(((1ll<<j)&x) == 0) continue;
		if(basis[j]) x ^= basis[j];
		else{
			basis[j] = x;
			break;
		}
	}
}

void solve(){
	for(int i = 0; i < 60; i++) basis[i] = 0;
	cin>>n;
	for(int i = 1; i <= n; i++) cin>>a[i];
	cin>>s; s = '0'+s;
	for(int i = n; i >= 0; i--){
		if(s[i] == '0') insert(a[i]);
		else if(!check(a[i])){ deb1(1) return; }
	}
	deb1(0)
}

int main(){
	GODSPEED;
	cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 3560
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, A = MAP()

print(ceil(H, A))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 112345;
bool dp[MAXN];
int v[111];
int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    for (int i = 1; i<=n; ++i) {
        scanf("%d", v+i);
    }

    for (int i = 1; i<=k; ++i) {
        for (int j = 1; j<=n; ++j) {
            if (v[j] > i) break;
            dp[i] |= !dp[i-v[j]];
        }
    }
    puts(dp[k] ? "First" : "Second");
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int x1 = sc.nextInt();
    int x2=  sc.nextInt();
    int Nums[]=new int[10];
    for(int i=0;i<10;i++){
      	if(i==0){
    	Nums[i]=r*x2-x1;
        }else{
          Nums[i]=r*Nums[i-1]-x1;
        }
    }
    for(int i=0;i<10;i++){
    System.out.println(Nums[i]);
    }
  }
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,ans = 0,i,x;
    cin >> n;
    rep(i,1, n + 1){
        cin >> x;
        if(i&1 && x&1)ans++;
    }  
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

//-----------------------------------------------------------------------------

ll a, b, c, k;

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

	cin >> a >> b >> c >> k;
	ll ans = a - b;
	if (k & 1) ans *= -1;
	
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
 
 
 int dp[3100][3100][2];
 
int main()
{
	string s,t;
	int m,n;
	cin>>s>>t;
	m=s.size();
	n=t.size();
 
	//last [2] here 0 stores value and 1 will store from the valve came
	//1 if it came from diagonal 
	//2 if it came from row
	//3 if it came from column
	//when row and column are same and add 2
	//we may store the the cordinates from where it came by using pair in vector
	int i,j;
	
	for(i=0;i<=m;i++)
		dp[i][0][0]=0;
 
	for(i=0;i<=n;i++)
		dp[0][i][0]=0;	
	
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j][0]=dp[i-1][j-1][0]+1;
				dp[i][j][1]=1;
			}
			else
			{
				dp[i][j][0]=max(dp[i-1][j][0] , dp[i][j-1][0]);
				if(dp[i-1][j][0] > dp[i][j-1][0])
					dp[i][j][1]=3;
				else
					dp[i][j][1]=2;
			}
		}
	}
	int len=dp[m][n][0];
	char ans[len+1];
 
 
 
	j=n;
    for(i=m;i>0;)
    {
    	for(;j>0;)
    	{
    		if(dp[i][j][1]==1)
    		{
    			ans[len--]=t[j-1];
    			i--;
    			j--;
    		}
    		else if(dp[i][j][1]==2)
    		{
    			j--;
    		}
    		else
    		{
    			i--;
    		}
          if(i <= 0) break;
    	}
    	if(j<=0)
    		break;
    }
    
    len=dp[m][n][0];
    for(i=1;i<=len;i++)
    	cout<<ans[i];
 
 
	return 0;
}

Measured memory_bytes: 73984
n=int(input())
a=[]
ans=0
for _ in range(n):
    a.append(int(input()))

for i in range(n-1):
    if a[i]==a[i+1]:
        ans+=a[i]
        a[i],a[i+1]=0,0
    elif a[i]>a[i+1]:
        if a[i]%2==0:
            ans+=a[i]//2
            a[i]=0
        else:
            ans+=(a[i]-1)//2
            a[i]=1
        if a[i]<a[i+1]:
            ans+=a[i]
            a[i+1]-=a[i]
            a[i]=0
    elif a[i]<a[i+1]:
        ans+=a[i]
        a[i+1]-=a[i]
        a[i]=0
if a[-1]%2==0:
    ans+=a[-1]//2
else:
    ans+=(a[-1]-1)//2

print(ans)

Measured memory_bytes: 80428
#include<bits/stdc++.h>
using namespace std;
typedef long long Long;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool vive = 1;
  while(vive){
    c -= b;
    if(c <=0){
      vive = 0;
      cout << "Yes";
      return 0;
    }
    a -= d;
    if(a <=0){
      vive = 0;
      cout << "No";
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(); // Aの枚数
        long b = sc.nextLong(); // Bの枚数
        long k = sc.nextLong(); // 使用回数
        // k <= aの場合
        // Aを使い切る前に使用回数が尽きる。
        // Aの残りは(a-k)枚、Bの残りはb枚のまま
        if (k <= a) {
            System.out.println(String.format("%s %s", a - k, b));
        }
        // a < k <= (a+b)の場合
        // まずAは全て使い切るため残り0枚
        // 残る使用回数は(k-a)回なので、Bの残り枚数はb-(k-a)枚
        if ((a < k) && (k <= (a + b))) {
            System.out.println(String.format("%s %s", 0, b - (k - a)));
        }
        // (a+b) < kの場合
        // AとBを全て使い切っても使用回数が残る。AもBも残り0枚
        if ((a + b) < k) {
            System.out.println(String.format("%s %s", 0, 0));
        }
        sc.close();
    }
}


Measured memory_bytes: 35812
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    cin >> H >> W;
    vector<vector<int>>c(10,vector<int>(10,INF));
    rep(i,10)rep(j,10)cin >> c[i][j];
    rep(k,10)rep(i,10)rep(j,10)cmin(c[i][j],c[i][k]+c[k][j]);
    vector<vector<int>>g(H,vector<int>(W,0));
    rep(i,H)rep(j,W)cin>>g[i][j];
    int ans = 0;
    rep(i,H)rep(j,W){
        int e = g[i][j];
        if(e == -1 or e == 1)continue;
        ans += c[e][1];
    }
    cout << ans << endl;
}




Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

/**
 * Returns the least index of elements that are modified, wrapped with Some.
 * If the entire array is reversed, it returns None instead.
 * v's elements must be pairwise distinct.
 */
fn next_permutation<T: Ord>(v: &mut [T]) -> Option<usize> {
    let mut tail_dec: usize = 1;
    let n = v.len();
    while tail_dec < n {
        if v[n - tail_dec - 1] > v[n - tail_dec] {
            tail_dec += 1;
        } else {
            break;
        }
    }
    // v[n - tail_dec .. n] is strictly decreasing
    if tail_dec < n {
        let x = n - tail_dec - 1;
        let mut y = n;
        {
            let pivot = &v[x];
            for i in (n - tail_dec .. n).rev() {
                if v[i] > *pivot {
                    y = i;
                    break;
                }
            }
            assert!(y < n);
        }
        v.swap(x, y);
    }
    v[n - tail_dec .. n].reverse();
    if tail_dec < n {
        Some(n - tail_dec - 1)
    } else {
        None
    }
}


fn main() {
    let n = get();
    let m = get();
    let mut tbl = vec![vec![0; n]; n];
    for _ in 0 .. m {
        let a: usize = get();
        let b: usize = get();
        tbl[a - 1][b - 1] = 1;
        tbl[b - 1][a - 1] = 1;
    }
    let mut p = vec![0; n];
    for i in 0 .. n {
        p[i] = i;
    }
    let mut cnt: i32 = 0;
    loop {
        // check
        let mut ok = true;
        for i in 0 .. (n - 1) {
            if 0 == tbl[p[i]][p[i + 1]] {
                ok = false;
            }
        }
        if ok {
            cnt += 1;
        }
        if next_permutation(&mut p[1 .. n]) == None {
            break;
        }
    }
    println!("{}", cnt);
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

void trace(int A[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertionSort(int A[], int N) {
  int j, i, v;
  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);
  }
}

int main()
{
  int N, i, j;
  int A[100];
  cin >> N;
  for (i = 0; i < N; i++) cin >> A[i];
  trace(A, N);
  insertionSort(A, N);

  return 0;
}



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

int main()
{
    int x, y;
    while(true)
    {
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        else if (x <= y)
            cout << x << " " << y << endl;
        else if (x > y)
            cout << y << " " << x << endl;
    }

    return 0;
}



Measured memory_bytes: 2980
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    s,t=['']*N,[0]*N
    for i in range(N):
        s[i],t[i]=input().split()
        t[i]=int(t[i])
    S=input()
    print(sum(t[s.index(S)+1:]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<cstdio>
int main() {
	int n, a[100], min=1000000000, tmp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = -100; i <= 100; i++) {
		tmp = 0;
		for (int j = 0; j < n; j++) {
			tmp += (a[j] - i)*(a[j] - i);
		}
		if (min > tmp) {
			min = tmp;
		}
	}
	printf("%d", min);
	return 0;
}

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

#define IOS cin.tie(0);ios::sync_with_stdio(0)

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail>
void OUT(Head&& head,Tail&&...tail){
    cout<<head<<(sizeof...(tail)?' ':'\n');
    OUT(move(tail)...);
}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

void print(){}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

int split_sum(int i){
    string s=to_string(i);
    int sum=0;
    for(auto item:s){
        sum+=item-'0';
    }
    return sum;
}

int main(){
    IOS;
    CIN(N);
    int n=split_sum(N);
    if(N%n==0) flag=true;
    else flag=false;
    Yes(flag);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,A[2000];
/*判定*/
int solve(int,int);

int main(){
  int q,mi[2000],i;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&mi[i]);}
  for(i=0;i<q;i++){
    /*一致と不一致の場合*/
    if(solve(0,mi[i]))printf("yes\n");
    else printf("no\n");
  }
  return 0;}
 int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;}




Measured memory_bytes: 2704
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int h, w, n; cin >> h >> w >> n;
    double ret = (double)n / max(h, w);

    if (ret == (int)ret) {
        cout << ret << endl;
    }
    else {
        cout << (int)(ret+1.0) << endl;
    }
    return 0;
}



Measured memory_bytes: 888
A,B = map(str, input().split())
A = int(A)
period_index = B.index(".")
B_after_the_decimal = int(B[period_index+1:])
B_before_the_decimal = int(B[0:period_index])

include_decimal = str(int(A*B_after_the_decimal))
include_decimal = include_decimal[:len(include_decimal)-(len(B) - period_index -1)]

if include_decimal != "":
    include_decimal = int(include_decimal)
    ans = include_decimal + A*B_before_the_decimal
else:
    ans = A*B_before_the_decimal
    
print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    string s, t; cin >> s >> t;
    int n = s.length();

    int start = -1;
    for (int i = 0; i < n; i++) {
        if (s[i] == t[0]) {
            start = i;
            break;
        } 
    }
    
    if(start == -1) {
        cout << "No" << endl;
        return 0;
    } 

    for (int i = 0; i < n; i++) {
        if(s[(start+i) % n] != t[i]) {
            cout << "No" << endl;
            return 0;
        } 
    }

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


Measured memory_bytes: 256
use List::Util qw(max);
my %s;
my $N = <STDIN>;
foreach my $i (0..$N-1) {
        my $str = <STDIN>;
        chomp($str);
        $s{$str} = 0 if (!exists($s{$str}));
        $s{$str}++;
}
my $M = <STDIN>;
foreach my $i (0..$M-1) {
        my $str = <STDIN>;
        chomp($str);
        $s{$str} = 0 if (!exists($s{$str}));
        $s{$str}--;
}
print max (values %s, 0);

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

int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0){
      cout<<1<<endl;
  }
  if(b==0){
      cout<<2<<endl;
  }
  if(c==0){
      cout<<3<<endl;
  }
  if(d==0){
      cout<<4<<endl;
  }
  if(e==0){
      cout<<5<<endl;
  }
}
  

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

int main()
{
  int N;
  cin >> N;
  int A;
  int a = 0;
  int max = 0;
  for(int i = 0; i < N; i++){
      cin >> A;
      if(A == 0) a = 0;
      if(A == 1){
          a += 1;
          if(a > max) max = a;
      }
  }
  cout << max + 1 << endl;
      
}



Measured memory_bytes: 3092
#include<stdio.h>
int x[1024],y[1024];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
	}
	int tp=((x[0]+y[0])&1);
	tp^=1;
	for(int i=0;i<n;i++)
	{
		x[i]-=tp;
		if(((x[i]+y[i])&1)==0)
		{
			printf("-1\n");
			return 0;
		}
	}
	if(tp)
	{
		printf("36\n1 ");
	}
	else
	{
		printf("35\n");
	}
	for(int i=0;i<35;i++)
	{
		printf("%lld",(long long)1<<i);
		if(i==34)
		{
			putchar('\n');
		}
		else
		{
			putchar(' ');
		}
	}
	for(int i=0;i<n;i++)
	{
		if(tp)
		{
			putchar('R');
		}
		long long dx=x[i]-((long long)1<<35)+1;
		long long dy=y[i];
		dx=-dx;
		long long u=((dx+dy)>>1);
		long long d=((dx-dy)>>1);
		for(int j=0;j<35;j++)
		{
			if((u&((long long)1<<j))&&(d&((long long)1<<j)))
			{
				putchar('L');
			}
			else if(u&((long long)1<<j))
			{
				putchar('U');
			}
			else if(d&((long long)1<<j))
			{
				putchar('D');
			}
			else
			{
				putchar('R');
			}
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
const int J=100005;
struct pp{
  char name[110];
  int t;
};
 struct pailie{
   pp a[J];
   int head,tail;
 bool isfull(){
   if((tail+1)%J==head)return 1;
   return 0;
 }
 bool isempty(){
  if(head==tail) return 1;
  return 0;
 }
  void push(pp x){
    if(!isfull()){
      a[tail%J]=x;
      tail++;
    }
  }
pp pop(){
    if(!isempty()){
      pp m=a[head%J];
       head++;
       return m;
    }
  }
 }q;
int main(){
    int n,m;
    pp p;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
    scanf("%s%d",p.name,&p.t);
    q.push(p);
    }
    int mn=0;
   while(!q.isempty()){
    pp p1;
    p1=q.pop();
    if(p1.t<=m){
       mn+=p1.t;
        printf("%s %d\n",p1.name,mn);
    }
    else {
       mn+=m;
       p1.t-=m;
       q.push(p1);

    }

   }
	return 0;
}

Measured memory_bytes: 14016
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        String s = "abacacaacaca";
        if (s.substring(x-1, x).equals(s.substring(y-1,y))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 23252
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>

int main(int argc, char **argv){
    unsigned long long int n, W, w0, w, v, ans, tmp;
    std::vector<int> ws[4];
    scanf("%lld %lld", &n, &W);
    scanf("%lld %lld", &w0, &v);
    ws[0].push_back(v);
    for(int i = 1; i<n; i++){
        scanf("%lld %lld", &w, &v);
        ws[w-w0].push_back(v);
    }
    for(int i = 0; i<4; i++){
        std::sort(ws[i].begin(), ws[i].end());
    }
    ans = 0;
    for(int a = 0; a <= ws[0].size(); a++){
        for(int b = 0; b <= ws[1].size(); b++){
            for(int c = 0; c <= ws[2].size(); c++){
                for(int d = 0; d <= ws[3].size(); d++){
                    if(w0*(a+b+c+d)+b+2*c+3*d <= W){
                        tmp = std::accumulate(ws[0].begin()+ws[0].size()-a, ws[0].end(), 0);
                        tmp += std::accumulate(ws[1].begin()+ws[1].size()-b, ws[1].end(), 0);
                        tmp += std::accumulate(ws[2].begin()+ws[2].size()-c, ws[2].end(), 0);
                        tmp += std::accumulate(ws[3].begin()+ws[3].size()-d, ws[3].end(), 0);
                        if(tmp>ans) ans = tmp;
                    }
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
    int r;
    cin >> r;
    double ans = 2 * r * 3.14159;
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    SegmentTree<int> seg(f, def) のように宣言する
    RMQの場合 : 
    auto f = [](int a, int b){return min(a, b);};
    def = INF;
*/
template <typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;
    int n;
    vector<Monoid> dat;
    F f;
    Monoid def; //初期値かつ単位元

    SegmentTree(F f, Monoid def) : f(f), def(def) {}

    void build(const vector<Monoid> & vec){ //元配列vecをセグメントツリーで表現する
        int siz = vec.size();
        n = 1;
        while (n < siz) n *= 2;
        dat.resize(2 * n - 1, def);
        for (int i = 0; i < siz; i++) dat[i + n - 1] = vec[i]; //最下段に値をいれる
        for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]); //下の段から順番に値をいれる
    }

    void update(int k, Monoid x){
        k += (n - 1); //最下段のノードにアクセスする
        dat[k] = x; //最下段のノードを更新したら、下の段から順番に値をいれる
        while (k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    //[a, b)の区間クエリを実行
    Monoid query(int a, int b){
        return query(a, b, 0, 0, n);
    }

private:
    Monoid query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l) return def; //要求区間と対象区間が交わらなければ、def
        if (a <= l && r <= b) return dat[k]; //要求区間が対象区間を完全に含んでいれば、対象区間を答えの計算に使う
        //要求区間が対象区間の一部を含んでいれば、
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

signed main(){
    int n;
    cin >> n;
    vector<P> vec(n);
    REP(i,n){
        cin >> vec[i].second >> vec[i].first;
    }
    sort(ALL(vec));
    vector<ll> vec1(n), vec2(n);
    REP(i,n){
        vec1[i] = vec[i].first;
        vec2[i] = vec[i].second;
    }
    auto f1 = [](ll a, ll b){return min(a, b);};
    auto f2 = [](ll a, ll b){return max(a, b);};
    SegmentTree<ll> seg1(f1, LINF);
    SegmentTree<ll> seg2(f2, (ll)0);
    seg1.build(vec1);
    seg2.build(vec2);
    ll ans = 0;
    REP(i,n - 1){
        ll sum = 0;
        sum += max((ll)0, seg1.query(0, i + 1) - seg2.query(0, i + 1) + 1);
        sum += max((ll)0, seg1.query(i + 1, n) - seg2.query(i + 1, n) + 1);
        ans = max(ans, sum);
    }
    REP(i,n){
        ll sum = 0;
        sum += vec[i].first - vec[i].second + 1;
        sum += max((ll)0, seg1.query(0, n) - seg2.query(0, n) + 1);
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7424
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  long long a[n+1],sum=0,ans=0;
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    sum+=a[i];
  }
  for(i=0;i<n;i++){
    long long temp;
    sum-=a[i];
    temp=a[i]*(sum%1000000007)%1000000007;
    ans+=temp;
  }
  ans%=1000000007;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int t,a;
  cin>>t;
  if(t>=0 && t<10)
  {
    if(t==2 || t==4 ||t==5 || t==7 || t==9)
    {
      cout<<"hon"<<endl;
    }
    else if(t==0 || t==1 ||t==6 || t==8)
    {
      cout<<"pon"<<endl;
    }
    else if(t==3)
    {
      cout<<"bon"<<endl;
    }
  }
  else if(t>=10 &&t<=999)
  {
    a = t% 10;
    if(a==2 || a==4 ||a==5 || a==7 || a==9)
    {
      cout<<"hon"<<endl;
    }
    else if(a==0 || a==1 ||a==6 || a==8)
    {
      cout<<"pon"<<endl;
    }
    else if(a==3)
    {
      cout<<"bon"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#define l(s) s.length()
#define sort(v) sort(v.begin(), v.end());
#define scan(v,n) rep(i,0,n) {ll k; cin >> k; v.pb(k);}
#define print(v,n) {rep(i,0,n) cout << v[i] << " "; cout << endl;}
#define printstr(s,n) {rep(i,0,n) cout << s[i]; cout << endl;}
#define rev(a) reverse(a.begin(), a.end());
#define pb push_back
typedef long long ll;
typedef long double lld;
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
 
const ll mxN=3e3;
const ll N=1e9+7;
 
ll dp[mxN+1][mxN+1];

//deque
//dp[i][j][2] is the score of each player when the remaining array is from index i to j
// dp[0][n-1]=0
//rep(i,1,n+1) cout max of dp[i][i-1][1]



  int main() {
      int T=1;// cin >> T;
      while(T--){
          ll n; cin >> n;
          vi v; scan(v,n);
          rep(i,0,n) dp[i][i]=v[i];
          rrep(l,n-2,0) {
              rep(r,l+1,n) {
                  dp[l][r]=(v[l]-dp[l+1][r]>v[r]-dp[l][r-1]?v[l]-dp[l+1][r]:v[r]-dp[l][r-1]);
              }
          }
          cout << dp[0][n-1];
      } 
	 return 0;
}


Measured memory_bytes: 49704
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * a + 2 * b;
        System.out.println(area+" "+length);
        sc.close();
    }
}


Measured memory_bytes: 25920
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<Int> a(h),b(w);
  for(Int i=0;i<h;i++) cin>>a[i];
  for(Int i=0;i<w;i++) cin>>b[i];

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<h;i++)
    vp.emplace_back(a[i],i);
  for(Int i=0;i<w;i++)
    vp.emplace_back(b[i],h+i);

  sort(vp.begin(),vp.end());
  Int ans=0;
  Int s=h,t=w;
  for(Int i=0;i<h+w;i++){
    if(vp[i].second<h){
      ans+=vp[i].first*t;
      s--;
    }else{
      ans+=vp[i].first*s;
      t--;
    }
  }

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



Measured memory_bytes: 8588
line = input().split(" ")

a = int(line[0])
b = int(line[1])
k = int(line[2])

takahashi = 0
aoki = 0

if k <= a:
  takahashi = a - k
  aoki = b
elif k <= a + b:
  aoki = a + b - k

print(str(takahashi) + " " + str(aoki))
    


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] A = new long[N];

        for(int i=0;i<N;i++){
            A[i] = sc.nextLong();
        }

        for(int i=K;i<N;i++){
                if(A[i] > A[i-K]){
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
        }






    }

}




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

using namespace std;

int si = 0, sj = 0;
vector<int> isp;

pair<int, int> toij(int p) {
    int u = 1;
    while (u * u < p)
        ++u;

    if (u % 2 == 0) {
        int ui = si - u / 2;
        int uj = sj - u / 2 + 1;
        if (u * (u - 1) < p) {
            return make_pair(ui, uj + (u * u - p));
        }
        else {
            return make_pair(ui + (u * (u - 1) - p) + 1, uj + u - 1);
        }
    }
    else {
        int ui = si + u / 2;
        int uj = sj + u / 2;
        if (u * (u - 1) < p) {
            return make_pair(ui, uj - (u * u - p));
        }
        else {
            return make_pair(ui - (u * (u - 1) - p) - 1, uj - u + 1);
        }
    }
}
int tov(int pi, int pj) {
    int dma = max(abs(pi - si), abs(pj - sj));
    int u = dma * 2;
    if (pi == si + dma) {
        return (u + 1) * (u + 1) - (sj + dma - pj);
    }
    if (pj == sj - dma) {
        return u * u + (pi - (si - dma) + 1);
    }
    if (pi == si - dma) {
        return u * u - (pj - (sj - dma + 1));
    }
    if (pj == sj + dma) {
        return u * (u - 1) + ((si - dma + 1) - pi);
    }

}
void sieve(int n) {
    isp.resize(n, 1);
    isp[1] = 0;
    for (int i = 2; i * i < n; ++i)
    {
        if (!isp[i]) continue;

        for (int j = i * i; j < n; j += i)
        {
            isp[j] = 0;
        }
    }
}

int main()
{
    sieve(1000010);
    while (true)
    {
        int m, n;
        cin >> m >> n;
        if (!m) return 0;

        vector<int> ma(m + 1, -1);
        vector<int> lp(m + 1);
        queue<int> q;
        q.push(n);
        ma[n] = isp[n];
        lp[n] = isp[n] ? n : 0;
        int ansi = 0, ansj = 0;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            auto p = toij(v);
            int pi = p.first, pj = p.second;
            int next = 0;
            for (int j = pj - 1; j <= pj + 1; ++j) {
                int nv = tov(pi + 1, j);
                if (nv > m) continue;

                next = 1;
                if (ma[nv] < 0)
                    q.push(nv);

                if (ma[nv] < ma[v] + isp[nv]) {
                    ma[nv] = ma[v] + isp[nv];
                    lp[nv] = isp[nv] ? nv : lp[v];
                }
                else if (ma[nv] == ma[v] + isp[nv]) {
                    lp[nv] = max(lp[nv], isp[nv] ? nv : lp[v]);
                }
            }
            if (!next) {
                if (ansi < ma[v]) {
                    ansi = ma[v];
                    ansj = lp[v];
                }
                else if (ansi == ma[v] && ansj < lp[v]) {
                    ansj = lp[v];
                }
            }
        }
        cout << ansi << " " << ansj << "\n";
    }
    return 0;
}

Measured memory_bytes: 14352
#include<stdio.h>
#define true 1
#define false 2
int solve(int,int);
int n,A[2000];
int main(){
    int i,q,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    int m[q];
    for(i=0;i<q;i++){
        scanf("%d",&m[i]);
    }
    i=0;
    for(j=0;j<q;j++){
        if(solve(i,m[j])==true) printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}

int solve(int i,int m){
    int res1,res2;
    if(m==0) return true;
    if(i>=n) return false;
    res1=solve(i+1,m);
    res2=solve(i+1,m-A[i]);
    if(res1==true || res2==true) return true;
    else return false;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S;
    cin >> S;
    int cnt[3] = {0,0,0};
    rep(i, S.size()) {
        cnt[S[i]-'a']++;
    }

    YES(
        abs(cnt[0] - cnt[1]) <= 1
     && abs(cnt[1] - cnt[2]) <= 1
     && abs(cnt[2] - cnt[0]) <= 1
    );
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[][][] rooms = new int[4][3][10];
		for(int i=0;i<n;i++){
			rooms[scan.nextInt()-1][scan.nextInt()-1][scan.nextInt()-1] += scan.nextInt();
		}
		for(int i=0; i<4; i++){
			for(int j=0;j<3;j++){
				for(int k=0; k<10; k++){
					System.out.print(" "+rooms[i][j][k]);
				}
				System.out.println();
			}
                        if(i==3) break;
			for(int l=0; l<20; l++) System.out.print("#");
			System.out.println();
		}
	}
}

Measured memory_bytes: 21068
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair


int main()
{
	int n,h,w,u,v,cnt;
	
	cnt=0;
	
	cin>>n>>h>>w;
	
	for(int i=0;i<n;i++)
	{
		cin>>u>>v;
		if(u>=h && v>=w)
		{
			cnt++;
		}
	}
	
	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split(" "))

d1 = x2 - x1
d2 = y2 - y1

x3,y3 = x2-d2,y2+d1
x4,y4 = x1-d2,y1+d1

print(x3,y3,x4,y4)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 2000005;
const int MOD = 998244353 ;




void solve(){
    int x, n, ans = 0, c1 = LLONG_MAX, c2 = LLONG_MAX, f1, f2;
    cin>>x>>n;
    int a[n+5], b[500] = {0};
    f(i,n){
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i = x; i <= 101; i++){
        if(b[i] == 0){
            c1 = abs(i-x);
            f1 = i;
            break;
        }
    }
    for(int i = x; i >= 0; i--){
        if(b[i] == 0){
            c2 = abs(i-x);
            f2 = i;
            break;
        }
    }
    if(c1 < c2){
        ans = f1;
    }
    else ans = f2;
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3640
def actual(n, V, C):
    # 購入するとプラスになるものだけ買って合計でおk
    sale_jewels = []

    for v, c in zip(V, C):
        if v - c > 0:
            sale_jewels.append(v - c)

    return sum(sale_jewels)

    # return sum([v - c for v, c in zip(V, C) if v - c > 0])


n = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

print(actual(n, V, C))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	}

}


Measured memory_bytes: 68456
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

type Town struct {
	Index int
	X     int
	Y     int
}

func Distance(t1, t2 Town) float64 {
	return math.Sqrt(float64((t1.X-t2.X)*(t1.X-t2.X) + (t1.Y-t2.Y)*(t1.Y-t2.Y)))
}

func nextPerm(arr []Town) func() []Town {
	/*
		how to use it:
			this is a generator, so should be invoked such as below example.
			"""code"""
			np := nextPermutation(arr)
			for{
				lis := np()
				if len(lis) == 0{
					break
				}
				fmt.Println(lis)
			}
			"""code end"""
	*/
	first := true
	ret := append([]Town{}, arr...)
	_nextPerm := func() []Town {
		if first {
			first = false
			return arr
		}
		n := len(ret)
		for i := n - 2; i >= 0; i-- {
			if ret[i].Index < ret[i+1].Index {
				j := n
				for {
					j--
					if ret[i].Index < ret[j].Index {
						break
					}
				}
				ret[i], ret[j] = ret[j], ret[i]
				for k := n - 1; i < k; i, k = i+1, k-1 {
					ret[i+1], ret[k] = ret[k], ret[i+1]
				}
				return ret
			}
		}
		return []Town{}
	}
	return _nextPerm
}

func main() {
	n := nextInt()
	ts := make([]Town, n)

	for i := 0; i < n; i++ {
		ts[i] = Town{i, nextInt(), nextInt()}
	}

	sum, count := 0.0, 0.0
	np := nextPerm(ts)
	for {
		l := np()
		if len(l) == 0 {
			break
		}

		count += 1.0
		for i := 0; i < n-1; i++ {
			sum += Distance(l[i], l[i+1])
		}
	}

	fmt.Println(sum / count)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> light(m);
    for(int i=0;i<m;++i) {
        int k;
        cin >> k;
        for(int j=0;j<k;++j) {
            light[i].resize(k); //kore!!!!
            cin >> light[i][j];
            --light[i][j];
        }
    }
    
    vector<int> p(m);
    for(int i=0;i<m;++i) cin >> p[i];

    // bit全探索
    // (1<<n) = 2^n
    // 今回はmax10なので1024回るーぷ
    int ans = 0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        // 電球m回(max 10)ループ
        bool flag = true;
        for (int i=0; i<m; i++) {
            int count = 0;
            for (int j = 0; j < (int)light[i].size(); ++j) {
                // onの時
                if((bit >> light[i][j]) & 1) {
                    ++count;
                }
            }
            if(count % 2 != p[i]) {
                flag = false;
                continue;
            }
        }
        if(flag) ans++;
    }

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

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  double A[110][110];
  double B[110][110];
  double C[110][110];
  int a,b,c,i,j,k;
 scanf("%d %d %d",&a,&b,&c);
  
  for(i=0;i<a;i++){
  	for(j=0;j<b;j++){
    	scanf("%lf ",&A[i][j]);
    }
    
  }
  
  for(i=0;i<b;i++){
  	for(j=0;j<c;j++){
    	scanf("%lf ",&B[i][j]);
    }
  }
  
  for(i=0;i<a;i++){
  	for(k=0;k<b;k++){
      for(j=0;j<c;j++){
      	C[i][j]+=A[i][k]*B[k][j];
      }
    }
  }
  
  for(i=0;i<a;i++){
  	for(j=0;j<c;j++){
    	if(j != c-1)printf("%.0f ",C[i][j]);
        else printf("%.0f",C[i][j]);
    }
    printf("\n");
  }
  
  return 0;
  
  
  
}


Measured memory_bytes: 2112
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

typedef long long LL;
LL n, m;

int main() {
	scanf("%lld%lld", &n, &m);
	if(n == 1ll && m == 1ll) {puts("1"); return 0;}
	if(n == 1ll) {printf("%lld\n", m-2); return 0;}
	if(m == 1ll) {printf("%lld\n", n-2); return 0;}
	printf("%lld\n", (n-2ll) * (m-2ll));
	return 0;
}

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

int A, B;
int ans = 0;

void arrayofdigits(int i, int n[5]) {
    for(int j = 0; j < 5; j++) {
        n[j] = i % 10;
        i /= 10;
    }
}


int main() {
    cin >> A >> B;
    
    for (int i = A; i <= B; i++) {
        int n[5];
        arrayofdigits(i, n);
        if (n[0] == n[4] && n[1] == n[3]) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>

int main() {
	int w, n;
	std::cin >> w >> n;

	std::vector<int> state(w);
	for (int i = 0; i < w; ++i)
		state[i] = i + 1;

	for (int i = 0; i < n; ++i) {
		int a, b;
		std::scanf("%d,%d", &a, &b);

		std::swap(state[a - 1], state[b - 1]);
	}

	for (auto&& v : state)
		std::cout << v << std::endl;
}

Measured memory_bytes: 3128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGoldenApple solver = new BGoldenApple();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGoldenApple {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), d = s.nextInt(), a = 1, cur = (d << 1) + 1;
            while (cur < n) {
                a++;
                cur += (d << 1) + 1;
            }
            w.println(a);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;
typedef long long ll;

int main(){
	ll n; cin >> n;
	ll min_num = 1001001001001001;
	for(int i = 0; i < 5; i++){
		ll tmp; cin >> tmp;
		min_num = min(tmp, min_num);
	}

	ll ans = (n + (min_num - 1)) / min_num;

	cout << ans + 4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
        ll N;
        cin >> N;
        vector<ll> A(N, 0);
        bool zero = false;
        double dans = 1.0;
        for (int i = 0; i < N; ++i) {
                cin >> A[i];
                if (A[i] == 0) zero = true;
                dans *= (double)A[i];
        }
        if (zero) {
                cout << 0 << endl;
                exit(0);
        }
        double dj = pow(10.0, 18);
//      cout << "dans = " << dans << endl;
//      cout << "dj = " << dj << endl;
        if (dans > dj) {
                cout << -1 << endl;
                exit(0);
        }

        ll ans = 1;
        ll j = pow(10, 18);
        for (int i = 0; i < N; ++i) {
                ans *= A[i];
                if (ans > j) {
                        cout << -1 << endl;
                        exit(0);
                }
        }
        if (ans > j) {
                cout << -1 << endl;
        }
        else
        cout << ans << endl;


}


Measured memory_bytes: 4336