akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [None] * N

for i in range(N):
  A[i] = list(map(lambda x:int(x) - 1,input().split()))[::-1]
  
# A[i]の最後尾が、次に対戦する相手

# 次に試合する候補の人を全員洗い出す。最初は全員
playable = set(range(N))

day = 0
while True:
  next_playable = set() # 次の日に試合できる状態になる人
  done = set() # その日に既に試合を終えた人を管理
  for player in playable:
    if player in done:
      continue
    if len(A[player]) == 0:
      continue
    rival = A[player][-1]
    if rival in done:
      continue
    if len(A[rival]) == 0:
      continue
    if A[rival][-1] == player:
      done.add(player)
      done.add(rival)
      A[player].pop()
      A[rival].pop()
      # この二人は次の試合の探索対象となる
      next_playable.add(player)
      next_playable.add(rival)
  if len(next_playable) == 0:
    break
  playable = next_playable
  day += 1

# できる試合がなくなった状態で、全員の試合が終わっていればOK
ok = True
for i in range(len(A)):
  if len(A[i]) != 0:
    ok = False
    break
    
print((-1,day)[ok])

Measured memory_bytes: 40852
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int h, w, n;
	cin >> h;
	cin >> w;
	cin >> n;


	int m = max(h, w);
	cout << (n % m == 0 ? n / m : n / m + 1);
}


Measured memory_bytes: 31488
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
ll ans=0;
     
void pf(ll n) 
{ 
    vi v;
	while(n%2==0) 
	{ 
		v.pb(2);
		n = n/2; 
	} 
    for (int i = 3; i <= sqrt(n); i = i + 2) 
	{ 
		while (n % i == 0) 
		{ 
			v.pb(i) ;
			n = n/i; 
		} 
	} 

    if (n > 2) 
		v.pb(n);
    ans=0;
    set<ll>s;
    multiset<ll>ms;
    f(i,(ll)v.size())
    {
        s.insert(v[i]);
        ms.insert(v[i]);
    }
    vi v1;
    for(auto itr=s.begin();itr!=s.end();itr++)
    {
        v1.pb(2*(ms.count(*itr)));
    }
    f(i,(ll)v1.size())
    {
        ll j=1;
        while(1)
        {
            if(j*(j+1)>v1[i])
            {
                j--;
                break;
            }
            j++;
        }
        ans+=j;
    }
} 
int main()
{
fast;
    ll n;
    cin>>n;
    pf(n);
    cout<<ans;
    return 0;
}

        
        
        
   

Measured memory_bytes: 3672
use proconio::input;

fn main() {
    input! {
        n: i64,
    }

    let primes = prime_sieve(n as usize);

    let mut v = vec![0i64; n as usize + 1];
    v[1] = 1;
    let mut now = vec![1];
    for p in primes {
        let mut next = vec![];
        for a in now.iter().copied() {
            if a * p > n {
                continue;
            }
            next.push(a);
            let mut b = a * p;
            let mut count = 2;
            while b <= n {
                v[b as usize] = v[a as usize] * count;
                next.push(b);
                b *= p;
                count += 1;
            }
        }
        now = next;
    }

    // dbg!(&v);

    let mut ans = 0;
    for i in 1..=n {
        ans += i * v[i as usize];
    }
    println!("{}", ans);
}

fn prime_sieve(n: usize) -> Vec<i64> {
    let mut table: Vec<i64> = vec![0; n + 1];
    let mut primes: Vec<i64> = Vec::new();

    for i in 2..=n {
        if table[i] == 0 {
            primes.push(i as i64);
            for j in 2..n {
                if i * j > n {
                    break
                }
                table[i * j] = 1
            }
        }
    }

    primes
}


Measured memory_bytes: 86448
import java.util.*;

public class Main {
	
	public static class MyPair implements Comparable<MyPair> {
		int cost;
		int supply;
		
		public MyPair(int cost, int supply) {
			this.cost = cost;
			this.supply = supply;
		}
		
