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

object Main extends App {
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val al = List.fill(n)(sc.nextInt)

  val colourType = al.foldLeft((0,0,0,0,0,0,0,0,0)){case ((gray, brouwn, green,lightBlue, blue, yellow, orange, red, free),a) =>
      a match{
        case x if    1 <= x && x <=  399 => (gray + 1, brouwn   , green   ,lightBlue   , blue   , yellow   , orange   , red    , free    )
        case x if  400 <= x && x <=  799 => (gray    , brouwn+ 1, green   ,lightBlue   , blue   , yellow   , orange   , red    , free    )
        case x if  800 <= x && x <= 1199 => (gray    , brouwn   , green+ 1,lightBlue   , blue   , yellow   , orange   , red    , free    )
        case x if 1200 <= x && x <= 1599 => (gray    , brouwn   , green   ,lightBlue+ 1, blue   , yellow   , orange   , red    , free    )
        case x if 1600 <= x && x <= 1999 => (gray    , brouwn   , green   ,lightBlue   , blue+ 1, yellow   , orange   , red    , free    )
        case x if 2000 <= x && x <= 2399 => (gray    , brouwn   , green   ,lightBlue   , blue   , yellow+ 1, orange   , red    , free    )
        case x if 2400 <= x && x <= 2799 => (gray    , brouwn   , green   ,lightBlue   , blue   , yellow   , orange+ 1, red    , free    )
        case x if 2800 <= x && x <= 3199 => (gray    , brouwn   , green   ,lightBlue   , blue   , yellow   , orange   , red + 1, free    )
        case _                           => (gray    , brouwn   , green   ,lightBlue   , blue   , yellow   , orange   , red    , free + 1)
      }
  }

  val (gray, brouwn, green,lightBlue, blue, yellow, orange, red, free) = colourType

  val diffinedCol =
    (if(gray > 0) 1 else 0) +
    (if(brouwn > 0) 1 else 0) +
    (if(green > 0) 1 else 0) +
    (if(lightBlue > 0) 1 else 0) +
    (if(blue > 0) 1 else 0) +
    (if(yellow > 0) 1 else 0) +
    (if(orange > 0) 1 else 0) +
    (if(red > 0) 1 else 0)

  val max = diffinedCol + free
  val min = if(diffinedCol == 0) 1 else diffinedCol

  println(s"$min $max")
}

Measured memory_bytes: 25516
object Main extends App {
  val in1 = io.StdIn.readLine.split(' ').map(_.toInt)

  val N = in1(0)
  val M = in1(1)
  val C = in1(2)

  val B = io.StdIn.readLine.split(' ').map(_.toInt)

  val As = for (i <- 1 to N) yield io.StdIn.readLine.split(' ').map(_.toInt)

  val out = As.count{ a =>
    (0 until a.size).map(i => a(i)*B(i)).sum + C > 0
  }

  println(out)
}



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

int main()
{
    string s; cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**8)

n = int(input())
edge = [[] for i in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append((b-1,i))
    edge[b-1].append((a-1,i))

k = max(len(e) for e in edge)
print(k)

ans = [-1]*(n-1)

def dfs(v=0, p=-1, to_p_col = -1):
    col = 1
    for u, idx in edge[v]:
        if u != p:
            if col == to_p_col:
                col += 1
            ans[idx] = col
            dfs(u, v, col)
            col += 1
dfs()
print('\n'.join(map(str,ans)))



Measured memory_bytes: 85688
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto s = readln().chomp();
    if(!s.canFind('C') || !s.canFind('F')) {
        writeln("No");
        return;
    }
    ulong ci, fi;
    foreach(i; iota(s.length)) {
        if(s[i] == 'F') {
            fi = i;
        }
    }
    foreach_reverse(i; iota(s.length)) {
        if(s[i] == 'C') {
            ci = i;
        }
    }
    writeln(ci < fi ? "Yes": "No");
}



Measured memory_bytes: 256
n, k = gets.strip.split.map(&:to_i)
xs = gets.strip.split.map(&:to_i)

rs = xs.sort.each_cons(2).map{|x| x[1] - x[0]}.sort
if k-n < 0 then
  puts 0
else
  p rs[0...(k-n)].inject(:+) || 0
end


Measured memory_bytes: 14704
#include <bits/stdc++.h>
using namespace std;
int main () {
    int ans = 0;
    int N;
    cin >> N;
    for (int i = 1; i <= N; i+=2) {
        int k = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                k++;
            }
        }
        if (k == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<set>
using namespace std;
string S;
set<string>st;
set<string>::iterator it;

int main()
{
    string S; int k;
    while(cin >> S >> k){
    int n = S.length();
    for(int i = 0; i  < n; i++){
        for(int j = 0; i + j < n && j < k; j++){
            string substr1 = S.substr(i, j + 1);
            st.insert(substr1);
        }
    }
    int id = 1;
    it = st.begin();
    while(id < k){
        it++;
        id++;
    }

     printf("%s\n",(*it).c_str());
    }

    return 0;
}


Measured memory_bytes: 1664
N=int(input())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]
sat=0

