akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    string s;
    cin>>s;
    int kati=0;
    int make=0;
    for(int i = 0; i < s.size();i++){
        if(s[i]=='o'){
            kati++;
        }else{
            make++;
        }
    }
    int size=s.size();
    int day=15-size;
    int sum=kati+day;
    if(sum>=8){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main() {
    int K, S;
    cin >> K >> S;

    int result = 0;
    for (int x = 0; x <= K; x++)
    {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (0 <= z && z<= K) {
                result++;
            }
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79740
s=int(input())
a=[s]
t=s
for i in range(1000001):
    if t%2==0:
        t=t//2
    else:
        t=3*t+1
    a.append(t)
    if i>=2 and a[i+1]==a[i-2]:
        print(i+2)
        exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int64_t>> vec(N,vector<int64_t>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  int64_t ans = 0;
  for(int i=N-1; i>=0; i--){
    if((vec.at(i).at(0)+ans) %vec.at(i).at(1) != 0){
    ans += vec.at(i).at(1) - ((vec.at(i).at(0)+ans) %vec.at(i).at(1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<set>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int a,b,c;
int main() {
	scanf("%d %d %d",&a,&b,&c);
	printf("%d",max(0,c-a+b));
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;

    vector<int>P(200010);
    for(int i=0;i<N;++i)cin>>P[i];
    
    int res=0;
    int left=0;
    for(int i=0;i<N;++i){
        if(i==0){
            left=P[i];
            res++;
            continue;
        }
        if(left>P[i]){
            res++;
            left=P[i];
        }
        
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1152
#[allow(unused_imports)]
use proconio::{input, marker::*};

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

#[allow(unused_imports)]
use std::io::Write;

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

fn main() {
    input! {
        n: usize,
        k: isize,
        p: [usize; n],
        c: [isize; n],
    }
    use std::cmp::max;

    let mut mx = std::isize::MIN;
    for start in 0..n {
        let mut current = start;
        let mut next = p[start] - 1;
        let mut cost = vec![0; n];
        let mut visited = vec![false; n];
        let mut hops = vec![0; n];
        visited[current] = true;
        hops[current] = 0;
        let mut mxt = std::isize::MIN;
        while !visited[next] {
            let co = cost[current] + c[next];
            mxt = max(co, mxt);
            cost[next] = co;
            hops[next] = hops[current] + 1;
            if hops[next] == k {
                mx = max(mxt, mx);
                break;
            }
            current = next;
            next = p[next] - 1;
        }
        let lc = cost[current] + c[next] - cost[next];
        if lc > 0 {
            let rem = k - hops[next];
            let l = hops[current] + 1 - hops[next];
            let r = rem % l;
            let mut mxtt = cost[next] + (rem / l - 1) * lc;
            let mut current = next;
            let mut co = mxtt;
            for _ in 0..r + l {
                current = p[current] - 1;
                co += c[current];
                mxtt = max(mxtt, co);
            }
            mxt = max(mxtt, mxt);
            mx = max(mxt, mx);
        } else {
            mx = max(mx, mxt);
        }
    }
    println!("{}", mx);
}


Measured memory_bytes: 2408
using System;

namespace AOJ.Volume1
{
    public class CandyAndClassFlag
    {
        public static int Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                int candy = int.Parse(input);
                // キャンディーを39で割った余りが出席番号
                // ※余りが0の場合は出席番号39
                int ans = candy % 39;
                if (ans == 0) { ans = 39; }

                Console.WriteLine(string.Format("3C{0:D2}", ans));
            }

            return 0;
        }
    }
}

Measured memory_bytes: 9128
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Map<Integer, Integer> AB = new HashMap<Integer, Integer>();
		int A[] = new int[N];

		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (AB.get(a) != null) {
				b += AB.get(a);
				A[i] = 0;
			} else {
				A[i] = a;
			}
			AB.put(a, b);
		}

		Arrays.sort(A);

		int i = 0;
		int b = 0;
		long result = 0L;
		while (true) {
			if (A[i] == 0) {
				i++;
				continue;
			}
			b = AB.get(A[i]);
			if (b < M) {
				result += (long) A[i] * b;
			} else {
				result += (long) A[i] * M;
			}

			M = M - b;
			if (M <= 0) {
				break;
			}
			i++;
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 97052
N = input() 
n = int(N)
a = 0;
b = 0;
d = n;
sum = 0;

while a != d:
  a = d % 10
  b = d - a
  d = b // 10
  sum += a;

if n % sum == 0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 1e6 + 5 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T> void read(T &a)
{
	int f = 1 ; a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	a *= f ;
}

ll n, rs, gs, bs, a[5], rl, gl, bl, b[5], ans = 1;

char s[maxn];

signed main()
{
	scanf("%lld", &n);
	rep(i, 1, n) (ans *= i) %= mod;
	// printf("%lld\n", fac);
	scanf("%s", s + 1);
	rep(i, 1, 3 * n)
	{
		if(s[i] == 'R') rs ++;
		if(s[i] == 'G') gs ++;
		if(s[i] == 'B') bs ++;
		a[1] = rs, a[2] = gs, a[3] = bs;
		sort(a + 1, a + 4);
		// rep(i, 1, 3) printf("%lld%c", a[i], " \n"[i == 3]);
		// if(a[3] != b[3]) (ans *= fac) %= mod;
		if(a[2] != b[2]) (ans *= b[3] - b[2]) %= mod;
		if(a[1] != b[1]) (ans *= b[2] - b[1]) %= mod;
		rl = rs, gl = gs, bl = bs;
		b[1] = rl, b[2] = gl, b[3] = bl;
		sort(b + 1, b + 4);
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 512
# n以下の素数を求める エラトステネスの篩
def primes(n):
    is_prime = [False] * 2 + [True] * (n - 1)
    for i in range(2, int(n ** 0.5) + 1): # 素数候補
        if not is_prime[i]: continue
        for j in range(2 * i, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

N = int(input())
n = 1450  # n = 1450以下の素数pのうち p mod 5 = 1となるpは55個ある
P = primes(n)

A = []
for p in P:
    if p % 5 == 1:
        A.append(str(p))

print(" ".join(A[0:N]))

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long LL;

void test_case(){
    
}

int main() {
    fastio
    int n;
    cin >> n;
    string s;
    cin >>s;
    int res = 0;
    for(int i = 0 ; i<1000; i++){
        // int flag = 0;
        string curr = to_string(i);
        if(curr.size() == 1){
            curr = "00" + curr;
        }
        if(curr.size() == 2)
            curr = "0" + curr;
        int ind = 0;
        for(int j = 0; j<n ; j++){
            if(s[j] == curr[ind]){
                ind++;
            }
        }
        if(ind == 3)
            res++;
    }
    cout<<res<<endl;
	return 0;
}






Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
	int N;
	int W[100];
	cin >> N;
	int ruisekiwa[110] = {};
	for (int i = 0; i < N; i++)cin >> W[i], ruisekiwa[i + 1] = ruisekiwa[i] + W[i];

	int ans = 100000000;
	for (int i = 1; i <= N; i++) {
		ans = min(ans, abs(ruisekiwa[i] - (ruisekiwa[N] - ruisekiwa[i])));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (i == 0 and x != 0) {
      cout << 0 << endl;
      return 0;
    }
    if (i != 0 and x == 0) {
      cout << 0 << endl;
      return 0;
    }
    d.at(x) += 1;
  }
  long long ans = 1;
  for (int i = 0; i < n-1; ++i) {
    if (d.at(i) == 0 and d.at(i+1) != 0) {
      cout << 0 << endl;
      return 0;
    }
    long long tmp = 1;
    for (int j = 0; j < d.at(i+1); ++j) {
      tmp *= d.at(i);
      tmp %= 998244353ll;
    }
    ans *= tmp;
    ans %= 998244353ll;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))

c=0

for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            c=1

if c==0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI=3.14159265358979323846;

int main(){
  int r;
  cin >> r;
  double ans = r*2*PI;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 3720
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 3e5 + 100, OO = 1e9, M = 998244353, P = 6151, SQ = 120, lg = 22;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
    use_fast;
    int n, k, s;
    cin >> n >> k >> s;
    for(int i = 0; i < k; i++) 
    	a[i] = s;
    for(int i = k; i < n; i++) {
    	if(s == OO)
    		a[i] = 1;
    	else
    		a[i] = s + 1;
	}
	for(int i = 0; i < n; i++)
		cout << a[i] << " ";
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
const int SZ=1000005;
int memo[SZ][2];
string s;
int dp(int x, int ext){
    if(x==-1) return ext;
    if(memo[x][ext]!=-1) return memo[x][ext];
    int dg=s[x]-'0'+ext;
    return memo[x][ext]=min(dp(x-1,0)+dg,dp(x-1,1)+(10-dg));
}
int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>s;
    reverse(s.begin(),s.end());
    memset(memo,-1,sizeof(memo));
    cout<<dp(s.size()-1,0);
    return 0;
}

Measured memory_bytes: 56092
#include <stdio.h>
#include <string.h>

int main(void)
{
    char a[20] ={0};
    char b[20] ={0};
    char c[20] ={0};
    int na,nb;
    
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);

    na = strlen(a);
    nb = strlen(b);

    if(a[na-1] == b[0] && b[nb-1] == c[0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

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

typedef long long int lli;

int main()
{
    char chN;
    int iCnt;
    int  iSumDigit;

    iSumDigit = 0;
    chN = getchar();
    while (chN != '\n')
    {
        //printf("%d\n", (int)(chN - '0'));
        iSumDigit += (chN - '0') % 10;
        chN = getchar();
        }

    if (iSumDigit % 9 == 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 1476
#include <stdio.h>
#define NIL -1
typedef struct{
  int parent;
  int left;
  int right;
  int depth;
  int sibling;
  int degree;
  int height;
} data;

void preparse(int);
void sibling(int,int,int);
void degree(int);
int height(int);
data A[25];
int B[25];
int main(){
  int N,i,id,l,r,root;

  scanf("%d",&N);

  for(i=0;i<N;i++) {
    A[i].parent=NIL;
    A[i].sibling=NIL;
  }
    for(i=0;i<N;i++){
    scanf("%d%d%d",&id,&l,&r);
    
    A[id].left=l;
    A[id].right=r;
    if(l!=NIL) A[l].parent=id;
    if(r!=NIL) A[r].parent=id;
    }
    for(i=0;i<N;i++){
      if(A[i].parent==NIL) root=i;
	}
 
    preparse(root);
  sibling(root,A[root].right,A[root].left);
  degree(root);
  height(root);
  
  for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);  
    if(A[i].parent==NIL) printf("root\n");
    else if(A[i].right==NIL&&A[i].left==NIL) printf("leaf\n");
    else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
  
  }
  return 0;
}

void preparse(int u){
  static int count;
 
  if(u==NIL) return;

  A[u].depth=count;
  count++;
  preparse(A[u].left);
  preparse(A[u].right);
  count--;
}

void sibling(int u,int r,int l){
  int i;
 
  if(u==NIL) return;


  if(A[u].left!=NIL && A[u].right!=NIL) {

    A[l].sibling=A[u].right;   
    A[r].sibling=A[u].left;
  }

  sibling(A[u].left,A[l].right,A[l].left);
  sibling(A[u].right,A[r].right,A[r].left);
  
}
  
void degree(int u){
  if(u==NIL) return;
  if(A[u].left!=NIL && A[u].right!=NIL) A[u].degree=2;
  else if((A[u].left==NIL && A[u].right!=NIL) || (A[u].left!=NIL && A[u].right==NIL)) A[u].degree=1;
  else A[u].degree=0;

  degree(A[u].left);
  degree(A[u].right);
}

int height(int u){
  int h1=0,h2=0;
  if(A[u].left!=NIL) h1=height(A[u].left)+1;
  if(A[u].right!=NIL) h2=height(A[u].right)+1;

if(h1>h2) B[u]=h1;
      else B[u]=h2;
 A[u].height=B[u];
 
 return B[u]; 
}

Measured memory_bytes: 612
S = input()
N = len(S)
i = 0
j = N-1
ans = 0
while i < j:
    if S[i] == 'x' and S[j] != 'x':
        ans += 1
        i += 1
    elif S[i] != 'x' and S[j] == 'x':
        ans += 1
        j -= 1
    elif S[i] == S[j]:
        i += 1
        j -= 1
    else:
        ans = -1
        break
print(ans)


Measured memory_bytes: 67368
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int h = 0, w = 0;
  cin >> h >> w;
  vector<string> field(h);
  int num_white = 0;
  for (int i=0; i<h; i++) {
    cin >> field.at(i);
    num_white += count(field.at(i).begin(), field.at(i).end(), '.');
  }
  queue<pair<int, int>> que;
  que.push(make_pair(0, 0));
  vector<vector<int>> dis(h, vector<int>(w, 1e8));
  dis.at(0).at(0) = 1;
  int dx[] = {-1, 0, 0, 1}, dy[] = {0, -1, 1, 0};
  while (!que.empty()) {
    auto cur = que.front(); que.pop();
    if (cur.first == h-1 && cur.second == w-1) {
      break;
    }
    int x = cur.first, y = cur.second;
    for (int i=0; i<4; i++) {
      int next_x = x + dx[i], next_y = y + dy[i];
      if (next_x < 0 || next_x >= h || next_y < 0 || next_y >= w) continue;
      if (field.at(next_x).at(next_y) == '#') continue;
      if (dis.at(next_x).at(next_y) <= dis.at(x).at(y) + 1) continue;
      dis.at(next_x).at(next_y) = dis.at(x).at(y) + 1;
      que.push(make_pair(next_x, next_y));
    }
  }
  if (dis.at(h-1).at(w-1) == 1e8) {
    cout << -1 << endl;
  } else {
    cout << num_white - dis.at(h-1).at(w-1) << endl;
  }
  return 0;
}


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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

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

  int H, W; cin >> H >> W;
  VS vs(H); REP(i,H) cin >> vs[i];

  queue<VS> q;
  map<VS,pair<VS,char>> memo;
  q.push(vs);
  memo[vs] = MP(VS(), '!');
  VS goal;
  while(!q.empty()){
	VS vs = q.front(); q.pop();
	int sx = -1, sy = -1, d = -1, cnt = 0;
	REP(y,H) REP(x,W){
	  if(vs[y][x] == '.') continue;
	  else if(vs[y][x] == 'o')
		++cnt;
	  else{
		sx = x; sy = y;
		if(vs[y][x] == 'U') d = 0;
		if(vs[y][x] == 'D') d = 1;
		if(vs[y][x] == 'L') d = 2;
		if(vs[y][x] == 'R') d = 3;
	  }
	}
	if(cnt == 0){
	  goal = vs;
	  break;
	}

	REP(i,4){
	  if(i == d) continue;
	  int tx = sx, ty = sy;
	  while(0<=tx&&tx<W&&0<=ty&&ty<H){
		if(vs[ty][tx] == 'o') break;
		tx += dx[i];
		ty += dy[i];
	  }

	  if(0<=tx&&tx<W&&0<=ty&&ty<H){
		VS vs_ = vs;
		vs_[sy][sx] = '.';
		char ch;
		switch(i){
		case 0: ch = 'D'; break;
		case 1: ch = 'U'; break;
		case 2: ch = 'R'; break;
		case 3: ch = 'L'; break;
		}
		vs_[ty][tx] = ch;
		if(!memo.count(vs_)){
		  memo[vs_] = MP(vs,ch);
		  q.push(vs_);
		}
	  }
	}
  }

  string ans;
  while(!goal.empty()){
	if(memo[goal].second == '!') break;
	ans += string(1, memo[goal].second);
	goal = memo[goal].first;
  }
  reverse(ALL(ans));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 34736
<?php
$haveCardNum = getInput();
$cardCheckList = createCardCheckList();
$nullCards = '';

for ($i = 0; $i < $haveCardNum; $i++) {
    list($mark, $num) = explode(' ', getInput());
    $cardCheckList[$mark][$num] = 'check';
}

foreach ($cardCheckList as $mark => $value) {
    for ($cardNum = 1; $cardNum <= 13; $cardNum++) {
        if (! isset($cardCheckList[$mark][$cardNum])) {
            $nullCards .= sprintf('%s %d', $mark, $cardNum).PHP_EOL;
        }
    }
}

echo $nullCards;

function getInput()
{
    return trim(fgets(STDIN));
}
 
function createCardCheckList()
{
    foreach (array('S', 'H', 'C', 'D') as $mark) {
        $checkList["$mark"] = array_fill(1, 13, null);
    }
    return $checkList;
}

Measured memory_bytes: 15364
n, k = map(int, input().split())
d = {}
for i in range(n):
  a, b = map(int, input().split())
  d[a] = d[a] + b if a in d else b

a = 0
for i in range(1, 10**5+1):
  if i in d and k <= d[i]:
    a = i
    break
  k -= d[i] if i in d else 0

print(a)


Measured memory_bytes: 10468
if __name__ == "__main__":
    
    n = int(input())
    index = "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".split()

    s = ""
    m = n
    while True:
        o = m%26
        if m > 0 and o == 0:
            m -= 26
            o = 26
        s = index[o-1] + s
        m = m // 26
        if m == 0: break

    print(s)

Measured memory_bytes: 9172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int sum = 0;

		while ((line = br.readLine()) != null) {
			// 行の開始・終端の判定しない
			line = " " + line + " ";
			char c;
			for (int i = 0; i < line.length(); i++) {
				c = line.charAt(i);
				if (c >= '0' && c <= '9') {
					int sta, end;
					sta = i;
					for (int j = sta; j < line.length(); j++) {
						i = j;
						c = line.charAt(j);
						if (c < '0' || c > '9') {
							break;
						}
					}
					end = i;
					// 負数の判定
					if (line.charAt(sta - 1) == '-')
						continue;
					// 小数点の判定
					if (line.charAt(end) == '.') {
						c = line.charAt(i + 1);
						if (c >= '0' && c <= '9') {
							for (int j = end + 1; j < line.length(); j++) {
								i = j;
								c = line.charAt(j);
								if (c < '0' || c > '9') {
									break;
								}
							}
							continue;
						}
					}
					sum += Integer.parseInt(line.substring(sta, end));
				}
			}
		}
		System.out.println(sum);
	}
}

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

int main () {

    int N;
    scanf("%d", &N);

    int a[N+1];
    for (int i = 1; i <= N; i++) {
        int rabbit;
        scanf("%d", &rabbit);

        a[i] = rabbit;
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (a[i] != 0) {
            if (a[a[i]] == i) {
                ans++;
                a[i] = a[a[i]] = 0;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 640
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  double a,b,x;cin>>a>>b>>x;

  double ta = (2*b*a*a-2*x)/(a*a*a);
  if (ta<=b/a){
    dump(ta);
  }
  else{
    dump(ta);
    ta = a*b*b/(2*x);
  }
  double ans = atan2(ta, 1)*180/M_PI;
  printf("%.10f", ans);

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
T next_combination(T sub) {
    T x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    s << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    s << ']';
	return s;
}

int main(){

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

    int r, g, b, n;
    cin >> r >> g >> b >> n;

    vector<int> AA;
    for(int i = 0; i*b <= n; ++i){
        AA.push_back(n-b*i);
    }

    map<int, int> BB;
    for(int i = 0; i <= n/r+1; ++i){
        for(int j = 0; j <= n/g+1; ++j){
            BB[r*i+g*j]++;
        }
    }
    ll cnt = 0LL;
    for(int i = 0; i < AA.size(); ++i){
        cnt += BB[AA[i]];
    }
    ppp(cnt);

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long int
#define ld long double
#define pb push_back
#define p1 1232
#define mod 998244353
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long binpow(long long a, long long b, long long m=mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
   IO
   ll a;
   string b;
   cin>>a>>b;
   ll r=0;
   ll e=0;
   for(int x=b.length()-1;x>=0;x--)
   {    if(b[x]!='.')
       {r+=((b[x]-'0')*binpow(10,e));
       ++e;
       }
   }
   //cout<<r<<"\n";
   ll f=(a*r)/100ll;
   cout<<f<<"\n";
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;

	return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;

    int flag = 1;
    int st;

    for (int i = 0; i < s.size(); i++) {
        if (i % 2==0 && s[i] != 'h') {
            flag = 0;
            break;
        }
        else if (i % 2 == 1 && s[i] != 'i') {
            flag = 0;
            break;
        }

    }
    if (s.size() % 2 != 0)flag = 0;
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No";
    
}


Measured memory_bytes: 256
# 25:50 - 
n, W_LIMIT = gets.to_s.split.map{|t| t.to_i }
wv = Array.new(n){ gets.to_s.split.map{|t| t.to_i } }.sort_by{|_, v| v }

V_MAX = (10 ** 3) * n

dp = Array.new(V_MAX+1){ (10**9) * n + 1 }
dp[0] = 0

v_sum = 0
wv.each do |(w_i, v_i)|
  v_sum = V_MAX < v_sum + v_i ? V_MAX : v_sum + v_i
  v_sum.downto(v_i) do |v|
    dp[v] = dp[v-v_i] + w_i if dp[v] > dp[v-v_i] + w_i
  end
end

v_sum.downto(0) do |v|
  if dp[v] <= W_LIMIT
    puts v
    exit
  end
end


Measured memory_bytes: 2552
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  vector<pair<int,int>>su(n);
  rep(i,n)
  {
    ll a,b;
    cin>>a>>b;
    su[i]={b,a};
  }
  sort(all(su),greater<pair<int,int>>());
  vector<bool>used(n+1);
  int syurui=0;

  vector<int>id;
  rep(i,n)
  {
    if(!used[su[i].second]){used[su[i].second]=1;id.push_back(i);syurui++;}
  }

  vector<ll>sum1(n+1),sum2(id.size()+1);
  rep(i,n)sum1[i+1]=su[i].first+sum1[i];
  rep(i,id.size())sum2[i+1]=su[id[i]].first+sum2[i];
  int inid=upper_bound(all(id),k-1)-id.begin();
  ll res=(ll)inid*inid+sum1[k];
  inid--;
  int idx=k-1;
  int maid=1+min(k,syurui);
  repi(i,inid+2,maid)
  {
    ll tres=(ll)i*i;
    while(idx==id[inid])
    {
      inid--;
      idx--;
    }
    idx--;
    tres-=sum2[inid+1];
    tres+=sum2[i];
    tres+=sum1[idx+1];
    chmax(res,tres);
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000 //5･10^10
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,o=0,e=0;
  cin>>n;
  rep(i,n) {
    int a;
    cin>>a;
    if(a%2) o++;
    else e++;
  }
  if(o%2) cout<<"NO"<<endl;
  else {
    cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll a(n); REP(i, n) cin >> a[i];
  vll bit(30, 0);
  ll x = 0;
  REP(i, n) {
    x ^= a[i];
    REP(j, 30) {
      if (a[i]&(1LL<<j)) {bit[j]++; break;}
    }
  }

  ll ans = 0;
  for(ll i=30; i>=0; i--) {
    if (x&(1LL<<i)) {
      if (bit[i]>0) {
        ans++;
        x = (x^(1LL<<i)) ^ ((1LL<<i)-1);
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int H,N,sum=0;
    cin>>H>>N;
    vector<int> A(N);
    for (int i=0;i<N;i++){
    	cin>>A.at(i);
        sum+=A.at(i);
    }
  if(sum>=H){
  cout<<"Yes"<<endl;
  }else{
  cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 3764
#include <cstdio>
#include <algorithm>

using std::sort;
int abs(int x)
{
    if(x<0)
        return -x;
    return x;
}
int main(void)
{
    int *a,*g;
    int i,M,N,R=0;
    scanf("%d%d",&N,&M);
    a=new int [M];
    for(i=0;i<M;i++)
        scanf("%d",a+i);
    if(N<M)
    {
        sort(a,a+M);
        g=new int [M-1];
        
        for(i=0;i<M-1;i++)
        {
            g[i]=abs(a[i+1]-a[i]);
        }
        sort(g,g+M-1);
        R=a[M-1]-a[0];
        i=M-2;
        while(N-->1)
        {
            R-=g[i];
            i--;
        }
        printf("%d\n",R);
    }
    else
        printf("0\n");
    return 0;


}


Measured memory_bytes: 1024
import fractions
n=int(input())
a=list(map(int,input().split()))

if n==2:
        print(max(a[0],a[1]))

else:
        l=[a[0]]
        r=[a[n-1]]
        for i in range(1,n):
                l.append(fractions.gcd(l[-1],a[i-1]))
        for i in range(n-1,0,-1):
                        r.append(fractions.gcd(r[-1],a[i]))
        r=r[::-1]
        l[0]=r[0]
        r[n-1]=l[n-1]
        ans=0
        for k in range(n):
                g=fractions.gcd(l[k],r[k])
                if g>=ans:
                        ans=g
        print(ans)

Measured memory_bytes: 16124
// Template Headers {{{
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	int k; string s; cin >> k >> s;
	if (int(s.size()) <= k)
		cout << s << endl;
	else
		cout << s.substr(0, k) << "..." << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int A,B,Q;
// vector<ll> s,t,x;

int main()
{
  cin >> A >> B >> Q;
  vector<ll> s(A), t(B), x(Q);
  REP(i,0,A) cin >> s[i];
  REP(i,0,B) cin >> t[i];
  REP(i,0,Q) cin >> x[i]; //クエリ

  // 位置のソート( → ソート済み)

  REP(i,0,Q) {
    // x[i]より大きい・一番左
    int a = upper_bound(ALL(s), x[i]) - s.begin();
    int b = upper_bound(ALL(t), x[i]) - t.begin();

//    cout << s[a] << " " << t[b] << endl;

    ll res = INF;
    // x[i]の右の2つ
    if (a < A && b < B) {
      chmin(res, max(s[a] - x[i], t[b] - x[i]));
    }
    // x[i]の左の2つ
    if (a - 1 >= 0 && b - 1 >= 0) {
      chmin(res, max(x[i] - s[a-1], x[i] - t[b-1]));
    }

    // xより左と右
    if (a - 1 >= 0 && b < B) {
      chmin(res, t[b] - s[a-1] + min(t[b] - x[i], x[i] - s[a-1]));
    }
    // xより右aと左b-1
    if (a < A && b - 1 >= 0) {
      chmin(res, s[a] - t[b-1] + min(s[a] - x[i], x[i] - t[b-1]));
    }

    cout << res << endl;

    // break; //1つ目だけで試す
  }

  return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
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 T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())

ll rec(ll h) {
    if (h == 1) return 1;
    ll res = 1;
    res += 2 * rec(h/2);
    return res;
}

int main() {
    /*

    ll N, K; cin >> N >> K;
    vll H(N);
    FOR(i,N) cin >> H[i];
    
    ll res = 0;
    SORT(H);
    FOR(i,N-K) {
        res += H[i];
    }
    cout << res << endl;*/

    ll H; cin >> H;

    cout << rec(H) << endl;
}


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

using namespace std;

int main()
{
    int a,b,s;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        s=0;
        s=a*b;
        if(s%2==0)
        {
            cout<<"Even"<<endl;
        }
        else
            cout<<"Odd"<<endl;

    }
    return 0;
}

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

//abc142C
int main(void) {
  int n, i, a;
  scanf("%d", &n);
  int num[n];
  for(i=0; i < n; i++){
    scanf(" %d", &a);
    num[a-1]=i+1;
  }
  for(i=0; i < n; i++)printf("%d ", num[i]);
}


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

divs = set()
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        q = N // i
        divs.add((min(q, i), max(q, i)))

res = float("inf")
for a, b in divs:
    res = min(res, a+b-2)

print(res)

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<char,P>P2;
#define F first
#define S second


signed main(){
    int a[3];
    r(i,3)cin>>a[i];
    sort(a,a+3);
    if(a[2]!=a[0])cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
const LL MOD = 1e9 + 7;
LL a[N], sum[N], fac[N], inv[N];

LL pw(LL x, LL y) {
	LL res = 1;
	for (; y; y >>= 1) {
		if (y & 1) res = res * x % MOD;
		x = x * x % MOD;
	}
	return res;
}

inline void update(LL &ans, LL add) {
	ans = (ans + add) % MOD;
}

int main() {
	int n;
	scanf("%d", &n);
	fac[0] = 1;
	for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % MOD;
	inv[N - 1] = pw(fac[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % MOD;
	for (int i = 1; i <= n; i++) scanf("%lld", a + i);
	for (int i = 1; i <= n; i++) sum[i] = (sum[i-1] + a[i]) % MOD;
	LL ans = 0;
	for (int l = 1; l <= n - 1; l++) {
		update(ans, sum[l] * fac[n] % MOD * fac[l] % MOD * inv[l + 1] % MOD);
	}
	for (int l = 1; l <= n - 1; l++) {
		update(ans, (((sum[n] - sum[n - l]) % MOD + MOD) % MOD)* fac[n] % MOD * fac[l] % MOD * inv[l + 1] % MOD);
	}
	LL s = ((sum[n - 1] - sum[1]) % MOD + MOD) % MOD;
	for (int l = 1; l <= n - 2; l++) {
		update(ans, s * fac[n] % MOD * 2 * fac[l] % MOD * inv[l + 2] % MOD);
		s += (sum[n - 1] - sum[1 + l]) - (sum[n - 1] - sum[n - 1 - l]);
		s = (s % MOD + MOD) % MOD;
	}
	update(ans, sum[n] * fac[n] % MOD);
	printf("%lld\n", ans);
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, c, k;
  cin >> n >> c >> k;
  
  vector<int> t(n);
  for(int i = 0; i < n; i++) cin >> t.at(i);
  
  sort(t.begin(), t.end());
  
  int ans = 0, num = 1, limit = t.at(0) + k;
  for(int i = 1; i < n; i++){
    if(num >= c || t.at(i) > limit){
      ans++;
      num = 1;
      limit = t.at(i) + k;
    }
    else{
      num++;
    }
  }
  if(num) ans++;
  
  cout << ans << '\n';
}

Measured memory_bytes: 640
#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>;

int n;

vector<int> rec(int i, vector<int> b) {
  if (b.size() == n) return b;
  b.insert(b.end(), i + 1);
  b.insert(b.begin(), i + 2);
  return rec(i + 2, b);
}

int main() {
  int n, a;
  cin >> n;
  deque<int> d;
  rep(i, n) {
    cin >> a;
    if (i % 2 == n % 2) {
      d.push_back(a);
    } else {
      d.push_front(a);
    }
  }

  rep(i, n) {
    cout << d[i];
    if (i != n - 1) cout << ' ';
  }
  cout << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

const int N = (int)1e6 + 5;

int a[N];

int main() {
  ios :: sync_with_stdio(0);
  cin.tie(0);
  int x, n;
  cin >> x >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    a[x] = 1;
  }
  for (int i = 0; i <= 1000; ++i) {
    if (x - i >= 0) {
      if (!a[x - i]) {
        cout << x - i;
        return 0; 
      }
    }
    if (!a[x + i]) {
      cout << x + i;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3652
N=int(input())
D,X = map(int,input().split())
A=[int(input()) for k in range(N)]

B=0

choco=0
for y in range(N):
    for x in range(0,D,A[y]):
        choco=choco+1
        B=B+1

choco=choco+X

print(choco)


Measured memory_bytes: 3060
d = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(d)]
T = [int(input())-1 for _ in range(d)]

last = [0] * 26
ans = 0
for i in range(d):
    v = T[i]
    ans += S[i][v]
    for j in range(26):
        if j == v:
            last[j] = 0
        else:
            last[j] += 1
        ans -= C[j] * last[j]
    print(ans)


Measured memory_bytes: 9280
n,m=gets.chomp.split.map { |e| e.to_i  }

a=Array.new(m,0)
b=Array.new(m,0)


m.times do |i|

  a[i],b[i]=gets.chomp.split.map { |e| e.to_i  }

end

c=Array.new(m)


for i in 0..m-1
  c[i] = {'a' => a[i],'b' => b[i]}
end

def quick_sort_hash(c)
  if c==[]
    return []
  end

  smaller = c.select{ |h| h["b"] < c[0]["b"] }
  same = c.select{ |h| h["b"] == c[0]["b"] }
  larger = c.select { |h| h["b"] > c[0]["b"]  }

  return quick_sort_hash(smaller) + same + quick_sort_hash(larger)

end

e=quick_sort_hash(c)

x=-1
dp = 0

m.times do |i|
  if e[i]["a"] >= x
    dp +=1
    x=e[i]["b"]
  end
end

puts dp

Measured memory_bytes: 54296
n = int(input())
lower_divisors, upper_divisors = [], []
i = 1
while i*i <= n:
    if n % i == 0:
        lower_divisors.append(i)
        upper_divisors.append(n // i)
    i += 1

ans = (lower_divisors[-1] - 1) + (upper_divisors[-1] - 1)

print(ans)


Measured memory_bytes: 3284
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
if n % 2 == 0:
    num = n // 2
    ans = sum(a[:num]) + sum(a[1:num])
else:
    num = n // 2
    ans = sum(a[:num]) + sum(a[1:num + 1])
print(ans)

Measured memory_bytes: 31544