akhauriyash/Code-Regression huggingface dataset:
// SeeAlso: https://atcoder.jp/contests/abc129/tasks/abc129_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int P, Q, R;

int main() {
    cin >> P >> Q >> R;
    priority_queue<int, vector<int>, greater<int>> m;
    m.push(P);
    m.push(Q);
    m.push(R);

    int ans = 0;
    ans += m.top();
    m.pop();
    ans += m.top();
    print(ans);
    return 0;
}


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

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int x, y;
	cin >> x >> y;
	cout << 6 - x - y << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=2e5+5;
int dist[200005];
int inf=1e18;
int arr[N];
signed main()
{
 int n;
 cin>>n;
 int prod=1;
int flag=0;
for(int i=0;i<n;i++)
 {
     int x;
     cin>>x;
     arr[i]=x;

 }
 sort(arr,arr+n);
 for(int i=0;i<n;i++)
 {
     int x=arr[i];
     int temp=prod;
     prod*=x;
     if(prod<temp) {flag=1;}
 }
 if(arr[0]==0) cout<<"0";
    
 else if(flag==1 || prod>inf) cout<<"-1";
 else
 cout<<prod;
}


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

bool isPrimeNumber(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; ++i) if (n % i == 0) return false;
    return true;
}

int main() {
    vector<int> like(50000);
    like[0] = 0;
    for (int i = 3; i < 100000; i += 2) {
        like[(i - 1) / 2] = like[(i - 1) / 2 - 1] + (isPrimeNumber(i) and isPrimeNumber((i + 1) / 2));
    }
    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int l, r;
        cin >> l >> r;
        cout << (l == 1 ? like[(r - 1) / 2] : like[(r - 1) / 2] - like[(l - 3) / 2]) << endl;
    }
}


Measured memory_bytes: 768
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let p: u16 = read();
    let q: u16 = read();
    let r: u16 = read();
    let mut vec: Vec<u16> = vec![];
    vec.push(p);
    vec.push(q);
    vec.push(r);
    vec.sort();
    println!("{}", vec[0] + vec[1]);
}


Measured memory_bytes: 4352
/*
	0513:Shuffle The Cards
*/
#include	<iostream>
#include	<vector>

using namespace std;

typedef vector<int> VC_int;

void R_Shuffle(VC_int *v, int n);
void C_Shuffle(VC_int *v, int n, int k);

int main(void) {
	int n, m;
	VC_int Cards;
	
	cin >> n >> m;
	for(int i = 1; i <= n*2; i++) {
		Cards.push_back( i );
	}
	for(int t = 0; t < m; t++) {
		int slc;
		
		cin >> slc;
		if(slc == 0) {
			R_Shuffle(&Cards, n);
		} else {
			C_Shuffle(&Cards, n, slc);
		}
	}
	
	VC_int::iterator it = Cards.begin();
	while( it != Cards.end() ) {
		cout << *it << endl;
		it++;
	}
}

void R_Shuffle(VC_int *v, int n) {
	VC_int subCard_A, subCard_B;
	VC_int::iterator it = v->begin();
	for(int i = 0; i < n; i++, it++) {
		subCard_A.push_back( *it );
		subCard_B.push_back( *(it+n) );
	}
	it = v->begin();
	VC_int::iterator a_it = subCard_A.begin();
	VC_int::iterator b_it = subCard_B.begin();
	for(int i = 0; i < n; i++, it += 2, a_it++, b_it++) {
		*it = *a_it;
		*(it+1) = *b_it;
	}
}

void C_Shuffle(VC_int *v, int n, int k) {
	VC_int subCard_A, subCard_B;
	VC_int::iterator it = v->begin();
	for(int i = 0; i < k; i++, it++) {
		subCard_A.push_back( *it );
	}
	for(int i = k; i < n*2; i++, it++) {
		subCard_B.push_back( *it );
	}
	it = v->begin();
	VC_int::iterator a_it = subCard_A.begin();
	VC_int::iterator b_it = subCard_B.begin();
	while( b_it != subCard_B.end() ) {
		*it = *b_it;
		it++;
		b_it++;
	}
	while( a_it != subCard_A.end() ) {
		*it = *a_it;
		it++;
		a_it++;
	}
}

Measured memory_bytes: 1220
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(list[k-1])

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;