for i in range(N):
    sat+=B[A[i]-1]
    if i!=0 and A[i]==A[i-1]+1:
        sat+=C[A[i-1]-1]

print(sat)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll n, h;

int main() {
    cin >> n >> h;
    V<Pll> x(n);
    ll maxA = -1;
    REP(i, n) {
        ll a, b; cin >> a >> b;
        x[i] = {b, a};
        maxA = max(a, maxA);
    }

    sort(ALL(x), greater<Pii>());

    ll cnt = 0;
    REP(i, n) {
        if (x[i].first <= maxA) break;
        cnt++;
        h -= x[i].first;
        if (h <= 0) {
            cout << cnt << '\n';
            return 0;
        }
    }

    cout << cnt + (h+maxA-1)/maxA << '\n';

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class UF{
	public int[] a;
	public UF(int size){
		Arrays.fill(a=new int[size],-1);
	}
	public int root(int t){
		return a[t]<0?t:(a[t]=root(a[t]));
	}
	public boolean connect(int p,int q){
		int r=root(p);
		int s=root(q);
		if(r==s)
			return false;
		if(a[r]>a[s]){
			a[s]+=a[r];
			a[r]=s;
		}else{
			a[r]+=a[s];
			a[s]=r;
		}
		return true;
	}
	public boolean isConnected(int a,int b){
		return root(a)==root(b);
	}
	public int groupSize(int t){
		return -a[root(t)];
	}
}

public class Main{
	public static void main(String[] $){
		var s=new Scanner(System.in);

		var n=s.nextInt();
		var q=s.nextInt();

		var uf=new UF(n);

		for(int i=0;i<q;++i)
			if(s.nextInt()==0)
				uf.connect(s.nextInt(),s.nextInt());
			else
				System.out.println(uf.isConnected(s.nextInt(),s.nextInt())?1:0);
	}
}


Measured memory_bytes: 66328
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int n, m;
int v[3] = {-1, -1, -1};

int32_t main(){
    cin >> n >> m;

    REP(i, n+1){
        REP(j, n+1){
            if(i+j>n) continue;

            int k = n-(i+j);
            if(10000*i+5000*j+1000*k == m){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define whyqx
#define N 10
#define ll long long
using namespace std;
ll n,a[N],i,j,k,ans,max1;
int main(){ 
    scanf("%d", &n);
    for(i=1;i<=6;i++)
        cin>>a[i];
    if(a[1]<=a[4]&&a[2]>=a[5]&&a[3]>=a[6]){
        n=n/a[1]*a[4]+n%a[1];
        for(i=0;i<=n;i++){
            j=n-i;
            max1=max(max1,i%a[5]+j%a[6]+i/a[5]*a[2]+j/a[6]*a[3]);
        }
    }
    else if(a[1]>=a[4]&&a[2]<=a[5]&&a[3]>=a[6]){
        n=n/a[2]*a[5]+n%a[2];
        for(i=0;i<=n;i++){
            j=n-i;
            max1=max(max1,i%a[4]+j%a[6]+i/a[4]*a[1]+j/a[6]*a[3]);
        }
    }
    else if(a[1]>=a[4]&&a[2]>=a[5]&&a[3]<=a[6]){
        n=n/a[3]*a[6]+n%a[3];
        for(i=0;i<=n;i++){
            j=n-i;
            max1=max(max1,i%a[4]+j%a[5]+i/a[4]*a[1]+j/a[5]*a[2]);
        }
    }
    else if(a[1]<=a[4]&&a[2]<=a[5]&&a[3]<=a[6]||a[1]>=a[4]&&a[2]>=a[5]&&a[3]>=a[6]){
        for(i=0;i<=n;i++)
            for(j=0;i+j<=n;j++){
                k=n-i-j;
                ans=max(i/a[1]*a[4]+i%a[1],i/a[4]*a[1]+i%a[4])+
                    max(j/a[2]*a[5]+j%a[2],j/a[5]*a[2]+j%a[5])+
                    max(k/a[3]*a[6]+k%a[3],k/a[6]*a[3]+k%a[6]);
                max1=max(max1,ans);
            }
    }
    else if(a[1]>=a[4]){
        for(i=0;i<=n;i++){
            j=n-i;
            max1=max(max1,i%a[2]+j%a[3]+i/a[2]*a[5]+j/a[3]*a[6]);
        }
        max1=max1/a[4]*a[1]+max1%a[4];
    }
    else if(a[2]>=a[5]){
        for(i=0;i<=n;i++){
            j=n-i;
            max1=max(max1,i%a[1]+j%a[3]+i/a[1]*a[4]+j/a[3]*a[6]);
        }
        max1=max1/a[5]*a[2]+max1%a[5];
    }
    else{
        for(i=0;i<=n;i++){
            j=n-i;
            max1=max(max1,i%a[1]+j%a[2]+i/a[1]*a[4]+j/a[2]*a[5]);
        }
        max1=max1/a[6]*a[3]+max1%a[6];
    }
    cout<<max1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N, M;
    cin >> N >> M;
    vector<int> box(N, 1), prob(N, 0);
    prob[0] = 1;
    REP(i, M){
        int x, y;
        cin >> x >> y;
        x--; y--;
        if(box[y] == 0) prob[y] = prob[x];
        else if(prob[x] == 1) prob[y] = 1;
        box[x]--;
        box[y]++;
    }
    int ans = 0;
    REP(i, N){
        //cout << box[i] << " " << prob[i] << "\n";
        if(box[i] != 0 && prob[i] == 1) ans++;
    }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[N],f[N],fa[N],x[N],y[N];
vector<int>e[N];
long long ans;
struct yb
{
	int u,x,y;
	yb(){}
	yb(int _u,int _x,int _y):u(_u),x(_x),y(_y){}
	bool operator<(const yb k)const
	{
		return (((long long)k.x*y==(long long)x*k.y)?(u<k.u):((long long)k.x*y<(long long)x*k.y));
	}
};
set<yb>s;
int get(int x){return x==fa[x]?x:fa[x]=get(fa[x]);}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&f[i]);
		e[f[i]].push_back(i);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		(a[i]?y[i]:x[i])=1;
		s.insert(yb(i,x[i],y[i]));
		fa[i]=i;
	}
	for(int i=1;i<=n;i++)
	{
		auto it=s.begin();
		int u=it->u;
		s.erase(s.begin());
		int p=get(f[u]);
		if(p)
			s.erase(yb(p,x[p],y[p]));
		ans+=(long long)y[p]*x[u];
		x[p]+=x[u],y[p]+=y[u];
		if(p)
			s.insert(yb(p,x[p],y[p]));
		fa[u]=p;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 31160
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long w = sc.nextLong();
        long h = sc.nextLong();
        long x = sc.nextLong();
        long y = sc.nextLong();

        double ans = 0.5 * w * h;

        StringBuilder builder = new StringBuilder(String.valueOf(ans));
        int flag = 0.5 * w == x && 0.5 * h == y ? 1 : 0;
        builder.append(" " + flag);

        System.out.println(builder);
    }
}

Measured memory_bytes: 21716
package main

import (
	"fmt"
	"strings"
)

func main() {
	var sa, sb, sc string
	fmt.Scan(&sa)
	fmt.Scan(&sb)
	fmt.Scan(&sc)
	num := len(sa + sb + sc)
	// fmt.Printf("sa = %s, sb = %s, sc = %s, num = %d\n", sa, sb, sc, num)

	var player string
	var ia, ib, ic int

	player = sa[0:1]
	ia++

	for i := 1; i < num; i++ {
		// fmt.Printf("player = %s, ia = %d, ib = %d, ic = %d\n", player, ia, ib, ic)
		if player == "a" {
			if ia >= len(sa) {
				break
			}
			player = sa[ia : ia+1]
			ia++
		} else if player == "b" {
			if ib >= len(sb) {
				break
			}
			player = sb[ib : ib+1]
			ib++
		} else if player == "c" {
			if ic >= len(sc) {
				break
			}
			player = sc[ic : ic+1]
			ic++
		}
	}
	fmt.Println(strings.ToUpper(player))
}


Measured memory_bytes: 640
// https://github.com/atcoder-live/library
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> void inarr(int s,int e,T &v){rp(i,s,e)cin>>v[i];}
// inarr<vi>(0,N,V);
#define NMAX 100000
int N,M;
string S, T;
vi V(NMAX);

string solve(){
	return N==M?"Yes":"No";
}

int main(){
	// N = in<int>();
	// S = in<string>();
	cin>>N;
	cin>>M;
	// cin>>S;
	// rpz(i,N){
	// 	cin>>V[i];
	// }
	ote(solve());
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int len = s.size();
    cout << string(len, 'x') << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);}

using namespace std;

int main(){

    int n,a,b;
    cin >> n >> a >> b;

    cout << min(a * n,b) << endl;
    
    return 0;
}

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

int main()
{
	string s;

	cin >> s;

	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  double a, b;
  while(scanf("%lf%lf", &a, &b) != EOF){
    if(a < 35.5 && b < 71.0) puts("AAA");
    else if(a < 37.5 && b < 77.0) puts("AA");
    else if(a < 40.0 && b < 83.0) puts("A");
    else if(a < 43.0 && b < 89.0) puts("B");
    else if(a < 50.0 && b < 105.0) puts("C");
    else if(a < 55.0 && b < 116.0) puts("D");
    else if(a < 70.0 && b < 148.0) puts("E");
    else puts("NA");
  }
  return 0;
}

Measured memory_bytes: 608
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]


h, n = na()
a = na()

print("Yes" if sum(a) >= h else "No")

Measured memory_bytes: 14544
#include<bits/stdc++.h>
using namespace std;
 
#define sz(x) (int)(x).size()
 
int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
   string s;
   int k,i,j,sz1,x,mov;
 
   cin>>s>>k;
 
   sz1=sz(s);
 
   for(i=0;i<sz1;i++)
    {
        if(i==sz1-1)
        {
            if(s[i]+k > 'z')
            {
                k-=('z'-s[i])+1;
 
                k=k%26;
 
                s[i]='a'+k;
            }
            else
                s[i]+=k;
        }
        else if (s[i] != 'a')
        {
            mov='z'-s[i]+1;
 
           // cout<<mov<<endl;
 
            if(k<mov)
                continue;
            else
            {
                k-=mov;
                s[i]='a';
            }
 
        }
 
    }
 
 
    cout<<s<<endl;
 
    return 0;
}

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

