akhauriyash/Code-Regression huggingface dataset:
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (0 ++^ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv
let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv
let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let between n x m = n <= x && x < m


(* ===== MAIN ===== *)

let n, k = scan "%d %d" (fun n k -> n, k)
let px = scan_list ?sep:(Some ' ') int_of_string

let rec take n xs =
  if (List.length xs) <= n then xs
  else if n == 0 then []
  else match xs with
    | [] -> (failwith "main.ml")
    | x :: xx -> x :: take (n-1) xx

let () =
  List.sort compare px
  |> take k
  |> List.sum
  |> string_of_int
  |> print_endline


Measured memory_bytes: 5800
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<random>
using namespace std;

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

void work()
{
    int ans=1;
    for (int i=1; i<=sqrt(m); ++i)
        if (m%i==0)
        {
            if (m/i>=n)
                ans=max(ans,i);
            if (i>=n)
                ans=max(ans,m/i);
        }
    cout<<ans<<endl;
}


int main()
{
    init();
    work();

    return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if a == usize::default() {
        b
    } else {
        gcd(b % a, a)
    }
}
fn lcm(a: usize, b: usize) -> usize {
    a * b / gcd(a, b)
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let a = get!([usize]);

    let base = (a[0]/2)%2;

    if a.iter().any(|&e| (e/2)%2 != base) {
        println!("0");
        return;
    }

    let mut l = a[0];
    for i in 0..n {
        l = lcm(l, a[i]);
    }

    let vec = a.iter().map(|&e| l/e).collect::<Vec<_>>();
    if vec.iter().any(|&e| e%2==0) {
        println!("0");
        return;
    }
    if m < l/2 {
        println!("0");
        return;
    }
    println!("{}", (m-l/2)/l+1);
}


Measured memory_bytes: 12540
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int ans,person[50],p,N,i,pp;
	while(1){
		scanf("%d %d",&N,&pp);
		if(N == 0 && pp == 0) break;
		p= pp;
		for(i = 0;i < N;i++){
			person[i] = 0;
		}
		ans = 0;
		while(1){
			if(p == 0){
				if(person[ans] == pp){
					break;
				}else{
					p = person[ans];
					person[ans] = 0;			
				}
			}else{
			//printf("%d  ",ans);
				person[ans]++;
				p--;			
			}
			ans = (ans + 1)%N;
		}

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

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> pll;


pll foo(ll a,ll b){
	return pll((a*10)/b,(a*10)%b);
}



int main(){
	ll p,q;
	while(cin>>p>>q){
		string ans;
		vector<ll> v;
		while(1){
			v.push_back(p);
			pll t=foo(p,q);
			stringstream ss;
			ss<<ans;
			ss<<t.first;
			ss>>ans;
			p=t.S;
			if(p==0){
				cout<<ans<<endl;
				break;
			}
			bool f=false;
			int pos=0;
			rep(i,v.size()){
				if(p==v[i]){
					f=true;
					pos=i;
				}
			}
			if(f){
				cout<<ans<<endl;
				rep(i,ans.size()){
					if(i>=pos) cout<<"^";
					else cout<<" ";
				}
				cout<<endl;
				break;
			}
		}
	}
}

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

const int N = 51;
int d[N];
int p[N];
int foo[N];
int n;
int res;

void backtrack(int i) {
    if (i == n) {
        copy(foo, foo + n, p);
        sort(p, p + n);
        int s = 24;
        for (int i = 0, j = n - 1; i < n; j = i++) {
            s = min(s, min(abs(p[i] - p[j]), 24 - abs(p[i] - p[j])));
        }
        res = max(res, s);
    } else {
        for (int t = -1; t <= 1; t += 2) {
            foo[i] = d[i] * t;
            backtrack(i + 1);
            if (d[i] == 12 || d[i] == 0) break;
        }
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> d[i + 1];
    foo[1] = d[1];
    ++n;
    if (n > 24) {
        cout << 0 << endl;
        return 0;
    }
    backtrack(2);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

N = int(input())
MOD = 10**9 + 7

def mul(a, b):
    return ((a % MOD)*(b % MOD)) % MOD

cnt = {}
for b in input():
    cnt[b] = cnt[b] + 1 if b in cnt else 2

print(reduce(mul, cnt.values()) - 1)

Measured memory_bytes: 39920
n, a, b, c, d = [int(i) for i in input().split()]
S = ' ' + input()

if '##' in S[a:c + 1]:
    print('No')
elif '##' in S[b:d + 1]:
    print('No')
else:
    if c < d:
        print('Yes')
    elif '...' in S[b - 1:d + 2]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 41968
def solve(h, n, a_list, b_list):
    res = 10 ** 10
    dp = [10 ** 10] * h
    dp[0] = 0
    for i in range(h):
        for j in range(n):
            if i + a_list[j] < h:
                dp[i + a_list[j]] = min(dp[i + a_list[j]], dp[i] + b_list[j])
            else:
                res = min(res, dp[i] + b_list[j])
    return res


def main():
    h, n = map(int, input().split())
    a_list = [0] * n
    b_list = [0] * n
    for i in range(n):
        a, b = map(int, input().split())
        a_list[i] = a
        b_list[i] = b
    res = solve(h, n, a_list, b_list)
    print(res)


def test():
    assert solve(9, 3, [8, 4, 2], [3, 2, 1]) == 4
    assert solve(100, 6, [1, 2, 3, 4, 5, 6], [1, 3, 9, 27, 81, 243]) == 100
    assert solve(
        9999, 10,
        [540, 691, 700, 510, 415, 551, 587, 619, 588, 176],
        [7550, 9680, 9790, 7150, 5818, 7712, 8227, 8671, 8228, 2461]
    ) == 139815


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 41456
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll n, m;
	cin >> n >> m;
	
	if( n > m ) swap(n, m);
	
	if( n == 1 && m == 1 ) {
		cout << 1 << endl;
	} else if( n == 1 && m != 1 ) {
		cout << m - 2 << endl;
	} else if( n >= 2 && m >= 2 ) {
		cout << (n - 2LL) * (m - 2LL) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
def main():
    x, y= map(int,input().split())
    for i in range(x+1):
        j = x - i
        if j >= 0:
            if y == 2*i + 4*j:
                print("Yes")
                exit()

    print("No")

    
    
    




    
if __name__ == "__main__":
    main()


Measured memory_bytes: 61668
import java.util.Scanner
object Main extends App {
  val sc = new Scanner(System.in)
  val n, m = sc.nextInt
  val uf = new UnionFind(n)
  (1 to m).foreach { i =>
    val x, y, _ = sc.nextInt - 1
    uf.union(x, y)
  }
  val (vs, trees) = (0 to n - 1).map(uf.find(_)._1).partition(_ == -1)
  println(vs.size + trees.groupBy(identity).size)
}

class UnionFind(size: Int) {
  val Undefined = -1
  val parents = Array.fill(size)(Undefined)

  /** @retrun (root, rank) */
  def find(x: Int, rank: Int = 0): (Int, Int) = {
    parents(x) match {
      case Undefined => parents(x) = x; (x, rank)
      case p if x == p => (p, rank)
      case p => {
        val (newRoot, newRank) = find(p, rank + 1)
        parents(x) = newRoot
        (newRoot, newRank)
      }
    }
  }

  def union(x: Int, y: Int): Unit = {
    val (xRoot, xRank) = find(x)
    val (yRoot, yRank) = find(y)
    val newRoot = if (xRank < yRank) yRoot else xRoot
    if (xRoot != yRoot) {
      parents(xRoot) = newRoot
      parents(yRoot) = newRoot
    }
    parents(x) = newRoot
    parents(y) = newRoot
  }
}

Measured memory_bytes: 146476
# -*- coding: utf-8 -*-

h, w = map(int, input().split())

a = [list(input()) for i in range(h)]

# あー､ループの中で元の配列を変えちゃってるからエラー出てたのか

a_new = list()

for i, li  in enumerate(a):
    if a[i].count('.')  != w:
        a_new.append(a[i])

b = [list(i) for i in zip(*a_new)]


b_new = list()

for i, li  in enumerate(b):
    if b[i].count('.')  != len(b[0]):
        b_new.append(b[i])

c = [list(i) for i in zip(*b_new)]
for i in c:
    print(''.join(i))




Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,M;
    cin >> N >> M;
    if(N==M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    for (int i = n; i >= 0; i--) {
        const string u = s + t.substr(i, n - i);
        const string utail = u.substr(u.size() - n, n);

        if (utail == t) {
            cout << u.size() << endl;
            return 0;
        }
    }
}


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

int main() {
  int A , B , C , D;
  
  cin >> A >> B >> C >>D;
  
  if (A + B > C + D)
    cout << "Left" << endl;
  else if (A + B < C + D)
    cout << "Right" << endl;
  else
    cout << "Balanced" <<endl;
}


Measured memory_bytes: 256
from fractions import gcd

def lcm(a, b):
    return a // gcd(a, b) * b

A,B,C,D = list(map(int,input().split()))
C1 = B//C
C2 = (A-1)//C
C3 = B//D
C4 = (A-1)//D
C5 = B//lcm(C,D)
C6 = (A-1)//lcm(C,D)
print((B-(A-1))-((C1-C2)+(C3-C4)-(C5-C6)))

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

int main()
{
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(ll b = 1; b <= n; ++b) {
    ll p = (n+1)/b;
    ans += p*max(b-k, 0ll);
    if(k==0) --ans;
    ans += max(0ll, ((n+1)%b)-k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp7
{
    class Program
    {
        static void MainA(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n0 = arr[0] + arr[1];
            var n1 = arr[0] - arr[1];
            var n2 = arr[0] * arr[1];
            Console.WriteLine(Math.Max(n0, Math.Max(n1, n2)));
        }
        static void MainB(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            List<int> nums = new List<int>();
            int start = arr[1] - arr[0] + 1;
            int end = arr[1] + arr[0];

            for (int i = start; i < end; i++)
            {
                nums.Add(i);
            }
            Console.WriteLine(string.Join(" ", nums));
        }

        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            var arr = new string[num];
            for (int i = 0; i < num; i++)
            {
                arr[i] = Console.ReadLine();
            }
            var arr2 = arr.Select(x => new string(x.OrderBy(y => y).ToArray())).ToArray();

            Dictionary<string, int> dic = new Dictionary<string, int>();
            long cnt = 0;
            for (int i = 0; i < arr2.Length; i++)
            {
                if (dic.ContainsKey(arr2[i]))
                {
                    cnt += dic[arr2[i]];
                    dic[arr2[i]]++;
                }
                else
                {
                    dic.Add(arr2[i], 1);
                }
            }
            Console.WriteLine(cnt);
        }

    }
}


Measured memory_bytes: 33932
#include<stdio.h>

int f(int x){
  return x*x;
}

main(){
  int d;
  int i;
  long long int ans;
  while(scanf("%d",&d)!=EOF){
    ans=0;
    for(i=d;i<=600-d;i+=d){
      ans+=f(i)*d;
    }
    //    for(i=600-d;i>0;i--)
      //      ans-=f(d-i);
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>                                             
#include <string>                                               
using namespace std;                                            
                                                                
int main(void) {                                                
  string x;                                                     
  while (true) {                                                
    cin >> x;                                                   
    if (x=="0") {                                               
      break;                                                    
    }                                                           
    int ans = 0;                                                
    for (int i=0; i<x.size(); i++) {                            
      ans += x[i]-'0';                                          
    }                                                           
    cout << ans << endl;                                        
  }                                                             
  return 0;                                                     
}                                                               
                                

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

int main(void){
    int n, k;
    double sum=0;
    int i;
    int j;

    scanf("%d",&n);
    scanf("%d",&k);

    for(i=1; i<=n; i++){
        j=0;
        while(i*pow(2,j)<k){
            j++;
        }
        //printf("%d",j);
        sum += 1/(double)n * pow(0.5, j);
    }
    printf("%.12f",sum);
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
#define EPS 1e-9

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e6 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int fr[N];

bool sieve(){
    vector<int> prime(N, 1);
    for(int i = 2;i < N;i++){
        if(prime[i]){
            int setwise = 0;
            for(int j = i;j < N;j += i){
                setwise += fr[j];
                prime[j] = 0;
            }
            if(setwise > 1) return 0;
        }
    }
    return 1;
}

void go(int tc = 0){
    int n;  cin >> n;

    int g = 0;
    for(int i = 0, x;i < n;i++)    cin >> x, g = __gcd(g, x), fr[x]++;

    if(sieve())
        cout << "pairwise coprime";
    else if(g == 1)
        cout << "setwise coprime";
    else
        cout << "not coprime";
}

int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

   int t = 1, tc = 1;
//   cin >> t;
    while(t--)
        go(tc++);
}

Measured memory_bytes: 11080
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
 
#define CASES int t;cin>>t;while(t--)
#define REP(i, val, b) for (int i = val; i < b; ++i)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
int main() {
	fastio
	int x, y;
	cin >> x >> y;
	if (x > 8 || y > 8)
		cout << ":(";
	else
		cout << "Yay!";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

struct station{
        char name[80];
        int h1;
        int m1;
        int h2;
        int m2;
        char next[80];
        int trance;
};

int main(void){
        struct station st[10];
        int n,t,que = 0;
        int i;
        int che[10] = {};

        scanf("%d %d",&n,&t);
        for(i = 0; i < n; i++)
                scanf("%d:%d %s %d:%d %s",&st[i].h1,&st[i].m1,st[i].name,&st[i].h2,&st[i].m2,st[i].next);

        for(i = 0; i < n-1; i++){
                if((st[i+1].h1 * 60 +st[i+1].m1 -st[i].h2 * 60 - st[i].m2) >= t){
                        st[i+1].trance = (st[i+1].h1 * 60 +st[i+1].m1 -st[i].h2 * 60 - st[i].m2);
                        che[que] = i+1;
                        que ++;
                }
        }
        printf("%d\n",que);
        for(i = 0; i < que; i++)
                printf("%s %d\n",st[che[i]].name,st[che[i]].trance);

        return 0;
}


Measured memory_bytes: 2112
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()
	N := nextInt()
	ds := nextInts(N)
	ans := 0
	for i := 0; i < len(ds); i++ {
		for j := i + 1; j < len(ds); j++ {
			ans += ds[i] * ds[j]
		}
	}
	fmt.Println(ans)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char a[50][50];
int c,d,b[55][55];
int main(){
    cin>>c>>d;
    for(int i=0;i<c;i++)
    cin>>a[i];
    for(int i=0;i<c;i++)
    for(int j=0;j<d;j++)
    if(a[i][j]=='#')
    b[i][j]++,b[i][j+1]++,b[i][j+2]++,
    b[i+1][j]++,b[i+1][j+1]++,b[i+1][j+2]++,
    b[i+2][j]++,b[i+2][j+1]++,b[i+2][j+2]++;
    for(int i=0;i<c;i++){
        for(int j=0;j<d;j++)
        if(a[i][j]=='#') cout<<'#';
        else cout<<b[i+1][j+1];
        cout<<endl;
    }

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
      
      if(a > 8 || b > 8){
        System.out.println(":(");
      }else{
        System.out.println("Yay!");
      }
     }
}

Measured memory_bytes: 35684
N,M = map(int,input().split())

if(N >= M):
  cost = 0
  print(cost)
else:
 X = input().split()
 for i in range(M):
  X[i] = int(X[i]) 
 X.sort() 

 L = []
 for i in range(M):
  if(i != 0): 
    L.append(X[i]-X[i-1])
 L.sort()

 #cost1 = (X[M-1]-X[0]) - sum(L[-(N-1):])
 #print(cost1)

 tmp = 0
 for i in range(N-1):
  tmp += L.pop(-1)
 cost2 =  (X[M-1]-X[0]) - tmp
 print(cost2)
 

Measured memory_bytes: 10248
#include<bits/stdc++.h>
using namespace std;
#define int long long
using Int = __int128;
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  {
    bool flg=1;
    for(int i=0;i<n;i++)
      flg&=a[i]<n;
    if(flg){
      cout<<0<<endl;
      return 0;
    }
  }
  Int sum=0;
  for(int i=0;i<n;i++) sum+=a[i];
  Int L=sum-n*(n-1),R=sum;
  for(Int k=L;k<=R;k++){
    Int s=0;
    for(int i=0;i<n;i++){
      if(a[i]+k<n) continue;
      s+=(a[i]+k-n)/(n+1)+1;
    }
    if(s<=k){
      cout<<(int)k<<endl;
      return 0;
    }
  }
  return 0;
}


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

int main(void){
    int a;
    char s[11];
    scanf("%d\n%s", &a, s);
    if(a>=3200)printf("%s\n", s);
    else printf("red\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, x, y;
	char ch;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			string s;
			cin >> s;
			if (s == "snuke") {
				x = i; y = j;
			}
				
		}
	}

	ch = 'A' + y;
	cout << ch << x + 1 << "\n";

	return 0;
}



Measured memory_bytes: 256
use std::io::Read;
use std::io::Write;

struct Dice {
    val: [usize; 6],
}

impl Dice {
    fn new() -> Self {
        let mut dice = Dice {
            val: [0; 6],
        };
        for i in 0..6 {
            dice.val[i] = i + 1;
        }
        dice
    }
    fn top(&self) -> usize {
        self.val[0]
    }
    fn rotate_by(&mut self, a: &[usize]) {
        let val = &mut self.val;
        let x = val[a[0]];
        let mut p = a[0];
        for &a in &a[1..] {
            val[p] = val[a];
            p = a;
        }
        val[p] = x;
    }
    fn north(&mut self) {
        let a = [0, 1, 5, 4];
        self.rotate_by(&a);
    }
    fn east(&mut self) {
        let a = [0, 3, 5, 2];
        self.rotate_by(&a);
    }
    fn west(&mut self) {
        let a = [0, 2, 5, 3];
        self.rotate_by(&a);
    }
    fn south(&mut self) {
        let a = [0, 4, 5, 1];
        self.rotate_by(&a);
    }
    fn right(&mut self) {
        let a = [1, 2, 4, 3];
        self.rotate_by(&a);
    }
    fn left(&mut self) {
        let a = [1, 3, 4, 2];
        self.rotate_by(&a);
    }
}

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    loop {
        let n: usize = it.next().unwrap().parse().unwrap();
        if n == 0 {
            break;
        }
        let dice = &mut Dice::new();
        let mut ans = 1;
        for _ in 0..n {
            let s = it.next().unwrap();
            match s {
                "North" => dice.north(),
                "East" => dice.east(),
                "South" => dice.south(),
                "West" => dice.west(),
                "Right" => dice.right(),
                "Left" => dice.left(),
                _ => unreachable!(),
            };
            ans += dice.top();
        }
        writeln!(out, "{}", ans).ok();
    }
}

fn main() {
    run();
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll N=1000;
const ll R = 1000000007;
ll so[N+1];

void bunkai(ll n){
	ll k=n;
	while(k!=1){
		FOR(i,2,k+1){
			if(k%i==0){
				so[i]++;
				k/=i;
				break;
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	CLR(so);
	ll ans=1;
	int n;cin>>n;
	for(int i=n;i>=2;i--)bunkai(i);

	for(int i=n;i>1;i--){
		ans*=(so[i]+1);
		ans%=R;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
//template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

void chmax(pii &a, pii b) {
	if (a.first < b.first)a.second = max(a.first, b.second), a.first = b.first;
	else a.second = max(a.second, b.first);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N; cin >> N;
	VI A(1 << N);
	VP dp;
	REP(i, 1 << N) {
		cin >> A[i];
		dp.push_back(pii(A[i], -INF));
	}

	REP(i, N) {
		REP(j, (1 << N)) {
			if (j&(1 << i))chmax(dp[j], dp[j ^ (1 << i)]);
		}
	}
	

	int ans = -INF;
	FOR(i, 1, 1 << N) {
		//cout << dp[i].first << " " << dp[i].second << endl;;
		ans = max(ans, dp[i].first + dp[i].second);
		cout << ans << '\n';
	}

	return 0;
}



Measured memory_bytes: 9324
def calc(num, counter)
    if(num == 1) then
        counter
    elsif(num % 2 == 0) then
        calc(num/2, counter+1)
    else
        calc(num*3+1, counter+1)
    end
end

while((num = gets.to_i) != 0) do
    puts calc(num, 0)
end

Measured memory_bytes: 8480
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 10010010010;

int main() {
  ll h, w, a, b, c;
  cin >> h >> w;
  ll ans = INF;
  for (ll i = 1; i < h; i++) {
    a = i * w;
    b = (w / 2) * (h - i);
    c = w * h - a - b;
    ll x = min(min(a, b), c);
    ll y = max(max(a, b), c);
    ans = min(ans, y - x);
    b = (h - i) / 2 * w;
    c = w * h - a - b;
    x = min(min(a, b), c);
    y = max(max(a, b), c);
    ans = min(ans, y - x);
  }
  for (ll j = 1; j < w; j++) {
    a = j * h;
    b = (h / 2) * (w - j);
    c = w * h - a - b;
    ll x = min(min(a, b), c);
    ll y = max(max(a, b), c);
    ans = min(ans, y - x);
    ans = min(ans, w * h - 3 * h * (w / 3));
    b = (w - j) / 2 * h;
    c = w * h - a - b;
    x = min(min(a, b), c);
    y = max(max(a, b), c);
    ans = min(ans, y - x);
  }
  if (h % 3 == 0 || w % 3 == 0) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
//static const int MAX = 10000;


int main(){
  int a = in(), b = in(), c;
  
  c = a*b;
  if(c%2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
int a[110];
int main(){
   scanf("%d%d",&n,&m);
   for(int i=1;i<=n;++i)scanf("%d",&a[i]);
   sort(a+1,a+n+1);
   int ans=0;
   for(int i=1;i<=n;++i){
     if(i==n){
     	if(m>a[i]||m<a[i])break;
     	else if(m==a[i]){
     		ans++;
     		break;
     	}
     }
   	 if(m>=a[i]){
   	 	ans++;
   	 	m-=a[i];
   	 }
   	 else break;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {

    string n;
    cin >> n;

    for(int i = 0; i < n.size(); ++i) {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }

    cout << n << endl;

    return 0;
}

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

int main() {
    int n;
    cin>>n;
    int d=0,c=0;
    for(int i=1;i<=n;i++){
        cin>>d;
        if(i%2!=0 && d%2!=0){
            c++;
        }
        
    }
    cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0287
{
    class Program
    {
        static readonly string[] units =
            { "", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko",
            "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};

        static void Main(string[] args)
        {
            while (true)
            {
                int[] mn = RArInt();
                if (mn.Sum() == 0) break;

                int[] num = new int[units.Length];
                num[0] = mn[0];
                for (int i = 1; i < mn[1]; i++)
                {
                    int carrying = 0;
                    for (int j = 0; j < num.Length; j++)
                    {
                        int nNum = num[j] * mn[0] + carrying;
                        num[j] = nNum % 10000;
                        carrying = nNum / 10000;
                    }
                }

                string res = string.Empty;
                for (int i = num.Length - 1; i >= 0; i--)
                {
                    if (num[i] > 0) res += num[i].ToString() + units[i];
                }

                Console.WriteLine(res);
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int N, K;
  cin >> N >> K;
  vector<bool> isHave(N + 1);
  for (int i = 0; i < K; i++)
  {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++)
    {
      int input;
      cin >> input;
      isHave[input] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++)
  {
    if (!isHave[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 
bool IsPrime(int 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;
}
const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

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

int main()
{
    ll N;
    cin >> N;
    string n = to_string(N);
    bool nine = true;
    bool near = true;
    int ans = 0;
    for (int i = 0; i < n.size(); i++)
    {
        if(n[i] != '9'){
            nine = false;
        }
    }
    for (int i = 1; i < n.size();i++)
    {
        if (n[i] != '9')
        {
            near = false;
        }
    }
    if(nine){
        ans += n.size() * 9;
        cout << ans << endl;
    }
    else{
        if(near){
            ans = n[0] - 48;
            ans += 9 * (n.size() - 1);
            cout << ans << endl;
        }
        else{
            ans = n[0] - 48;
            ans += 9 * (n.size() - 1);

            if (ans >= 10)
            {
                cout << ans - 1 << endl;
            }
            else{
                cout << ans << endl;
            }
        }
    }
}


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

int main(){
  int N ;
  cin >> N ;
  vector<int> A(N), B(N), C(N - 1);
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < N; i++) cin >> B[i];
  for(int i = 0; i < N - 1; i++) cin >> C[i];
  
  int ans = 0;
  for(int i = 0; i < N; i++) ans += B[A[i] - 1];
  for(int i = 0; i < N - 1; i++) 
    if(A[i] != N && A[i] + 1 == A[i + 1]) ans += C[A[i] - 1];
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
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 gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  vector<ll> P;
  for(int i=0;i<N;i++){
    P.push_back(input());
  }

  ll min = INF;
  ll count = 0;
  for(int i=0;i<N;i++){
    chmin(min, P[i]);

    if(P[i+1] <= min){
      count++;
    }
  }
  output(count);
  
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

int main(){
    int N;
    cin >> N;
    vector<long> p(N);
    vector<long> s(N);
    long sum = 0;
    REP(i, N){
        cin >> p[i];
        p[i]--;
        s[p[i]]++;
    }
    REP(i, N){
        if(s[i] < 2){
            continue;
        }
        sum += s[i]*(s[i]-1)/2;
    }
    REP(i, N){
        cout << sum - (s[p[i]] - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int i,n,m;cin>>n>>m;
  vector<int> h(n);
  for(i=0; i<n; ++i) cin>>h[i];
  vector<int> a(m),b(m);
  for(i=0; i<m; ++i) cin>>a[i]>>b[i];
  
  vector<int> t(n,0);
  for(i=0; i<m; ++i){
    t[a[i]-1]|=h[a[i]-1]-h[b[i]-1]-1;
    t[b[i]-1]|=h[b[i]-1]-h[a[i]-1]-1;
  }
  int cnt=0;
  for(i=0; i<n; ++i) if(t[i]>=0) ++cnt;
  cout<<cnt<<endl;
  return 0;
}


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

const int INF = 1001001001;

// DP[集合S] : Sを開けられる鍵の買い方の最小コスト
int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > key;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j,b){
            int c;
            cin >> c;
            --c;
            s |= 1<<c; // c個目が1になる
        }
        key.emplace_back(s,a);
    }
    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    rep(s,1<<n) {
        rep(i,m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <list>

const int MAX = 100000;
const int INFTY = (1<<29);

std::vector<int> G[MAX];
std::list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s)
{
    std::queue<int> q;
    q.push(s);
    V[s] = true;

    while (!q.empty()) {
        int u = q.front(); q.pop();
        out.push_back(u);

        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            indeg[v]--;
            if (indeg[v] == 0 && !V[v]) {
                V[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort()
{
    for (int i = 0; i < N; i++) {
        indeg[i] = 0;
    }

    for (int u = 0; u < N; u++) {
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            indeg[v]++;            
        }
    }

    for (int u = 0; u < N; u++) {
        if (indeg[u] == 0 && !V[u]) bfs(u);
    }

    for (std::list<int>::iterator it = out.begin(); it != out.end(); it++) {
        std::cout << *it << std::endl;
    }
}

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

    std::cin >> N >> M;

    for (int i = 0; i < N; i++) V[i] = false;

    for (int i = 0; i < M; i++) {
        std::cin >> s >> t;
        G[s].push_back(t);
    }

    tsort();

    return 0;
}


Measured memory_bytes: 6172
#include<iostream>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int keta=1;
  int keta_max=K;
  while(keta_max-1<N){
    keta++;
    keta_max *= K;
  }
  cout << keta << endl;
  return 0;
}

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

int main () {
  vector<string> v(3);
  
  for (int i = 0; i < 3; i++) {
    cin >> v.at(i);
    reverse(v.at(i).begin(), v.at(i).end());
    //cout << v.at(i) << endl;
  }
  
  int i = 0,
  	  j = 0;
  //v.at(i).pop_back();v.at(i).pop_back();v.at(i).pop_back();
  //cout << v.at(i).size() << endl;
  while (v.at(i).size() != 0) {
    int len = v.at(i).size();
    j = i;
    if (v.at(i).at(len-1) == 'a') {
      i = 0;
    } else if (v.at(i).at(len-1) == 'b') {
      i = 1;
    } else if (v.at(i).at(len-1) == 'c') {
      i = 2;
    }
    v.at(j).pop_back();
  }
  
  if (i == 0) {
    cout << 'A' << endl;
  } else if (i == 1) {
    cout << 'B' << endl;
  } else if (i == 2) {
    cout << 'C' << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    string ans = ((100*a+10*b+c)%4)==0?"YES":"NO";
    cout << ans << endl;
    return 0;
}

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

class Program
{
	static void Main(string[] args)
	{
		//文字列を読み込む
		string[] S = Console.ReadLine().Split(' ');
		long N = long.Parse(S[0]);
		long A = long.Parse(S[1]);
		long B = long.Parse(S[2]);

		//全体を一セットで割った余り
		long div = N / (A+B);

		//答えを入れる変数
		long answer = div * A;

		//余り
		long resid = N % (A+B);

		//余りが0ではない場合
		if(resid != 0){
				//余りがA以上の場合
				if(resid >= A){
						answer += A;
				}
				//そうでない場合
				else{
						answer += resid;
				}
		}

		Console.WriteLine(answer);

	}
}



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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s; cin >> s;
  string t = s;

  reverse(all(s));
  if (s == t) cout << "Yes\n";
  else cout << "No\n";
  
  return (0);
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> x(N);
  vector<long long> y(N);
  vector<long long> h(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i) >> y.at(i) >> h.at(i);
  }

  long long ansx=-1,ansy=-1;
  long long ansh=-1;
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      long long CY=i,CX=j;
      long long CH=-1;
      for(int k=0;k<N;k++){
        if(h.at(k)!=0){
          CH=h.at(k)+labs(x.at(k)-CX)+labs(y.at(k)-CY);
          break;
        }
      }
      if(CH<1)  continue;
      bool flag=true;
      for(int k=0;k<N;k++){
        long long ch=h.at(k)+labs(x.at(k)-CX)+labs(y.at(k)-CY);
        if(ch<1)  flag=false;
        else if(h.at(k)!=0 && ch!=CH)  flag=false;
        else if(h.at(k)==0 && ch<CH)  flag=false;
      }
      if(flag){
        ansx=CX;
        ansy=CY;
        ansh=CH;
      }
    }
  }
  cout << ansx << " " << ansy << " " << ansh << endl;

  return 0;
}


Measured memory_bytes: 256
function Main(input) {
    var alp = /[A-Z]/;
    var result;
    
    function isUpperCase(str){
        return str.match(alp);
    }
    
    if(isUpperCase(input)){
        result = "A";
    }else{
        result = "a";
    }
    
    console.log(result);
}

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

Measured memory_bytes: 29632
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    int x = n % 10;
    if(x==2 || x==4 || x==5 ||x ==7 || x==9){
        cout << "hon" << endl;
    }
    else if(x==0 || x==1 || x==6 || x==8){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636