int main() {
	int x;
	cin >> x;
	int coin[2] = { 500,5 };
	int happy[2] = { 1000,5 };
	int ans = 0;
	for(int i=0;i<2;i++) {
		int num = x / coin[i];
		ans += num * happy[i];
		x %=coin[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

if not any(ti == ai == t[-1] == a[0] for ti, ai in zip(t, a)):
    print(0)
    exit()

ans = 1
for i in range(1, n - 1):
    if t[i - 1] == t[i] and a[i] == a[i + 1]:
        ans = ans * min(t[i], a[i]) % mod
print(ans)


Measured memory_bytes: 97792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = new string(Console.ReadLine().OrderBy(x => x).ToArray());
            var t = new string(Console.ReadLine().OrderByDescending(x => x).ToArray());
            if (s.CompareTo(t) < 0)
            {
                Console.WriteLine("Yes");   
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int a, b;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	double tmp;
	cin >> a >> tmp;
	b = round(tmp*100);
	int ans = a*b / 100;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3728
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
#include <numeric>
using namespace std;
#define mod 1000000007

double get(int i){
    double value=0.0;
    double sum = double(i*(i+1))/double(2);
    value = double(sum)/double(i);
    return value;
}

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

#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    vector<double>v(1010,0);
    for(int i=1;i<(int)v.size();++i){
        v.at(i)=double(get(i));
    }
    int n , k; cin>>n>>k;
    vector<int>arr(n);
    for(auto&itr:arr){
        cin>>itr;
    }
    int i(0);
    double t_ex{};
    double exp{};
    for(;i<k;++i){
        t_ex+=(v.at(arr[i]));
    }
    exp = max(exp , t_ex);
    for(;i<arr.size();++i){
        t_ex-=(v.at(arr[i-k]));
        t_ex+=(v.at(arr[i]));
        exp = max(exp , t_ex);
    }
    cout<<fixed<<setprecision(7)<<exp<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long max = 1000000000000000000l;
		long ans = 1;
		boolean of = false;
		for(int i=0; i<N; i++) {
			long A = sc.nextLong();
			if(A==0) {
				ans = 0;
				of = false;
			}
			if(ans>0) {
				long Amax = max/ans;
				if(A>Amax) {
					of = true;
				} else {
					ans *= A;
				}
			}
		}
		System.out.println(of? -1 : ans);

		sc.close();
	}
}


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

#define PI acos(-1)
using namespace std;

int main() {
  double ans,rad,deg,A,B;
  double H,M;
  cin >> A >> B >> H >> M;
  H = 30*H + 0.5*M;
  M *= 6;
  if(H > M){
    deg = H - M;
  }
  else{
    deg = M - H;
  }
  /*
  rad = cos((deg*PI)/180.0);
  ans = A*A + B*B - rad*2*A*B;
  cout << setprecision(20) << sqrt(ans) << endl;
  */
  rad = cos((deg*M_PI)/180.0);
  ans = A*A + B*B - rad*2*A*B;
  cout << setprecision(20) << sqrt(ans) << endl;
  return 0;
}

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

int base = 226732710;
int n,k;
ll ans = 0;

ll dis(ll a,ll b){
  if(a <= b) return (b-a+1);
  if(a >= b){
    return (mod-a+1 + b);
  }
}

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n>>k;
  for(ll i = k;i <= n+1;i++){
    ll down = i*(i-1)/2;
    ll up = (2*n-i+1)*i/2;
    ans = (ans + up-down+1)%mod;
  }
  cout<<ans%mod<<endl;
  return 0;
}


Measured memory_bytes: 3640
n,m=map(int,input().split())
a=[]
for _ in range(n):
  b=list(map(int,input().split()))
  a.append(b)
  
a.sort(key=lambda x: x[0])
ans=0
h=0

for y in a:
  d=y[0]
  e=y[1]
  if h+e>m:
    ans+=(m-h)*d
    h+=(m-h)
  else:
    h+=e
    ans+=d*e

print(ans)

Measured memory_bytes: 28512
program main
  implicit none
  integer :: n, i
  integer, allocatable :: b(:), res(:)

  read (*, *) n
  allocate (b(n), res(n))
  read (*, *) b(:)

  do i = 1, n
    if (b(i) > i) then
      write (*, "(i0)") -1
      stop
    end if
  end do

  do i = 1, n
    call remove(b, res(n - i + 1))
  end do

  do i = 1, n
    write (*, "(i0)") res(i)
  end do

  contains

  subroutine remove(b, ret)
    integer, allocatable, intent(inout) :: b(:)
    integer, intent(out) :: ret
    integer :: n, i, c(size(b))
    n = size(b)
    c = [(b(i) - i, i = 1, n)]
    loop: block
      do i = n, 1, -1
        if (c(i) == 0) exit loop
      end do
      stop 1
    end block loop
    ret = b(i)
    b = [b(:i - 1), b(i + 1:)]
  end subroutine remove
end program main


Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static int h, w;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        var b = int.Parse(line[2]);
        var ps = new List<P>();
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
                if (s[j] == '#') ps.Add(new P { x = i, y = j });
        }
        getAns(b, ps);
    }
    static int check(List<P> ps, int x, int y)
    {
        var count = 0;
        foreach (var t in ps)
        {
            var cx = (x >> t.x) & 1;
            var cy = (y >> t.y) & 1;
            if (cx == 0 && cy == 0) count++;
        }
        return count;
    }
    static void getAns(int b, List<P> ps)
    {
        var imax = 1 << h;
        var jmax = 1 << w;
        var ans = 0;
        for (int i = 0; i < imax; i++)
        {
            for (int j = 0; j < jmax; j++)
            {
                if (check(ps, i, j) == b) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 27820
L, R = map(int, input().split())

minimize = 2018
P = 0

if R-L >= 2019:
	print(0)
	exit()
else:
	for i in range (L, R):
		for j in range (i+1, R+1):
			P = (i*j)%2019
			if P < minimize:
				minimize = P
print(minimize)

Measured memory_bytes: 9104
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

string s;
int q;
deque<char> dq;


int main()
{
  cin >> s;
  for(auto c : s)
    dq.push_back(c);
  int rev = 0;
  cin >> q;
  while(q--) {
    int t; 
    cin >> t;
    if(t == 1) {
      rev ^= 1;
    } else {
      int f;
      char c;
      cin >> f >> c;
      --f;
      if(rev) f ^= 1;
      if(f == 0)
        dq.push_front(c);
      else
        dq.push_back(c);
    }
  }
  string r = "";
  for(auto c : dq)
    r += c;
  if(rev)
    reverse(all(r));
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1412
import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil

# def gcd(a, b):
# 	if(a==0):
# 		return b 
# 	return gcd(b%a,a)

# def sieve(n): 
# 	prime=[True for i in range(n+1)]
# 	p=2
# 	while(p*p<=n): 
# 		if (prime[p]==True): 
# 			for i in range(p*p,n+1,p): 
# 				prime[i]=False
# 		p+=1
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s 

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())

#_______________________________________________________________________________________________________________________________________

l=list_input()
print(15-sum(l))

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

int main(){
  int X,N;
  cin >> X >> N;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i];
  }
  int flag=0,ansp=300,ansm=200;
  for(int i=0; i<100; i++){
    flag=0;
    for(int j=0; j<N; j++){
      if(X+i == p[j]){
        flag=1;
      }
    }
    if(flag == 0){
      ansp = i;
      break;
    }
  }
  
  for(int i=0; i<100; i++){
    flag=0;
    for(int j=0; j<N; j++){
      if(X-i == p[j]){
        flag=1;
      }
    }
    if(flag == 0){
      ansm = i;
      break;
    }
  }
  if(ansp >= ansm) cout << X-ansm;
  else cout << X+ansp;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c){
        printf("%d %d %d\n",a,b,c);
    }else if(a<=b&&a<=c&&b>=c){
        printf("%d %d %d\n",a,c,b);
    }else if(b<=a&&a<=c){
        printf("%d %d %d\n",b,a,c);
    }else if(b<=a&&b<=c&&c<=a){
        printf("%d %d %d\n",b,c,a);
    }else if(c<=a&&a<=b){
        printf("%d %d %d\n",c,a,b);
    }else if(c<=a&&c<=b&&a>=b){
        printf("%d %d %d\n",c,b,a);
    }
}




