akhauriyash/Code-Regression huggingface dataset:
require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
ans=0
A.each do|a|
    next if a.odd?
    primes=Prime.prime_division(a)
    ans+=primes[0][1] if primes[0][0]==2
end
puts ans

Measured memory_bytes: 3196
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = zeros(Int,n)
	sb = a[1]>0?0:1-a[1]
	b[1] = a[1]>0?a[1]:1
	for i in 2:n
		b[i]=b[i-1]+a[i]
		if b[i]<=0&&b[i-1]<=0
			sb += 1-b[i]
			b[i] = 1
		elseif b[i]>=0&&b[i-1]>=0
			sb += b[i]+1
			b[i] = -1
		end
	end
	c = zeros(Int,n)
	sc = a[1]<0?0:a[1]+1
	c[1] = a[1]<0?a[1]:-1
	for i in 2:n
		c[i]=c[i-1]+a[i]
		if c[i]<=0&&c[i-1]<=0
			sc += 1-c[i]
			c[i] = 1
		elseif c[i]>=0&&c[i-1]>=0
			sc += c[i]+1
			c[i] = -1
		end
	end
	println(min(sb,sc))
end

main()

Measured memory_bytes: 172036
def main():
    N = int(input())
    words = [input()]
    ans = True
    for _ in range(N - 1):
        s = input()
        if words[-1][-1] != s[0] or s in words:
            ans = False
        else:
            words.append(s)

    if ans is True:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

using namespace std ;
typedef  long long ll;

ll min( ll a , ll b )
{
    return (a<b)?a:b;
}

int main()
{
    ll arr[100005] ;
    ll n;
    ll result[100005];
    while( cin >> n ){
        for( int i = 0; i < n; i++ ){
            result[i] = 1000000000;
            cin >> arr[i];
        }
        result[0] = 0;
        for( int i = 0; i < n-1; i++ ){
            ll current = result[i] ;
            ll first = abs( arr[i]-arr[i+1] ) ;
            ll second = 10000000 ;
            if(i+2 < n){
                second = abs( arr[i]-arr[i+2] );
            }
            result[i+1] = min( result[i+1] , result[i]+first );
            result[i+2] = min( result[i+2] , result[i]+second );
        }
        cout << result[n-1] << endl;
    }
}


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

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define pb push_back
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a);
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a);
#define sor(vec) sort(vec.begin(),vec.end())
#define rev(vec) reverse(vec.begin(),vec.end())
#define pque(x) priority_queue<x>
#define rpque(x) priority_queue<x,vector<x>,greater<x>>


