akhauriyash/Code-Regression huggingface dataset:
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xy.sort()
dict_xy = {}

if n == 1:
    print(1)
    exit()

for i in range(n):
    for j in range(i+1, n):
        if (xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]) not in dict_xy:
            dict_xy[xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]] = 1
        else:
            dict_xy[xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]] += 1

print(n - max(dict_xy.values()))

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll K;
    string S;
    cin >> K >> S;

    ll N = (ll)S.size();

    if (N <= K) {
        cout << S << "\n";
    }
    else {
        S = S.substr(0, K);
        S += "...";
        cout << S << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3652
using System;

class Program
{
    static void Main(string[] args)
    {
        var o = Console.ReadLine();
        var e = Console.ReadLine();

        for (int i = 0; i < o.Length + e.Length; i++)
        {
            if (i % 2 == 1)
            {
                Console.Write(e[i / 2]);
            }
            else
            {
                Console.Write(o[i / 2]);
            }
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 13140
N=int(input())
a=[]
sum=0
for i in range(N):
    temp=int(input())
    sum+=temp
    a.append(temp)
a.sort()
flg=0
if sum%10==0:
    flg=1
i=0
while flg==1 and i<N and a[i]%10==0:
    i+=1
if i==N:
    print("0")
elif flg==1:
    print(str(sum-a[i]))
else:
    print(str(sum))

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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

int n, a[N], ans;
int f[1000005];

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 

    cin >> n;
    FOR(i,1,n){
        cin >> a[i];
        f[a[i]]++;
    }
    FOR(i,1,n){
        int val = a[i];
        f[val]--;
        bool yes = 1;

        for(int d = 1; d * d <= val; d++) if(val % d == 0){
            yes &= f[d] == 0 && f[val/d] == 0;
        }

        ans += yes;
        f[val]++;
    }
    cout << ans;
}

Measured memory_bytes: 13012
package main

import (
	"fmt"
)

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)
	for x := 0; x <= N; x++ {
		for y := 0; y <= (N - x); y++ {
			z := N - (x + y)
			//fmt.Printf("x=%v y=%v z=%v N=%v Y=%v\n", x, y, z, N, Y)
			if Y == (10000*x + 5000*y + 1000*z) {
				fmt.Printf("%v %v %v\n", x, y, z)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int k, n;
    cin >> k >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];

    REP(i,n) a.push_back(a[i]+k);

    ll ans = 1LL << 60;
    REP(i,n) ans = min(ans,a[n-1+i] - a[i]);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    int y,m,d;
    char a,b;
    cin >> y >> a >> m >> b >> d;
    if(m > 4){
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }
}

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

int main()
{
	while (true) {
		int n, r;
		int cards[50];

		cin >> n >> r;

		if (n == 0 && r == 0) {
			break;
		}

		for (int i = 0; i < 50; i++) {
			int temp = max(0, n - i);
			cards[i] = temp;
		}

		for (int i = 0; i < r; i++) {
			int p, c;

			cin >> p >> c;

			vector<int> shuffle;

			for (int j = 0; j < c; j++) {
				shuffle.push_back(cards[p - 1 + j]);
			}

			for (int j = p - 2; j >= 0; j--) {
				cards[c + j] = cards[j];
			}
			
			for (int j = 0; j < c; j++) {
				cards[j] = shuffle[j];
			}
		}

		cout << cards[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <algorithm>


int main(){
	int count_num;
	std::cin >> count_num;
	
	std::vector<int> fig;
	fig.resize(count_num);
	for(int i=0; i<count_num; ++i){
		std::cin >> fig[i];
	}
	
	std::vector<long int> ans_number;
	ans_number.resize(21);
	ans_number[fig[0]] = 1;
	for(int i=1; i<count_num-1; ++i){
		std::vector<long int> number;
		number.resize(21);
		
		for(int j=0; j<21; ++j){
			if(ans_number[j] != 0){
				if(j + fig[i] <= 20)
					number[j+fig[i]] += ans_number[j];
				if(j - fig[i] >= 0)
					number[j-fig[i]] += ans_number[j];
			}
		}
		
		std::copy(number.begin(), number.end(), ans_number.begin());
	}
	
	std::cout << ans_number[fig.back()] << std::endl;
	return 0;
}

Measured memory_bytes: 1212
def main():
    S = raw_input()
    Q = int(raw_input())

    is_reversed = False
    sentou = []
    owari = []

    for _ in range(Q):
        query = raw_input().split()
        if query[0] == "1":
            is_reversed = not is_reversed
        elif query[0] == "2":
            F = query[1]
            C = query[2]
            if F == "1":
                if not is_reversed:
                    sentou.append(C)
                else:
                    owari.append(C)
            elif F == "2":
                if not is_reversed:
                    owari.append(C)
                else:
                    sentou.append(C)

    S = "".join(sentou[::-1]+list(S)+owari)


    if not is_reversed:
        print S
    else:
        print S[::-1]

if __name__ == "__main__":
    main()



Measured memory_bytes: 15748
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
string ans[3]={"Sunny","Cloudy","Rainy"};
int main() {
  string s;
  cin>>s;
  if(s==ans[0]) cout<<ans[1]<<endl;
  else if(s==ans[1]) cout<<ans[2]<<endl;
  else cout<<ans[0]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x, y;
    
    while(1){
    scanf("%d%d", &x, &y);
    
    if(x == 0 && y == 0){
        break;
    }
    else if(x > y)
         printf("%d %d\n", y, x);
    else printf("%d %d\n", x, y);
    }
    return 0;
}


Measured memory_bytes: 1972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	double n, m, d;
	cin >> n >> m >> d;
	if (n - d <= 0) {
		cout << 0 << endl;
		return 0;
	}
	double sum = (m - 2) * 2 + 2;
	if (d == 0)cout << setprecision(16) << (sum*(n - d)) / 2 / n / n << endl;
	else cout <<setprecision(16)<< (sum*(n - d)) / n / n << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	fmt.Scan(&x)
	cur := float64(100)
	var i int

	for {
		i++
		cur = math.Trunc(cur*1.01)
		if x <= cur{
			fmt.Println(i)
			return
		}

	}
}


Measured memory_bytes: 1756
import sys
def input(): return sys.stdin.readline().rstrip()
def run_length(s):
    ans=[]
    if len(s)==1:
        ans.append((s,1))
        return ans
    s_pre=s[0]
    cunt=1
    for i,ss in enumerate(s[1:],1):
        if ss==s_pre:
            cunt+=1
        else:
            ans.append((s_pre,cunt))
            cunt=1
            s_pre=ss
    ans.append((s_pre,cunt))
    return ans

def main():
    s=input()
    k=int(input())
    s_lis=run_length(s)
    ans=0    
    if len(s_lis)==1:
        print(k*s_lis[0][1]//2)
    else:
        for tup in s_lis:
            ans+=tup[1]//2  
        if s_lis[0][0]==s_lis[-1][0]:
            a=s_lis[0][1]
            b=s_lis[-1][1]
            print(ans*k-(a//2+b//2-(a+b)//2)*(k-1))
        else:
            print(ans*k)


if __name__=='__main__':
    main()

Measured memory_bytes: 3064
s=input()
t=input()

n=len(s)
k=len(t)
if k>n:
    print('UNRESTORABLE')
    exit()
mozi=[]
for i in range(n-k+1):
    ok=True
    for j in range(k):
        if s[i+j]==t[j] or s[i+j]=='?':
            pass
        else:
            ok=False
    if ok:
        # print('==s==')
        # print(i)
        # print(s[:i])
        # print(s[i+k:])
        # print('==e==')
        # print(s[:i]+t+s[i+k:])
        mozi.append(s[:i]+t+s[i+k:])

if len(mozi)==0:
    print('UNRESTORABLE')
    exit()

for i in range(len(mozi)):
    mozi[i]=mozi[i].replace('?','a')
mozi.sort()
print(mozi[0])


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

struct Card
{
    char suit;
    int rank;
};

bool comp(Card a, Card b)
{
    return a.rank < b.rank;
}

int partition(Card A[], int p, int r)
{
    int x = A[r].rank;
    int i = p - 1;
    for (int j = p; j < r; j++)
    {
        if (A[j].rank <= x)
            swap(A[++i], A[j]);
    }
    swap(A[r], A[i + 1]);
    return i + 1;
}

void quickSort(Card A[], int p, int r)
{
    if (p < r)
    {
        int q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
}

int main()
{
    int n;
    scanf("%d%*c", &n);
    Card A[n], B[n];

    for (int i = 0; i < n; i++)
    {
        scanf("%c %d%*c", &A[i].suit, &A[i].rank);
        B[i] = A[i];
    }

    quickSort(A, 0, n - 1);
    stable_sort(B, B + n, comp);

    bool flag = true;
    for (int i = 0; i < n; i++)
    {
        if (A[i].suit != B[i].suit)
        {
            flag = false;
            break;
        }
    }

    if (flag)
        printf("Stable\n");
    else
        printf("Not stable\n");

    for (int i = 0; i < n; i++)
        cout << A[i].suit << " " << A[i].rank << "\n";
    return 0;
}


Measured memory_bytes: 4752
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Handstand2 solver = new Handstand2();
        solver.solve(1, in, out);
        out.close();
    }

    static class Handstand2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] pair = new int[10][10];

            for (int i = 1; i <= n; i++) {
                String s = String.valueOf(i);
                int a = Integer.parseInt(s.substring(0, 1));
                int b = Integer.parseInt(s.substring(s.length() - 1));
                pair[a][b]++;

            }
            long result = 0;
            for (int i = 0; i < pair.length; i++) {
                for (int j = 0; j < pair.length; j++) {
                    result += pair[i][j] * pair[j][i];
                }
            }

            out.println(result);
        }

    }
}



Measured memory_bytes: 53988
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    B=[int(_) for _ in input().split()]
    ans=0
    for i in range(N):
        if A[i]<B[i]:
            # 余力が残っている
            ans += (A[i]+min(A[i+1],B[i]-A[i]))
            A[i+1] = max(A[i+1]-(B[i]-A[i]),0)
        else:
            # 倒しきった or 倒しきれなかった時
            ans += min(A[i],B[i])
    print(ans)

main()

Measured memory_bytes: 19648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int gcd(int m, int n)
{
	if (0 == m || 0 == n)
		return 0;
	while(m != n) {
		if (m > n) m = m - n;
    else n = n - m;
	}
	return m;
}

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

  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  int res = a[0];

  for (int i = 1; i < n; ++i) {
    res = __gcd(res, a[i]);
  }

  cout << res << endl;
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int l; cin >> l;
  double v = l*l*l/27.;

  printf("%.12f\n",v);
  
  return 0;  
}


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

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        List<int> a = Console.ReadLine().Split().Select(int.Parse).ToList();
        Console.WriteLine(solve(n, a));
    }
    static int solve(int n, List<int> a) {
        int[] lgcd = new int[n-1];
        lgcd[0] = a[0];
        for(int i = 1; i < n-1; i ++) {
            lgcd[i] = Gcd(a[i],lgcd[i-1]);
        }
        a.Reverse();
        int[] rgcd = new int[n-1];
        rgcd[0] = a[0];
        for(int i = 1; i < n-1; i ++) {
            rgcd[i] = Gcd(a[i],rgcd[i-1]);
        }
        a.Reverse();
        int[] ans = new int[n];
        ans[0] = rgcd[n-2];
        ans[n-1] = lgcd[n-2];
        for(int i = 1; i < n-1; i ++) {
            ans[i] = Gcd(lgcd[i-1], rgcd[n-2-i]);
        }
        return ans.Max();
    }
    static int Gcd(int a, int b) {
        if (a < b) return Gcd(b, a);
        while (b != 0) {
            var tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }
}

Measured memory_bytes: 25052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    char c;
    cin >> c;
    c = 'a' + (c - 'a' + 1);
    OUT(c);
}

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

int main(int argc, char *argv[])
{
    long long n,a,b,c,d,e;
    cin >> n; cin >> a; cin >> b; cin >> c; cin >> d; cin >> e;
    long long mv = min(a, min(b, min(c, min(d, e))));
    printf("%lld", n / mv + (n % mv != 0? 1:0) + 4);
    return 0;
}


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

typedef long long ll;

const int N = 2000006;

ll a[N];
bool b[N];
pair<ll,ll> p[N];
ll v[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	ll ans = 1000;
	vector<ll>v;
	a[0]  = 1000000;
	a[n+1] = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for(int i=1;i<n;i++){
		if(a[i] <= a[i-1] && a[i] <= a[i+1])b[i] = true;
		if(a[i] >= a[i-1] && a[i] >= a[i+1])b[i] = true;
		//cout<<b[i]<<" ";
	}
	//cout<<endl;
	ll mn = 1000,pr = 0;
	for(int i=1;i<=n;i++){
		if(b[i]){
			if(a[i] <= a[i-1] && a[i] <= a[i+1]){
				pr += mn/a[i];
				mn -= (a[i])*(mn/a[i]);
			}else{
				mn += pr*a[i];
				pr = 0;
			}
		}
		ans = max(ans,mn + pr*a[i]);
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3644
use std::io::{self, BufRead, Write, BufWriter};

fn read<R: BufRead, T: std::str::FromStr>(input: &mut R) -> T {
    let mut s = String::new();
    input.read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let mut max1 = 0;
    let mut max2 = 0;
    let mut index = 0;
    let n =
    {
        let input = io::stdin();
        let mut input = input.lock();
        let n = read::<_, usize>(&mut input);
        for i in 0..n {
            let ai = read::<_, usize>(&mut input);
            if max1 <= ai {
                index = i;
                max2 = max1;
                max1 = ai;
            } else if max2 <= ai {
                max2 = ai;
            }
        }
        n
    };

    let stdout = io::stdout();
    let mut buf = BufWriter::new(stdout.lock());

    for i in 0..n {
        let res = if i == index {
            max2
        } else {
            max1
        };
        writeln!(buf, "{}", res).unwrap();
    }
}

Measured memory_bytes: 5628
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
int dp[maxn];
void doit()
{
	memset(dp,inf,sizeof(dp));
	dp[0] = 0;
	for(int i = 0;i < maxn; ++i)
	{
		dp[i] = min(dp[i],dp[i - 1] + 1);
		for(int j = 1;j + i < maxn; j *= 9)
		{
			dp[i + j] = min(dp[i + j],dp[i] + 1);
		}
		for(int j = 1;j + i < maxn; j *= 6)
		{
			dp[i + j] = min(dp[i + j],dp[i] + 1);
		}
	}
}
int main(int argc, char const *argv[])
{
	doit();
	int n;
	cin>>n;
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    const int inf=1000000;
    int N,Ma,Mb,ans=inf;
    cin>>N>>Ma>>Mb;
    vector<int> a(N),b(N),c(N);
    int dp[40+1][400+1][400+1];
    for(int i=0;i<N;i++) cin>>a[i]>>b[i]>>c[i];
    for(int i=0;i<N+1;i++){
        for(int j=0;j<10*N+1;j++){
            for(int k=0;k<10*N+1;k++){
                dp[i][j][k]=inf;
            }
        }
    }
    dp[0][0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<10*N+1;j++){
            for(int k=0;k<10*N+1;k++){
              	if(dp[i][j][k]==inf) continue;	//ないとRE
                dp[i+1][j][k]=min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
            }
        }
    }
    for(int i=1;i<=10*N;i++){
        if(i*Mb/Ma>10*N) break;
      	if(i%Ma!=0) continue;
        ans=min(ans, dp[N][i][i*Mb/Ma]);
    }
    cout<<(ans==inf?-1:ans)<<endl;
}

Measured memory_bytes: 25984
def resolve():
    x, n = [int(i) for i in input().split()]
    if n != 0:
        l = [int(i) for i in input().split()]
    c = 0
    while 1:
        if n == 0:
            print(x)
            break
        if not(x - c in l):
            print(x - c)
            break
        elif not(x + c in l):
            print(x + c)
            break
        c += 1
resolve()

Measured memory_bytes: 9184
import scala.io.StdIn.readLine
object Main {
  def input[A](change: String => A) = readLine.split(" ").map(change(_))
  def main(args: Array[String]): Unit = {
    val N = input((a=>a.toInt))
    val M = N.sortBy(a=>a)
    println(M.tail.foldLeft(M.head, 1)((acc, c) => (acc._1+c*acc._2, acc._2*10))._1)
  }
}


Measured memory_bytes: 25400
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int W, H;
bool S[111][111];
bool visited[111][111];

int dfs(int x, int y) {
  if (x < 0 || x > W+1 || y < 0 || y > H+1) return 0;
  if (visited[y][x]) return 0;
  if (S[y][x] == 1) return 1;

  visited[y][x] = true;
  if (y % 2 == 1) {
    return dfs(x, y-1) + dfs(x+1, y-1) + dfs(x-1, y) + dfs(x+1, y) + dfs(x, y+1) + dfs(x+1, y+1);
  }
  else {
    return dfs(x-1, y-1) + dfs(x, y-1) + dfs(x-1, y) + dfs(x+1, y) + dfs(x-1, y+1) + dfs(x, y+1);
  }
}

int main() {
  cin >> W >> H;
  for (int y=1; y<=H; y++) {
    for (int x=1; x<=W; x++) {
      cin >> S[y][x];
    }
  }
  int ans = 0;
  for (int y=0; y<=H; y++) {
    ans += dfs(0,   y);
    ans += dfs(W+1, y);
  }
  for (int x=0; x<=W; x++) {
    ans += dfs(x, 0);
    ans += dfs(x, H+1);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3480
A,B = gets.chomp.split.map(&:to_i)
a = [*(A*12.5).ceil..((A+1)*12.5).ceil-1]
b = [*(B*10).ceil..((B+1)*10).ceil-1]

if a&b == []
  puts -1
else
  puts (a&b).min
end


Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<string>
#include<iterator>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstdlib>
#include<bits/stdc++.h>
using namespace std;
 
#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)
 
/********* GCD *********/
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}
 
/********* FAST EXPO *******/
ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = (result * x) / MOD;
        n = n / 2;
        x = (x * x) / MOD;
    }
    return result;
}
void solution()
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    ll arr1[n];
    ll mx[n];
    ll max1=-1;
    lp0(i,0,n)
    {
        cin>>arr1[i];
        max1= max(arr1[i],max1);
        mx[i] = max1;
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ans+= (mx[i]-arr1[i]);
    }
    cout<<ans<<"\n";
}
int main()
{
    ll compte = 1;
    //test()
    //{
        solution();
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 6720
A=input()
B=input()
C=input()
D=input()
E=input()
import math
l_total=[A,B,C,D,E]
l=[A[-1],B[-1],C[-1],D[-1],E[-1]]
l=list(map(int,l))
n_l= list(range(1,10))
n_l.append(0)
min_n=0
for i in n_l:
    if i in l:
        min_n=i
        break
min_n=l.index(min_n)
ans=int(l_total[min_n])
l_total.pop(min_n)
for i in range(4):
    ans += math.ceil(int(l_total[i]) / 10) * 10
print(ans)

Measured memory_bytes: 3064
// AtCoder Beginner Contest 143b
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {

        // Input
        Scanner sc = new Scanner(System.in);

        int kosuu = sc.nextInt();
        int[] arrayOishi = new int[kosuu];
        for ( int i = 0; i < arrayOishi.length; i++ ) {
            arrayOishi[i] = sc.nextInt();
        }

        // Calc
        int result = 0;
        for ( int j = 0; j < kosuu; j++ ) {
           for ( int k = j + 1; k < kosuu; k++ ) {
              result += arrayOishi[j] * arrayOishi[k];
           }
        }

        // Output
        System.out.println(result);

        sc.close();
    }
}