		@Override
		public int compareTo(MyPair other) {
			return (this.cost - other.cost);
		}
	}
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		
		boolean AOdd = A%2 == 1;
		boolean BOdd = B%2 == 1;
		
		if (A == B) {
			System.out.println(A);
		} else if (AOdd && BOdd) {
			long diff = B - A;
			long LSB = (diff)/2%2;
			if (LSB == 1) {
				System.out.println(A-1);
			} else {
				System.out.println(A);
			}
		} else if (AOdd && !BOdd) {
			long diff = B - A;
			long LSB = (diff)/2%2;
			long BToCompare = B + LSB;
			long AToCompare = A;
			long solution = 0;
			long multiplier = 1;
			while (BToCompare > 0) {
				if (AToCompare == 0) {
					solution += BToCompare%2*multiplier;
					BToCompare /= 2;
				} else {
					if (BToCompare%2 != AToCompare%2) {
						solution += multiplier;
					}
					BToCompare /= 2;
					AToCompare /= 2;
				}
				multiplier *= 2;
			}
			System.out.println(solution);
		} else if (!AOdd && BOdd) {
			long diff = B - A;
			long LSB = (diff+1)/2%2;
			System.out.println(LSB);
		} else {
			long diff = B - A;
			long LSB = (diff)/2%2;
			System.out.println(B+LSB);
		}
    }
  
}


Measured memory_bytes: 23124
import sys
import math
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
    
N,D=LI()
MAT=[LI() for i in range(N)]


cnt = 0
for i in range(N):
    for j in range(i+1, N):
        dist = 0
        for k in range(D):
            dist += (MAT[i][k]-MAT[j][k])*(MAT[i][k]-MAT[j][k])
        distrt = math.ceil(math.sqrt(dist))
        if distrt*distrt == dist:
            cnt += 1
print(cnt)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(int)rept;++i)
typedef long long ll;
using namespace std;

ll sumdig(ll num) 
{

	ll d = 0;

	while (num > 0) {
		num /= 10;
		d++;
	}

	return d;
}