int main(){
	while(1){
		int n;
		int A,B;
		vector<int> veca,vecb;
		
		scanf("%d",&n); if(n==0)break;
		rep(i,n){
			scanf("%d",&A);
			veca.pb(A);
		}
		rep(i,n){
			scanf("%d",&B);
			vecb.pb(B);
		}
		sor(veca);
		rev(veca);
		sor(vecb);
		rev(vecb);
		
		static int a[40010];
		static int b[40010];
		static int c[40010]; rep(i,40010)c[i]=-1;
		int loca=0;
		int locb=1;
		
		rep1(i,n)a[i]=veca[i-1];
		rep1(i,n)b[i]=vecb[i-1];
		
		int ret=-1;
		rep1(k,n/2){
			if(loca==k-1)loca++;
			else {
				c[loca]=c[k-1];
				loca++;
			}
			while(loca<=2*k-1&&locb<=n&&a[loca]<=b[locb]){
				c[loca]=b[locb];
				loca++;
				locb++;
			}
			if(loca<=2*k-1){ret=2*k-1; break;}
			/*printf("%d %d %d\n",k,loca,locb);
			rep1(i,n){
				printf("%d ",c[i]);
			}
			printf("\n");*/
		}
		if(ret==-1)printf("NA\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 2096
n = int(input())

a, b = map( int, input().split() )

x = list( map(int,input().split() ) )


first = sum( 1 if i<=a else 0 for i in x )
sec = sum( 1 if a<i and i<=b else 0 for i in x)
third = sum(1 if b<i else 0 for i in x)

ans = min([first,sec,third])
print(ans)

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

int gcd(int a, int b) {
    if(b == 0) return a;

    return gcd(b, a % b);
}

int main() {
    int K;

    cin >> K;
    unsigned int sum = 0;
    for(int i = 1; i <= K; i ++) {
        for(int j = 1; j <= K; j++) {
            for(int k = 1; k <= K; k++) {
                sum += gcd(gcd(k, j), i);
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3160
#include <cstdio>
#include <cstring>
int n,m,p;
int fie[8][8][8];
int cnt[8][8];
int dx[13]={1,0,0,1,1,0,1,1,0,1,1,1,1};
int dy[13]={0,1,0,1,0,1,-1,0,1,1,1,-1,-1};
int dz[13]={0,0,1,0,1,1,0,-1,-1,1,-1,1,-1};

bool check(){
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			for(int k=0;k<8;k++){
				if(fie[i][j][k]==-1)continue;
				for(int l=0;l<13;l++){
					for(int x=i,y=j,z=k,g=0;g<m;x+=dx[l],y+=dy[l],z+=dz[l],g++){
						if(x<0 || x>n || y<0 || y>n || z<0 || z>n)break;
						if(fie[x][y][z]!=fie[i][j][k])break;
						if(g==m-1)return true;
					}
				}
			}
		}
	}
	return false;
}

int x[500],y[500];

int main(void){
	while(1){
		scanf("%d %d %d",&n,&m,&p);
		if(n+m+p==0)break;
		memset(cnt,0,sizeof(cnt));
		memset(fie,-1,sizeof(fie));
		int i;
		for(i=0;i<p;i++){
			scanf("%d %d",&x[i],&y[i]);
		}
		for(i=0;i<p;i++){
			fie[x[i]][y[i]][cnt[x[i]][y[i]]]=i%2;
			cnt[x[i]][y[i]]++;
			if(check()){
				printf("%s %d\n",i%2==0?"Black":"White",i+1);
				break;
			}
		}
		if(i==p)printf("Draw\n");
	}
	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,m;
    cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    cin >> m;
    vector<ll> p(m),x(m);
    rep(i,m) cin >> p[i] >> x[i];
    vector<ll> b;
    rep(i,m){
        int sum = 0;
        b = t;
        b[p[i]-1] = x[i]; 
        rep(j,n){
            sum += b[j];
        }
        cout << sum << endl;
    }
}


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

typedef struct{
  double x;
  double y;
}Point;

void koch(int n, Point a, Point b){
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;
  if(n == 0) return;

  s.x = (2 * a.x + 1 * b.x) / 3;
  s.y = (2 * a.y + 1 * b.y) / 3;
  t.x = (1 * a.x + 2 * b.x) / 3;
  t.y = (1 * a.y + 2 * b.y) / 3;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main(){
  Point p1, p2;
  int n;

  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);

  return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();

        if(n * a > b){
            System.out.println(b);
        }else{
            System.out.println(n * a);
        }
	}
}


Measured memory_bytes: 35660
package main

import (
	"fmt"
	"math"
)

type point struct {
	X, Y float64
}

func main() {
	var N int
	fmt.Scanf("%d", &N)

	L := make([]point, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&L[i].X, &L[i].Y)
	}

	ans := 0.0
	for _, A := range L {
		for _, B := range L {
			ans += math.Hypot((A.X - B.X), (A.Y - B.Y))
		}
	}
	ans /= float64(N)

	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner s = new Scanner(System.in);

		 int h = s.nextInt();
		 int w = s.nextInt();
		 int k = s.nextInt();

		 String[][] str = new String[h][w];

		 int result = 0;

		 for(int i = 0; i < h; i++) {
			 String tmp = s.next();
			 for(int j = 0; j < w; j++) {
				 str[i][j] = tmp.substring(j, j + 1);
			 }
		 }

		 for(int i = 0; i < (int)Math.pow(2, h); i++) {
			 for(int j = 0; j < (int)Math.pow(2, w); j++) {
				 String row = (String)Integer.toBinaryString(i);
				 row = row.format("%" + h + "s", row).replace(" ", "0");
				 row = row.substring(0, h);
				 String col = (String)Integer.toBinaryString(j);
				 col = col.format("%" + w + "s", col).replace(" ", "0");
				 col = col.substring(0, w);

				 int tmpCount = 0;
				 for(int m = 0; m < row.length(); m++) {
					 if (m > h - 1 || "0".equals(row.substring(m, m+1))) {
						 continue;
					 }
					 for(int n = 0; n < col.length(); n++) {
						 if(n > w - 1) {
							 break;
						 }
						 if("1".equals(col.substring(n, n+1))) {
							 if("#".equals(str[m][n])) {
								 tmpCount++;
							 }
						 }
					 }
				 }
				 if(tmpCount == k) {
					 result++;
				 }
			 }
		 }

		 System.out.println(result);
	}

}


Measured memory_bytes: 46120
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	while(n--)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3668
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
long long num(long long A, long long b){
   if(b==1){
      long long mod = (A+1)%4;
      if(mod==2||mod==3) return 1;
      else return 0;
   }
   else{
      long long mod = (A+1)%(b*2);
      return max(0LL,mod-b);
   }
}

int main(){
   long long A,B;
   cin >> A >> B;
   long long ans =0;
   for(int i=0; i< 60; i++){
      long long target = 1LL<<i;
      long long n = num(B,target)+num(A-1,target);
      if(n%2==1) ans += target;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int a, b, c, ct = 0;

int main(){
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) if (c%i == 0) ct++;
	cout << ct << endl;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
using namespace std;
  
int main(){
  int n,A[100],mini,count=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
    
  for(int i=0;i<n-1;i++){
    mini=i;
    for(int j=i+1;j<n;j++){
      if(A[j]<A[mini])mini=j;
    }
      
    if(i!=mini){
      count++;
      swap(A[i],A[mini]);
    }
  }
    
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<A[i];
  }
  cout<<endl<<count<<endl;
  
  return 0;
}


Measured memory_bytes: 3076
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long s = readln.split.to!(long[]).sum;
  if (s >= 22) {
    writeln("bust");
  } else {
    writeln("win");
  }
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int is_include(vector<int> as, vector <int> bs) {
    for (auto a : as) {
        if (find(all(bs), a) == bs.end()) return 0;
    }
    return 1;
}

int main()
{
    int n;
    while (cin >> n, n) {
        vector<vector<int>> pss;
        pss.resize(n);
        loop (n, i) {
            int m; cin >> m;
            pss[i].resize(m);
            loop(m, j) {
                int tmp; cin >> tmp;
                pss[i][j] = tmp;
            }
        }
        vector<int> ks;
        int k; cin >> k;
        loop (k, i) { int tmp; cin >> tmp; ks.push_back(tmp); }

        int ans = -1;
        int count = 1;
        for (auto ps : pss) {
            if (is_include(ks, ps)) {
                if (ans == -1) {
                    ans = count;
                } else {
                    ans = -1;
                    break;
                }
            }
            count++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3192
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Ld a, b;
    cin >> a >> b;

    cout << fixed << setprecision(0) << floorl(a * b) << endl;

    return 0;
}

Measured memory_bytes: 3832
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll l[8];

int main(void){
    ll n, a, b, c; cin >> n >> a >> b >> c; for(int i = 0;i < n;i++)cin >> l[i];
    ll ans = INF;
    int s = (1 << n)-1;
    int sa = s;
    do{
        //printf("a\n");
        if(sa == 0)break;
        ll ta = 0; int ca = 0;
        for(int i = 0;i < n;i++)if((sa >> i)&1){ta += l[i]; ca++;}
        ta = (ca - 1)*10 + abs(ta - a);
        int sb = s - sa;
        do{
        //printf("b\n");
            if(sb == 0)break;
            ll tb = ta; int cb = 0; ll bb = 0;
            for(int i = 0;i < n;i++)if((sb >> i)&1){bb += l[i]; cb++;}
            tb += (cb - 1)*10 + abs(bb - b);
            int sc = s - sa - sb;
            do{
        //printf("c\n");
                if(sc == 0)break;
                ll tc = tb; int cc = 0; ll ccc = 0;
                for(int i = 0;i < n;i++)if((sc >> i)&1){ccc += l[i]; cc++;}
                ans = min(ans, tc + (cc-1)*10+abs(ccc - c));
                sc = (sc - 1)&(s - sa - sb);
            }while(sc != s - sa - sb);
            sb = (sb - 1)&(s - sa);
        }while(sb != s - sa);
        sa = (sa - 1) & s;
    }while(sa != s);
    cout << ans << endl;
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    int sum = x1 + x2 + x3 + x4 + x5;
    cout << (15 - sum) << endl;
    return 0;
}


Measured memory_bytes: 3616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)


struct tree{
    size_t n,r,md;
    vector<vector<int>> e;
    vector<int> pa,d;
    explicit tree(int n_){
        n=n_;
        e.resize(n);
    }
    void add(int a,int b){
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    void r_dfs(int i,int p=-1,int D=0){
        pa[i]=p;d[i]=D;md=max(md,(size_t)D);++D;
        for(auto j:e[i]) if(j!=p) r_dfs(j,i,D);
    }
    void r_i(int r_){
        pa.resize(n);d.resize(n);r=r_;md=0;
        r_dfs(r);
    }
    int r2(){
        r_i(0);
        int m=0,M=0;
        fr(i,n) m=max(m,d[i]);
        fr(i,n) if(d[i]==m) M=i;
        pa.clear(),d.clear();
        r_i(M);
        m=0;
        fr(i,n) m=max(m,d[i]);
        return m;
    }
};

class CRemovingCoins {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,a,b;
        in>>n;
        tree t(n);
        fr(i,n-1){
            in>>a>>b;
            t.add(--a,--b);
        }
        int r2=t.r2()+2;
        out<<(r2%3?"First":"Second")<<endl;
    }
};

int main() {
    CRemovingCoins solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 19072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max((ll)0,min(b,d) - max(a,c)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int x;
    cin >> x;
    if(x==0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3632
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
int n, r, s, p, k;
int judge[1005];
char pr[maxn], gr[maxn];
start{
    /**
    ll n=read,m=read;
    char judge[10];
    ll cnt=0;
    while(m--){
        cin>>judge+1;
        if(judge[3]=='y'){
            if(cnt==0) printf("F\n");
            else if(cnt!=0) printf("T\n");
        }
        else if(judge[3]=='u') printf("%lld\n",cnt);
        else if(judge[3]=='n'){
            ll shu=read;
            if(num[shu]==0) printf("F\n");
            if(num[shu]==1) printf("T\n");
        }
        else if(judge[3]=='l'){
            ll temp=read;
            if(num[temp]==0){
                num[temp]=1;
                cnt++;
            }
            else if(num[temp]==1){
                num[temp]=0;
                cnt--;
            }
        }
    }
    **/
    n=read,k=read,r=read,s=read,p=read;
    judge['r']=r;
    judge['s']=s;
    judge['p']=p;
    cin>>pr+1;
    for (int i=1;i<=n;i++) {
        if (pr[i]=='s') pr[i]=gr[i]='r';
        else if (pr[i]=='p') pr[i] = gr[i] = 's';
        else pr[i]=gr[i]='p';
    }
    for (int i=1; i<=n;i++)
        if(i+k<=n&&gr[i]==gr[i+k])
            gr[i+k]='9';///重复
    int ans=0;
    for(int i=1;i<=n;i++)
        if(pr[i]==gr[i])
            ans+=judge[gr[i]];
    printf("%d\n", ans);
    end;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int N,A,m;
    m=1000000000;
    cin >> N;
    for(int i=0;i<N;i++)
    {
        cin >> A;
        int k=0;
        while (A%2==0)
        {
            A=A/2;
            k++;
        }
        m=min(m,k);
    }
    cout << m <<endl;
return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

al = "abcdefghijklmnopqrstuvwxyz"
ald = {}
for i in range(26):
    ald[al[i]] = i

def BIT_query(BIT, idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

def BIT_update(N, BIT, idx, x):
    while idx <= N:
        BIT[idx] += x
        idx += idx&(-idx)
    return

N = int(input())
S = input()
Q = int(input())

S = [s for s in S]

bits = [[0]*(N+1) for i in range(26)]

for i in range(N):
    ind = ald[S[i]]
    BIT_update(N, bits[ind], i+1, 1)

for i in range(Q):
    f, a, b = (i for i in input().split())
    if f == "1":
        a = int(a)
        if S[a-1] == b:
            pass
        else:
            ind = ald[S[a-1]]
            BIT_update(N, bits[ind], a, -1)
            ind = ald[b]
            BIT_update(N, bits[ind], a, 1)
            S[a-1] = b
    else:
        a = int(a)
        b = int(b)
        ans = 0
        for bit in bits:
            if a != 1:
                mi = BIT_query(bit, a-1)
            else:
                mi = 0
            if BIT_query(bit, b) > mi:
                ans += 1
        print(ans)

Measured memory_bytes: 165580
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
int main(){
    int a;
    cin >> a;
    int b;
    b=a%500;
    a/=500;
    b/=5;
    cout << a*1000+b*5;

}
    




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

int main(){
	long long n, k;
	cin >> n >> k;
	if (n % k == 0) cout << n % k;
	else if (n < k) {
      if (abs(n - k) < n) cout << abs(n - k);
  	  else cout << n % k;}
	else cout << k - n % k;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
    int n,i,p;
    set<int> s;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>p;
        s.insert(p);
    }
    cout<<s.size()<<'\n';
    return(0);
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
using ll=long long;

int main(){
    ll n,k;cin >> n >>k;
    vector<ll> a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    ll res=0;
    rep(i,30){
        if((1<<i)&k){
            ll t=(1<<i);
            ll p=((k-t)|(t-1));
            ll sum=0;
            rep(j,n){
                if(p==(p|a[j]))sum+=b[j];
            }
            res=max(res,sum);
        }
    }
    ll tot=0;
    rep(j,n){
        if(k==(k|a[j]))tot+=b[j];
    }
    cout << max(res,tot) <<endl;
}   


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

struct tree{
	tree * list[4];
	bool isInserted;
};

tree* newTree(){
	tree* newTree = (tree*)calloc(1,sizeof(tree));
	return newTree;
}

inline int getIndex(char c){
		switch(c){
			case 'A':
				return 0;
			case 'C':
				return 1;
			case 'T':
				return 2;
			default: 
				return 3;
		}
}
void insert(tree* pearent, char* str){
	if(*str == '\0'){
		pearent->isInserted = true;	
		return;
	}
	int index = getIndex(*str);
	if(pearent->list[index] == NULL)pearent->list[index] = newTree();
	insert(pearent->list[index], str + 1);
}

void find(tree* pearent, char* str){
	int index = getIndex(*str);
	if(*str == '\0'){
		if(pearent->isInserted)cout << "yes" << endl;
		else cout << "no" << endl;
	}else if(pearent->list[index] == NULL){
	cout << "no" << endl;
	}else{
		find(pearent->list[index], str + 1);
	}
}


void disposeTree(tree* t){
	for(int i = 0; i < 4; i++){
		if(t->list[i] != NULL) disposeTree(t->list[i]);
	}
	free(t);
}

int main(){
	char order[7];
	char val[12];

	cin >> val;
	tree* root = newTree();
	while (cin >> order){
		cin >> val;
		if(order[0] == 'i'){
			insert(root, val);	
		}else{
			find(root, val);
		}
	}
	
	disposeTree(root);


	return 0;
}

Measured memory_bytes: 17480
using System; using System.Text; using System.Collections.Generic; using System.Linq; using E = System.Linq.Enumerable; 
class Program { static int[] L; static void Main(string[] args) {
    var KS = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
  var K = KS[0];
  var S = KS[1];
  var count1 = 0L;
  var count2 = 0L;
  for(int i = 0;i<=K && i <= S;i++){
    for(int j = 0;j<=K && i+j<=S;j++){
      count1 += Math.Min(S-(i+j)+1,K+1);
    }
  }
  //Console.WriteLine(count1);
  S--;
  for(int i = 0;i<=K && i <= S;i++){
    for(int j = 0;j<=K && i+j<=S;j++){
      count2 += Math.Min(S-(i+j)+1,K+1);
    }
  }
//  Console.WriteLine(count2);
    Console.WriteLine(count1-count2);
  }
             
     }


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
    long H,W;
    cin>>H>>W;
    unsigned long mindif = -1;
    for(int c= 0; c<2; c++){
        if(c == 1)
            swap(H,W);
        for(int i = 1; i < H; i++){
            long size_A = i*W;
            long h = (H-i)/2;
            long size_B1 = W*h;
            long size_C1 = W*(H-i-h);
            long w = W/2;
            long size_B2 = (H-i)*w;
            long size_C2 = (H-i)*(W-w);
            vector<long> l1,l2;
            l1.push_back(size_A);
            l1.push_back(size_B1);
            l1.push_back(size_C1);
            l2.push_back(size_A);
            l2.push_back(size_B2);
            l2.push_back(size_C2);
            long max1 = *max_element(l1.begin(),l1.end());
            long min1 = *min_element(l1.begin(),l1.end());
            long max2 = *max_element(l2.begin(),l2.end());
            long min2 = *min_element(l2.begin(),l2.end());
            long dif = min(abs(max1-min1),abs(max2-min2));
            if(dif<mindif)
                mindif = dif;
        }
    }
    cout<<mindif;
}

Measured memory_bytes: 256
n = int(input())
a= list(map(int, input().split()))
from collections import Counter
c=Counter(a)
dic={}
for k,v in c.items():
    dic[k]=v*(v-1)//2
su=0
for k in dic.values():
    su+=k
for i in a:
    print(su-dic[i]+(c[i]-1)*(c[i]-2)//2)

Measured memory_bytes: 32640
N = int(input())
mem = [[0]*10 for i in range(10)]

for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    mem[a][b] += 1

ans = 0
for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    ans += mem[b][a]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans = 1e18, sum = 0, sum1 = 0;
	rep(i,n){
		sum += a.at(i);
	}
	rep(i,n - 1){
		sum -= a.at(i);
		sum1 += a.at(i);
		ans = min(ans, abs(sum1 - sum));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll dp[2][10001];
int main(void) {
    ll c, n, m;
    cin >> c >> n >> m;
    vector<ll> s(n), p(n);
    REP(i, n) cin >> s[i] >> p[i];

    ll cur = 0, nxt = 1;
    FOR(i, 1, c+1) dp[0][i] = -INF;
    REP(i, n) {
        REP(j, c+1) {
            if(j+s[i]<=c) chmax(dp[nxt][j+s[i]], dp[cur][j] + p[i]);
            chmax(dp[nxt][j], dp[cur][j]);
        }
        swap(cur, nxt);
        REP(j, c+1) dp[nxt][j] = -INF;
    }

    FOR(i, 1, c+1) chmax(dp[cur][i], dp[cur][i-1]);
    REP(i, m) cout << dp[cur][c/(i+1)] * (i+1) << "\n";
    cout << flush; 

    return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string s; cin >> s;
    if(s=="SUN") cout << 7;
    else if(s=="MON") cout << 6;
    else if(s=="TUE") cout << 5;
    else if(s=="WED") cout << 4;
    else if(s=="THU") cout << 3;
    else if(s=="FRI") cout << 2;
    else if(s=="SAT") cout << 1;
    cout << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<int> cnt(3, 0);
  rep(i,s.size()) cnt[s[i] - 'a']++;
  int mx = *max_element(cnt.begin(), cnt.end());
  int mi = *min_element(cnt.begin(), cnt.end());
  if (mx - mi > 1) cout << "NO" << endl;
  else cout << "YES" << endl; 
  return 0;
}

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

int main() {
 int N;	
  cin>>N;
 double sum=0;
  for(int i=0;i<N;i++){
  double x;
    cin>>x;
  string u;
    cin>>u;
  if(u=="JPY"){
    sum+=x;
  }
  else{
    sum+=x*380000.0;
  }
}
   cout<<sum<<endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
long long ans=n%10;
if(ans==2||ans==4||ans==5||ans==7||ans==9){
    cout<<"hon"<<endl;
}
else if(ans==0||ans==1||ans==6||ans==8){
    cout<<"pon"<<endl;
}
else{
    cout<<"bon"<<endl;
}
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
long a,b;
long max=(10*10*10*10);
long max2=(10*10*10*10*10);
long max3;
max3=max*max2;
max3=max3+7;
cin >> a>>b;
long  c;
long  ans;
long x=1;
long i;
long j=1;
long s=1;
c = abs(a-b);
if(c >= 2){
cout << 0;
}
else if(c==1){
for(i=a;i>0;i--){
j=j*i;
j=j%max3;
}
for(i=b;i>0;i--){
s=s*i;
s=s%max3;
}
x=j*s;

ans = x%max3;
cout << ans;
}
else{
for(i=a;i>0;i--){
j=j*i;
j=j%max3;
}
for(i=b;i>0;i--){
s=s*i;
s=s%max3;
}
x=j*s;
x=x*2;
ans = x%max3;
cout << ans;
}
return 0;
}

Measured memory_bytes: 384
#Solver:Rute
a,b,c,k = map(int,input().split())
if k<=a:
  print(k)
elif a<k<a+b:
  print(k)
else:
  #-1のカードの枚数超過 (k-(a+b))枚
  print(a-(k-(a+b)))

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

int N,A,B,C,D;
char S[1000000];
int main(void){
  cin>>N>>A>>B>>C>>D;
  cin>>S;
  A--; B--; C--; D--;

  if(C<B){
    bool check=true;
    int cnt=0;
    for(int i=A+1;i<C;i++){
      if(S[i]=='#') cnt++;
      else cnt=0;
      if(cnt>=2) check=false;
    }
    cnt=0;
    for(int i=B+1;i<D;i++){
      if(S[i]=='#') cnt++;
      else cnt=0;
      if(cnt>=2) check=false;
    }
    if(check) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
  }

  int L=A, R;
  if(C<D) R=D;
  else    R=C;
  int cnt=0;
  for(int i=L;i<=R;i++){
    if(S[i]=='#') cnt++;
    else cnt=0;
    if(cnt>=2){
      R=i-cnt;
      break;
    }
  }

  if(R<C||R<D){
    cout<<"No"<<endl;
    return 0;
  }

  if(C<D){
    cout<<"Yes"<<endl;
    return 0;
  }

  bool check=false;
  cnt=0;
  for(int i=B-1;i<=D+1;i++){
    if(S[i]=='.') cnt++;
    else cnt=0;
    if(cnt>=3){
      check=true;
      break;
    }
  }

  if(check) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 384
function Main(input){
var A = parseInt(input.split(" ")[0],10);
var B = parseInt(input.split(" ")[1],10);
if(A>=13){
  console.log(B);
}else if(A>=6&&A<=12){
  console.log(B/2);
}else{
  console.log(0);
}

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

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  string s;cin >> s;
  if(s == "zyxwvutsrqponmlkjihgfedcba"){
    cout << "-1\n";return 0;
  }
  int n = s.size(),i,j;
  bool use[26] = {};
  for(i=0;i<n;i++) use[s[i]-'a'] = true;
  for(i=0;i<26;i++){
    if(!use[i]){
      cout << s << char(i+'a') << "\n";return 0;
    }
  }
  for(i=n-2;i>=0;i--){
    if(s[i] < s[i+1]){
      for(j=i+1;j<n;j++) use[s[j]-'a'] = false;
      s = s.substr(0,i+1);
      while(use[s[s.size()-1]-'a']) s[s.size()-1]++;
      cout << s << "\n";
      return 0;
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt"adj[i], "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
vector < int > adj[maxn];
int mat[maxn];
bool ok = 0;

void dfs(int v , int par = 0){
    for(auto u : adj[v])
        if(u!=par){
            dfs(u, v);
            if(mat[u] == 0 and mat[v] == 0){
                mat[u] = 1 , mat[v] = 1;
            }
        }
}

int main(){
    migmig
    cin >>  n;
    for(int i = 0 ; i < n- 1 ; i ++){
        int u , v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i = 1 ; i <= n ; i ++){
        if(adj[i].size()> 1 ){
            dfs(i);
            break;
        }
    }
    ok = 1;
    for(int i = 1 ; i <= n ; i ++){
        ok&=(mat[i]!=0);
    }
    if(n==2)dokme("Second");
    cout << ((!ok) ? "First" : "Second");
    return(0);
}

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

using namespace std;

int n, m;
vector<vector<int>> ed(1e5 + 5);
vector<int> dp;

int solve(int x){
    if(dp[x] != -1) return dp[x];
    int res = 0;
    for(auto y : ed[x]){
        res = max(res, 1 + solve(y));
    }
    return dp[x] = res;
}

int main(){
    cin>>n>>m;
    // ed.assign(n);
    while(m--){
        int x, y;
        cin>>x>>y; x--; y--;
        ed[x].push_back(y);
    }
    dp.assign(n, -1);
    int res = -1;
    for(int i = 0; i < n; i++){
        res = max(res, solve(i));
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N = 1000000;
const int MOD = 998244353;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }

inline int power(int x, int k) {
	int tmp = 1;
	while(k) {
		if(k & 1) tmp = mul(tmp,x);
		x = mul(x,x);
		k >>= 1;
	}
	return tmp;
}

int fac[N + 10], ifac[N + 10];
inline void prepare() {
	fac[0] = ifac[0] = 1;
	for(int i = 1;i <= N;i ++) fac[i] = mul(fac[i - 1],i);
	ifac[N] = power(fac[N],MOD - 2);
	for(int i = N - 1;i >= 1;i --) ifac[i] = mul(ifac[i + 1],i + 1);
}

inline int C(int n, int m) {
	if(n < 0 || m < 0 || n < m) return 0;
	return mul(fac[n],mul(ifac[m],ifac[n - m]));
}

int n, K;

inline int solve1(int r, int b) {
	return dec(C(r + b - 1,b - 1),C(r + b - 1,2 * r - n + 1));
}

inline int solve2(int r, int b) {
	return dec(C(r + b,b),C(r + b,2 * r - n + 1));
}

int main() {
  scanf("%d%d", &n, &K);
	if(n > K) {
		puts("0");
		return 0;
	}
	prepare();
	int Ans = 0;
  for(int r = 0;r <= K;r ++) {
		int b = K - r;
		if(r < b) continue;
		int tmp;
    if(r == b) tmp = solve1(r,b);
		if(r > b) tmp = solve2(r,b);
		Ans = inc(Ans,tmp);
	}
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    int a,b;
    int now=1;
    int count=0;

    cin>>a>>b;

    while(1){
        if(now>=b){
            break;
        }
        now--;
        now+=a;
        count++;
    }
    cout<<count<<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int n;
	cin >> n;
	int res = 0;
	vector<int> v(n+1);
	vector<int>c(n+1);
	FOR(i, 1, n) {
		cin >> v[i];
	}
	FOR(i, 1, n) {
		cin >> c[i];
	}
	FOR(i, 1, n) {
		if (v[i] > c[i]) {
			res += (v[i] - c[i]);
		}
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
D=[]
for i in range(N):
    D.append(int(input()))
num=[0]*110
for i in range(N):
    #print(D[i])
    num[D[i]]+= 1
    #print(num[D[i]])
for i in range(110):
    if num[i] > 0:
        ans += 1
print(ans)

Measured memory_bytes: 9072
#include <iostream>

int main()
{
	int n, x;
	while (std::cin >> n >> x, n || x)
	{
		int count = 0;
		for (int i = 1; i <= n - 2; i++)
		{
			for (int j = i + 1; j <= n - 1; j++)
			{
				for (int k = j + 1; k <= n; k++)
				{
					if (i + j + k == x)
					{
						count++;
					}
				}
			}
		}
		std::cout << count << '\n';
	}
	return 0;
}

Measured memory_bytes: 3108
A, B, M = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

min_cost = min(A_list) + min(B_list)
for i in range(M):
  x, y, c = map(int, input().split())
  min_cost = min(min_cost, A_list[x - 1] + B_list[y - 1] - c)

print(min_cost)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
#define endl "\n"
#define INF (ll) (3e18)
const ll mod=1e9+7;
ll dp[1000][1000];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,m;cin>>n>>m;
    char maze[n][m];
    for(ll i=0;i<n;i++)
        for(ll j=0;j<m;j++)
            cin>>maze[i][j];
    dp[0][0]=1;
    for(ll i=0;i<n;i++)
        for(ll j=0;j<m;j++){
            if(i>=1 and maze[i-1][j]!='#')
                (dp[i][j]+=dp[i-1][j])%=mod;;
            if(j>=1 and maze[i][j-1]!='#')
                (dp[i][j]+=dp[i][j-1])%=mod;
        }
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}





Measured memory_bytes: 9088
import java.util.Scanner;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();


        int result = (H-h) * (W-w);

        System.out.println(result);
    }
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)

//MIN-MAX
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

bool is_prime(ll a)
{
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)
            return false;

    }
    return true;


}
int main()
{
	FASTIO;
	ll a;
	 cin>>a;

	 while(!is_prime(a))
     {
         a++;
     }
     cout<<a<<"\n";
}













Measured memory_bytes: 256