Measured memory_bytes: 35508
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll n;
	cin >> n;
	ll k = (n + 1) / 2;
	ld ans = (k*1.) / (n*1.);
	cout << setprecision(6) << fixed << ans;




	








	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
long long ans;
int n;
int main() {
    std::cin >> n;
    for (int i = 1; i <= n; ++i)
    	if (i % 3 != 0 && i % 5 != 0) ans += (long long)i;
    std::cout << ans << '\n';

}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,k;
  cin>>n>>k;
  vector<P> v(n);
  rep(i,n){
    cin>>v[i].F>>v[i].S;
  }

  int ng=0,ok=INF;
  while(ok-ng>1){
    int m=(ok+ng)/2;
    int sum=0;
    rep(i,n){
      if(m<v[i].F) continue;
      sum+=(m-v[i].F+v[i].S)/v[i].S;
      if(sum>k) break;
    }
    //cout<<ok<<' '<<ng<<' '<<sum<<endl;
    if(sum<k) ng=m;
    else ok=m;
  }

  cout<<ok<<endl;


}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define deb(n) cout<<"[ "#n<<" = "<<n<<" ]"<<endl;
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1 << 18;
int case_no = 1;
#define w(x) int x; cin>>x; while(x--)

int main() {
	FIO
	/*
	#ifndef ONLINE_JUDGE 
   	freopen("input.txt", "r", stdin); 
   	freopen("error.txt", "w", stderr); 
   	freopen("answer.txt", "w", stdout); 
   	#endif 
   	*/
	int n, d, cnt = 0;
	cin >> n >> d;
	for(int i = 0; i < n; i++) {
		long long x, y;
		cin >> x >> y;
		if(sqrt(x*x + y*y) <= d) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3708
import sys
#input = sys.stdin.buffer.readline

def main():
    N,K,C = map(int,input().split())
    s = input()
    wf,wb = [],[]
    
    now = -10**10
    for i,st in enumerate(s):
        if st == "o" and i+1 > now+C:
            wf.append(i+1)
            now = i+1
            
    now = 10**10
    s = s[::-1]
    for i,st in enumerate(s):
        if st == "o" and N-i < now-C:
            wb.append(N-i)
            now = N-i
            
    wf = wf[:K]
    wb = wb[:K]
    for f,b in zip(wf,wb[::-1]):
        if f == b:
            print(f)

if __name__ == "__main__":
    main()


Measured memory_bytes: 56960
#include <stdio.h>

#define WIDTH 3001
#define HEIGHT 51

int dp[HEIGHT * WIDTH];

int main(void)
{
	int i, j, k;
	int n, m, s;
	while(scanf("%d%d%d", &n, &m, &s), n){
		n *= n;
		dp[0] = 1;
		for(i=1; i<WIDTH*HEIGHT; ++i)
			dp[i] = 0;

		for(i=1; i<=m; ++i){
			for(j=n; j>=0; --j){
				for(k=s; k>=0; --k){
					if(j && i <= k){
						dp[j*WIDTH + k] = (dp[j*WIDTH + k] + dp[(j-1)*WIDTH + k-i]) % 100000;
					}
				}
			}
		}

		printf("%d\n", dp[n*WIDTH + s]);
	}

	return 0;
}

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

using namespace std;

int main(){
	
	int a, b;
	
	cin >> a >> b;
	
	
	for (int i = 1; i < 1e4; i++){
		
		int a1 = i * 8/100;
		int b1 = i * 10/100;
		
		if (a1==a && b1==b){
			cout << i;
			return 0;
		}
		
	}
	
	cout << "-1";
	
}


Measured memory_bytes: 256
(r1,g1,b1)=input().split()
(r,g,b)=(int(r1),int(g1),int(b1))
k=int(input())
flg=0
for i in range(k):
  if not g > r :
    g *= 2
  elif not b > g:
    b *= 2

if ( b > g > r):
  print ("Yes")
else:
  print ("No")
  
    
  


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

int main(){
	int w,a,b;
  	cin >> w >> a >> b;
  	if (a<=b) {
    	if (a+w<=b) cout << b-a-w << endl;
      	else cout << 0 << endl;
    }
  	else {
    	if (b+w<=a) cout << a-b-w << endl;
      	else cout << 0 << endl;
    }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var ab = IO.RSDouble;
            var a = (long)ab[0];
            var b = (decimal)ab[1];
            var ans = a * b;
            var ans2 = (long)ans;
            WriteLine(ans2);
        }

        public class IO
        {
            #region Input
            public static int RInt => int.Parse(ReadLine());
            public static long RLong => long.Parse(ReadLine());
            public static double RDouble => double.Parse(ReadLine());

            public static string[] RSString => ReadLine().Split();
            public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
            public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }
    }
}