using namespace std;

const int N = 3e5 + 7;

long long a[N];

int main() {
	long long n; cin >> n;
	for(int i = 0; i < n*3;i++){
		cin >> a[i];
	}
	sort(a, a + n * 3);
	unsigned long long ans = 0;
	long long k = 1;
	for(int i = 0;i < n;i++){
		ans += a[n*3-k-1];
		k += 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
import sys
from collections import deque
from heapq import heapify, heappop, heappush

def decide_next_dst(cost, order):
    d = 0
    c = 0
    for key in order:
        if cost[key] > c:
            d = key
            c = cost[key]
    return (d, c)

def solve():
    inf = 10000000000
    input = sys.stdin.readline
    
    V, E = map(int, input().split())
    edge = dict()
    wf = dict()
    next_id = dict() #iからjに行くときにiの次に訪れる地点
    for i in range(V):
        edge[i] = dict()
        wf[i] = dict()
        next_id[i] = dict()
        for j in range(V):
            edge[i][j] = (0 if i == j else inf)
            next_id[i][j] = j
            wf[i][j] = (0 if i == j else inf)

    for _ in range(E):
        u, v, d = map(int, input().split())
        edge[u - 1][v - 1] = d
        edge[v - 1][u - 1] = d
        wf[u - 1][v - 1] = d
        wf[v - 1][u - 1] = d

    #全頂点最短経路と目的の頂点に向かうとき次に行くべき頂点の復元
    for k in range(V): 
        for i in range(V):
            for j in range(V):
                if wf[i][j] > wf[i][k] + wf[k][j]:
                    wf[i][j] = wf[i][k] + wf[k][j]
                    next_id[i][j] = next_id[i][k] 

    T = int(input())
    order = set()
    stuck_order = set()

    command = [None] * T
    heading = 0 #次に向かう地点
    dist_left = 0 #次に向かう地点までの残り距離
    final_dist = 0
    stuck_cost = [0 for _ in range(V)] 
    cost = [0 for _ in range(V)] 
    driver_hold = 0
    store_hold = 0

    for t in range(T):
        N = int(input()) #注文の発生
        if N == 1:
            new_id, dst = map(int, input().split())
            stuck_order |= {dst - 1}
            stuck_cost[dst - 1] += 1
            store_hold += 1

        if dist_left > 0: #移動中の場合そのまま移動を続ける
            command[t] = heading + 1
            dist_left -= 1
        
        else:
            if heading == 0: #店にいるときの処理
                if store_hold == driver_hold == 0: 
                    command[t] = -1
                    continue
                else:
                    order |= stuck_order
                    for key in order: 
                        cost[key] += stuck_cost[key]
                        stuck_cost[key] = 0
                    driver_hold = sum(cost)
                    stuck_order = set()
                    store_hold = 0
        
            if heading in order and heading > 0: #顧客のいる場所で荷物を積み下ろすとき
                order -= {heading} 
                driver_hold -= cost[heading]
                cost[heading] = 0

            current_id = heading #現在地の更新
            if len(order) > 0: #まだ配達すべき荷物があるとき
                if current_id == final_dist: #目的地に到着したときは残りの荷物で先に運ぶべき荷物を選ぶ
                    final_dist, max_hold = decide_next_dst(cost, order)
                    if driver_hold < store_hold and current_id > 0 and max_hold == 1: final_dist = 0  
            else: final_dist = 0 #荷物が無いので店に戻る
                
            heading = next_id[current_id][final_dist]
            dist_left = edge[current_id][heading] - 1
            command[t] = heading + 1

    for i in range(T): print(command[i])


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 36344
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;




int main(){
      //memset( par, -1, sizeof par );
    int n;
    cin>>n;
    string s;
    cin>>s;
    char x=s[0];
    ll cnt=1;
    for(int i=1;i<n;i++){
            if(s[i]!=s[i-1]){
                    cnt++;
            }
    }
    cout<<cnt;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int N, i, sign, margin, a[101], b[101]; // b is how many times the number has appeared
	margin = 0;
	for (i=1;i<=100;i++) b[i]=0;
	scanf("%d",&N);
	for (i=1;i<=N;i++){ scanf("%d",&a[i]);
		b[a[i]]=b[a[i]]+1; 
	}
	sign = 1;
	for (i=100;i>=1;i--){
		if (b[i]%2==0) ;
		else{ margin=margin + sign * i;
		sign = sign * (-1);}
	}
	printf("%d",margin);
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

li t[2];
li a[2];
li b[2];

inline li divup(li x, li y) {
    li res = x / y;
    return (x % y == 0 ? res : res + 1);
}
int main() {
    rep(i, 2) {
        cin >> t[i];
    }
    rep(i, 2) {
        cin >> a[i];
    }
    rep(i, 2) {
        cin >> b[i];
    }

    li first_diff = t[0] * a[0] - t[0] * b[0];
    li second_diff = t[1] * a[1] - t[1] * b[1];

    if (first_diff + second_diff == 0) {
        puts("infinity");
        return 0;
    }

    if ((first_diff > 0 && second_diff > 0) ||
            (first_diff < 0 && second_diff < 0)) {
        puts("0");
        return 0;
    }

    if (abs(first_diff) > abs(second_diff)) {
        puts("0");
        return 0;
    }

    if (first_diff < 0) {
        first_diff *= -1;
        second_diff *= -1;
    }

    li res = divup(first_diff, abs(first_diff + second_diff));
    res += first_diff / abs(first_diff + second_diff);
    cout << res << endl;



    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.regex;

void main(){
    auto s = chomp(readln());
    split(s,regex("[ ,.]+")).filter!(a => 3<=a.length&& a.length<=6).join(" ").writeln();;
    }

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    int n;
    cin>>n>>s>>t;
    for(int i = 0;i<n;i++)
    {
        int l = n - i;
        if(s.substr(i,l) == t.substr(0,l))
        {
            cout<<2*n - l;
            return 0;
        }
    }
    cout<<2*n;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

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


/*----------------------------------------------------------------*/
signed main(){

	int n,m;
	cin >> n >> m;

	set<ll> a;
	ll g;
	int cnt = 0;
	rep(i,n){
		ll v;
		cin >> v;
		a.insert(v/2);
		g = v/2;
		if(g > m){
			cout << 0 << endl;
			return 0;
		}
		if(i == 0){
			while(v%2==0){
				cnt++;
				v /= 2;
			}
		}else{
			int cnt2 = 0;
			while(v%2==0){
				cnt2++;
				v /= 2;
			}
			if(cnt != cnt2){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	for(auto x:a){
		g = x/(gcd(g,x))*g;
		if(g > m){
			cout << 0 << endl;
			return 0;
		}
	}

	cout << m/g-(m/g)/2 << endl;
	return 0;


}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc150.contest.atcoder.jp/tasks/abc150_b

Measured memory_bytes: 4992
from heapq import heappush, heappop
import sys


class PriorityQueue:
    def __init__(self):
        self._queue = []

    def push(self, value):
        heappush(self._queue, value)

    def pop(self):
        return heappop(self._queue)

    @property
    def empty(self):
        return not self._queue

    def __len__(self):
        return len(self._queue)

    def __contains__(self, item):
        return item in self._queue


v, e = map(int, input().split())
if v == 1:
    print(0)
    sys.exit()
edge = [[] for _ in range(v)]
for _ in range(e):
    s, t, w = map(int, input().split())
    # 無向グラフ
    edge[s].append((w, t))
    edge[t].append((w, s))

V = set()
pq = PriorityQueue()
weight = 0
V.add(0)
for i in edge[0]:
    pq.push(i)

while True:
    nw, nv = pq.pop()
    if nv in V:
        continue
    else:
        weight += nw
        V.add(nv)
        for i in edge[nv]:
            pq.push(i)

    if len(V) == v:
        break

print(weight)




Measured memory_bytes: 32820
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P2;
#define int ll
struct segtree{
private:
  vector<P> node;
  int siz;
public:
  segtree(int n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,P(17441744174417,0));
  }
  void upd(int pos,int x){
    ll fpos=pos;
    pos+=siz-1;
    node[pos]=P(x,fpos);
    while(pos>0){
      pos=(pos-1)/2;
      node[pos]=min(node[pos*2+1],node[pos*2+2]);
    }
  }
  P get_min(int a,int b,int pos,int l,int r){
    if(a<=l&&r<=b) return node[pos];
    if(r<=a||b<=l) return P(17441744174417,0);
    int mid=(l+r)/2;
    P lb=get_min(a,b,pos*2+1,l,mid);
    P rb=get_min(a,b,pos*2+2,mid,r);
    return min(lb,rb);
  }
  P min_q(int a,int b){
    return get_min(a,b,0,0,siz);
  }
};
P2 mk_P(ll x,ll y,ll z){
  return P2(x,P(y,z));
}
signed main(){
  ll n;
  cin>>n;
  ll am=17441744174417;
  segtree Oseg(n+15),Eseg(n+15);
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(i%2==0) {
      Oseg.upd(i,a);
      am=min(am,a);
    }
    else Eseg.upd(i,a);
  }
  priority_queue<P2,vector<P2>,greater<P2>> pque;
  pque.push(mk_P(am,0,n));
  vector<ll> ans;
  for(int la=0;la<n/2;la++){
    P2 p=pque.top();
    pque.pop();
    ll i=p.second.first,j=p.second.second;
    //cout<<p.first<<" "<<i<<" "<<j<<endl;
    if(i%2==0){
      P lf=Oseg.min_q(i,j);
      ll lidx=lf.second;
      P rf=Eseg.min_q(lidx,j);
      ll ridx=rf.second;
      ans.push_back(lf.first);
      ans.push_back(rf.first);
      Oseg.upd(lidx,17441744174417);
      Eseg.upd(ridx,17441744174417);
      if(lidx-i>0){
        ll min_v=Oseg.min_q(i,lidx).first;
        pque.push(mk_P(min_v,i,lidx));
      }
      if(ridx-lidx>1){
        ll min_v=Eseg.min_q(lidx+1,ridx).first;
        pque.push(mk_P(min_v,lidx+1,ridx));
      }
      if(j-ridx>1){
        ll min_v=Oseg.min_q(ridx+1,j).first;
        pque.push(mk_P(min_v,ridx+1,j));
      }
    }
    else{
      P lf=Eseg.min_q(i,j);
      ll lidx=lf.second;
      P rf=Oseg.min_q(lidx,j);
      ll ridx=rf.second;
      ans.push_back(lf.first);
      ans.push_back(rf.first);
      Eseg.upd(lidx,(ll)17441744174417);
      Oseg.upd(ridx,(ll)17441744174417);
      if(lidx-i>0){
        ll min_v=Eseg.min_q(i,lidx).first;
        pque.push(mk_P(min_v,i,lidx));
      }
      if(ridx-lidx>1){
        ll min_v=Oseg.min_q(lidx+1,ridx).first;
        pque.push(mk_P(min_v,lidx+1,ridx));
      }
      if(j-ridx>1){
        ll min_v=Eseg.min_q(ridx+1,j).first;
        pque.push(mk_P(min_v,ridx+1,j));
      }
    }
  }
  for(int i=0;i<n;i++) cout<<ans[i]<<" ";
  cout<<endl;
}


Measured memory_bytes: 20640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}

ll mul(ll A, ll B) {
	return (A*B)%MOD;
}

ll add(ll A, ll B) {
	return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll ans = 0;
    vl data(N); F0R(i, N) cin >> data[i];
    sort(all(data));
    reverse(all(data));

    F0R(i, N) {
        ans += data[i] * (i+2);
        ans %= MOD;
    }
    ans *= modExp(2, 2*N-2);
    ans %= MOD;
    cout << ans << endl;
    
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
typedef long long ll;
ll n, c, d[40][40], a[3][40], b, ans, res = 100000000000000000;
int main(void){
    // Your code here!
    cin >> n >> c;
    for (ll i = 1; i <= c; i++) {
        for (ll j = 1; j <= c; j++) {
            cin >> d[i][j];
        }
    }
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            cin >> b;
            a[(i + j) % 3][b]++;
        }
    }
    for (ll i = 1; i <= c; i++) {
        for (ll j = 1; j <= c; j++) {
            for (ll k = 1; k <= c; k++) {
                if (i == j || j == k || k == i) continue;
                ans = 0;
                for (ll l = 1; l <= c; l++) {
                    ans += d[l][i] * a[0][l] + d[l][j] * a[1][l] + d[l][k] * a[2][l];
                }
                res = min(res, ans);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
ans = 0
if A == B  == C and A % 2 == 0:
    ans = -1
else:
    while A % 2 == B % 2 == C % 2 == 0:
        a = (B + C) / 2
        b = (C + A) / 2
        c = (A + B) / 2
        A, B, C = a, b, c
        ans += 1
print(ans)


Measured memory_bytes: 3060
program main
  implicit none
  integer :: a, b, k, i
  read(*, *) a, b, k
  if (b - a > 200) then
    do i = 0, k - 1
      write(*, "(i0)") a + i
    end do
    do i = k - 1, 0, -1
      write(*, "(i0)") b - i
    end do
  else
    do i = a, b
      if (i - a < k .or. b - i < k) then
        write(*, "(i0)") i
      end if
    end do
  end if
end program main


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

ll fact[maxs];
ll ifact[maxs];

void pre(){

    fact[0] = ifact[0] = 1;
    for(int i=1;i<maxs;i++){
        fact[i] = (fact[i-1]*i)%mod;
        ifact[i] = inv(fact[i]);
    }

}

ll ncr(ll n,ll r){
    ll tmp = (fact[n]*ifact[r])%mod;
    tmp = (tmp*ifact[n-r])%mod;
    return tmp;
}

void solve(){

    ll n;
    cin >> n;
    if(n==1){
        cout << 0;
        return;
    }
    ll ans=0;
    for(int i=2;i<=n;i++){
        ll tmp = ncr(n,i);
        ll tmp2 = (tmp*(fast(2,i) - 2))%mod;
        ll rem = n-i;
        ll rem2 = fast(8,rem);
        ans += (tmp2*rem2)%mod;
        ans %= mod; 
    }
    cout << ans;
       
}

int32_t main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<char> color(n);
  for (int i = 0; i < n; i ++) {
    cin >> color.at(i);
  }

  int p = 0, w = 0, g = 0, y = 0;
  for (int i = 0; i < n; i ++) {
    if (color.at(i) == 'P') {
      p ++;
    } else if (color.at(i) == 'W') {
      w ++;
    } else if (color.at(i) == 'G') {
      g ++;
    } else {
      y ++;
    }
  }

  if (p == 0 || w == 0 || g == 0 || y == 0) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
//#pragma GCC optimize "trapv"
vector<pair<int,int>> mr(300000+10,{0,0});
vector<pair<int,int>> mc(300000+10,{0,0});
unordered_map<string,int>map1;
bool comp(pair<int,int>a,pair<int,int>b)
{
	return a.first>b.first;
}
int main()
{
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
	    
	int h,w,m;
	cin>>h>>w>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		mr[a].first++;
		mc[b].first++;
		string s= to_string(a)+"|"+to_string(b);
		map1[s]=1;
		// cout<<s<<"\n";
	}
	for(int i=0;i<h;i++)
		mr[i].second=i;
	for(int i=0;i<w;i++)
		mc[i].second=i;

	partial_sort(mr.begin(),mr.begin()+h,mr.end(),comp);
	partial_sort(mc.begin(),mc.begin()+w,mc.end(),comp);
ll ma=mr[0].fi,mb=mc[0].fi,flag=0;
// for(int i=0;i<h;i++)
// {
// 	cout<<mr[i]<<" ";
// }
// cout<<"\n";
// for(int i=0;i<w;i++)
// {
// 	cout<<mc[i]<<" ";
// }
// cout<<"\n";
for(int i=0;i<h;i++)
{
	if(mr[i].first!=ma)
		break;
	else
	{
		for(int j=0;j<w;j++)
		{
			if(mc[j].first!=mb)
				break;
			else
			{
				string s= to_string(mr[i].second)+"|"+to_string(mc[j].second);
				if(map1.find(s)==map1.end())
				{
				// cout<<s<<"\n";
					flag=1;
					break;
				}
			}
		}

	}
}
if(flag==1)
	cout<<ma+mb<<"\n";
else
	cout<<ma+mb-1<<"\n";



}

Measured memory_bytes: 30876
#include <stdio.h>
#include <math.h>

int main(void) {
	double a, b, C;
	double PI = atan(1.0) * 4.0;
	double angle, h;
	if (scanf("%lf%lf%lf", &a, &b, &C) != 3) return 1;
	angle = C * PI / 180.0;
	h = b * sin(PI - angle);
	printf("%.15f\n", a * h / 2.0);
	printf("%.15f\n", a + b + sqrt(a*a + b*b - 2*a*b*cos(angle)));
	printf("%.15f\n", h);
	return 0;
}



Measured memory_bytes: 2068
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#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 mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> P(N), Q(N);
  for(int i=0;i<N;++i) cin>>P[i];
  for(int i=0;i<N;++i) cin>>Q[i];
  vector<int> arr(N);
  for(int i=0;i<N;++i) arr[i] = i+1;
  int a, b;
  bool cana, canb;
  int index = 0;
  do {
    cana = true;
    canb = true;
    for(int i=0;i<N;++i) {
      if(arr[i]!=P[i]) cana = false;
    }
    for(int i=0;i<N;++i) {
      if(arr[i]!=Q[i]) canb = false;
    }
    if(cana) a = index;
    if(canb) b = index;
    index++;
  }while(next_permutation(arr.begin(), arr.end()));
  cout<<abs(a-b)<<endl;
}



Measured memory_bytes: 3600
#include<stdio.h>

int solve(int,int);

 int S [2000];
 int n;
 int m [2000];

int main(){

  int i,k,j,h;
  int x = 0;
 
    
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&j);

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

  
  
  for(h= 0; h < j; h++){
   k =  solve(x,m[h]);
   if(k == 1){
     printf("yes\n");
   }else if(k == 0){
     printf("no\n");
     
   }
   }
  

  return 0;
}


int solve(int i, int m){

  int res;
  //printf("%d\n",m);
    if(m == 0){
    return 1;
  }else if(i > n){
    return 0;
  }

    if((solve(i+1,m) == 1) || (solve(i+1,m-S[i]) == 1)){
    res = 1;
    return res;
  }else{
    res = 0;
    return res;
  }
}



Measured memory_bytes: 2104
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int k;
        static string s;

        public static void Main(string[] args)
        {
            input();

            if (s.Length <= k)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine(s.Substring(0, k) + "...");
            }
        }

        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            k = int.Parse(buf[0]);
            s = Console.ReadLine();
        }

    }
}