Measured memory_bytes: 2760
package main
import (
	"fmt"
)
/*
func main() {
	ans := map[int]bool{}
	for i := 1; i<=100; i++ {
		ans[i] = false
	}
	for y := 1; y <= 9; y++ {
		for x := 1; x <= 9; x++ {
			ans[x*y] = true
		}
	}
	s := `ans := []string{ "No" `
	for i := 1; i<=100; i++ {
		if ans[i] {
			 s += `, "Yes"`
		} else {
			 s += `, "No"`
		}
	}
	s += `}`
	fmt.Println(s)
}
*/

func main() {
	var i int
	fmt.Scanf("%d", &i)
	ans := []string{ "No" , "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "No", "Yes", "No", "Yes", "Yes", "Yes", "No", "Yes", "No", "Yes", "Yes", "No", "No", "Yes", "Yes", "No", "Yes", "Yes", "No", "Yes", "No", "Yes", "No", "No", "Yes", "Yes", "No", "No", "No", "Yes", "No", "Yes", "No", "No", "Yes", "No", "No", "Yes", "Yes", "No", "No", "No", "No", "Yes", "No", "Yes", "No", "No", "No", "No", "No", "No", "Yes", "Yes", "No", "No", "No", "No", "No", "No", "No", "Yes", "No", "No", "No", "No", "No", "No", "No", "No", "Yes", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No"}
	fmt.Println(ans[i])
}




Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf")]*(N)
dp[0] = 0
 
for i in range(1,N):
    for j in range(max(i-K,0),i):
        dp[i] = min(abs(h[i]-h[j])+dp[j],dp[i])
 