Measured memory_bytes: 28224
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }


const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> p){
	ll c = 0;
	REP(i, N) {
		if (p[i] != i+1) c++;
	}
	if (c<3) cout << YES << "\n";
	else cout << NO << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

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

typedef long long ll;

using namespace std;

int main() {
    
    vector<int> x(3);
    
    cin >> x[0] >> x[1] >> x[2];
    
    sort(x.begin(),x.end());
    
    int cnt=0;
    
    cnt += (x[2]-x[1])/2;
    x[1] += cnt*2;
    if(x[2]-x[1]==1){
            cnt++;
            x[1]++;
            x[0]++;
    }
        
    if((x[2]-x[0])%2==0){
        cnt += (x[2]-x[0])/2;
    }else{
        cnt += (x[2]-x[0])/2;
        cnt += 2;
    }
    
    cout << cnt << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,c,d;
  int temp,check;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a<b)temp=a;
  else temp=b;
  if(c<d)check=c;
  else check=d;

  printf("%d",temp+check);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int a[3005];

bool visited[3005][3005];
long memo[3005][3005];

long solve(int l, int r, bool turn){
  if(l==r) return 0;
  if(visited[l][r]) return memo[l][r];

  long lv = solve(l+1, r, !turn);
  long rv = solve(l, r-1, !turn);

  if(turn){
    memo[l][r] = max(lv + a[l], rv + a[r-1]);
  } else {
    memo[l][r] = min(lv - a[l], rv - a[r-1]);
  }

  visited[l][r] = true;
  return memo[l][r];
}

int main(){
  int n;
  cin>>n;
  rep(i,n) cin>>a[i];

  fill(visited[0], visited[3004], false);

  cout << solve(0,n,true) << endl;

  return 0;
}


Measured memory_bytes: 79744
def judgeAllBulbsOn(switchOn, conds, p):
    m = len(conds)
    bulbOnFlag = True
    for i in range(m):
        k = conds[i][0]
        numOfSwitchOn = 0
        for j in range(1, k + 1):

            # switchOn is 0 - index
            if switchOn[conds[i][j] - 1] is True:
                numOfSwitchOn += 1
        if numOfSwitchOn % 2 != p[i]:
            bulbOnFlag = False
            break
    return bulbOnFlag


# n:switch, m:bulb
n, m = map(int, input().split())

conds = []
for i in range(m):
    connect = list(map(int, input().split()))
    conds.append(connect)

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

switchOn = [False] * n

ans = 0
for bit in range(1 << n):
    for i in range(n):
        if bit & 1 << i:
            switchOn[i] = True
        else:
            switchOn[i] = False
    if judgeAllBulbsOn(switchOn, conds, p):
        ans += 1
print(ans)


Measured memory_bytes: 3064
N, L = map(int, input().split())
tastes = [L + i - 1 for i in range(1, N+1)]
apple_eaten = min([abs(t) for t in tastes])
if apple_eaten in tastes:
    print(sum(tastes) - apple_eaten)
else:
    print(sum(tastes) + apple_eaten)

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

INF = 10 ** 18
lst1 = [[INF] * (N + 1) for _ in range(N+1)] #頂点1に隣接する辺以外の道の管理
# u-->vへコストlで行ける時
for i in range(N+1):
    lst1[i][i] = 0
for _ in range(M):
    a, b, c = map(int, input().split())
    lst1[a][b] = c
    lst1[b][a] = c

# 処理する部分
def WarshallFloyd(lst):
    for k in range(N+1):
        for i in range(N+1):
            for j in range(N+1):
                lst[i][j] = min(lst[i][j], lst[i][k] + lst[k][j])
    return
# i-->jのコストはlst[i][j]

WarshallFloyd(lst1)

lst2 = [[INF] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    lst2[i][i] = 0
    for j in range(i + 1, N + 1):
        if lst1[i][j] <= L:
            lst2[i][j] = 1
            lst2[j][i] = 1

WarshallFloyd(lst2)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    if lst2[s][t] >= INF:
        print (-1)
    else:
        print (max(lst2[s][t] - 1, 0))

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

const int N=1e5+5;
int n,l,a[N],ok;

void init()
{
	int i;
	scanf("%d%d",&n,&l);
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	for(i=1;i<n;++i)
		if(a[i]+a[i+1]>=l)
			ok=1;
	if(!ok) printf("Impossible\n");
	else printf("Possible\n");
}

void work()
{
	int i,j;
	for(i=1;i<n;++i)
		if(a[i]+a[i+1]>=l)
			break;
	for(j=1;j<i;++j) printf("%d\n",j);
	for(j=n-1;j>i;--j) printf("%d\n",j);
	printf("%d\n",i);
}

int main()
{
	init();if(ok) work();
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	string s;
	int ans=700;
	cin>>s;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='o')
		{
			ans+=100;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

//#define int long long
#define oset tree < int , null_type , less<> , rb_tree_tag , tree_order_statistics_node_update >
const int mod = 998244353;
//const int inf = 1e18;
const int MAX = 1e6 + 10;

//    auto random_address = [] {
//        char *p = new char;
//        delete p;
//        return (uint64_t) p;
//    };
//    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1ull));


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i <= 200; ++i) {
        s.insert(i);
    }
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        s.erase(a);
    }

    auto it = s.lower_bound(x);
    if (abs(*it - x) < abs(x - *prev(it)))cout << *it << endl;
    else cout << *prev(it) << endl;
}

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