Measured memory_bytes: 27484
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif


template <typename T>
vector<size_t> sort_indexes(const vector<T> &v) {

  // initialize original index locations
  vector<size_t> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](size_t i1, size_t i2) {return v[i1] < v[i2];});

  return idx;
}


void solve() {
    ll N;
    cin >> N;
    vector<ll> X(N);
    vector<ll> X_sorted(N);
    for (ll i = 0; i < N; ++i) {
        cin >> X[i];
        X_sorted[i] = X[i];
    }
    sort(X_sorted.begin(), X_sorted.end());
    for (auto&& x: X) {
        if (x < X_sorted[N/2]) {
            printf("%lld\n", X_sorted[N/2]);
        } else {
            printf("%lld\n", X_sorted[N/2 - 1]);
        }
    }
}


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 5376
const main = (input) => {
  const n = Number(input)
  if (n < 10) {
    console.log('Yes')
    return
  }
  let result = 'No'
  for (let i = 2; i < 10; i++) {
    if (n%i === 0 && n/i < 10) {
      result = 'Yes'
      break
    }
  }
  console.log(result)

  
  
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] S = sc.next().toCharArray();
    char[] T = sc.next().toCharArray();
    for(int i=0; i<S.length; i++){
      if(S[i] != T[i]){
        System.out.print("No");
        return;
      }
    }
    if(T.length - S.length == 1 ){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
  }
}


