akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        while (cnt < x) {
            ++ans;
            cnt += ans;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var D int
var cs []int
var ss [][]int

func main() {
	D = ReadInt()
	cs = ReadInts(26)
	ss = make([][]int, D)
	for i := 0; i < D; i++ {
		ss[i] = ReadInts(26)
	}

	answers := ReadInts(D)

	M := ReadInt()
	for i := 0; i < M; i++ {
		d, q := ReadInt(), ReadInt()
		answers[d-1] = q
		score, _ := scores(answers)
		fmt.Println(score)
	}
}

func scores(answers []int) (int, []int) {
	scores := []int{}
	last := make([]int, 26)
	score := 0
	for d := 1; d <= D; d++ {
		t := answers[d-1] - 1
		score += ss[d-1][t]
		last[t] = d
		for i := 0; i < 26; i++ {
			score -= cs[i] * (d - last[i])
		}
		scores = append(scores, score)
	}
	return score, scores
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6500
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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



///////////////////////////



int main() {

	string s;
	cin >> s;

	ll K = s.size();

	vector<ll> N;

	rep(i, K) {
		N.push_back(s[K - 1 - i] - '0');
	}

	N.push_back(0);
	
	ll ansk = N[0];
	ll anst = 10 - N[0];

	repn(i, K) {
		ll nansk = min(ansk + N[i], anst + N[i] + 1);
		ll nanst = min(ansk + 10 - N[i], anst + 10 - N[i] - 1);
		ansk = nansk;
		anst = nanst;
	}

	cout << min(ansk, anst);


	
	system("PAUSE");

}


Measured memory_bytes: 11896
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,K;
    cin>>N>>K;
    int i;
    
    int c1=0;
    int c2=0;
    
    for(i=1;i<=N;i++){
        if(i%2==0){
            c1++;
        }else{
            c2++;
        }
    }
    
    if(c1==K||c2==K){
        cout<<"YES"<<endl;
    }else if(K<c1||K<c2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define MAXN 109

string s[MAXN];

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

    for(int i=1; i<=n; i++)
        cin >> s[i];

    sort(s+1, s+n+1);

    for(int i=1; i<=n; i++)
        cout << s[i];

    cout << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public void main(Scanner sc) {
		int n = sc.nextInt();
		long ans = 1;

		for (int i = 0; i < n; i++) {
			long a = sc.nextLong();

			if (ans != -1) {
				if (((int) Math.ceil(Math.log10(ans) + Math.log10(a))) > 18) {
					ans = -1;
				} else {
					ans *= a;
				}
			} else {
				if (a == 0) {
					ans = 0;
				}
			}
		}

		System.out.println(ans > 1000000000000000000L ? -1 : ans);
	}

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


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> cnt(h,vector<int>(w));
  
  rep(i,h){
    vector<int> done(w);
    rep(j,w){
      if(s[i][j]=='#')continue;
      if(done[j])continue;
      
      int l = 0;
      
      while(j+l<w){
        if(s[i][j+l]=='#') break;
        l++;
      }
      
      rep(k,l){
        cnt[i][j+k] +=l;
        done[j+k] = 1;
      }
    }
  }
  
  rep(j,w){
    vector<int> done(h);
    rep(i,h){
      if(s[i][j]=='#')continue;
      if(done[i])continue;
      
      int l = 0;
      
      while(i+l<h){
        if(s[i+l][j]=='#')break;
        l++;
      }
      
      rep(k,l){
        cnt[i+k][j] +=l;
        done[i+k] = 1;
      }
    }
  }

  int ans = 0;
  rep(i,w){
    rep(j,h){
      ans = max(ans,cnt[j][i]-1);
    }
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 20096
#!/usr/bin/env python3
#ABC145 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x,y = LI()
fact = [1]*(10**6+1)
for i in range(1,10**6+1):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

if (x+y) % 3 != 0:
    print(0)
    quit()

n,m = (2*x - y)/3,(2*y - x)/3
if n < 0 or m < 0:
    print(0)
    quit()
if n % 1 == 0 and m % 1 == 0:
    n = int(n)
    m = int(m)
    ans = fact[n+m]*pow(fact[n],mod-2,mod)*pow(fact[m],mod-2,mod)
    ans %= mod
    print(ans)
else:
    print(0)



Measured memory_bytes: 47980
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef complex<double> P;

int n;
P p[100], q[100];
P x[10000];

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int is_intersected_ls(P a1, P a2, P b1, P b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

P intersection_ls(P a1, P a2, P b1, P b2) {
  P b = b2-b1;
  double d1 = abs(cross(b, a1-b1));
  double d2 = abs(cross(b, a2-b1));
  double t = d1 / (d1 + d2);

  return a1 + (a2-a1) * t;
}

void solve(){
	rep(i,n){
		double x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		p[i] = P(x1,y1);
		q[i] = P(x2,y2);
	}
	int cnt = 0, st;
	int ans = n+1;
	rep(i,n){
		st = cnt;
		for(int j = 0; j < i; j++){
			if(!is_intersected_ls(p[i],q[i],p[j],q[j])) continue;
			P tmp = intersection_ls(p[i],q[i],p[j],q[j]);
			//cout << tmp.real() << " " << tmp.imag() << endl;
			if(tmp.real() < -100+EPS || tmp.real() > 100-EPS) continue;
			if(tmp.imag() < -100+EPS || tmp.imag() > 100-EPS) continue;
			bool ok = true;
			for(int k = st; k < cnt; k++){
				if(abs(x[k]-tmp) < EPS){
					ok = false;
					break;
				}
			}
			if(!ok) continue;
			ans++;
			/*
			rep(k,st){
				if(abs(x[k]-tmp) < EPS){
					ok = false;
					break;
				}
			}
			if(!ok) continue;
			*/
			x[cnt] = tmp;
			cnt++;
		}
	}
	cout << ans << endl;
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

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

int main()

{

    int a,b,c;

    map<string,int> MAP;
    map<string,int>::iterator it;
    scanf("%d ",&a);
    string s;

    for(int k=0;k<a;k++){
    scanf("%d",&b);
    if (b==0 ){

            cin >> s >> c;
			MAP[s] = c;

            }
    else if (b==1){

            cin >> s;
			it=MAP.find(s);
            if(it!=MAP.end()){

             printf("%d\n",MAP[s]);
            }
             else{
               cout<<"0"<<endl;
            }



    }
     else if (b==2){

            cin >> s;
			MAP.erase (s);

}

    }


    return 0;



}




Measured memory_bytes: 27820
<?php
fscanf(STDIN,"%d",$N);
$input_line = fgets(STDIN);
$array = explode(" ", $input_line);
$num_even = 0;
foreach($array as $elem){
    if(intval($elem)%2==0){
        $num_even++;
    }
}
echo pow(3,count($array))-pow(2,$num_even);
?>

Measured memory_bytes: 4604
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(N)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, left, right):
        """
        [left, right)のsegfuncしたものを得る
        left: index(0-index)
        right: index(0-index)
        """
        res = self.ide_ele
        left += self.num
        right += self.num
        while left < right:
            if left & 1:
                res = self.segfunc(res, self.tree[left])
                left += 1
            if right & 1:
                res = self.segfunc(res, self.tree[right - 1])
            left >>= 1
            right >>= 1
        return res


def resolve():
    n, c = map(int, input().split())
    XY = [list(map(int, input().split())) for _ in range(n)]
    R1 = [0]
    prev = 0
    for x, y in XY:
        R1.append(R1[-1] + y - (x - prev))
        prev = x
    R2 = [0]
    prev = 0
    for x, y in XY[::-1]:
        R2.append(R2[-1] + y - ((c - x) - prev))
        prev = (c - x)

    res = max(max(R1), max(R2))
    seg1 = SegTree(R2, lambda x, y: max(x, y), 0)
    for i in range(1, n + 1):
        point1 = R1[i] - XY[i - 1][0]
        point2 = seg1.query(0, n + 1 - i)
        res = max(res, point1 + point2)

    seg2 = SegTree(R1, lambda x, y: max(x, y), 0)
    for i in range(1, n + 1):
        point1 = R2[i] - (c - XY[-i][0])
        point2 = seg2.query(0, n + 1 - i)
        res = max(res, point1 + point2)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 41484
s = int(input())
if round(s**0.5)**2==s:
    tmp = round(s**0.5)
    print(0, 0, tmp, 0, 0, tmp)
    exit()
i = int(s**0.5)+1
for j in range(i, 0, -1):
    if i*j<s:
        print(0, 0, i, 1, i*(j+1)-s, j+1)
        break

Measured memory_bytes: 3188
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let h: i64 = sc.read();
    let w: i64 = sc.read();
    let n: usize = sc.read();
    let r: i64 = sc.read();
    let c: i64 = sc.read();
    let s = sc.chars();
    let t = sc.chars();

    let check = |left: char, right: char, w: i64, c: i64| {
        let mut seg = vec![(0, 0); n + 1];
        let mut left_win = 0;
        let mut right_win = w + 1;
        for i in (0..n).rev() {
            if t[i] == left && right_win <= w {
                right_win += 1;
            }
            if t[i] == right && left_win > 0 {
                left_win -= 1;
            }
            if s[i] == left {
                left_win += 1;
            }
            if s[i] == right {
                right_win -= 1;
            }
            seg[i] = (left_win, right_win);
        }
        seg[n] = (0, w + 1);

        let mut left_cur = c;
        let mut right_cur = c;
        for (i, &(left_win, right_win)) in seg.iter().enumerate() {
            if left_cur <= left_win || right_win <= right_cur {
                return true;
            }
            if i == n {
                return false;
            }

            let (left_win, right_win) = seg[i + 1];
            if s[i] == left {
                left_cur -= 1;
            }
            if s[i] == right {
                right_cur += 1;
            }
            if t[i] == left && left_win < right_cur - 1 {
                right_cur -= 1;
            }
            if t[i] == right && left_cur + 1 < right_win {
                left_cur += 1;
            }
        }
        unreachable!()
    };

    if check('L', 'R', w, c) || check('U', 'D', h, r) {
        println!("NO");
    } else {
        println!("YES");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
a,b = map(str, input().split())
judge = True
tmpa = a
tmpb = b
if a > b:judge = True
else: judge = False
if judge:
    for i in range(int(a) - 1):
        b += tmpb
    print(b)
else:
    for i in range(int(b) - 1):
        a += tmpa
    print(a)

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

int main() {
	int h,w,c[10][10];
	bool hoge=true;
	long long p=0;
	cin>>h>>w;
	for(int i=0;i<10;i++){
	    for(int j=0;j<10;j++){
	        cin>>c[i][j];
	    }
	}
	while(hoge){
	hoge=false;
	for(int i=0;i<10;i++){
	    for(int j=0;j<10;j++){
	        if(j!=i){
	            for(int k=0;k<10;k++){
	                if(c[i][j]>c[i][k]+c[k][j]){
    hoge=true;
    c[i][j] = c[i][k]+c[k][j];
}
	            }
	        }
	    }
	}
	}
	for(int i=0;i<h;i++){
	    for(int i=0;i<w;i++){
	        int a;
	        cin>>a;
	        if(a>-1)p+=c[a][1];
	    }
	}
	cout<<p<<endl;
}

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


int main(){
	int N;
	cin >> N;
	int ans[55] = {11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381};
	for(int i=0;i<N;i++){
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let p: i32 = input();
    let abc: Vec<(usize, usize, i32)> = (0..m).map(|_| (input(), input(), input())).collect();

    let mut edge = vec![];
    let mut e1 = vec![vec![]; n];
    let mut e2 = vec![vec![]; n];
    for (a, b, c) in abc {
        let (a, b) = (a - 1, b - 1);
        let c = -(c - p);
        edge.push((a, b, c));
        e1[a].push(b);
        e2[b].push(a);
    }

    let mut ok1 = vec![false; n];
    dfs(0, &e1, &mut ok1);
    let mut ok2 = vec![false; n];
    dfs(n - 1, &e2, &mut ok2);

    let mut dist = vec![1001001001; n];
    dist[0] = 0;
    let mut updated = true;
    let mut step = 0;
    let mut cycle = false;
    while updated {
        updated = false;
        for &(a, b, c) in &edge {
            if !ok1[a] || !ok2[a] || !ok1[b] || !ok2[b] {
                continue;
            }
            if dist[a] + c < dist[b] {
                updated = true;
                dist[b] = dist[a] + c;
            }
        }
        step += 1;
        if step > n {
            cycle = true;
            break;
        }
    }

    if cycle {
        println!("-1");
    } else {
        println!("{}", std::cmp::max(0, -dist[n - 1]));
    }
}

fn dfs(cur: usize, e: &Vec<Vec<usize>>, ok: &mut Vec<bool>) {
    ok[cur] = true;
    for &nxt in &e[cur] {
        if !ok[nxt] {
            dfs(nxt, e, ok);
        }
    }
}


Measured memory_bytes: 4476
#!/usr/bin/env python3
import sys


def solve(N: int):
    answer = (N-1)*N//2
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N, Q = map(int,input().split())
S= input()
lr_list = [list(map(int,input().split())) for _ in range(Q)]

# ac_tf_list = [1 if S[i:i+2]=='AC' else 0 for i in range(N-1)]
t = [0]*N
for i in range(N-1):
    if S[i:i+2]=='AC':
        t[i+1] = t[i]+1
    else:
        t[i+1] = t[i]

for i in range(Q):
    l = lr_list[i][0]-1
    r = lr_list[i][1]-1
    print(t[r]-t[l])


Measured memory_bytes: 30664
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	char s[101];
	bool p=1;
	cin>>a>>b;
	cin>>s;
	for (int i=0;i<a;i++){
		if (s[i]>'9'||s[i]<'0') p=0;
	}
	for (int i=a+1;i<a+b+1;i++){
		if (s[i]>'9'||s[i]<'0') p=0;
	}
	if (s[a]!='-') p=0;
	if (p) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

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


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

#define INF (INT64_MAX/2)

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long long> a( N );
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	long long ans = INF;
	for( int mask = 0; mask < 1 << N; mask++ ) {
		if( (mask & 1) == 0 ) continue;
		if( __builtin_popcount( mask ) != K ) continue;
		long long cost = 0;
		long long mah = a[0];
		for( int i = 1; i < N; i++ ) {
			long long h = a[i];
			if( mask >> i & 1 ) {
				long long d = 0;
				if( mah >= a[i] ) d = mah - a[i] + 1;
				cost += d;
				h = a[i] + d;
			}
			mah = max( mah, h );
		}
		ans = min( ans, cost );
	}

	cout << ans << endl;
}


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

int main() {
  vector<int>x(5);
  rep(i,5) cin >> x[i];
  int cnt = 0;
  rep(i,5){
    cnt++;
    if(x[i]==0) break;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3628
while(True):
    n,x=map(int,input().split())
    if(n==0 and x==0):
        break
    ans=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if(i+j+k==x):
                    ans+=1
    print(ans)



Measured memory_bytes: 5592
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll n;
ll cycle(ll x){
  return x%n;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    F0R(i,n) {cin >> a[i]; sum +=a[i];}
    sum -= n;
    cout << sum << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main() {
  double a, b, C;
  std::cin >> a >> b >> C;
  double rc = C * M_PI / 180;
  double h = b * sin(rc);

  std::cout << std::fixed << a * h / 2.0 << std::endl
            << a + b + sqrt(a * a + b * b - 2 * a * b * cos(rc)) << std::endl
            << h << std::endl;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;
 
int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
 
int max(int a,int b){return (a>b?a:b);}
 
int min(int a,int b){return (a<b?a:b);}
 
struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};
 
struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

int32_t main(){
    IOS
    int a,b;
    cin >> a >> b;
    cout<<6-a-b<<endl;
} 

Measured memory_bytes: 3660
#include <iostream>
using namespace std;
main() {
	int h, w;
	while (cin >> h >> w, h!=0||h!=w) {
		for (int i=0; i<h; i++) {
			for (int j=0; j<w; j++)
				cout << ((i+j)%2?'.':'#');
			cout << endl;
		}
		cout << endl;
	}
}

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

int main()
{
    int a , b;
    int n;
    cin>>n>>a>>b;
    if((b-a-1)&1) cout<<"Alice"<<endl;
    else if((b-a-1)%2==0)cout<<"Borys"<<endl;
    else cout<<"Draw"<<endl;
 return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
a = []
for i in range(N):
    a.append(0)
for i in range(K):
    d_i = int(input())
    A_i = list(map(int,input().split()))
    for k in range(N):
        if (k+1 in A_i) == True :
            a[k] =a[k] + 1
sum = 0
for i in range(N):
    if a[i] == 0:
        sum += 1
print(sum)

Measured memory_bytes: 9204
import java.util.*;
public class Main {
    private static long dp[][];
    private static int N;
    private static int A[];
    private static int B[];
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String res = "";
        if(3 == x.length()) {
            res += x.substring(2,3);
            res += x.substring(1,2);
            res += x.substring(0,1);
        } else {
            res = x;
        }
        System.out.println(String.format("%s", res));
    }
}

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

bool C (char d){
  if(d == 'A' ||d == 'T' ||d == 'C' ||d == 'G' ) return true;
  else return false;
}
int main() {
  string s;
  int max =0;
  cin >> s ;
  for(int i =0;i<s.size();i++){
    int k =i;
    int count =0;
    while(C(s[k])==true){
      count++;
      k++;
    }
    if(count > max)max =count;
  }
  cout << max << endl;
  return 0;
}

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

bool topological_sort(const vector< vector<int> >& g, vector<int>& res){
    const int v = (int)g.size();
    res.clear();

    vector<int> deg(v, 0);
    for(int i = 0 ; i < v ; ++i){
        for(auto to : g[i]){
            ++deg[to];
        }
    }

    vector<int> st;
    for(int i = 0 ; i < v ; ++i){
        if(deg[i] == 0){
            st.emplace_back(i);
        }
    }

    while(!st.empty()){
        int k = st.back();
        st.pop_back();
        res.emplace_back(k);
        for(auto to : g[k]){
            --deg[to];
            if(deg[to] == 0){
                st.emplace_back(to);
            }
        }
    }

    return (int)res.size() == v;
}

#include<iostream>
#include<algorithm>

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

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

    int n;
    cin >> n;

    vector< vector<int> > a(n, vector<int>(n - 1));
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < n - 1 ; ++j){
            cin >> a[i][j];
            --a[i][j];
        }
    }

    vector< vector<int> > g(n * n + 2);
    for(int i = 0 ; i < n * n ; ++i){
        g[n * n].emplace_back(i);
        g[i].emplace_back(n * n + 1);
    }

    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < n - 2 ; ++j){
            g[min(i, a[i][j]) * n + max(i, a[i][j])].emplace_back(min(i, a[i][j + 1]) * n + max(i, a[i][j + 1]));
        }
    }

    vector<int> v;

    if(!topological_sort(g, v)){
        cout << -1 << endl;
        return 0;
    }

    vector<int> dp(n * n + 2, -1);
    dp[v[0]] = 0;

    for(int i = 0 ; i < n * n + 2 ; ++i){
        for(auto to : g[v[i]]){
            chmax(dp[to], dp[v[i]] + 1);
        }
    }

    cout << dp[n * n + 1] - 1 << endl;

    return 0;
}

Measured memory_bytes: 76780
n,t,r;double S,sin();main(i){for(;~scanf("%d",&n);(i=-i)>0?S=!puts(fabs(S)>1e-6?S>0?"1":"2":"0"):0)for(r=360;n--;r-=t)!n?t=r:scanf("%d",&t),S+=sin(t/57.3)*i;}

Measured memory_bytes: 0
n,m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
r = [0]*(m+1)
for i in l:
    i.append(sum(i))
for j in range(m+1):
    r[j] = sum([x[j] for x in l])
l.append(r)
for i in range(n+1):
    print(" ".join(map(str,l[i])))


Measured memory_bytes: 5700
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

signed main()
{
int n,k;
std::cin >> n >> k;
std::vector<int> a;
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    a.push_back(temp);
}
std::vector<int> sumlist;
std::vector<int> nsumlist;
if(n < k){
    int tempsum = 0;
    for(int i = 0; i < n; i++){
        tempsum++;
    }
    std::cout << max(tempsum,(int)0) << std::endl;
} else {
    int startsum = 0;
    int nstartsum = 0;
    for(int i = 0; i < k; i++){
        startsum += a[i];
        if(a[i] > 0){
            nstartsum += a[i];
        }
    }
    sumlist.push_back(startsum);
    nsumlist.push_back(nstartsum);
    for(int i = k; i < n; i++){
        sumlist.push_back(a[i] + sumlist[i - k] - a[i - k]);
        if(a[i] > 0){
            if(a[i - k] > 0){
                nsumlist.push_back(a[i] + nsumlist[i - k] - a[i - k]);
            } else {
                nsumlist.push_back(a[i] + nsumlist[i - k]);
            }
        } else {
            if(a[i - k] > 0){
                nsumlist.push_back(nsumlist[i - k] - a[i - k]);
            } else {
                nsumlist.push_back(nsumlist[i - k]);
            }
        }
    }
    int flag = 0;
    int min =  INF;
    for(int i = 0; i < n - k + 1; i++){
        if(min >= abs(-abs(max(sumlist[i],(int)0)) + abs(nsumlist[i]))){
            min = abs(-abs(max(sumlist[i],(int)0)) + abs(nsumlist[i]));
            flag = i; 
        }
    }
    int sum = 0;
    for(int i = 0; i < flag; i++){
        if(a[i] > 0){
            sum += a[i];
        }
    }
    sum += max(sumlist[flag],(int)0);
    for(int i = flag + k; i < n; i++){
        if(a[i] > 0){
            sum += a[i];
        }
    }
    std::cout << sum << std::endl;

}
return 0;
}

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = "";

        if(a < 1200){
            s = "ABC";
        } else if(a < 2800){
            s = "ARC";
        } else {
            s = "AGC";
        }

        System.out.println(s);
    }
}


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


int main(){


    string s;

    int i;

    int k = 0;

 
    cin >> s;


    for( ; s.size() > 0 ; ){

         s.pop_back();

         if( s.size() % 2 == 0 ){

             if( s.substr( 0, s.size() / 2 ) == s.substr( s.size() / 2 , s.size() / 2 ) ){

                 k = s.size();

                 break;

                 }

             }

         }


    cout << k << endl;


    return 0;


    }

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    writeln(readln.chomp.count!"a == 'o'" * 100 + 700);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double angle=abs((11/2.0)*m-30.0*h);
    if(angle>180){
        angle=abs(360-angle);
    }
    double third=(a*a)+(b*b)-2*a*b*cos((angle*(acos(-1)/180.000000000000000)));
    cout<<fixed<<setprecision(15)<<sqrt(third)<<'\n';
    return 0;
}


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

