akhauriyash/Code-Regression huggingface dataset:
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 c = sc.nextInt();
        System.out.println(c + " " + a + " " + b);
    }
}

Measured memory_bytes: 21972
n = int(input())
tt = []
for i in range(n):
    tt.append(int(input()))
    
ss = 1

for i in tt:
    p = []
    p.append(int(ss))
    p.append(int(i))
    q = list(sorted(p))
    while q[1] % q[0] != 0:
        r = [q[1] % q[0] , q[0]]
        s = list(sorted(r))
        q[0] = int(s[0])
        q[1] = int(s[1])

        
    ss = int(ss * i) // q[0]

print(ss)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main(void){
  char s[256];
  scanf("%s",s);
  if(strcmp(s,"AAA")==0||strcmp(s,"BBB")==0){
    printf("No");
  }
  else{
    printf("Yes");
  }
  return 0;
}
  


Measured memory_bytes: 128
import java.util.*;
public class Main {
	class C {
		int sec;
		String color;
		public C(int sec, String color) {
			this.sec = sec;
			this.color = color;
		}
		
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		while(true){
			String str = sc.next();
			if(str.equals("0"))
				break;
			//create a goal
			int len = str.length();
			char [] c = new char[len];
			String [] goal = new String[3];
			for(int i=0; i < len; i++){
				c[i] = 'r';
			}
			goal[0] = new String(c);
			for(int i=0; i < len; i++){
				c[i] = 'g';
			}
			goal[1] = new String(c);
			for(int i=0; i < len; i++){
				c[i] = 'b';
			}
			goal[2] = new String(c);
			//sum of color
			char sumColor = 'r' + 'g' + 'b';
			
			//create a open
			LinkedList<C> open = new LinkedList<C>();
			//create a close
			TreeSet<String> close = new TreeSet<String>();
			
			//set start point
			C startObj = new C(0, str);
			open.add(startObj);
			close.add(str);
			
			boolean flg = false;
			
			while(! open.isEmpty()){
				//pop a first obj
				int nowCost = open.getFirst().sec;
				String nowColor = open.getFirst().color;
				open.removeFirst();
				
				for(int i=0; i < 3; i++){
					if(nowColor.equals(goal[i])){
						flg = true;
						break;
					}
				}
				if(flg){
					System.out.println(nowCost);
					break;
				}
				
				
				//get change way
				for(int i=0; i < nowColor.length() - 1 ; i++){
					char now = nowColor.charAt(i);
					char next = nowColor.charAt(i+1);
					if(now != next){
						//find a diff color
						char diffColor =  (char) (sumColor - now - next);
						//set a color
						StringBuilder sb = new StringBuilder(nowColor);
						sb.setCharAt(i, diffColor);
						sb.setCharAt(i+1, diffColor);
						String newColor = sb.toString();
						
						if(!close.contains(newColor)){
							//add a open
							open.addLast(new C(nowCost + 1, newColor));
							close.add(newColor);
						}
					}
				}
				
			}	
			
			if(!flg){
				System.out.println("NA");
			}
		}
			
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 16000
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll a = 100;
    ll x;
    ll ans = 0;

    cin >> x;