print(dp[N-1])

Measured memory_bytes: 54876
#include <iostream>
using namespace std;
const int mod = 1000000007;
int N, A, B, C, D, dp[1009][1009], comb[1009][1009], inv[1009];
int main() {
	comb[0][0] = 1;
	for (int i = 1; i <= 1000; i++) {
		for (int j = 0; j <= i; j++) {
			comb[i][j] = comb[i - 1][j];
			if (j >= 1) {
				comb[i][j] += comb[i - 1][j - 1];
				if (comb[i][j] >= mod) comb[i][j] -= mod;
			}
		}
	}
	inv[1] = 1;
	for (int i = 2; i <= 1000; i++) inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
	cin >> N >> A >> B >> C >> D; dp[0][0] = 1;
	for (int i = 0; i <= B - A; i++) {
		int num = i + A;
		for (int j = 0; j <= N; j++) {
			dp[i + 1][j] = dp[i][j];
			int mul = 1;
			for (int k = 1; k < C && j - num * k >= 0; k++) mul = 1LL * mul * comb[j - num * (k - 1)][num] % mod * inv[k] % mod;
			for (int k = C; k <= D && j - num * k >= 0; k++) {
				mul = 1LL * mul * comb[j - num * (k - 1)][num] % mod * inv[k] % mod;
				dp[i + 1][j] = (dp[i + 1][j] + 1LL * dp[i][j - num * k] * mul) % mod;
			}
		}
	}
	cout << dp[B - A + 1][N] << endl;
	return 0;
}

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

int main(){
  int A,B,C;

  cin >> A >> B >>C;

  for(int i=1;i<=B;i++){
    if(i*A % B == C){
      cout << "YES" <<endl;
      return 0;
    }
  }

  cout << "NO" <<endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    string o, e;
    cin >> o >> e;
    int n = o.length() + e.length();
    rep(i, n) {
        if ( !(i&1) ) cout << o[i/2];
        else          cout << e[i/2];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll c = 0, b = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] % 2 == 0)
            b++;
        else
            c++;
    }
    if (b == 0)
    {
        if (c <= 2)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    else if (c == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        if (c % 2 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
}


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

const int mod = 1e9 + 7;
long long calc(long long a, long long b, long long p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		long long d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}
signed main(void)
{
	long long n, k;
	cin >> n >> k;
	long long sum[n + 1], ans;
	int l, r;
	ans = 0;
	rep(i, n + 1) sum[i] = i;
	rep(i, n) sum[i + 1] += sum[i];
	for(int i = k; i <= n + 1; i++)
	{
		if (n - i >= 0)
			ans += (sum[n] - sum[n - i]) - sum[i - 1];
		ans += 1;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
int k,a[105],b[105],s=0,j;
int main(){
	cin>>k;
	for(j=1;j<k;j++){cin>>a[j+1];}
	a[1]=a[2];
	for(j=1;j<k;j++)
	{
		b[j]=min(a[j+1],a[j]);
		s+=b[j];
	}
	cout<<s+a[k]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int cnt = 0;
    int k = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            cnt++;
            k = max(k,cnt);
        }else{
            cnt = 0;
        }
    }
    cout << k+1 << endl;
}



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

int main() 
{
	int n; cin>>n;
	string s,q;
	cin>>s>>q;
	string res="";
	int bit=1;
	for(int i=0;i<n;i++)
	{
		res+=s[i];
		res+=q[i];
	}
	cout<<res;
	
}

Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        // Your code here!
        var A=System.Console.ReadLine();
        var B=System.Console.ReadLine();
        
        
        int count=0;
        
        for(var i=0;i<A.Length;i++)
        {
            if(A[i]==B[i])
            {
                
            }else
            {
                count=count+1;
            }
        }
        
        System.Console.WriteLine(count);
    }
}


Measured memory_bytes: 27332
N = int(input())
a = list(map(int, input().split()))
K = 0
p = 0
bricks = [[] for i in range(N)] #iと書かれたレンガがどこにあるか

for i in range(N):
  bricks[a[i] - 1].append(i)

for i in range(N):
  if len(bricks[i]) == 0:
    break
  elif bricks[i][-1] < p:
    break
  else:
    for j in bricks[i]:
      if j >= p:
        p = j
        K += 1
        break
if K == 0:
  print(-1)
else:
  print(N - K)

Measured memory_bytes: 40900
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
  int N, Q, M, t, n, d;
  while (cin >> N >> Q, N||Q){
    vector<int> D(100,0);
    d = 0;
    n = 0;
    for (int i = 0; i < N; ++i){
      cin >> M;
      for (int j = 0; j < M; ++j){
    cin >> t;
    D[t-1] += 1;
      }
    }
    for (int i = 0; i < 100; ++i){
      if (D[i] > n){
    n = D[i];
    d = i;
      }
    }
    if (n >= Q) cout << d+1 << endl;
    else cout << 0 << endl;
  }
}