Measured memory_bytes: 35536
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUTP(p) cout << p.first << ' ' << p.second << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN2(n,m);
  vp ab;
  FOR(i,0,m) {
    ll a,b;
    IN2(a,b);
    ab.push_back(P(a, b));
  }
  //sort(ALL(ab), [](const P &a, const P &b) {
  sort(ALL(ab), [](P a, P b) {
      return a.second < b.second;
    });
  // FOR(i,0,m) OUTP(ab[i]);
  ll last = -1;
  FOR(i,0,m) {
    if (ab[i].first < last && last <= ab[i].second) {
      // pass
    } else {
      ans++;
      last = ab[i].second;
      //debug(i);
      //debug(last);
    }
  }
  OUT(ans);
}


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

char will(bool q,char now){
	char wi;
	if(now=='a')wi=(q)?'y':'x';
	else if(now=='x')wi=(q)?'z':'l';
	else if(now=='z')wi=(q)?'b':'w';
	else if(now=='b')wi=(q)?'x':'y';
	else if(now=='w')wi=(q)?'y':'b';
	else if(now=='y')wi=(q)?'l':'x';
	return wi;
}


int main(){

		string data;
	while(cin>>data,data!="#"){
		char now='a';

	bool flag=true;
	
	for(int i=0;i<data.size();i++){
		now=will(data[i]-'0',now);
		if(now=='l'){
		flag=false;
		break;
		}
	}
	flag=(now=='b');
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


return 0;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

int n, a, b;

int main(void) {
  scanf("%d%d%d", &n, &a, &b);
  if (a - b & 1) {
    puts("Borys");
  } else {
    puts("Alice");
  }
}


Measured memory_bytes: 128