int main() {
	long long int  k1 = 2, k2 = 1;
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		long long int a = k1;
		k1 = k2;
		k2 = a + k2;
	}
	cout << k2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;

  for(ll i=1;i<n;i++){
    ans+=(n-1)/i;
    //if (i*i<n)ans--;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

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

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		String ans = "";
		if(a == b && b == c ) {
			ans = "No";
		}else if(a != b && a!= c && b != c ) {
			ans = "No";
		}else {
			ans = "Yes";
		}
		
		System.out.println(ans);

	}



}

Measured memory_bytes: 22996
#include <stdio.h>
 
int main(void){
  int r,c,i,j;
  static int s[101][101];
 
  scanf("%d%d",&r,&c);
 
  for(i=0;i<=r;i++){
    for(j=0;j<c;j++){
      scanf("%d", &s[i][j]);
      printf("%d ", s[i][j]);
      s[i][c] += s[i][j];
      s[r][j] += s[i][j];
    }
    printf("%d\n",s[i][c]);
  }
 
  return 0;
}


Measured memory_bytes: 2112
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N];
    int[] Y = new int[N];
    for (int i=0; i<N; i++) {
      X[i] = sc.nextInt();
    }
    Y = X.clone();
    Arrays.sort(X);
    int med1 = X[N/2-1];
    int med2 = X[N/2];

    for (int i=0; i<N; i++) {
      int med;
      if (Y[i] <= med1) {
        med = med2;
      } else {
        med = med1;
      }
      System.out.println(med);
    }
  }
}