const int MOD = 998244353;
int main()
{
  int N, S;
  cin >> N >> S;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  // C++ MOD をとるような値になったときはlong longにする。
  // intが2**31-1 で2*10**9程度なので、 今回はぎり収まらないくらい
  vector<vector<long long>> DP(N + 1, vector<long long>(S + 1, 0));
  // 初期化 0 0 = 1
  DP[0][0] = 1;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= S; j++)
    {
      if (j >= A[i])
        DP[i + 1][j] = DP[i][j] * 2 + DP[i][j - A[i]];
      else
        DP[i + 1][j] = DP[i][j] * 2;
      DP[i + 1][j] %= MOD;
    }
  }
  cout << DP[N][S] << endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    bool black[w][h] = {};

    rep(k, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            rep(i, x) rep(j, h) black[i][j] = true;
        } else if (a == 2) {
            REP(i, x, w) rep(j, h) black[i][j] = true;
        } else if (a == 3) {
            rep(i, w) rep(j, y) black[i][j] = true;
        } else if (a == 4) {
            rep(i, w) REP(j, y, h) black[i][j] = true;
        }
    }

    int white = 0;
    rep(i, w) rep(j, h) if (!black[i][j]) white++;

    cout << white << endl;

    return 0;
}



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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 ;
    cin >> num1 >> num2 ;
    cout << num1 * num1 - num2 ;



    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        long[] l = new long[n + 1];

        l[0] = 2;
        l[1] = 1;

        for (int i = 2; i <= n; i++)
        {
            l[i] = l[i - 1] + l[i - 2];
        }

        long answer = l[n];

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p = {64,32,16,8,4,2,1};
    for (int i=0; i<7; i++){
        if (n >= p[i]){
            cout << p[i] << endl;
            return 0;
        }else{
            continue;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){
	if(b==0){
		return a;
	}
	return gcd(b, a%b);
}
int main(){
	ll sum=0;
	int n; cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ll g=gcd(i,j);
			for(int k=1;k<=n;k++){
				ll gc=gcd(g,k);
				sum+=gc;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
	long long S;
	cin >> S;
	
	long long X,Y,x,y;
	
	long long ok=1000000000LL,ng=0;
	while(abs(ok-ng)>1){
		long long mid=(ok+ng)/2;
		if(mid*mid>=S)ok=mid;
		else ng=mid;
	}
	X=Y=ok;
	
	if(X*Y-S>X && (X*Y-S)%2==1){
		X--;
		if(Y%2==0)Y++;
		
		long long s=X*Y-S;
		x=2;
		y=s/2;
		
		cout << "0 0 " << X << " " << y << " " << x << " " << Y << endl;
	}
	else{
		long long s=X*Y-S;
		if(s)x=1;
		else x=0;
		y=s;
		cout << "0 0 " << X << " " << y << " " << x << " " << Y << endl;
	}
	return 0;
}

Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
p = sorted(map(int,input().split()), reverse = True)
q = sorted(map(int,input().split()), reverse = True)
r = sorted(map(int,input().split()), reverse = True)
ans = sorted(p[:x]+q[:y]+r,reverse = True)
print(sum(ans[:x+y]))



Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

  cout << (n >= 1000? "ABD": "ABC") << endl;
  
  return 0;
}

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

// input
// a[0] L

// output
//    j where i is the smallest number that safisfies the condition
//            a[i] = a[j] (i > j)
//    a[i]
//    i - j

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> a;
    int L;
    while(true){
        a.clear();
        a.resize(25);
        cin >> a[0] >> L;
        if(a[0] == "0" && L == 0) break;
        for(int _ = L - a[0].size(); _ > 0; _--){
            a[0].push_back('0');
        }
        int i, j;
        bool found = false;
        i = 1;
        stringstream ss;
        for(; i < 25; i++){
            string t(a[i-1]);
            sort(t.begin(), t.end());
            string min_ai(t), max_ai(t);
            reverse(max_ai.begin(), max_ai.end());
            int min_n, max_n;
            ss.clear();
            ss << min_ai;
            ss >> min_n;
            ss.clear();
            ss << max_ai;
            ss >> max_n;
            ss.clear();
            ss << (max_n - min_n);
            ss >> a[i];
            for(int _ = L - a[i].size(); _ > 0; _--){
                a[i].insert(0, 1, '0');
            }
            for(j = 0; j < i; j++){
                if(a[j] == a[i]){
                    found = true;
                    break;
                }
            }
            if(found) break;
        }
        int ans;
        ss.clear();
        ss << a[i];
        ss >> ans;
        cout << j << ' ' << ans << ' ' << (i - j) << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int X, N;
	cin >> X >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	vector<bool> a(201,true);
	for (int i = 0; i<N; i ++) {
		a[p[i]] = false;
	}
	int min_dif = 300;
	int ans;
	for (int i = 0; i <= 200; i++) {
		if (a[i] && min_dif > abs(X - i)) {
			min_dif = abs(X - i);
			ans = i;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3628
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,a,b=parseMap(split(readline()))
    if (b-a)%2==0
        println((b-a)÷2)
    elseif a-1<n-b
        println((b-(a-1)-1)÷2+a)
    else
        println((n-(a+n-b))÷2+n-b+1)
    end
end
main()

Measured memory_bytes: 113364
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define first F
#define second S
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int t = 5;
	int arr[t];
	for(int i=0; i<t; i++){
		cin>>arr[i];
	}
	for(int i=0; i<t; i++){
		if(arr[i]==0)cout<<i+1<<endl;
	}
}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n,m;
  cin>>n>>m;
  vector<vector<T> >vec(n);
  rep(i,m){
    T t;
    cin>>get<1>(t)>>get<0>(t);
    get<2>(t)=i;
    get<3>(t)=-1;
    vec[get<1>(t)-1].push_back(t);
  }
  rep(i,n) sort(vec[i].begin(),vec[i].end());
  rep(i,n){
    for(int j=0;j<vec[i].size();j++){
      get<3>(vec[i][j])=j+1;
    }
  }
  vector<T>ans;
  rep(i,n){
    for(auto t:vec[i]){
      swap(get<0>(t),get<2>(t));
      ans.push_back(t);
    }
  }
  sort(ans.begin(),ans.end());
  rep(i,m){
    printf("%06lld%06lld\n",get<1>(ans[i]),get<3>(ans[i]));
  }
}

    

Measured memory_bytes: 13164
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    ll v = 1e9;
    ll x = v;
    ll y2 = (s-1)/v + 1;
    ll x2 = 1;
    ll y = x*y2 - s;

    cout << "0 0 " << x << " " << y << " " << x2 << " " << y2 << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    int x = a[0];
    for(int i = 1; i < n; i++){
        if(a[i]>a[i-1]){
            x+=a[i]-a[i-1];
        }
    }
    cout << x << endl;
    
}


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

int main(){

    int n,d,ans = 0;

    cin>>n>>d;
    
    double x[n][d];

    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            
            double rt = 0;
            
            for(int l=0;l<d;l++){           
                rt += (x[i][l]-x[j][l]) * (x[i][l]-x[j][l]);               
            }

            if( sqrt(rt) == (int)(sqrt(rt)) ) ans++;
        }
    }
  
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

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

    int slen = size(s);
    int tlen = size(t);

    if(tlen > slen){
        println("LESS");
        stop;
    }else if(tlen < slen){
        println("GREATER");
        stop;
    }

    int c = s.compare(t);
    if(c >= 1){
        println("GREATER");
    }else if(c <= -1){
        println("LESS");
    }else{
        println("EQUAL");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    int x=0;
    string s;
 
    while(cin>>s)
	{
        int len=s.length();
        bool b=true;
        for(int i=0;i<len/2;i++)
		
             if(s[i]!=s[len-i-1])    
				b=false;
				 if(b)   
				x++;
		
    }
    cout<<x<<endl;
	return 0;
}		
 

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int T[N], sum = 0;
	for(int i = 0; i < N; i++) {
		cin >> T[i];
		sum += T[i];
	}
	int M; cin >> M;
	int P[M], X[M];
	for (int i = 0; i < M; i++)
	{
		cin >> P[i] >> X[i];
		P[i]--;
	}

	for (int i = 0; i < M; i++)
	{
		cout << sum - T[P[i]] + X[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
ans = 0
for i in range(0, 10):
    for j in range(0, 10):
        for k in range(0, 10):
            t = str(i) + str(j) + str(k)
            tmp = []
            for z in s:
                if t[len(tmp)] == z:
                    tmp.append(0)
                if len(tmp) == 3:
                    ans += 1
                    break
print(ans)


Measured memory_bytes: 44124