Measured memory_bytes: 3000
import math
N = int(input())
s = math.floor(math.sqrt(N))
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
ans = make_divisors(N-1)
for i in range(2, s+1):
    temp = N % i
    if temp == 0:
        temp2 = N // i
        temp = temp2 % i
        while temp == 0:
            temp2 = temp2 // i
            temp = temp2 % i
        if temp == 1 and i not in ans:
            ans.append(i)
    elif temp == 1 and i not in ans:
        ans.append(i)
print(len(ans))

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

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

ll h[100010];
ll dp[100010]; 

int main(){

    int n; cin >> n;
    rep(i, n) cin >> h[i];

    rep(i, 100010) dp[i] = INF18;
    dp[0] = 0;

    for(int i = 1; i < n; i++){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i > 1){
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }

    cout << dp[n-1];
return 0;
}

Measured memory_bytes: 5128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] min = new long[n];
        
        int count = 1;
        min[0] = sc.nextLong();
        for(int i = 1;i < n;i++) {
            long p = sc.nextLong();
            if(p <= min[i - 1]) {
                min[i] = p;
                count++;
            }
            else {
                min[i] = min[i - 1];
            }
        }
    
        System.out.println(count);
    }
}


Measured memory_bytes: 82524
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#include<string>
#include<map>
#include<utility>
#include<functional>
typedef long long ll;
using namespace std;
typedef pair<int,float> p;

vector<ll> q;
int n,m;
string s;

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  printf("%d\n",(A*B >= C*D) ? A*B : C*D);
  return 0;
}


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

