akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	int a[5],m=10,s,sum=0;
	for (int i = 0; i < 5;i++) cin >> a[i];
	for (int i = 0; i < 5; i++) {
		s = a[i] % 10;
		if(s!=0) m = min(m, s);
	}
	for (int i = 0; i < 5; i++) {
		if (a[i] % 10 == 0) sum += a[i];
		else sum+= (a[i] / 10 + 1) * 10;
	}
	cout << sum + m - 10 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if (x-r>=0 && y-r>=0 && x+r<=w && y+r <= h)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}


Measured memory_bytes: 3108
import numpy as np

def chk(i,S):
    pass
    

S=input()
S+="R"
S="L"+S
x=[0]*len(S)
i=0
befRLi=0
befLRi=-1
while True:
   # print(i)
    if i==len(S):

        break
    if S[i:(i+2)]=="RL":        
        n=i-befLRi
        x[i]+=np.ceil(n/2)
        x[i+1]+=np.floor(n/2)

        befRLi=i  
        i+=1
        
    else:
        if S[i:(i+2)]=="LR":            
            n=i-befRLi
            x[befRLi+1]+=np.ceil(n/2)
            x[befRLi]+=np.floor(n/2)
            befLRi=i
        i+=1


print(" ".join(map(lambda x:str(int(x)),x[1:-1])))


Measured memory_bytes: 23240
K = int(input())
A, B = map(int, input().split())

q1, mod1 = divmod(A, K)
q2, mod2 = divmod(B, K)

if mod1 == 0:
    print("OK")
elif mod2 == 0:
    print("OK")
elif A + K - mod1 <= B:
    print("OK")
else:
    print("NG")


Measured memory_bytes: 61704
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn calc(n: u64) -> u64 {
    let mut digit = 27u32;
    let mut buf = 0;
    let mut sum = 0;
    while digit > 0 {
        let m = n / 5u64.pow(digit) / 2;
        // println!("{}, {}, {}", digit, m, buf);
        // println!("{}", (m - buf) * digit as u64);
        sum += (m - buf) * digit as u64;
        buf = m;
        digit -= 1;
    }
    sum
}