int main() {
	//12日目-2

	cin.tie(0); ios::sync_with_stdio(false);

	ll n = 0, ans = 0, f = 0;

	cin >> n;
	ans = sumdig(n);
	
	for (ll i = 1; i * i <= n; i++) {

		if (n%i != 0) {
			continue;
		}
		f = max(sumdig(i), sumdig(n / i));
		ans = min(f, ans);
		f = 0;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; a[i] != 2;)
  {
    i = a[i] - 1;
    ans++;
    if (ans > N)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
long long n, k, res;

string minus(string x,string y){
  bool jjjj=false;
  if(x.length()<y.length() || (x.length()==y.length() && x<y))
    swap(x,y),jjjj=true;
  if(y.length()==0)
    return x;
  int u=y[y.length()-1]-'0',p=x[x.length()-1]-'0';
  string t;
  if(p<u){
    p+=10;
    for(int i=x.length()-2;i>=0;i--)
      if(x[i]>'0'){
	x[i]--;
	break;
      }
      else
	x[i]+=9;
  }
}
int toi(string s){
  int r=s[0]-'0';
  for(int i=1;i<s.length();i++)
    r*=10,r+=s[i]-'0';
  return r;
}
string tos(int n){
  string r;
  while(n>9){
    r.push_back(n%10+'0');
    n/=10;
  }
  r.push_back(n%10+'0');
  reverse(r.begin(),r.end());
  return r;
}
string sum(string s,string p,int m=10,char z='0'){
  string r;
  int b=0;
  reverse(s.begin(),s.end());
  reverse(p.begin(),p.end());
  if(s.size()<p.size())s.swap(p);
  for(int i=0;i<s.size();i++){
    if(i>=p.size()){
      r.push_back((s[i]-z+b)%m+z);
      if(s[i]-z+b>=m)b=1;
      else b=0;
    }
    else{
      r.push_back((p[i]-z+s[i]-z+b)%m+z);
      if(p[i]-z+s[i]-z+b>=m)b=1;
      else b=0;
    }
  }
  if(b>0)r.push_back(b+z);
  reverse(r.begin(),r.end());
  return r;
}
string multiplyint(string s,int n){
  string r=tos((s[0]-'0')*n);
  for(int i=1;i<s.length();i++){
    r.push_back('0');
    r=sum(r,tos((s[i]-'0')*n));
  }
  return r;
}
string multiply(string s,string p){
  string r=multiplyint(p,s[0]-'0');
  for(int i=1;i<s.length();i++){
    r.push_back('0');
    r=sum(r,multiplyint(p,s[i]-'0'));
  }
  return r;
}

int32_t main () {
    cin >> n >> k;
    int b = n / k;
    string j = tos(b);
    string res = multiply(j, multiply(j, j));
    if (k % 2 == 0) {
	int l = (n / k);
	if (n / k * k + k / 2 <= n) l++;
	string a = tos(l);
	res = sum(res, multiply(a, multiply(a, a)));
    }
    cout << res << endl;
}


Measured memory_bytes: 256
I=lambda:[int(i) for i in input().split()]
n, m = I()
P = I()
D = {i:i for i in range(n+1)}

def U(x):
  if D[x] != x:
    D[x] = U(D[x])
  return D[x]

for _ in range(m):
  x, y = I()
  D[U(x)] = U(y)

print(sum(U(i)==U(p) for i, p in enumerate(P,1)))

Measured memory_bytes: 20704
package main
import "fmt"

func main() {
  var (
    X int
    A int
    B int
  )
  fmt.Scan(&X)
  fmt.Scan(&A)
  fmt.Scan(&B)

  remainAfterA := X - A
  buyB := remainAfterA / B
  ans := remainAfterA - buyB * B

  fmt.Println(ans)

}


Measured memory_bytes: 512
/**
 *    author:  [itmo] enot110
 *    created: 06.05.2017 14:59:46       
**/
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = 1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */




int main()
{
    #ifdef home
        assert(freopen("1.in", "r", stdin));
        assert(freopen("1.out", "w", stdout));
    #endif
    ll a, b, c;
    int res = 0;
    cin >> a >> b >> c;
    while (1)
    {
        if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) break;
        res++;
        ll aa = (b / 2) + (c / 2);    
        ll bb = (a / 2) + (c / 2);
        ll cc = (a / 2) + (b / 2);
        a = aa, b = bb, c = cc;
        if (res > 1e5)
        {
            printf("-1\n");
            return 0;
        }
    }
    printf("%d\n", res);
    #ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;


signed main(){
  
  string S;
  cin >> S;
  
  int ans = 0;
  int l = 0;
  int r = S.size()-1;
  while( l < r ){
    if( S.at(l) == S.at(r) ){
      l++;
      r--;
    }else if( S.at(l) == 'x' ){
      ans++;
      l++;
    }else if( S.at(r) == 'x' ){
      ans++;
      r--;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,s,f;
	char d[2];
	while(1){
		scanf("%d %c %d",&a,&d[1],&s);
		if(d[1]=='?')
			break;
		if(d[1]=='+')
			f=a+s;
		if(d[1]=='*')
			f=a*s;
		if(d[1]=='-')
			f=a-s;
		if(d[1]=='/')
			f=a/s;
		printf("%d\n",f);
	}
	return 0;
}	

Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main()
{
    int n, k;
    cin >> n >> k;

    combination cnb(2*n);

    mint sum =  cnb(2*n-1, n);
    mint sum_d = 0;
    for (int m = 0; m <= n-k-2; m++)
    {
        sum_d += cnb(n-1,m) * cnb(n,m+1);
    }

    cout << (sum-sum_d).x << endl;

}



Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 ll n;
  cin>>n;
  string s;
  cin>>s;
  ll c=0;
  for(ll i=0;i<=s.length()-3;i++)
  {
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C' )
      c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{	
	public static void main(String[] args){
		
		//RLで収束する。RLのうち偶数回目に到着した方が答えになる。
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		int ans[] = new int[N];
		for(int i=0;i<N;i++)ans[i]=0;
		char before ='R';
		int cnt = 0;
		for(int i=0;i<N;i++) {
			if(before=='R') {
				if(S.charAt(i)=='R')cnt++;
				else {//Lの時
					ans[i-1]+=(cnt+1)/2;
					ans[i]+=cnt/2;
					before='L';
					cnt=1;
				}
			}else {//beforeがLの時
				if(S.charAt(i)=='L')cnt++;
				else {//Rの時
					ans[i-cnt]+=(cnt+1)/2;
					ans[i-cnt-1]+=cnt/2;
					before='R';
					cnt=1;
				}
			}
		}
		ans[N-cnt]+=(cnt+1)/2;
		ans[N-cnt-1]+=cnt/2;
		
		StringBuilder sb = new StringBuilder();
		for(int tmp:ans) sb.append(tmp+" ");
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 40576
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	string S, T; cin >> S >> T;

	if (S.size() != T.size() - 1) {
		cout << "No" << endl;
		return 0;
	}

	rep(i, S.size()) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 10956
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=d;j++)
        {
            if(j>9)
            {
                int x=j%10;
                int y=j/10;
                if(x>=2&&y>=2)
                {
                    if(x*y==i)
                    {
                        ans++;
                    }
                }
            }
        }
    }

    cout<<ans;
} 



Measured memory_bytes: 256
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    string s;
    cin >> s;
    if (s == "0") break;

    int n = s.size();
    int sum = 0;

    for (int i = 0; i < n; i++) sum += s[i] - '0';

    printf("%d\n", sum);
  }

  return 0;
}

Measured memory_bytes: 1196
#include<cstdio>


int main(void)
{
	int a, b;

	while(scanf("%d%d", &a, &b)==2)
	{
		int ans=-1;

		if((b%a)==0) ans=a+b;
		else ans=b-a;

		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var D = array[0];
        var N = array[1] == 100? 101: array[1];
        Console.WriteLine(N * Math.Pow(100, D));
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define mod 1000000007
void solve(){
	int n,k;
	cin>>n>>k;
	int a[3];
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<k;i++){
		for(int j=i;j<n;j+=k){
			ans+=((s[j]=='r')?a[2]:0)+((s[j]=='s')?a[0]:0)+((s[j]=='p')?a[1]:0);
			if(s[j]==s[j+k])
				j+=k;
		}
	}
	cout<<ans<<endl;
}

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


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

const double EPS = 1e-8;

double pow2(double x) { return x * x; }

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> x(n), y(n), z(n), r(n);
  vector<ll> l(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
  }
  for (int i = 0; i < q; i++) {
    int sx, sy, sz, dx, dy, dz;
    cin >> sx >> sy >> sz >> dx >> dy >> dz;
    ll ans = 0;
    int vx = dx - sx;
    int vy = dy - sy;
    int vz = dz - sz;
    for (int j = 0; j < n; j++) {
      int wx = x[j] - sx;
      int wy = y[j] - sy;
      int wz = z[j] - sz;
      double t = 0.0;
      t += vx * wx;
      t += vy * wy;
      t += vz * wz;
      t /= pow2(vx) + pow2(vy) + pow2(vz);
      double len2 = 0.0;
      len2 += pow2(vx * t - wx);
      len2 += pow2(vy * t - wy);
      len2 += pow2(vz * t - wz);
      if (0.0 < t && t < 1.0 && len2 <= pow2(r[j]) + EPS) ans += l[j];
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3100
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char a[] = new char[N+1];
        String s = sc.next();
        a = Arrays.copyOf(s.toCharArray(), N+1);
        char tmp = a[0];

        int result = 0;

        for (int i = 1; i <= N; i++) {
            if (a[i] != tmp) {
                result++;
                tmp = a[i];
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 25684
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,i;
  cin>>n>>m;
  vector<int> x(n+1),y(m+1);
  cin>>x.at(0)>>y.at(0);
  for(i=1;i<=n;i++) cin>>x.at(i);
  for(i=1;i<=m;i++) cin>>y.at(i);
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if(x.at(n)<y.at(0)) cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<unordered_map>
using namespace std;

vector<int>rinsetu[900];
int main() {;
	int a, b;
	while (cin >> b >> a, a | b) {
		for (int k = 0; k < 900; k++)rinsetu[k].clear();
		for (int c = 0; c < a*2-1; c++) {
			if (c & 1) {
				for (int d = 0; d < b; d++) {
					int e; scanf("%d", &e);
					if (e == 0) {
						rinsetu[(c / 2)*b + d].push_back((c / 2 + 1)*b + d);
						rinsetu[(c / 2+1)*b + d].push_back((c / 2)*b + d);
					}
				}
			}
			else {
				char f; scanf("%c", &f);
				for (int d = 0; d < b - 1; d++) {
					int e; scanf("%d", &e);
					if (e)continue;
					rinsetu[(c / 2)*b + d].push_back((c / 2)*b + d + 1);
					rinsetu[(c / 2)*b + d+1].push_back((c / 2)*b + d);
				}
			}
		}
		int mincost[900]{};
		queue<int>Q;
		mincost[0] = 1;
		Q.push(0);
		while (Q.size()) {
			int t = Q.front(); Q.pop();
			for (int i : rinsetu[t]) {
				if (mincost[i] == 0) {
					mincost[i] = mincost[t] + 1;
					Q.push(i);
				}
			}
		}
		if (mincost[a*b - 1] == 0)puts("0");
		else cout << mincost[a*b - 1] << endl;
	}
}

Measured memory_bytes: 3148
N, K = map(int, input().split())

if K == 0:
    print(N**2)
    exit()

ans = 0
for b in range(K + 1, N + 1):
    q, r = divmod(N, b)
    ans += q * (b - K)
    ans += max(0, r - K + 1)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>


using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> heights(n);
  for (int i = 0; i < n; ++i) cin >> heights[i];
  vector<vector<int>> adj(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >>a>>b;
    adj[a-1].push_back(b-1);
    adj[b-1].push_back(a-1);
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    int h = heights[i];
    bool pass = true;
    for (auto& c : adj[i]) {
      if (heights[c] >= h) {
	pass = false;
	break;
      }
    }
    if (pass) ++ret;
  }
  cout << ret << endl;
  return 0;
}

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

int n, d;
vector<vector<int>> points;

bool integerdist(vector<int> x, vector<int> y) {
    int sum = 0;
    for (int i = 0; i < d; i++) sum += (x[i]-y[i])*(x[i]-y[i]);
    double dis = sqrt((double)sum);
    int intdis = (int)dis;
    return dis == (double)intdis;
}

int main() {
    cin >> n >> d;
    points = vector<vector<int>>(n,vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            scanf("%d", &points[i][j]);
        }
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            count += integerdist(points[i], points[j]);
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

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

  int lower[6] = {1, -1, 100, -1, 10000, -1};
  int base[6] = {10, 100, 1000, 10000, 100000, 1000000};

  int keta = log10(n);
  // int keta = n / 10;

  int64_t sum = 0;
  for (int i = 0; i <= keta; ++i) {
    if ((i % 2) == 1) {
      continue;
    }
    if (i == keta) {
      sum += (n - lower[i] + 1);
    } else {
      sum += (base[i] - lower[i]);
    }
  }
  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

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

unsigned int a[200000];

int
main()
{
  unsigned int n;
  cin >> n;

  unsigned int rank[2][2] = {}; // 1 = in, 2 = val;

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] >= rank[0][1]) {
      rank[1][0] = rank[0][0];
      rank[1][1] = rank[0][1];
      rank[0][0] = i;
      rank[0][1] = a[i];
    } else if (a[i] >= rank[1][1]) {
      rank[1][0] = i;
      rank[1][1] = a[i];
    }
  }

  bool fse = false;
  bool sse = false; // first same exist, second same exist;

  for (int i = 0; i < n; ++i) {
    if (a[i] == rank[0][1]) {
      if (i != rank[0][0]) {
        fse = true;
        cout << rank[0][1] << endl;
        continue;
      } else {
        cout << rank[1][1] << endl;
        continue;
      }
    } else {
      cout << rank[0][1] << endl;
    }
  }

	return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,ans,a[100010],ma=-10;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	a[n+1]=100000000000;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=a[i+1])
		{
			ans++;
		}
		else 
		{
		ma=max(ma,ans);	
		ans=0;	
		}
	}
	cout<<ma;
}

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

int main() {
  long long X,N,A,B,C,ans;
  cin >>X;
  ans=0;
  A=100;
  while(A<X){
    A*=1.01;
    A=floor(A);
    ans++;
  }
  cout <<ans<< endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll l = 1, t;
    rep(i,n){
        cin >> t;
        l = lcm(l, t);
    }
    cout << l << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
struct State { int i, j, cost; };

int H, W, N;
vector<string> vs;
const int di[] = { 0, -1, 0, 1 };
const int dj[] = { 1, 0, -1, 0 };

void main2() {
  queue<State> Q;
  rep(i,H) rep(j,W) {
    if (vs[i][j] == 'S') Q.push((State){i,j,0});
  }
  int ans = 0;
  rep(loop,N) {
    vector<vector<int > > d(H, vector<int>(W, 1<<30));
    while (!Q.empty()) {
      State s = Q.front(); Q.pop();
      if (d[s.i][s.j] <= s.cost) continue;
      d[s.i][s.j] = s.cost;
      rep(i,4) {
        int ti = s.i + di[i], tj = s.j + dj[i];
        if (ti < 0 || tj < 0) continue;
        if (ti >= H || tj >= W || vs[ti][tj] == 'X') continue;
        if (d[ti][tj] > s.cost + 1)
          Q.push((State){ti, tj, s.cost + 1});
      }
    }
    rep(i,H) rep(j,W) if (vs[i][j] - '0' == loop+1) {
      ans += d[i][j];
      Q.push((State){i,j,0});
    }
  }
  printf("%d\n", ans);
}

int main() {
  while (cin >> H >> W >> N) {
    vs.clear();
    cin.ignore();
    string line;
    rep(i,H) {
      getline(cin, line);
      vs.push_back(line);
    }
    main2();
  }
  return 0;
}

Measured memory_bytes: 5860
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back

int n;

int t[300],v[300];

int main(){
  cin>>n;
  rep(i,n){
    cin>>t[i];
    t[i]*=2;
    if(i)
      t[i]+=t[i-1];
  }
  rep(i,n){
    cin>>v[i];
    v[i]*=2;
  }
  vector<int> c(2*t[n-1]+1,inf);
  c[0]=0;
  c[t[n-1]]=0;
  int x=0;
  rep(i,n){
    FOR(j,x,t[i]+1){
      c[j]=min(c[j],v[i]);
    }
    x=t[i];
  }
  FOR(i,1,t[n-1]+1){
    c[i]=min(c[i],c[i-1]+1);
  }
  rrep(i,t[n-1]-1){
    c[i]=min(c[i],c[i+1]+1);
  }

  double ans=0;
  rep(i,t[n-1]){
    ans+=c[i]+c[i+1];
  }
  
  printf("%.10lf\n",ans/8);
}


Measured memory_bytes: 512
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
///////////////////////////////////////////////////////////

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int a,b,m;cin >> a >> b >> m;
    vector<pair<int,int> > A(a),B(b);
    REP(i,a){
        int x;cin >> x;
        A[i] = mp(x,i);
    }
    REP(i,b){
        int x;cin >> x;
        B[i] = mp(x,i);
    }
    int ans = INT_MAX;
    REP(i,m){
        int x,y;cin >> x >> y;
        x--,y--;
        int c;cin >> c;
        ans = min(ans,A[x].first + B[y].first - c);
    }
    sort(all(A));
    sort(all(B));
    ans = min(ans,A[0].first + B[0].first);
    cout << ans << '\n';
    return 0;
}
/*
 * ちょっと待って！
 * そのコード本当に提出して大丈夫？
 * たくさんのコーナーケースがあるよ！
 * 君の注意力は大したことないよ！
 * WAを出すと君は冷静さを失うよ！
 * */


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    string s; int k; cin >> s >> k;
    int now = 0;
    int n = s.size();
    while(k){
        int tmp = s[now] - 'a';
        if(now == n-1){
            tmp += k;
            tmp %= 26;
            s[now] = 'a' + tmp;
            k = 0;
        }
        else if(0 < tmp && tmp + k >= 26){
            s[now] = 'a';
            k -= 26 - tmp;
        }
        now++;
    }
    cout << s << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

int main(void) {
    int64_t N,A;
    int64_t minabs;
    int64_t sum = 0;
    int64_t minuscnt = 0;

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A;
        sum += abs(A);
        if(A < 0) minuscnt++;
        if(minabs > abs(A)) {
            minabs = abs(A);
        }
    }

    if(minuscnt%2) cout << sum - minabs - minabs << endl;
    else cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

int main() {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0;
  string s;
  cin >>s;
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


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

// Grading

int main(){
	int a, b, c;
	int sum;
	while(1){
		cin >> a >> b >> c;
		sum = 0;
		if(a == -1 && b == -1 && c == -1) break;

		if(a == -1 || b == -1){
			cout << 'F' << endl;
			continue;
		}

		sum = a + b;

		if(sum >= 80){
			cout << 'A' << endl;
		}
		else if(sum >= 65){
			cout << 'B' << endl;
		}
		else if(sum >= 50){
			cout << 'C' << endl;
		}
		else if(sum >= 30){
			if(c >= 50){
				cout << 'C' << endl;			
			}else{
				cout << 'D' << endl;			
			}
		}
		else{
			cout << 'F' << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    vector<ll> p,q,r;
    rep(i,a){
        ll t; cin >> t;
        p.pb(t);
    }
    rep(i,b){
        ll t; cin >> t;
        q.pb(t);
    }
    rep(i,c){
        ll t; cin >> t;
        r.pb(t);
    }
    sort(ALL(p),greater<ll>());
    sort(ALL(q),greater<ll>());
    sort(ALL(r),greater<ll>());
    
    priority_queue<ll, vector<ll>, greater<ll> > pq;
    ll ans=0;
    rep(i,x){
        pq.push(p[i]);
        ans+=p[i];
    }
    rep(i,y){
        pq.push(q[i]);
        ans+=q[i];
    }
    rep(i,c){
        ll tp=pq.top();
        if(r[i]>tp){
            pq.pop();
            pq.push(r[i]);
            ans-=tp;
            ans+=r[i];
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 4724
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 17, M = N << 2, mod = 1e9 + 7; 

int tt = 1;
ll a, b, c;

void solve () {
	cin >> a >> b >> c;
	if (a % 2 + b % 2 + c % 2 != 3) cout << 0;
	else cout << min(a * b, min(b * c, a * c));
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

Measured memory_bytes: 3576
N = int(input())

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


b = sorted(list(A))
dp = [0]*(max(A)+1)

m_a = max(A)+1
for i in b:
    dp[i] += 1
    if dp[i]==1 :
        if m_a%i:
            a = m_a//i+1
        else:
            a = m_a//i
        for j in range(2, a):
            dp[j*i] +=100

print(dp.count(1))

Measured memory_bytes: 41340
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
int main(){
	int a=read(),b=read();
	if((a&1)!=(b&1)) puts("IMPOSSIBLE");
	else printf("%d\n",(a+b)>>1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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() {
  int A, B, K;
  cin >> A >> B >> K;

  int r = A + K - 1;
  int l = B - K + 1;

  if (r >= l) {
    repp(i, A, B) { cout << i << endl; }
  } else {
    repp(i, A, r) { cout << i << endl; }
    repp(i, l, B) { cout << i << endl; }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    INIT;

    ll N, M;
    cin >> N >> M;
    vector<ll> a(M);
    rep(i, M) cin >> a[i];

    vector<mint> dp(N + 5, 0);
    dp[0] = 1;
    rep(i, N) {
        bool flg = true;

        if (binary_search(ALL(a), i)) flg = false;
        if (flg) {
            dp[i + 2] += dp[i];
            dp[i + 1] += dp[i];
        }
    }

    // rep(i, N + 1) { cout << dp[i] << " "; }
    // cout << endl;

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 4596
from heapq import heappush, heappop


# 入力
N = int(input())
x, y = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

# x座標およびy座標について街をソートし、ソート後に隣り合う街を辺で結んだ重み付きグラフを作成する
# 作成したグラフに対してプリム法により解を求める
ts = list(zip(range(1, N + 1), x, y))
ts_x = sorted(ts, key=lambda t: t[1])
ts_y = sorted(ts, key=lambda t: t[2])
G = [{} for _ in range(N + 1)]
for ((i, a, b), (j, c, d)) in zip(ts_x[1:], ts_x):
    G[i][j] = min(abs(c - a), abs(d - b))
    G[j][i] = G[i][j]
for ((i, a, b), (j, c, d)) in zip(ts_y[1:], ts_y):
    G[i][j] = min(abs(c - a), abs(d - b))
    G[j][i] = G[i][j]


def prim(G):
    used = [False for _ in range(len(G))]
    res = 0
    q = []
    used[1] = True
    for j, w in G[1].items():
        heappush(q, (w, j))
    while q:
        w, j = heappop(q)
        if not used[j]:
            used[j] = True
            res += w
            for j2, w2 in G[j].items():
                heappush(q, (w2, j2))
    return res


ans = prim(G)
# 出力
print(ans)


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

int main()
{
    int d, t, s;

    cin >> d >> t >> s;

    if (t * s >= d)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3616
#include  <iostream>
#include  <cstdio>

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

int main(){
for(;;){
        int n;
        scanf("%d",&n);
        
        if(n==0){return 0;}
        
        int x[n],y[n];
        x[0]=0;
        y[0]=0; 
        
        int c,d;

        for(int i=1;i<n;i++){
                scanf("%d %d",&c,&d);
                x[i]=x[c]+dx[d];
                y[i]=y[c]+dy[d];
        }
        
        int xmin=n;
        int ymin=n;
        int xmax=-n;
        int ymax=-n;
        
        for(int i=0;i<n;i++){
                if(xmin>x[i]){xmin=x[i];}
                if(xmax<x[i]){xmax=x[i];}
                if(ymin>y[i]){ymin=y[i];}
                if(ymax<y[i]){ymax=y[i];}       
        }
        
        printf("%d %d\n",xmax-xmin+1,ymax-ymin+1);
}
}

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

int main() {
  int N;
  int X = 0;
  cin >> N;

  for (int i = 0; i < 9; ++i) {
  	X += (N / (int)pow(10,i)) % 10;  
  }
  
  if (N % X == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll m;
	cin >> m;
	
	ll ans = 0;
	ll sum = 0;
	REP(i, m) {
		ll d, c;
		cin >> d >> c;
		ans += c;
		sum += d * c;
	}

	sum--;
	sum /= 9;//繰り上げする数
	ans += sum;
	ans--;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256