int main(){
    int N,M,X;
    cin >> N>>M>>X;
    int C[N];
    int A[N][M];
    int u[M];
    int tmp,ans=10000000,sum;
    int flag=0,flag2=0;
    for(int i=0;i<N;i++){
        cin >>C[i];
        for (int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }

    for(int i=1;i<(int)pow(2,N);i++){
        tmp=i;
        sum=0;
        flag=1;
        for(int k=0;k<M;k++) u[k]=0;
        for(int j=0;j<N;j++){
            if(tmp%2==1){
                for(int k=0;k<M;k++){
                    u[k]+=A[j][k];
                }
                sum+=C[j];
            }
            tmp/=2;
        }
        for(int k=0;k<M;k++){
            if (u[k]<X) flag=0;
        }
        if ((flag==1)&&(sum<ans)){
            flag2=1;
            ans=sum;
        }
        
    }   
    if(flag2==0) ans = -1;
    cout <<ans;
}

Measured memory_bytes: 4064
# Studying https://img.atcoder.jp/abc164/editorial.pdf

# Inputs

N,M,S = gets.split.map(&:to_i)
E = Array.new(N){ [] }
M.times{
	u,v,a,b = gets.split.map(&:to_i)
	E[u-1] << [v-1,a,b]
	E[v-1] << [u-1,a,b]
}
X = N.times.map{
	c,d = gets.split.map(&:to_i)
	lambda{|＿,￣|
		x = (￣-＿+c-1)/c
		return c*x, d*x
	}
}

# Tools

class PQ
	def initialize
		@h = [] # min-heap
	end

	def enq v
		@h << v
		up_heap
	end

	def deq
		min, last = @h[0], @h.pop
		unless @h.empty?
			@h[0] = last
			dn_heap
		end
		return min
	end

private
	def up_heap
		i, up = @h.size-1, @h[-1]
		while 0 <= (iP = (i-1)/2)
			break unless up < @h[iP]
			@h[i], i = @h[iP], iP
		end
		@h[i] = up
	end

	def dn_heap
		i, dn, size = 0, @h[0], @h.size
		while (iC = 2*i+1) < size
			iC += 1 if iC+1 < size and @h[iC+1] < @h[iC]
			break unless @h[iC] < dn
			@h[i], i = @h[iC], iC
		end
		@h[i] = dn
	end
end

R = lambda{|t,s,u|
	next t<<18 | [s,2450].min<<6 | u
}
Я = lambda{|r|
	next r>>18, r>>6&4095, r&63
}

# Main

n,T = 0, [nil]*N
２,３,４ = [-1]*N, [0]*N, [nil]*N
Q = PQ.new; Q.enq R[0,S,0]
while r = Q.deq
	t,s,u = Я[r]

	next if s <= ２[u] # 銭なしの再訪に用なし
	２[u] = s

	unless T[u] # first arrived.
		n, T[u] = n+1, t
		break if n == N # completed.
	end

	least_s = 2450
	E[u].each{|v,a,b|
		z, y = ２[v]+a, ３[v]+a # z < y
		if z < s
			c, d = s < y ? X[v][s-a,３[v]] : [0,0]
			if ４[v] != r = R[t+b+d,s-a+c,v]
				Q.enq(４[v] = r)
			end
		end
		least_s = [[s,z].max+1,least_s].min
	}
	３[u] = least_s

	c,d = X[u][s,least_s]
	if ４[u] != r = R[t+d,s+c,u]
		Q.enq(４[u] = r)
	end
end

# Output

T.shift
p(*T)


Measured memory_bytes: 14520
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n, m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        vector<int> h(n), w(m);
        vector<int> hsum(n + 1, 0), wsum(m + 1, 0);
        rep(i, n) {
            cin >> h[i];
            hsum[i + 1] = hsum[i] + h[i];
        }
        rep(i, m) {
            cin >> w[i];
            wsum[i + 1] = wsum[i] + w[i];
        }
        set<int> se;
        vector<int> hse, wse;
        for(int i = 0; i < n + 1; ++i) {
            for(int j = i + 1; j < n + 1; ++j) {
                se.insert(hsum[j] - hsum[i]);
                hse.pb(hsum[j] - hsum[i]);
            }
        }
        for(int i = 0; i < m + 1; ++i) {
            for(int j = i + 1; j < m + 1; ++j) {
                wse.pb(wsum[j] - wsum[i]);
            }
        }
        sort(all(wse)); sort(all(hse));
        int ans = 0;
        for(auto x : se) {
            ans += (upper_bound(all(wse), x) - lower_bound(all(wse), x)) * (upper_bound(all(hse), x) - lower_bound(all(hse), x));
        }
        cout << ans << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


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

using namespace std;

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

	int n;
	cin >> n;

	vector<string> s(n);
	map<string, long long> mp;
	for(int i = 0; i < n; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		mp[s[i]]++;
	}

	long long ans = 0;

	for(auto i : mp) {
		ans += (i.second)*(i.second-1)/2;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 16640
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;

int main() {
	
	int h, w;
	cin >> h >> w;
	vector<string> maze;

	string first;
	rep(i, w+2) {
		first += ".";
	}
	maze.push_back(first);
	rep(i, h) {
		string s;
		cin >> s;
		s = "." + s + ".";
		maze.push_back(s);
	}
	maze.push_back(first);
	bool ans = true;
	for (int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; j++) {
			if (maze[i][j] == '#') {
				if (maze[i][j + 1] == '#' || maze[i + 1][j] == '#' || maze[i][j - 1] == '#' || maze[i - 1][j] == '#') {
					continue;
				}
				else ans = false;

			}
		}
		if (ans == false) break;
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    roop_num = int(input())

    get_freebie = {}
    for i in range(roop_num):
        freebie = input()

        if not freebie in get_freebie:
            get_freebie[freebie] = 0

    print(len(get_freebie))

if __name__ == '__main__':
    main()

Measured memory_bytes: 35272
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	string s,t;
	cin>>s;
	cin>>t;
	int i,c=0;
	for(i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		c++;
	}
	cout<<c<<endl;
	return 0;
}

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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
	int n , k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	bool dp[k+1];
	for(int i = 0; i < a[0]; i++) dp[i] = false;
	for(int i = a[0]; i <= k; i++) {
		dp[i] = false;
		for(int j = 0; a[j] <= i && j < n; j++) dp[i] = dp[i] || (!dp[i-a[j]]);
	}

	if(dp[k]) cout << "First\n";
	else cout << "Second\n";

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

set<lint> decomp(lint N){
    set<lint> res;
    for(int i=2;i<=1100000;i++){
        while(N%i==0) N/=i,res.insert(i);
        if(N==1) break;
        if(i==1100000) res.insert(N);
    }
    return res; 
}

int main(void){
    lint A,B;
    int ans=0;
    cin >> A >> B;
    set<lint> Adiv=decomp(A),Bdiv=decomp(B);
    Adiv.insert(1),Bdiv.insert(1);
    for(int i=1;i<=1000000;i++) if(Adiv.count(i) && Bdiv.count(i)) ans++;
    auto Aend=Adiv.end(),Bend=Bdiv.end();
    Aend--,Bend--;
    if(*Aend==*Bend && *Aend>1000000) ans++;
    cout << ans << endl;
}

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

for i in range(1, N + 1):
  p = len(str(i))
  a = i // (10 ** (p - 1))
  b = i % 10
  C[a][b] += 1
  
count = 0
for i in range(10):
  for j in range(10):
    count += C[i][j] * C[j][i]
    #if C[i][j] * C[j][i] > 0:
      #print(i, j)
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int64_t k;
  cin >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  int64_t mod=1000000007,ans=0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(a.at(i)>a.at(j)) ans = (ans+(k*(k+1)/2))%mod;
      else if(a.at(i)<a.at(j)) ans = (ans+(k*(k-1)/2))%mod;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	
	int n;
	scanf("%d",&n);
	int h=1,de=1;
	int i;
	for(i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		h *= 3;
		if(!(a&1))
			de *= 2;
	}
	printf("%d\n",h-de);
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(A<=D&&C<=B){
        int po1;
        if(A>C)po1=A;
        else po1=C;
        int po2;
        if(B<D)po2=B;
        else po2=D;
        printf("%d",po2-po1);
    }
    else printf("0");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  double sum = 0;
  rep(i, n) {
    double a; cin >> a;
    sum += 1.0 / a;
  }
  cout << setprecision(15) << 1.0 / sum << endl;
}

Measured memory_bytes: 256
N =int(input())
li = list(map(int, input().split()))
a = 1
for i in li:
  if i == 0:
    print(0)
    exit()
for i in range(N):
  a *= li[i]
  if a > 10**18:
    print(-1)
    break
else:
  print(a)

Measured memory_bytes: 84464
#include <iostream>
using namespace std;
int n, a[10000000];
inline int search(int key) {
	int l = 0;
	int r = n;

	while (r != l) {
		int mid = (l + r) / 2;
		if (a[mid] == key)
			return 1;
		else if (a[mid] < key)
			l = mid + 1;
		else if (a[mid] > key)
			r = mid;
	}
	return 0;
}
int main() {
	const int num = 10001;
	int q, key, sum=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (search(key)) sum++;
		
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3380
class Katana(val at : Int, val th : Int)

fun ceilDiv(t : Int, d : Int) : Int{
    return if(t % d > 0) t / d + 1 else t / d
}

fun thrower(attacker : Katana, lKatana : MutableList<Katana>, h : Int, n : Int) : Pair<Int, Int>{
    var cnt = 0
    var hp = h
    for(i in 0..(n - 1)){
        if(hp <= attacker.th) return Pair(cnt, hp)
        if(lKatana[i].th <= attacker.at) return Pair(cnt, hp)
        hp -= lKatana[i].th
        cnt++
        if(hp <= 0) return Pair(cnt, hp)
    }
    return Pair(cnt, hp)
}

fun battle(attacker : Katana, lKatana : MutableList<Katana>, h : Int, n : Int) : Int{
    var (cnt, hp) = thrower(attacker, lKatana, h, n)
    if(hp <= 0) return cnt
    hp -= attacker.th
    cnt++
    if(hp <= 0) return cnt

    return cnt + ceilDiv(hp, attacker.at)
}

fun main(args: Array<String>){
    val (n, h) = readLine()!!.split(" ").map(String::toInt)

    val lKatana = mutableListOf<Katana>()
    for(i in 0..(n-1)){
        val (at, th) = readLine()!!.split(" ").map(String::toInt)
        lKatana.add(Katana(at, th))
    }

    lKatana.sortByDescending { it.at }
    val attacker = lKatana[0]
    lKatana.removeAt(0)

    lKatana.sortByDescending { it.th }
    println(battle(attacker, lKatana, h, n - 1))
}

Measured memory_bytes: 82784
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let n: usize = read();
    let mut other_shops = vec![];
    for _i in 0..n {
        let o: Vec<usize> = readnc();
        let mut sum = 0;
        for j in 0..10 {
            if o[j] == 1 {
                sum |= 1<<j;
            }
        }
        other_shops.push(sum);
    }

    let mut count_table: Vec<Vec<i32>> = vec![];
    for _i in 0..n {
        count_table.push(readnc())
    }

    let mut ans = -1e9 as i32;
    for p in 1..(1<<10) {
        let mut total_profit = 0;
        for i in 0..n {
            let cnt = ((p & other_shops[i]) as usize).count_ones() as usize;
            total_profit += count_table[i][cnt];
        }
        ans = max(ans, total_profit);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 2017, mo = 1e9 + 7 ;
using namespace std ;

int n, m, fac[N * N], inv[N * N], f[N][N] ; 

inline int mul(int a, int b) {
	int ans = 1, w = a ;
	for ( ; b; b /= 2) {
		if (b & 1) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;
	}
	return ans ;
}

inline void upd(int &x, int y) {
	x = (x + y) % mo ;
}

inline int C(int x, int y) {
	return (ll) fac[x] * inv[y] % mo * inv[x - y] % mo ;
}

int main() {
	scanf("%d%d", &n, &m) ;
	if (m == 1) {
		printf("%d\n", 1) ;
		return 0 ;
	}
	fac[0] = 1 ;
	rep(i, 1, n * m) fac[i] = (ll) fac[i - 1] * i % mo ;
	inv[n * m] = mul(fac[n * m], mo - 2) ;
	for (int i = n * m - 1; i >= 0; -- i) inv[i] = (ll) inv[i + 1] * (i + 1) % mo ;
	f[0][0] = 1 ;
	rep(i, 0, n) rep(j, 0, n) {
		if (i < j) upd(f[i + 1][j], f[i][j]) ;
		if (j < n) upd(f[i][j + 1], (ll) f[i][j] * C(i + j * (m - 1) + m - 2, m - 2) % mo) ;
	}
	printf("%d\n", (ll) f[n][n] * fac[n] % mo) ;
	return 0 ;
}

Measured memory_bytes: 47616
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include<cstdio>
 
using namespace std;
 
int main(){
 
    double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
    double a_bottom,a_top,a_left,a_right,b_top,b_bottom,b_left,b_right;
 
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)!=EOF){
        a_bottom = ya1;
        a_left = xa1;
        a_top = ya2;
        a_right = xa2;
 
        b_bottom = yb1;
        b_left = xb1;
        b_top = yb2;
        b_right = xb2;
 
        if(((a_right >= b_left && a_right <= b_right)||(b_right >= a_left && b_right <= a_right))
                &&((b_top >= a_bottom && b_top <= a_top)|| (a_top >= b_bottom && a_top <= b_top))){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2584
N = int(input())
max = 0
A = [[0 for i in range(N)] for j in range(2)]
for j in range(2):
    st = input().split()
    for i in range(N):
        A[j][i] = int(st[i])
for i in range(N):
    S1 = 0
    S2 = 0
    for j in range(i + 1):
        S1 += A[0][j]
    for j in range(i, N):
        S2 += A[1][j]
    if max <= S1 + S2:
        max = S1 + S2
print(max)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int INF = 10000;
int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	vector<int> B(N);
	for (int i = 0; i < N; i++){
		cin >> B[i];
	}
	vector<vector<int>> dp(1 << N, vector<int>(N, INF));
	for (int i = 0; i < N; i++){
		dp[1 << i][i] = i;
	}
	for (int i = 0; i < (1 << N); i++){
		for (int j = 0; j < N; j++){
			if (i >> j & 1){
				int num;
				if (j % 2 != __builtin_parity(i)){
					num = A[j];
				} else {
					num = B[j];
				}
				int cnt = 0;
				for (int k = 0; k < N; k++){
					if (!(i >> k & 1)){
						int num2;
						if (k % 2 == __builtin_parity(i)){
							num2 = A[k];
						} else {
							num2 = B[k];
						}
						if (num <= num2){
							dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + cnt);
						}
						cnt++;
					}
				}
			}
		}
	}
	int ans = INF;
	for (int i = 0; i < N; i++){
		ans = min(ans, dp[(1 << N) - 1][i]);
	}
	if (ans == INF){
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 29924
let N = Int(readLine()!)!
let a = readLine()!.split(separator: " ").map({Int($0)!})
let T = a[0]
let A = a[1]

let H_line = readLine()!.split(separator: " ").map{abs(T*1000 - 1000*A - Int($0)! * 6)}
print(H_line.firstIndex(of: H_line.min()!)! + 1)

Measured memory_bytes: 8268
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	vector<string>s(3);
	rep(i,3)cin>>s[i];
	vi as(3,0);
	as[0]=1;
	int ne =0;
	while(s[0].length()>=as[0]&&s[1].length()>=as[1]&&s[2].length()>=as[2]){
		ne = s[ne][as[ne]-1]-'a';
		as[ne]++;
	}
	char res[3]={'A','B','C'};
	rep(i,3){
		if(s[i].length()+1==as[i])cout<<res[i]<<endl;
	}
}

Measured memory_bytes: 256
while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while N != '6174':
        N = list(N)
        S = int(''.join(sorted(N)))
        L = int(''.join(sorted(N)[::-1]))
        ans += 1
        N = str(L-S).zfill(4)
    print(ans)

Measured memory_bytes: 7452
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int N=1e5+5;
struct node
{
	 int u,v;
 }z[N] ;
int main()
{
  int n=rr,k=rr,ans=(n-1)*(n-2)/2; 
  if(ans<k)
  {
  	printf("-1");
  	return 0;
  }
  int cnt=0;
  repb(i,2,n)
  {
  	z[++cnt].u=1;
  	z[cnt].v=i; 
	   }
	for(int i=2;i<=n;i++)
	{
		 for(int j=i+1;j<=n;j++)
		 {
		 	if(ans-k)
		 	{
		 		z[++cnt].u=i;
		 		z[cnt].v=j;
		 		k++;
			 }
		 }
	}
	  printf("%d\n",cnt);
	  for(int i=1;i<=cnt;i++)
	  printf("%d %d\n",z[i].u,z[i].v);
}




Measured memory_bytes: 256