fn main() {
    let n: u64 = input();
    if n % 2 == 1 {
        println!("0");
    } else {
        println!("{}", calc(n));
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h> 
using namespace std;
  
void cyclicSwap(int* a, int* b, int* c) 
{ 
    int temp = *b; 
    *b = *a; 
    *a = *c; 
    *c = temp; 
} 
  
int main() 
{ 
    int a ,b,c;
    cin>>a>>b>>c;
    cyclicSwap(&a, &b, &c); 
    cout<<a<<" "<<b<<" "<<c;
    return 0; 
} 

Measured memory_bytes: 256
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(input().split())
g = []
r = []
for i in range(H):
    for j in range(W):
        if a[i][0][j] == "#":
            g.append(i)
            break
#print(g)
for i in range(W):
    for j in range(H):
        if a[j][0][i] == "#":
            r.append(i)
            break
#print(r)
ans = ""
for i in g:
    for j in r:
        ans += a[i][0][j]
    print(ans)
    ans = ""

Measured memory_bytes: 3064
use std::io::*;
use std::ops::Add;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let mut ans = vec![vec![vec![0isize; 10]; 3]; 4];
    for _ in 0..n {
        let b: usize = read();
        let f: usize = read();
        let r: usize = read();
        let v: isize = read();
        ans[b - 1][f - 1][r - 1] += v;
    }
    for (i, bld) in ans.iter_mut().enumerate() {
        for (j, fl) in bld.iter_mut().enumerate() {
            for (k, rm) in fl.iter_mut().enumerate() {
                print!(" {}", rm);
            }
            println!("");
        }
        if i < 3 {
            println!("{}", "#".repeat(20));
        }
    }
}



Measured memory_bytes: 5028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long tate = sc.nextLong();
        long yoko = sc.nextLong();
        long result = 0;
        if (tate == 1 || yoko == 1){
            result = 1;
        } else if(tate % 2 == 0){
            result = (tate / 2) * yoko;
        } else {
            for (int i = 1; i <= yoko; i++){
                if (i % 2 != 0){
                    result = result + (tate / 2) + 1;
                }else{
                    result = result + (tate / 2);
                }
            }
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 23636
s = input()
n = len(s)

def dfs(i,tmp):
    if i == n-1:
        return sum(list(map(int,tmp.split("+"))))
    
    return dfs(i+1, tmp+s[i+1]) + dfs(i+1,tmp+"+"+s[i+1])

print(dfs(0,s[0]))

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  int a[n],cnt=0;
  for(int i=0; i<n; i++) cin >>a[i];
  for(int i=0; i<n-2; i++){
    if((a[i+1]>a[i]&&a[i+2]>a[i+1])||(a[i]>a[i+1]&&a[i+1]>a[i+2])) cnt++;
  }

  cout <<cnt;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3660
//Name: Nails
//Level: 3
//Category: DP,動的計画法
//Note:

/*
 * ある釘から何段下までが囲まれるかを持ってDP．
 * 三角形の形より，ひとつの釘からは必ず左下と右下に領域が広がる．
 */
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct Triangle {
    int a, b, x;
    bool operator <(const Triangle &other) const {
        return a < other.a;
    }
};

bool update(int &a, int v) {
    if(a > v) return false;
    a = v;
    return true;
}

int dp[2][5000];
int main() {
    int N, M;
    cin >> N >> M;
    vector<Triangle> triangles(M);
    for(int i = 0; i < M; ++i) {
        Triangle &t = triangles[i];
        cin >> t.a >> t.b >> t.x;
    }
    sort(triangles.begin(), triangles.end());

    int ans = 0;
    int ptr = 0;
    vector<Triangle>::iterator it = triangles.begin();
    dp[ptr][0] = -1;
    for(int i = 0; i < N; ++i) {
        int np = 1-ptr;
        while(it != triangles.end() && it->a-1 == i) {
            update(dp[ptr][it->b-1], it->x);
            ++it;
        }
        for(int j = 0; j < N; ++j) {
            dp[np][j] = -1;
        }
        for(int j = 0; j <= i; ++j) {
            if(dp[ptr][j] != -1) {
                ++ans;
                update(dp[np][j], dp[ptr][j]-1);
                if(j+1 < N) update(dp[np][j+1], dp[ptr][j]-1);
            }
        }
        ptr = np;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6760
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    int n, m, x;
    scanf("%d %d %d",&n,&m,&x);
    int l = 0;
    int r = 0;
    bool tol[n];
    memset(tol, false, sizeof(tol));
    forn(i, 0, m) {
        int ai;
        scanf("%d",&ai);
        tol[ai-1] = 1;
    }
    x--;
    forn(i, 0, n) {
        if (tol[i]) {
            if (i > x) {
                r++;
            } else if (i < x) {
                l++;
            }
        }
    }
    printf("%d\n",min(l,r));
    return 0;
}


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

int gcd(int x,int y,int z){
  int m = min(min(x,y),z);
  int g = 0;
  for(int i=1;i<m+1;i++){
    if(x%i==0 && y%i==0 && z%i==0){
      g = i;
    }
  }
  return g;
}
 
int main() {
  int k;
  cin >> k;
  int sum = 0;
  for(int i=1;i<k+1;i++){
    for(int j=1;j<k+1;j++){
      for(int l=1;l<k+1;l++){
        sum += gcd(i,j,l);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
n = gets.to_i

n.times do
    nums = gets.split.map(&:to_i)
    b = c = 0
    ans = "YES"

    10.times do |i|
#        puts "nums= #{nums[i]} b=#{b}, c = #{c}"
#        puts nums[i] - b
#        puts  nums[i] - c
        sabun_b = (nums[i] - b) < 0 ? 0 : (nums[i] - b)
        sabun_c = (nums[i] - c) < 0 ? 0 : (nums[i] - c)
        if (nums[i] - b < 0) && (nums[i] - c < 0) then
            ans = "NO"
            break;
        elsif b == 0 then
            b = nums[i]
        elsif nums[i] - b < 0 then
            c = nums[i]
        elsif sabun_b > sabun_c then
            c = nums[i]
        else
            b = nums[i]
        end
        
    end

    puts ans
end


Measured memory_bytes: 6840
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long n2 = 2;
		long n1 = 1;
		long lucas = 1;
		for (int i = 2; i <= n; i++) {
			lucas = n2 + n1;
			n2 = n1;
			n1 = lucas;
		}
		System.out.println(lucas);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////



int main(){fastio
    string s;cin>>s;
    ll n=s.size();
    if(n==2){
        if(s[0]==s[1]){
            cout<<"1 2"<<endl;return 0;
        }else{
            cout<<"-1 -1"<<endl;return 0;
        }
    }
    rep(i,0,n-3){
        if(s[i]==s[i+1]||s[i+1]==s[i+2]||s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;return 0;
        }
    }
    cout<<"-1 -1"<<endl;
    
    
    return 0;
}



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

namespace AtCoder {
    class Program {

        static void Main(string[] args) {

            var n = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToList();
            var result = 0;
            var av = new List<int>();
            var bv = new List<int>();

            for (int i = 0; i < v.Count; i++) {

                if (i % 2 == 0) {

                    av.Add(v[i]);
                } else {

                    bv.Add(v[i]);
                }
            }
            var a = av.GroupBy(g => g).OrderByDescending(o => o.Count()).First().Key;
            var b = bv.GroupBy(g => g).OrderByDescending(o => o.Count()).First().Key;
            if (a == b) {

                if (av.Distinct().Count() != 1 && bv.Distinct().Count() != 1) {

                    var aa = av.GroupBy(g => g).OrderByDescending(o => o.Count()).Skip(1).First().Count();
                    var bb = bv.GroupBy(g => g).OrderByDescending(o => o.Count()).Skip(1).First().Count();

                    if (aa > bb) {

                        a = av.GroupBy(g => g).OrderByDescending(o => o.Count()).Skip(1).First().Key;
                    } else if (aa < bb) {

                        b = bv.GroupBy(g => g).OrderByDescending(o => o.Count()).Skip(1).First().Key;
                    }
                } else {

                    b = a + 2;
                }
            }

            for (int i = 0; i < v.Count; i += 2) {

                if (a != v[i]) {
                    result++;
                }
            }
            for (int i = 1; i < v.Count; i += 2) {

                if (b != v[i]) {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 32956
n,k = map(int,input().split())
x = list(map(int,input().split()))
res = 10**10
for i in range(0,n-k+1):
    l = x[i]
    r = x[i+k-1]
    lrsmall = min(abs(l),abs(r))
    res = min(r-l+lrsmall,res)
print(res)

Measured memory_bytes: 14392
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <cstring>

using namespace std;

const int INF = 1e9 + 7;

int n;
int happy[100000][3];
long long dp[100000][4];

long long dfs(int now, int before){
    if(now == n) return 0;
    if(~dp[now][before]) return dp[now][before];
    long long res = 0;
    for(int i = 0; i < 3; i++){
        if(before == i) continue;
        res = max(res, happy[now][i] + dfs(now + 1, i));
    }
    return dp[now][before] = res;
}

int main(){
    cin >> n;
    memset(dp, -1, sizeof dp);
    for(int i = 0; i < n; i++){
        for(auto&& j : happy[i]){
            cin >> j;
        }
    }
    cout << dfs(0, 3) << "\n";
}

Measured memory_bytes: 12288
#include <stdio.h>

int main(void){
    int input[3],dummy;
    int i,j;
    
    scanf("%d %d %d",&input[0],&input[1],&input[2]);
    for(i=0;i<3;i++){
        if(input[i]<1 || 10000<input[i]){
            printf("error\n");
            return 0;
        }
    }
    
    for(i=2;i>=0;i--){
        for(j=0;j<i;j++){
            if(input[j]>input[j+1]){
                dummy=input[j];
                input[j]=input[j+1];
                input[j+1]=dummy;
            }
        }
    }
    printf("%d %d %d\n",input[0],input[1],input[2]);
    
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using std::vector;
using std::pair;
using pii = pair<int, int>;
using lint = long long;

int abss(int a) {
	if (a > 0) return a;
	else return -a;
}
int main() {
	int x, a, b; scanf("%d %d %d", &x, &a, &b);
	if (abss(x - a) > abss(x - b)) printf("B");
	else printf("A");
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {

	int n, i, p[100000], a = 0, b = 0, c = 0;

	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &p[i]);
	}

	for (i = 1; i < n; i++) {
		if (i == p[i]) {
			p[i] = a;
			p[i + 1] = b;
			p[i] = b;
			p[i + 1] = a;
			c++;
		}
	}

	if (n == p[n]) {
		p[n] = a;
		p[1] = b;
		p[n] = b;
		p[1] = a;
		c++;
	}

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

	return 0;
}

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

int main()
{
    int n,max=0,i,p,c,d;
    int a[100],b[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
        scanf("%d",&b[i]);
    for(i=0;i<n;i++){
        c=0,d=0;
        for(p=0;p<=i;p++)
            c=c+a[p];
        for(p=i;p<n;p++)
            d=d+b[p];
        if(c+d>max)
            max=c+d;
    }
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,a;
    cin>>n;
    std::deque<long long int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end());
    deq.emplace_front(0);
    long long int sum=0;
    for (int i=1;i<n;i++) {
        sum+=deq[n-(i/2)];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 5272
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define                          ll                          long long int
ll gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

#define                          in(x)                       scanf("%lld",&x)
#define                          in2(x,y)                    scanf("%lld %lld",&x,&y)
#define                          in3(x,y,z)                  scanf("%lld %lld %lld",&x,&y,&z)
#define                          out(x)                      printf("%lld\n",x)
#define                          cy                          printf("YES\n")
#define                          cn                          printf("NO\n")
#define                          inf                         1e18
#define                          neg                         -1e18
#define                          mx                          2111111
#define                          fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                          fi                          first
#define                          si                          second
#define                          ce                          cout<<endl
#define                          pb                          push_back
#define                          vc(x)                       x.begin(),x.end()
#define                          pb                          push_back
#define                          pi                          pair<ll,ll>
#define                          debug                       printf("ok\n");
#define                          pg                          pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> >
#define                          mod                         1000000007


int main(){

   ll n;
     in(n);
     if(n==0)cout<<1<<endl;
     else cout<<0<<endl;

}



Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define rep(i, N) for(int i = 0; i < N; ++i)

using namespace std;
int N;
int A[100100];

int partition(int p, int r) {
    int x = A[r];
    int i = p-1;
    for(int j = p; j < r; ++j) {
        if (A[j] <= x) {
            ++i;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
   return i+1;
}

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];
    
    int q = partition(0, N-1);
    rep(i, N) {
        if(i) cout << " ";
        if (i == q) cout << "[" << A[i] << "]";
        else cout << A[i];
    }
    cout << endl;
}



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

int main(){
    int a, b;
    while (1){
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        else{
            if (a > b) cout << b << ' ' << a << endl;
            else cout << a << ' ' << b << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3000
// C++ (GCC 9.2.1)
// 解き直し.
// https://img.atcoder.jp/abc172/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
const int LIMIT = 1010101;
LL FAC[LIMIT], INV[LIMIT];

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

// 順列(nPk)計算用(mod版).
// ※配列FAC, INV は, 事前に計算済のものを使う.
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 順列(nPk)の計算結果(mod版).
LL permutation(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0LL;
    LL ret = FAC[n] * INV[n - k] % MOD;
    return ret;
}

// 組み合わせ(nCk)計算用(mod版).
// ※配列FAC, INV は, 事前に計算済のものを使う.
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 組み合わせ(nCk)の計算結果(mod版).
LL combination(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0LL;
    if(n == k || k == 0LL) return 1LL;
    LL ret = FAC[n] * INV[k] % MOD * INV[n - k] % MOD;
    return ret;
}

int main(){
    
    // 1. 入力情報.
    int n, m;
    scanf("%d %d", &n, &m);
    FAC[0] = 1;
    repx(i, 1, LIMIT) FAC[i] = (LL)i * FAC[i - 1] % MOD;
    rep(i, LIMIT) INV[i] = mPow(FAC[i], MOD - 2);
    
    // 2. 解説通り.
    LL ans = 0;
    rep(k, n + 1){
        // 2-1. nCk.
        LL c = combination((LL)n, (LL)k);
        
        // 2-2. -1 の k乗.
        c *= mPow(MOD - 1, (LL)k);
        c %= MOD;
        
        // 2-3. mPk.
        c *= permutation((LL)m, (LL)k);
        c %= MOD;
        
        // 2-4. (m - k)P(n - k).
        c *= permutation((LL)(m - k), (LL)(n - k));
        c %= MOD;
        
        // 2-5. (m - k)P(n - k).
        c *= permutation((LL)(m - k), (LL)(n - k));
        c %= MOD;
        
        // 2-6. 集計.
        ans += c;
        ans %= MOD;
    }
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 19600
#include <cstdio>
#include <iostream>
#define rep(i,k,n) for(int i=k;i<(int)(n);i++)
int n;
using namespace std;
int main(){
  cin >> n;
  int mi = n;
  rep(i,0,n+1){
    int cc = 0;
    int t = i;
    while(t>0) cc+=t%6 , t/=6;
    t = n-i;
    while(t>0) cc+=t%9 , t/=9;
    if(mi>cc) mi=cc;
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 256
#coding: utf-8

dirc = ((0,), (4, 0, 2, 3, 5, 1), (3, 1, 0, 5, 4, 2),
(2, 1, 5, 0, 4, 3), (1, 5, 2, 3, 0, 4), (5, 4, 2, 3, 1, 0))
sideNum = (1, 2, 4, 3)

labelA = list(map(int, input().split()))
labelB = list(map(int, input().split()))

for i in labelB:
    if labelA.count(i) != labelB.count(i):
        print('No')
        exit()

for i in range(6):
    labelC = [0 for k in range(6)]
    if i == 0:
        labelC = labelA[:]
    else:
        for j in range(6):
            labelC[dirc[i][j]] = labelA[j]
    if labelB[0] == labelC[0] and labelB[5] == labelC[5]:
        sideB = ''
        sideC = ''
        for j in sideNum:
            sideB += str(labelB[j])
            sideC += str(labelC[j])
        sideC += sideC
        if sideB in sideC:
            print('Yes')
            exit()
print('No')



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n, m, s, t;
struct edge{
   int to, a, b;
};
vector<edge> G[100010];

struct Dijkstra{
    vector<int> d;
    Dijkstra(int V){
        d.resize(V, INF);
    }
    void calc(int s){
        d[s] = 0;
        priority_queue<P, vector<P>, greater<P> > q;
        q.push(P(d[s], s));
        while(!q.empty()){
            P p = q.top(); q.pop();
            int from = p.second;
            int cost = p.first;
            if(d[from] < cost) continue;
            rep(i, 0, G[from].size()){
                int next = G[from][i].to;
                int newCost = cost + G[from][i].a;
                if(d[next] > newCost){
                    d[next] = newCost;
                    q.push(P(newCost, next));
                }
            }
        }
    }
};

struct Dijkstra2{
    vector<int> d;
    Dijkstra2(int V){
        d.resize(V, INF);
    }
    void calc(int s){
        d[s] = 0;
        priority_queue<P, vector<P>, greater<P> > q;
        q.push(P(d[s], s));
        while(!q.empty()){
            P p = q.top(); q.pop();
            int from = p.second;
            int cost = p.first;
            if(d[from] < cost) continue;
            rep(i, 0, G[from].size()){
                int next = G[from][i].to;
                int newCost = cost + G[from][i].b;
                if(d[next] > newCost){
                    d[next] = newCost;
                    q.push(P(newCost, next));
                }
            }
        }
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> s >> t;
    s--; t--;
    rep(i, 0, m){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        G[u].push_back({v, a, b});
        G[v].push_back({u, a, b});
    }
    Dijkstra dks(n);
    Dijkstra2 dks2(n);
    dks.calc(s);
    dks2.calc(t);
    vector<int> ans;
    int MIN = INF;
    int money = 1e15;
    repr(i, n - 1, 0){
        int tmp = dks.d[i] + dks2.d[i];
        chmin(MIN, tmp);
        ans.push_back(MIN);
    }
    reverse(ans.begin(), ans.end());
    rep(i, 0, n){
        cout << money - ans[i] << endl;
    }
}

Measured memory_bytes: 13952
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}

	sort(l.begin(), l.end());

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int a = l[i];
			int b = l[j];
			int can = lower_bound(l.begin(), l.end(), a + b) - l.begin();
			ans += can - j - 1;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    int digit = 0;
	    Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
	    boolean no = true;
	    while(n != 0){
	        digit = n % 10;
	        if(digit == 7){
	            System.out.println("Yes");
	            no = false;
	            break;
	        }
	        n= Math.floorDiv(n, 10);
	        
	    }
	    if(no == true)
	    System.out.println("No");
	}
}


Measured memory_bytes: 35768
n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if (10000 * i + 5000 * j + 1000 * k) == y and k >= 0:
            print(i,j,k)
            exit()
print('-1 -1 -1')

Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
res = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            tmp = math.gcd(i,j)
            res += math.gcd(tmp,k)
print(res)

Measured memory_bytes: 77764
#include<stdio.h>

int main(void) {
int n,m;
int i,j;
int ans;

scanf("%d %d", &n, &m);
int matA[n][m];
int matB[m];

for(i = 0; i < n; i++) {
for(j = 0; j < m; j++) {
scanf("%d", &matA[i][j]);
}
}
for(j = 0; j < m; j++) {
scanf("%d", &matB[j]);
}

for(i = 0; i < n; i++) {
ans = 0;
for(j = 0; j < m; j++) {
ans += matA[i][j]*matB[j];
}
printf("%d\n", ans);
}

return (0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
	ll n,i,j,k,p;
	cin>>n;
	ll a[100005][3];
	for(i=0;i<n;i++)
	{
	    cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	for(i=1;i<n;i++)
	{
	    for(j=0;j<3;j++)
	    {
	        p=0;
	        for(k=0;k<3;k++)
	        {
	            if(j!=k)
	            {
	                p=max(p,a[i][j]+a[i-1][k]);
	            }
	        }
	        a[i][j]=p;
	    }
	}
	ll w=max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
	cout<<w<<"\n";
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;

bool sq(int n) {
	bool f = 0;
	for (int i = 0; i < sqrt(n) + 1; i++) {
		if (n == i * i)f = 1;
	}
	return f;
}
int main() {
	int a, b;
	int ans=INF+1;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % 2019 == 0) {
			ans = 0;
			cout << ans << endl;
			return 0;
		}
	}
	a = a % 2019;
	b = b % 2019;
	if (a >= b)ans = 0;
	else {
		for (int i = a; i <= b; i++) {
			for (int j = i ; j <= b; j++) {
				if (i!=j&&ans > (i * j) % 2019)ans = (i * j) % 2019;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3680
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(input()) for _ in range(N)]

    max_num = max(As)
    max_index = As.index(max_num)

    for i in range(N):
        if i == max_index:
            del As[max_index]
            print(max(As))
        else:
            print(max_num)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 16936
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    ll N, K;
    cin>>N>>K;
    ll A[N];
    for(int i=0;i<N;++i){
        cin>>A[i];
        A[i]--;
    }
    map<int, int> amap;
    amap[0]++;
    ll cycle = 0;
    ll now = 0;
    int get[N];
    ll doko;
    while(true){
        get[now] = cycle;
        cycle++;
        if(amap[A[now]]>0){
            doko = A[now];
            cycle -= get[A[now]];
            break;
        }
        amap[A[now]]++;
        now = A[now];
    }
    int ans;
    if(K>=get[doko]){
        ans = doko;
        K -= get[doko];
        K %= cycle;
        for(int i=0;i<K;++i){
            ans = A[ans];
        }
    }
    else{
        ans = 0;
        for(int i=0;i<K;++i){
            ans = A[ans];
        }
    }
    cout<<ans+1<<endl;
}



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

int main(){
    int n;
    cin >> n;
    long long int l[87];
    l[0] = 2;l[1] = 1;
    for(int i = 2;i <= n;i++){
        l[i] = l[i-1]+l[i-2];
    }
    cout << l[n];
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  if (s == "RRR") ans = 3;
  if (s == "RRS") ans = 2;
  if (s == "RSR") ans = 1;
  if (s == "RSS") ans = 1;
  if (s == "SRR") ans = 2;
  if (s == "SRS") ans = 1;
  if (s == "SSR") ans = 1;
  if (s == "SSS") ans = 0;
  cout << ans << endl;
  return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  ll ans = 0;
  for (long long i = 1; i < n; i++) {
    ans += a.at(i / 2);
  }

  cout << ans << endl;
}


Measured memory_bytes: 4812
// ABC085B - Kagami Mochi
package main

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

var sc = bufio.NewScanner(os.Stdin)

func newLine() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	N, _ := strconv.Atoi(newLine())
	d := make(map[string]int)
	for i := 0; i < N; i++ {
		d[newLine()]++
	}

	fmt.Println(len(d))
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int a,b;
	scanf("%d %d", &a, &b);
	if (a > b)
		printf("a > b\n");
	else if (a < b)
		printf("a < b\n");
	else if (a == b)
		printf("a == b\n");
	return 0;
}


Measured memory_bytes: 2068
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr ,greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,0 }, dy[] = { 1,0,-1,0,0 };
const int SIZE1 =3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 22;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE3][SIZE3], answer = zero;
LL A[SIZE], B[SIZE];
LL solve() {
	LL a, b, x;
	cin >> a >> b >> x;
	LL ans = 0;
	LL diff = a - b;
	ans += x;
	ans %= p;
	x -= a;
	if (x >= 0) {
		ans += (x / diff + 1)%p*(b%p)%p;
		ans %= p;
	}
	ans += p;
	ans %= p;
	cout << ans << endl;
	return 0;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	solve();
//	cin >> N;
	return 0;
}


Measured memory_bytes: 10240
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((a + b) == (c + d)) cout << "Balanced" << endl;
    else if((a + b) > (c + d)) cout << "Left" << endl;
    else cout << "Right" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char a, b;

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

    void run() {
        FastReader sc = new FastReader();
        a = sc.next().charAt(0);
        b = sc.next().charAt(0);
        solve();
    }

    void solve() {
        if (a < b) {
            System.out.println("<");
        } else if (a > b) {
            System.out.println(">");
        } else {
            System.out.println("=");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    int K;
    cin >> K;
    vector<string> v;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= K; j++){
            if(i + j > s.size()) break;
            v.push_back(s.substr(i, j));
        }
    }
    sort(v.begin(), v.end());
    auto ite = unique(v.begin(), v.end());
    v.erase(ite, v.end());
    cout << v[K - 1] << endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    int n;
    int s[1000] = {};
    double alpha;

    cout << fixed << setprecision(5);

    while (true) {
        cin >> n;
        if (n == 0) break;

        double sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            sum += s[i];
        }
        double ave = sum / n;
        sum = 0;
        for (int i = 0; i < n; i++) {
            sum += pow(s[i] - ave, 2);
        }
        alpha = sqrt(sum / n);

        cout << alpha << endl;
    }

    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
typedef long long ll;
using namespace std;
#define rep(i,n) for (int i = 0; i <= int(n); i++)
#define mod 1000000007

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i <= n; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	cout << A.back() - A.front() << endl;	
}

Measured memory_bytes: 256
#include <stdio.h>
typedef struct{
  char c;
  int number;
}donald;
void Bub(donald *a,int n);
void Sel(donald *a, int n);
void PP(donald *a,int n);
int stablecheck(donald *a,int n,donald *b);
int judge(donald *a, int n,donald *b);
int main(){
  
  int n,i,stable=0;
  donald trump[36],trump1[36],trump2[36];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf(" %c%d",&trump[i].c,&trump[i].number);
    trump1[i].c=trump[i].c;
    trump1[i].number=trump[i].number;
    trump2[i].c=trump[i].c;
    trump2[i].number=trump[i].number;
  }
  /*bubblr sort */
  Bub(trump1,n);
  PP(trump1,n);
  stable=stablecheck(trump,n,trump1);
  printf("Stable\n");
  
  /*selection sort*/
 
  Sel(trump2,n);
  PP(trump2,n);
  stable=judge(trump1,n,trump2);
  if(stable==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  
  return 0;
}

void PP(donald *a,int n){
  int i;
  for(i=0;i<n;i++){
    if(i==(n-1)){
      printf("%c%d\n",a[i].c,a[i].number);
    }
    else {
      printf("%c%d ",a[i].c,a[i].number);
    }
  }
}



void Bub(donald *a,int n){
  int j,flag=1,sub,i;
  char subc;
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j].number<a[j-1].number){
	sub=a[j].number;
	a[j].number=a[j-1].number;
	a[j-1].number=sub;
	subc=a[j].c;
	a[j].c=a[j-1].c;
	a[j-1].c=subc;
	flag=1;
      }
    }
  }
}
			


void Sel(donald *a,int n){
  int i,min,sub,j;
  char subc;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j].number<a[min].number){
	min=j;
      }
    }
    if(a[i].number>a[min].number){
      sub=a[i].number;
      a[i].number=a[min].number;
      a[min].number=sub;
      subc=a[i].c;
      a[i].c=a[min].c;
      a[min].c=subc;
    }
  }
}



     
int stablecheck(donald *in, int n,donald *out){
  int i,j,a,b;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if(in[i].number==in[j].number && in[i].number==out[a].number && in[j].number==out[b].number && in[i].c==in[j].c && in[i].c==out[a].c && in[j].c==out[b].c){
	    return 0;
	  }
	}
      }
    }
  }
  return 1;
}

  
int judge(donald *a,int n,donald *b){
  int judge=0,i;
  for(i=0;i<n;i++){
    if(a[i].number==b[i].number && a[i].c==b[i].c){
      judge++;
    }
  }
  if(judge==n){
    return 1;
  }
  else {
    return 0;
  }
}
  

Measured memory_bytes: 608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
#define out(a) printf("%d",a)
using namespace std;
int n,ans;
int num;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int find(int x)
{
	int sum=0;
	while (x>0) {
	  sum+=x%10; x/=10;
    }
    return sum;
}
int main()
{
	n=read(); ans=233333;
	for (int i=1;i<=n-1;i++){
		num=find(i)+find(n-i);
		ans=min(num,ans);
	  }
	  out(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,X,Y; cin >> N >> X >> Y;
    X--;Y--;
    int s=Y-X-1;
    vector<int> out(N,0);
    vector<int> lp(N,0);
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int a=j-i;
            int b=abs(X-i)+abs(Y-j)+1;
            int tmp=min(a,b);
            out[tmp]++;
            //cerr << i << " " << j << " " << tmp << endl;
        }
    }
    for(int i=1;i<N;i++){
        cout << out[i] << endl;
    }
    return 0;
}


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

using namespace std;

int H[100002];
int dp[100002];

int main(){
    int N, K;
    cin >> N >> K;
    for(int i=1; i<=N; i++){
        cin >> H[i];
    }
    dp[0] = 0;
    dp[1] = 0;
    for(int i=2; i<=N; i++){
        int minCost = INT_MAX;
        for(int j=1; j<=min(K, i-1); j++){
            if (dp[i-j] +  abs(H[i] - H[i-j]) < minCost){
                minCost = dp[i-j] +  abs(H[i] - H[i-j]);
            }
        }
        dp[i] = minCost;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
//babinho legenda
//hvala
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef pair<long long, long long> par;
const int maxn = 2e5+10;
const long long inf = 0x3f3f3f3f;

int n;
long long c;
long long niz[maxn];
long long dp[maxn];
vector< par > hul;

long long ccw(par a, par b, par c) {
	return a.X * (b.Y - c.Y) + b.X * (c.Y - a.Y) + c.X * (a.Y - b.Y);
}

long long search(long long x) {
	/**
	long long out = inf;
	for (int i = 0; i < hul.size(); i++) {
		out = min(out, x * hul[i].X + hul[i].Y);
	}
	return out;
	**/
	
	int lo = 0, hi = hul.size() - 1;
	while (lo < hi) {
		int mid = (lo + hi + 1) / 2;
		
		long long lef = inf;
		if (mid > 0) lef = x * hul[mid - 1].X + hul[mid - 1].Y;
		
		long long rig = inf;
		if (mid < hul.size() - 1) rig = x * hul[mid + 1].X + hul[mid + 1].Y;
		
		long long tren = x * hul[mid].X + hul[mid].Y;
		if (lef < tren) hi = mid - 1;
		else lo = mid;
	}
	return x * hul[lo].X + hul[lo].Y;
}

void update(par x) {
	while (hul.size() > 1 && ccw(hul[hul.size() - 2], hul.back(), x) >= 0) 
		hul.pop_back();
	hul.push_back(x);
}

int main() {
	scanf("%d%lld", &n, &c);
	for (int i = 0; i < n; i++)
		scanf("%lld", niz+i);
		
	dp[0] = 0;
	hul.push_back(make_pair(-2*niz[0], niz[0] * niz[0]));
	for (int i = 1; i < n; i++) {
		dp[i] = c + niz[i] * niz[i] + search(niz[i]);
		update(make_pair(-2*niz[i], niz[i] * niz[i] + dp[i])); 
	}
	
	//for (int i = 0; i < n; i++) printf("%d ", dp[i]); printf("\n");
	printf("%lld\n", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 9200
#include <iostream>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    vector<ll> s(n, 0);
    REP(i, n){
        ll ai;
        cin >> ai;
        s.at(--ai)++;
    }
    priority_queue<ll, vector<ll>, greater<ll>> que;
    REP(i, n){
        if(s.at(i)){
            que.push(s.at(i));
        }
    }
    vector<ll> ans(n, 0);
    for(ll i = que.size(); i >= 1; --i){
        ans.at(i - 1) = que.top();
        if(que.size() > 1){
            ll x1 = que.top(); que.pop();
            for(; x1 > 0; --x1){
                ll x2 = que.top(); que.pop();
                que.push(x2 + 1);
            }
        }
    }
    REP(i, ans.size()){
        cout << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 10604
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] n = new int[10000];
		
		int N = scan.nextInt();
		
		int kai = N;
		int x = 0;
		
		for(int i=0; i<N; i++){
			n[i] = scan.nextInt();
		}
		
		for(int i=0; i<N; i++){
			if(n[i]%2==0 && n[i]!=2){
				kai--;
				x++;
				continue;
			}
			for(int q=2; q<=Math.sqrt(n[i]); q++){
				if(n[i]%q==0){
					kai--;
					break;
				}
			}
		}
		
		System.out.println(kai);
	}
}


Measured memory_bytes: 42988
N = int(input())
T = [int(x) for x in input().split()]
V = [int(x) for x in input().split()]
T.append(0)
V.append(0)
Vt = [0 for i in range(N + 1)]
r = sum(T)
R = [0 for i in range(N)]
for i in range(N - 1):
  r -= T[i]
  R[i] = r
for i in range(N - 1, -1, -1):
  Vt[i] = min(V[i], V[i + 1], Vt[i + 1] + T[i + 1])
L = 0
v0 = 0
for i in range(N):
  ta = min(V[i] - v0, (T[i] - (v0 - Vt[i])) / 2, T[i])
  tb = max(v0 + ta - Vt[i], 0)
  L += (2 * v0 + ta) * ta / 2 + (v0 + ta) * (T[i] - ta - tb) + (2 * (v0 + ta) - tb) * tb / 2
  v0 = v0 + ta - tb
print(L)

Measured memory_bytes: 3064