Measured memory_bytes: 95440
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;
int GetMaxKouyaku(int, int);

int main()
{
    int N;
    int m;

    cin >> N >> m;

    for(int i = 1; i < N; i++)
    {
        int a;
        cin >> a;
        if(a < m)
        {
            m = GetMaxKouyaku(m, a);
        }
        else
        {
            m = GetMaxKouyaku(a, m);
        }
    }

    cout << m << endl;
    return 0;
}

int GetMaxKouyaku(int Waru, int Amari)
{
    int a = Waru % Amari;
    if(a == 0) return Amari;
    else return GetMaxKouyaku(Amari, a);
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;

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

fn main() {
    let k:u64 = read();
    let mut x = 7%k; //剰余をとらないとk=7のときNG
    let mut s = HashSet::new();
    let mut i = 1;

    while s.contains(&x) == false {
        if x == 0 {
            println!("{}",i);
            return;
        }
        s.insert(x);
        x = (x*10+7)%k;
        i += 1;
    }
    println!("-1");

}


Measured memory_bytes: 29588
import java.util.*;

class Main {
    static int a,b,c,small,middle,large;
  
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      a = sc.nextInt();    
      b = sc.nextInt();    
      c = sc.nextInt();
      if (a>b) {
        if (b>c) {
          small = c;
          middle = b;
          large = a;
        } else {
          small = b;
          if (a>c) {
            large = a;
            middle = c;
          } else { 
            middle = c;
            large = a;
          } 
        }
      } 
      
      if (a<=b) {
        if(b<c) {
          small = a;
          middle = b;
          large = c;
        } else {
          large = b;
          if (a>c) {
            small = c;
            middle = a;
          } else { 
            small = a;
            middle = c;
          } 
        }
      } 
       System.out.println(small + " " + middle + " " + large);
    }
}


Measured memory_bytes: 26304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll H,W;
	ll result=0;
	cin>>H>>W;
	VVC grid(H,VC(W,'#'));
	REP(j,H){
		REP(i,W) {
			cin >> grid[j][i];
		}
	}

	REP(j,H){
		int count=0;
		REP(i,W) {
			if(grid[j][i]=='.') count++;
		}
		if(count==W) {
			REP(i,W) grid[j][i] = 'x';
		}
	}
	REP(i,W){
		int count=0;
		REP(j,H){
			if(grid[j][i]=='.'||grid[j][i]=='x') count++;
		}
		if(count==H) {
			REP(j,H) grid[j][i] = 'x';
		}
	}

	REP(j,H) {
		bool skip=false;
		REP(i, W) {
			if (grid[j][i] != 'x'){
				cout << grid[j][i];
				skip=true;
			}
		}
		if(skip) cout<<endl;
	}
	return;
}

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

Measured memory_bytes: 256