    while (1)
    {
        ans++;
        a *= 1.01;

        if (a >= x)
        {
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3636
from math import *

def L(xi, di):
    return xi - di

def R(xi, di):
    return xi + di

def D(yi, di):
    return yi - di

def U(yi, di):
    return yi + di

def main():
    N = int(input())
    x_list = [list(map(int, input().split())) for i in range(N)]
    sum_list = [x[0] + x[1] for x in x_list]
    checker = sum_list[0] % 2

    for wa in sum_list:
        if wa % 2 != checker:
            print("-1")
            return

    arm_list = []
    if checker == 0:
        arm_list.append(1)

    pow_i = 0
    max_sum = max(sum_list)
    while max_sum > sum(arm_list):
        arm_list.append(2 ** pow_i)
        pow_i += 1
    arm_list = sorted(arm_list, key=lambda x: -x)
    print(len(arm_list))
    print(" ".join(map(str, arm_list)))

    for c in x_list:
        now_c = [0,0]
        order = ""

        for arm in arm_list:
            dx = c[0] - now_c[0]
            dy = c[1] - now_c[1]

            if abs(dx) > abs(dy):
                if dx > 0:
                    order += "R"
                    now_c[0] = R(now_c[0], arm)
                else:
                    order += "L"
                    now_c[0] = L(now_c[0], arm)
            else:
                if dy > 0:
                    order += "U"
                    now_c[1] = U(now_c[1], arm)
                else:
                    order += "D"
                    now_c[1] = D(now_c[1], arm)
        print(order)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    N,=pin()
    n,t=N//100,N%100
    if n*5>=t:
        print(1)
        return
    print(0)
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """615"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """217"""
        output = """0"""
        self.assertIO(input, output)
if __name__=="__main__":resolve()

Measured memory_bytes: 51308
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	//cout << fixed << setprecision(10);
	long long int n, m,x, res = 0, cou = 1, mi = 999999999, ma = -9999999999;
	long long int max_id, min_id,L[200000];
	cin >>n>>x ;
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	for (int i = 0; i < n; i++) {
		res += L[i];
		if (res <= x) { cou++; }
	}
	cout << cou;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $x, $y);
$g_a = [1, 3, 5, 7, 8, 10, 12];
$g_b = [4, 6, 9, 11];
$g_c = [2];
if((in_array($x, $g_a) && in_array($y, $g_a))
    || (in_array($x, $g_b) && in_array($y, $g_b))
    || (in_array($x, $g_c) && in_array($y, $g_c))) {
    echo 'Yes'. "\n";
} else {
    echo 'No'. "\n";
}

Measured memory_bytes: 4728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a ; i <= b; ++ i) 
const int N = 101, inf = 1e4 ;
using namespace std ;
int n, m ;
char a[N][N] ;
short f[N][N][N][N], sum[2][N][N] ;
void upd(short &x, short y) { if (y > x) x = y ; }
int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, n) scanf("%s", a[i] + 1) ;
	int x, y ;
	rep(i, 1, n) rep(j, 1, m) {
		sum[0][i][j] = sum[1][i][j] = a[i][j] == 'o' ;
		if (a[i][j] == 'E') x = i, y = j ;
		sum[0][i][j] += sum[0][i - 1][j], sum[1][i][j] += sum[1][i][j - 1] ;
	}
	rep(u, 0, x - 1) rep(d, 0, n - x) rep(l, 0, y - 1) rep(r, 0, m - y) f[u][d][l][r] = - inf ;
	f[0][0][0][0] = 0 ;
	rep(u, 0, x - 1) rep(d, 0, n - x) rep(l, 0, y - 1) rep(r, 0, m - y) {
		upd(f[u + 1][d][l][r], f[u][d][l][r] + (x - u - 1 > d ? max(sum[1][x - u - 1][min(m - l, y + r)] - sum[1][x - u - 1][max(r, y - l - 1)], 0) : 0)) ;
		upd(f[u][d + 1][l][r], f[u][d][l][r] + (x + d + 1 <= n - u ? max(sum[1][x + d + 1][min(m - l, y + r)] - sum[1][x + d + 1][max(r, y - l - 1)], 0) : 0)) ;
		upd(f[u][d][l + 1][r], f[u][d][l][r] + (y - l - 1 > r ? max(sum[0][min(n - u, x + d)][y - l - 1] - sum[0][max(d, x - u - 1)][y - l - 1], 0) : 0)) ;
		upd(f[u][d][l][r + 1], f[u][d][l][r] + (y + r + 1 <= m - l ? max(sum[0][min(n - u, x + d)][y + r + 1] - sum[0][max(d, x - u - 1)][y + r + 1], 0) : 0)) ;
	}
	printf("%d\n", f[x - 1][n - x][y - 1][m - y]) ;
	return 0 ;
}

Measured memory_bytes: 201088
/*
god taekyu
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n,m;
int A[100005];

struct node {
    ll val,t;
} seg[800005];
node B[200005];
void updt1(int idx,int s,int e,int l,int r) {
    //for(int i=l;i<=r;i++) B[i].t++;
    if(e<l || r<s) return;
    if(l<=s && e<=r) {
        seg[idx].t++;
        return;
    }
    updt1(idx*2,s,(s+e)/2,l,r);
    updt1(idx*2+1,(s+e)/2+1,e,l,r);
}
void updt2(int idx,int s,int e,int l,int r,int v) {
    //for(int i=l;i<=r;i++) B[i].val+=v;
    if(e<l || r<s) return;
    if(l<=s && e<=r) {
        seg[idx].val+=(ll)v;
        return;
    }
    updt2(idx*2,s,(s+e)/2,l,r,v);
    updt2(idx*2+1,(s+e)/2+1,e,l,r,v);
}
ll q1(int idx,int s,int e,int x) {
    if(s==e) return seg[idx].t;
    if(x<=(s+e)/2) return seg[idx].t + q1(idx*2,s,(s+e)/2,x);
    else return seg[idx].t + q1(idx*2+1,(s+e)/2+1,e,x);
}
ll q2(int idx,int s,int e,int x) {
    if(s==e) return seg[idx].val;
    if(x<=(s+e)/2) return seg[idx].val + q2(idx*2,s,(s+e)/2,x);
    else return seg[idx].val + q2(idx*2+1,(s+e)/2+1,e,x);
}
ll query(int idx) {
    ll t1 = q1(1,1,2*m,idx);
    ll t2 = q2(1,1,2*m,idx);
    return t1 * idx + t2;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>A[i];
    ll sum = 0;
    for(int i=0;i<n-1;i++) {
        int l = A[i], r = A[i+1];
        if(l > r) r += m;
        sum += r-l;
    }
    for(int i=0;i<n-1;i++) {
        int l = A[i], r = A[i+1];
        if(l > r) r += m;
        updt1(1,1,2*m,l+1,r);
        updt2(1,1,2*m,l+1,r,-(l+1));
    }
    ll _max = 0;
    for(int i=1;i<=m;i++) {
        _max = max(_max , query(i) + query(i+m));
    }
    cout<<sum - _max;
    return 0;
}

/*
god taekyu
*/


Measured memory_bytes: 10880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

ll int gcd(ll int a, ll int b)
{
	return (a % b ? gcd(b, a % b) : b);
}

ll int num(ll int a, ll int b, ll int c)
{
	ll int sum = 0LL;
	sum += b / (ll int)c - a / (ll int)c;
	if (!(a % c)) {
		sum += 1LL;
	}

	return sum;
}

int main()
{
	ll int a, b, c, d;
	ll int ans = 0LL;
	cin >> a >> b >> c >> d;
	ll int lcm = c * d / gcd(c, d);

	ans += b - a + 1LL;
	ans -= num(a, b, (ll int)c);
	ans -= num(a, b, (ll int)d);
	ans += num(a, b, lcm);

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n:usize,
        a:[usize; n-1],
    }
    let mut sub = vec![0; n];
    for i in a {
        sub[i-1] += 1;
    }
    for i in sub {
        println!("{}", i)
    }
}


Measured memory_bytes: 5540
def main():
    n = int(input())
    dp = [0] * 100

    dp[0] = 2
    dp[1] = 1

    for i in range(2, n+1):
        dp[i] = dp[i-1] + dp[i-2]

    print(dp[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 62012
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a==1||a==2||a==3||a==5||a==6||a==9||a==10||a==13||a==17)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int w[N] , d[N] , cnt[20] , res , n , st , book[N] , sxr[N];
int main()
{
    scanf("%d" , &n);
    for(int i=1,u,v,va;i<n;i++){scanf("%d%d%d",&u,&v,&va);w[u]^=va;w[v]^=va;}
    for(int i=0;i<n;i++){cnt[w[i]]++;}
    for(int i=1;i<=15;i++)res+=cnt[i]/2,st|=(cnt[i]&1)<<(i-1);  
    for(int i=1;i<(1<<15);i++)d[i]=d[i>>1]+(i&1);
    for(int i=1;i<(1<<15);i++)d[i]-=1; 
    for(int i=1;i<(1<<15);i++)
        for(int j=0;j<15;j++)if((i>>j)&1)sxr[i]^=(j+1);
    for(int i=1;i<(1<<15);i++)
    {
        if(sxr[i]!=0)continue;
        for(int k=(i-1)&i;k;k=(k-1)&i)
            if(sxr[k]==0)d[i]=min(d[i],d[k]+d[i^k]);
    }printf("%d",res+d[st]);return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  int h;
  rep(i,N) {
    cin >> h;
    if ( h >= K ) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c = gets().split().map(&:to_i)

if a > b then
    k = b
    b = a
    a = k
end
if b > c then
    k = c
    c = b
    b = k
end
if a > b then
    k = b
    b = a
    a = k
end

puts [a,b,c].join(" ")




Measured memory_bytes: 6864
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;



void  solve(){
    int n,s,k;
    cin>>n>>k>>s;
    vl a(n);
    for(int i=0;i<k;i++){
        a[i] = s;
    }
    for(int i=k;i<n;i++){
        a[i] = s/2+1;
        if(a[i] == s) a[i] = s+1;
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<" ";
    }   
    cout<<endl;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

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

int main(){
  int N,K; cin >> N >> K;
  vector<int> v(N,0);
  for(int i=0; i<K; i++){
    int d; cin >> d;
    for(int j=0; j<d; j++){
      int a; cin >> a;
      a--;
      v[a]++;
    }
  }
  int c=0;
  for(int i=0; i<N; i++) c+=(v[i]==0);
  cout << c << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ca = min(a, k);
    int cb = min(b, k - ca);
    int cc = min(c, k - ca - cb);
    int ans = ca - cc;
    cout << ans << endl;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
double dp[n+1][n+1];
for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++)
    dp[i][j]=0.0;
dp[0][0]=1.0;
     for(int i=1;i<=n;i++)
        for(int j=0;j<=i;j++)
     {
         dp[i][j]=dp[i-1][j]*p[i-1];
         if(j>0)
            dp[i][j]+=(dp[i-1][j-1]*(1-p[i-1]));
     }

    double ans=0.0;
    for(int i=0;2*i<n;i++)
    {
        ans+=dp[n][i];
    }

    cout<<fixed<<setprecision(10)<<ans;
    return 0;

}


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

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, k;
	cin>>n>>k;
	vector<int> v(n);
	int mn = 0, mx = 0;
	for (int i = 0; i<n; i++){
		cin>>v[i];
		if (v[i]>mx)
			mx = v[i]; 
	}
	mx+=10;
	int M, cnt;
	while(mn+1<mx){
		cnt = 0;
		M = (mn+mx)/2;
		for(auto u : v)
			cnt+=(u-1)/M;
		if(cnt<=k) mx = M;
		else mn = M;
	}
	cout<<mx;
}


Measured memory_bytes: 3932
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

int main(){
	ll m,n,sum=0;
	cin>>n;
	ll a[n+1];
	rep(i,n)cin>>a[i];
	a[n]=0;
	rep(i,n){
		sum+=a[i]/2;
		if(a[i]%2){
			if(a[i+1]!=0){
				sum++;
				a[i]--;
				a[i+1]--;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

  int d[100] = {};
  int N;

  cin >> N;

  for(int i = 0; i < N; i++){
	cin >> d[i];
  }

  sort(d,d+N);

  int num = d[0];
  int cnt = 1;
  for(int i = 1; i < N; i++){
	if(num < d[i]){
	  cnt++;
	  num = d[i];
	}
  }

  cout << cnt << "\n";
  
  return 0;
}


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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	cout << (n / 2) * (n - n / 2) << "\n";
	
	return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using  namespace std;
#define pb push_back
#define M 1000000007
#define f first
#define s second
typedef long long int ll;

void solve(){
	
	ll n, arr[105], cnt = 0;
	cin >> n;
	for(int i =0 ; i < n; i++)
		cin >> arr[i];
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			for(int k = j+1; k < n; k++){
				if(arr[i] == arr[j] || arr[j] == arr[k] || arr[k] == arr[i])
					continue;
				else if(arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[k] + arr[j] > arr[i]){
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;

}		

int main(){

	int t;
	// cin >> t;
	t = 1;
	for(int q = 0; q < t; q++){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

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;
}



int main()
{
	ll  i, j, k, l, m, sum, flag, N, x, y, M, K, H, W, A, B;
	cin >> N>>x;
	flag = 0;
	vector<ll>a(N*2-1);
	vector<ll>b;
	REP(i, 1, 2 * N ) {
		b.pb(i);
	}
	if (N == 2) {
		if (x == 2) {
			output("Yes");
			output(1);
			output(2);
			output(3);
			return 0;
		}
		output("No");
		return 0;
	}
	if (x >= 2 && x <=2*N - 2) {
		flag = 1;
		if (x < 2*N - 2) {
			a[N - 1] = x;
			a[N] = 1;
			a[N - 2] = x + 2;
			a[N + 1] = x + 1;
			b.erase(b.begin());
			b.erase(b.begin() + x - 2);
			b.erase(b.begin() + x - 2);
			b.erase(b.begin() + x - 2);
			REP(i, 0, N - 2) {
				a[i] = b[i];
			}
			REP(i, N + 2, 2 * N - 1) {
				a[i] = b[i- 4];
			}
			output("Yes");
			REP(i, 0, 2 * N - 1) {
				output(a[i]);
			}
			return 0;
		}
		a[N - 1] = x;
		a[N] = x+1;
		a[N - 2] = x - 2;
		a[N + 1] = x - 1;
		b.erase(b.begin() + x - 3);
		b.erase(b.begin() + x - 3);
		b.erase(b.begin() + x - 3);
		b.erase(b.begin() + x - 3);
		REP(i, 0, N - 2) {
			a[i] = b[i];
		}
		REP(i, N + 2, 2 * N - 1) {
			a[i] = b[i - 4];
		}
		output("Yes");
		REP(i, 0, 2 * N - 1) {
			output(a[i]);
		}
		return 0;


	}
	output("No");
	return 0;
	
}













Measured memory_bytes: 4720
c = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
e = [int(i) for i in input().split()]
if c[0] - d[0] == c[1] - d[1] == c[2] - d[2] and \
   c[0] - e[0] == c[1] - e[1] == c[2] - e[2]:
    print('Yes')
else:
  print('No')

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--)
    {
       
       string s;
       cin>>s;
       int cnt=0;
       int ma=0;
       for(int i=0;i<s.size();i++)
       {
           if(s[i]=='R')
           cnt++;
           else
           {
               ma=max(ma,cnt);
               cnt=0;
           }
       }
       ma=max(ma,cnt);
       cout<<ma;
       
      
       
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
int nyakusu(int x){
    int ans=1;
    rep2(i,2,x+1){
        int j=0;
        while(1){
            if(x%i!=0)break;
            x/=i;
            j++;
        }ans*=(j+1);
    }
    return ans;
}

int main() {
    vi a(201,0);
    int n;
    cin>>n;
    rep2(i,1,201){
        if(i%2==1&&nyakusu(i)==8)a.at(i)++;
    }
    //rep2(i,1,201)cout<<i<<" "<<nyakusu(i)<<endl;
    rep2(i,2,201)a.at(i)+=a.at(i-1);
    cout<<a.at(n)<<endl;
}



Measured memory_bytes: 3508
def judge(l):
    #yoko
    if sum(l[0]) == 3 or sum(l[1])==3 or sum(l[2])==3:
        return 1
    else:
        if l[0][0]+l[1][0]+l[2][0] == 3:
            return 1
        elif l[0][1]+l[1][1]+l[2][1] == 3:
            return 1
        elif l[0][2]+l[1][2]+l[2][2] == 3:
            return 1
        else:
            if l[0][0]+l[1][1]+l[2][2] == 3:
                return 1
            elif l[0][2]+l[1][1]+l[2][0] == 3:
                return 1
            else:
                return 0

A1 = [int(i) for i in input().split(' ')]
A2 = [int(i) for i in input().split(' ')]
A3 = [int(i) for i in input().split(' ')]
N = int(input())
bs = []
for n in range(N):
    bs.append(int(input()))

dic = {}
for i,a in enumerate(A1):
    dic[a] = (0,i)
for i,a in enumerate(A2):
    dic[a] = (1,i)
for i,a in enumerate(A3):
    dic[a] = (2,i)

l = [[0,0,0],[0,0,0],[0,0,0]]
for b in bs:
    if b in dic:
        index = dic[b]
        l[index[0]][index[1]] = 1

if judge(l) == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 62240
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long int;
//typedef pair<int,int> P;

int main(void){
	int a;
	for(int s=0;s<5;s++){
		cin >> a;
		if(a==0){

			a=s+1;
			cout <<a;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int h,w;

  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0)
      return 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}



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

#define _ << " _ " <<
#define TRACE(x) cout << #x << " = " << x << endl

set<string> s;
string a;
int k;

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

    cin >> a;
    cin >> k;

    for (int i = 0; i < a.length(); i++) {
        for (int j = 1; j <= 5; j++)
            s.insert(a.substr(i, j));
    }

    for (int i = 0; i < k - 1; i++) {
        string b = *s.begin();
        s.erase(b);
    }

    cout << *s.begin();

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll N;
    cin >> N;
    cout << N*(N-1)/2;
    


}

/*



 */



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える




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

    ll ans = 0;

    map<char, ll> rgb_map;
    rep(i, n){
        if(s[i] == 'R') rgb_map['R']++;
        else if(s[i] == 'G') rgb_map['G']++;
        else if(s[i] == 'B') rgb_map['B']++;
    }

    //とりあえずr,g,bの個数の積を保存
    ans += rgb_map['R'] * rgb_map['G'] * rgb_map['B'];

    //これからj-i == k-j かつ3文字が異なるモノを引いてゆく
    for(int i=0; i<(n-2); ++i) for(int j=i+1; j<=(n-2); ++j){

        int k = 2*j - i;
        
        if(k >= n) break;

        else if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
//void _(){
//    int n,d;
//    cin >> n >> d;
//    vl dist(n+1);
//    dist[0] = d;
//    vi arr(n);
//    cin >> arr;
//    rep(i,0,n-1)
//        if(arr[i] <= dist[i])
//            dist[i+1] = dist[i]-arr[i];
//        else
//            dist[i+1] = min(arr[i]-dist[i],dist[i]);
//    ll reach = 0;
//    vi ans(n);
//    for(int i = n-1; i >= 0; --i){
//        if(dist[i] > reach)
//            ans[i] = true;
//        if(arr[i]/2 <= reach)
//            reach += arr[i];
//    }
//    int q;
//    cin >> q;
//    while(q--){
//        int i;
//        cin >> i;
//        if(ans[i-1])
//            print("YES");
//        else
//            print("NO");
//    }
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    int n,d;
    cin >> n >> d;
    vl dist(n+1);
    dist[0] = d;
    vi arr(n);
    cin >> arr;
    rep(i,0,n-1)
        if(arr[i] <= dist[i])
            dist[i+1] = dist[i]-arr[i];
        else
            dist[i+1] = min(arr[i]-dist[i],dist[i]);
    ll reach = 0;
    vi ans(n);
    for(int i = n-1; i >= 0; --i){
        if(dist[i] > reach)
            ans[i] = true;
        if(arr[i]/2 <= reach)
            reach += arr[i];
    }
    int q;
    cin >> q;
    while(q--){
        int i;
        cin >> i;
        if(ans[i-1])
            print("YES");
        else
            print("NO");
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


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

using namespace std;

typedef long long ll;

struct triple {
    string s;
    int x, i;
};

bool operator < (const triple &a, const triple &b) {
    if (a.s == b.s) {
        if (a.x == b.x) {
            return a.i < b.i;
        }
        return a.x > b.x;
    }
    return a.s < b.s;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <triple> t;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int x;
        cin >> x;
        t.push_back({s, x, i + 1});
    }
    sort(t.begin(), t.end());
    for (auto to : t) {
        cout << to.i << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by paz on 17-3-18.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        long sum = 0;
        for(int i = 1; ;i++) {
            sum += i;
            if(sum >= x) {
                System.out.print(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N; cin >> N;
	queue<int> q;
	for (int i = 0; i < N; i++) {
		int a; cin >> a; q.push(a);
	}

	int ans = 0;

	while (q.size()) {
		int f = q.front();
		q.pop();
		int count = 1;
		while (q.front() == f) {
			q.pop();
			count++;
		}
		ans += count / 2;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int kind=26;
const int INF=1e9;
const int max_queries=5e4;

int main(){
	int D;
	cin >> D;
	vector<int> c(kind);
	rep(i,kind) cin >> c[i];
	int c_sum=0;
	rep(i,kind) c_sum+=c[i];
	vector<vector<int>> s(D,vector<int>(kind));
	rep(i,D){
		rep(j,kind) cin >> s[i][j];
	}
	vector<int> t(D), max_score(D,-INF);
	vector<int> last(kind);
	int dec=0;
	for(int day=1; day<=D; day++){
		int k=-1;
		dec+=c_sum;
		rep(i,kind){
			int res=s[day-1][i];
			res-=dec;
			res+=c[i]*(day-last[i]);
			if(res>max_score[day-1]){
				max_score[day-1]=res;
				k=i;
			}
		}
		dec-=c[k]*last[k];
		last[k]=day;
		t[day-1]=k;
	}
	/*
	vector<set<int>> hold(kind);
	rep(i,kind) hold[i].insert(0);
	rep(i,D) hold[t[i]].insert(i+1);
	*/
	int M=max_queries;
	vector<int> d(M), q(M);
	q[0]=1;
	vector<int> t_new(D);
	rep(i,D) t_new[i]=t[i];
	int fin_score=0;
	rep(i,M){
		int ch_ans=0, ch_dec=0;
		vector<int> ch_last(kind);
		set<P> change;	
		t_new[d[i]]=q[i];
		for(int day=1; day<=D; day++){
			int k=t_new[day-1];
			ch_ans+=s[day-1][k];
			ch_dec+=c_sum;
			ch_ans-=ch_dec;
			ch_ans+=c[k]*(day-ch_last[k]);
			ch_dec-=c[k]*(day-ch_last[k]);
			int tot=s[day-1][k]-ch_dec+c[k]*(day-ch_last[k]);
			change.insert(P(tot,day));
			ch_last[k]=day;
		}
		if(fin_score>=ch_ans){
			t_new[d[i]]=t[d[i]];
		}
		else{
			fin_score=ch_ans;
			/*
			hold[t[d[i]]].erase(d[i]+1);
			hold[q[i]].insert(d[i]+1);
			*/
		}
		if(i!=M-1){
			auto itr=change.begin();
			int r=rand()%20, plus=0;
			if(r<=10) plus=0;
			else if (r<=15) plus=1;
			else if (r<=17) plus=2;
			else if (r<=18) plus=3;
			else plus=4;
			rep(j,plus) itr++;
			d[i+1]=(itr->second)-1;
			/*
			int res=-INF, n=-1;
			rep(j,kind){
				auto itr=hold[j].upper_bound(d[i+1]);
				itr--;
				int prev=*itr;
				int dif=c[j]*((d[i+1]+1)-prev);
				if(res<dif){
					res=dif;
					n=j;
				}
			}
			q[i+1]=n;
			*/
			q[i+1]=rand()%26;
		}
	}
	rep(i,D) cout << t_new[i]+1 << endl;

	return 0;
}

Measured memory_bytes: 3732
#include <iostream>

int main() {
  int a, b;
  std::cin >> a >> b;
  int ans = -1;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    ans = a * b; 
  }
  std::cout << ans << std::endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 110,  MAXH = 110;

int main()
{
    int n, w, h, x, y, s, t;

    while(cin >> n && n)
    {
        int tile[MAXW][MAXH] = {}, dp[MAXW][MAXH] = {};
        cin >> w >> h;
        REP(n)
        {
            cin >> x >> y;
            tile[x - 1][y - 1] = 1;
        }

        int ans = 0;
        cin >> s >> t;
        rep(j, t)rep(i,s)dp[0][0] += tile[i][j];
        rep(j, h - t + 1)
        {
            rep(i, w - s + 1)
            {
                dp[i+1][j] = dp[i][j];
                rep(k, t) dp[i+1][j] -= tile[i][j + k];
                rep(k, t) dp[i+1][j] += tile[i + s][j + k];
            }
            dp[0][j + 1] = dp[0][j];
            rep(k, s) dp[0][j + 1] -= tile[k][j];
            rep(k, s) dp[0][j + 1] += tile[k][j + t];
        }

        rep(j, h - t + 1)rep(i, w - s + 1) ans = max(ans, dp[i][j]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int h,w,k;
    cin >> h >> w >> k;
    int sq[h][w];
    
    for (int i=0;i<=h-1;i++)
    {
        for (int j=0;j<=w-1;j++)
        {
            char a;
            cin >> a;
            if (a=='.')
            {
                sq[i][j]=0; // white
            }
            else
            {
                sq[i][j]=1; // black
            }
        }
    }

    int ans=0;
    for (int x=0;x<=pow(2,h)-1;x++)
    {
        for (int y=0;y<=pow(2,w)-1;y++)
        {
            int arr[h][w];
            for (int i=0;i<=h-1;i++)
            {
                for (int j=0;j<=w-1;j++)
                {
                    arr[i][j]=sq[i][j];
                }
            }

            bitset<8> alpha=x;
            bitset<8> beta=y;
            
            for (int i=0;i<=h-1;i++)
            {
                if (alpha[i]==1)
                {
                    for (int j=0;j<=w-1;j++)
                    {
                        arr[i][j]=2; // red
                    }
                }
            }

            for (int i=0;i<=w-1;i++)
            {
                if (beta[i]==1)
                {
                    for (int j=0;j<=h-1;j++)
                    {
                        arr[j][i]=2; //red
                    }
                }
            }

            int count=0;
            for (int i=0;i<=h-1;i++)
            {
                for (int j=0;j<=w-1;j++)
                {
                    if (arr[i][j]==1)
                    {
                        count++;
                    }
                }
            }

            // cout << "-----------------------" << endl;
            // cout << "alpha= " << alpha << endl;
            // cout << "beta= " << beta << endl;
            // cout << "count= " << count << endl;

            // for (int i=0;i<=h-1;i++)
            // {
            //     for (int j=0;j<=w-1;j++)
            //     {
            //         cout << arr[i][j] << " ";
            //     }
            //     cout << endl;
            // }
            // cout << "-----------------------" << endl;

            if (count==k)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4072
# Union-Find木（サイズ付き）
class UnionFind():
    # 初めは全ての頂点が別々の木の根
    def __init__(self, n):  # n要素で初期化
        self.parent = [None] * n # 親
        self.rank = [None] * n   # 木の深さ
        self._size = [1] * n # 要素が属する集合の大きさ（根の要素のみ参照すること）
        for i in range(n):
            self.parent[i] = i
            self.rank[i] = 0

    # 木の根を求める
    def root_of(self, x):
        children = [x]
        while self.parent[x] != x:
            x = self.parent[x]
            children.append(x)

        for ch in children:
            self.parent[ch] = x

        return x

    # xとyの属する集合を併合
    def unite(self, x, y):
        rx = self.root_of(x)
        ry = self.root_of(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]: # ランクの小さい木から大きい木の根に辺を張る
            self.parent[rx] = ry  # rxをryの子とする
            self._size[ry] += self._size[rx]
        else:
            self.parent[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するかどうか
    def is_same(self, x, y):
        return self.root_of(x) == self.root_of(y)

    # 頂点xが属する集合のサイズ
    def size(self, x):
        return self._size[self.root_of(x)]


# 入力
N, M, K = [int(x) for x in input().split()]

Ef = [[int(x) - 1 for x in input().split()] for _ in range(M)]
Eb = [[int(x) - 1 for x in input().split()] for _ in range(K)]

ans = [0] * N
uf = UnionFind(N)
for i in range(M):
    uf.unite(Ef[i][0], Ef[i][1])
    ans[Ef[i][0]] -= 1  # すでに友達なら友達候補ではない
    ans[Ef[i][1]] -= 1

for i in range(K):
    if uf.is_same(Eb[i][0], Eb[i][1]):
        ans[Eb[i][0]] -= 1  # ブロックしているなら友達候補ではない
        ans[Eb[i][1]] -= 1

for i in range(N):
    ans[i] += uf.size(i) - 1

print(" ".join([str(i) for i in ans]))


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p )
{
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v )
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu ()
{
    cerr << endl;
}

template <typename T>
void faltu( T a[], int n )
{
    for(int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


int gcd(int a,int b)
{
    return b ? gcd(b,a%b) : a;
}
int lcm(int a,int b)
{
    return (a*( b/ gcd(a,b)));
}

void f()
{
    ll a[6],mn=INT_MAX,sum;
    for(int i=0; i<5; i++)
    {
        cin>>a[i];
    }
    do
    {
        sum=a[0];
        for(int i=1; i<5; i++)
        {
            if(sum%10!=0)
                sum=ceil(sum/10.0)*10;
            sum+=a[i];
        }
        mn=min(mn,sum);
    }
    while(next_permutation(a,a+5));

    cout<<mn<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3604
n, m = gets.split.map(&:to_i)
abs = []
m.times do
  abs << gets.split.map(&:to_i)
end

abs.sort!{|a,b| a[1] <=> b[1]}

ans = 1
current = abs[0][1]
abs.each do |ab|
  if ab[0] >= current
    ans += 1
    current = ab[1]
  end
end

puts ans


Measured memory_bytes: 10488
import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p+=[i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2]]
for e in sys.stdin:print(p[int(e)])


Measured memory_bytes: 50424
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int h,w,n;cin >> h>>w>>n;
	int x = max(h,w);
	int i = 1;
	while(i * x< n){
		i++;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    pair<long long int,long long int> work[n];
    for(int i=0;i<n;i++){
        cin>>work[i].second>>work[i].first;
    }
    sort(work,work+n);
    long long int time=0;
    for(int i=0;i<n;i++){
        time=time+work[i].second;
        if(time>work[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<stack>
#include<sstream>
#include<string>
#include<cassert>
#include<ctime>
#include<functional>
#include<deque>
#include<bitset>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
int kase = 0;
int n, m;
const int maxn = 5e5 + 10;
set<int> s;

int main()
{
	int now = 1, fir = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		if (fir)
		{
			printf("No\n");
			continue;
		}
		else if(x == now - 1 && s.size() == now - 1)
		{
			fir = 1;
			printf("Yes\n");
		}
		else if (x < now)  printf("No\n");
		else
		{
			while (s.find(x) != s.end())
			{
				s.erase(x);
				x--;
			}
			s.insert(x);
			while (s.find(now) != s.end()) now++;
			printf("Yes\n");
		}
	}
}

Measured memory_bytes: 14776
import java.util.*;
public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
      long a = sc.nextInt();
      long b = sc.nextInt();
      long c = sc.nextInt();
      long d = sc.nextInt();
      //int x = 0;
      //int y = 0;

      //ansが負になることを考えて、想定される最低値を設定
      //int型の最大値を超えるためlongを使用※末尾にLをつける
      long calc = 0;
      long ans = -1000000000000000000L; 


    //パターン１、全てのXとYのパターンを試して最大値を比較して更新する
    /*  for (int x = a; x <= b; x++) {
        for (int y = c; y <= d; y++) {
            calc = x*y;
            if(calc>=ans){
                ans = calc;
            }
        }
      }
      */
    
      //パターン２、プラス同士やマイナス同士を優先するやり方
      //絶対値取得 Math.abs(i);
    if(a>=0){
        if(c>=0){
        //全て正の範囲同士
        ans = b*d;
        }else if(c<0){
            if(d>=0){
            //xが正、yが正負あり得る
            ans = b*d;
            }else if(d<0){
            //xが正、yが負
            ans = a*d;     
            }         
        }
    }else if(a<0){
        if(b>=0){
            //xが正負あり得る、bが最大
            if(c>=0){
                //xが正負ありえる、yが正
                ans = b*d;
            }else if(c<0){
                if(d>=0){
                    //xが正負ありえる、yが正負あり得る
                    ans = a*c;
                    calc = b*d;
                    if(ans<calc){
                        ans = calc;
                    }
                }else if(d<0){
                //xが正負ありえる、yが負
                    ans = a*c;     
                }         
            }
        }else if(b<0){
            if(c>=0){
            //xが負、yが正
            ans = b*c;
            }else if(c<0){
                if(d>=0){
                //xが負、yが正負あり得る
                ans = a*c;
                }else if(d<0){
                //xが負、yが負
                ans = a*c;     
                }         
            }
        }
    }
    
      System.out.println(ans);   
  }
}

Measured memory_bytes: 35640
def isPrime( x )
	return true if ( 2 == x || 3 == x )
	return false if ( 0 == x%2 )
	
	for i in ( 3 .. x )
		break if x < i*i
		return false if 0 == x%i
	end
	
	return true
end

n = gets.to_i
cnt = 0
n.times {
	num = gets.to_i
	if isPrime( num )
		cnt += 1
	end	
}
puts( cnt )

Measured memory_bytes: 6096
#include <stdio.h>

int gcd(int m, int n) {
  if (m < n) {
    int tmp = m;
    m = n;
    n = tmp;
  }

  do {
    int r = m % n;
    m = n;
    n = r;
  } while (n > 0);
  
  return m;
}

int main(void) {
  int m,n;
  
  scanf("%d %d", &m, &n);

  printf("%d\n", gcd(m,n));

  return 0;

}

Measured memory_bytes: 592
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 15
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

ans = [0] * n
q = I()
Q = LIR(q)
dq = deque()
depth = [-1] * n
for v, d, c in Q[::-1]:
    if depth[v - 1] >= d:
        continue
    if ans[v - 1] == 0:
        ans[v - 1] = c
    depth[v - 1] = d
    if d:
        dq += [v - 1]
    while dq:
        u = dq.popleft()
        for x in G[u]:
            if ans[x] == 0:
                ans[x] = c
            if depth[x] >= depth[u] - 1:
                continue
            depth[x] = depth[u] - 1
            if depth[x]:
                dq += [x]

print(*ans, sep="\n")


Measured memory_bytes: 90144
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int INF=1<<30;

struct edge{
  int to,id;
};
vector<vector<edge> > g;
vector<int> ans;

void dfs(int v,int p=-1,int c=-1){
  int k=1;
  rep(i,g[v].size()){
    int nv=g[v][i].to;
    int ei=g[v][i].id;
    if(nv==p) continue;
    if(k==c) k++;
    ans[ei]=k;
    dfs(nv,v,k);
    k++;
  }
}

int main(){
  int N; cin >> N;
  g.resize(N,vector<edge>(0));
  ans.resize(N-1);
  vector<int> a(N);
  vector<int> b(N);
  rep(i,N-1){
    int x,y;
    cin >> x >> y;
    x--; y--;
    g[x].push_back(edge{y,i});
    g[y].push_back(edge{x,i});
  }
  dfs(0);
  int mx=0;
  rep(i,N-1){
    chmax(mx,int(g[i].size()));
  }
  cout << mx << endl;
  rep(i,N-1){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 8832