akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;  //このネームスペースを使う

int main(){
  const float BTC_RATE = 380000.0;
  int N ;
  int i ;
  int sum,max;

  cin >> N ;
  
  int L[N] ;

  sum=0;
  max=0;
  for(i=0;i<N;i++){
    cin >> L[i] ;
    sum += L[i] ;
    if(max < L[i]){
      max = L[i];
    }
  }

  if(2*max < sum){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::HashSet;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let hw = read_vec::<usize>();
    let h = hw[0];
    let w = hw[1];

    let mut shogai_tab : Vec<HashSet<usize>> = Vec::with_capacity(h);
    
    for i in 0..h {
        let mut set : HashSet<usize> = HashSet::new();
        let s = read::<String>();
        for (i, c) in s.chars().enumerate() {
            if c == '#' {
                set.insert(i);
            }
        }
        shogai_tab.push(set);
    }


    let answer = solve(h, w, &shogai_tab);
    println!("{}", answer);
}

fn solve(h: usize, w: usize, shogai: &[HashSet<usize>]) -> usize {
    // yoko, tate
    let mut dp : Vec<Vec<(usize, usize)>> = Vec::with_capacity(h);
    for _i in 0..h {
        let v : Vec<(usize, usize)> = vec![(0, 0); w];
        dp.push(v);
    }

    let mut max : usize = 0;
    for i in 0..h {
        for j in 0..w {
            if shogai[i].contains(&j) {
                continue;
            }

            // yoko
            if is_left_shogai_or_kabe(i, j, shogai) {
                // right
                dp[i][j].0 = check_right(w, i, j, shogai);
            } else {
                dp[i][j].0 = dp[i][j-1].0;
            }

            // tate
            if is_up_shogai_or_kabe(i, j, shogai) {
                // down
                dp[i][j].1 = check_down(h, i, j, shogai);
            } else {
                dp[i][j].1 = dp[i-1][j].1;
            }

            //println!("{}, {} -> {}, {}", i, j, dp[i][j].0, dp[i][j].1);
            let val = dp[i][j].0 + dp[i][j].1 + 1;
            if val > max {
                max = val;
            }
        }
    }

    return max;
}


fn check_right(w: usize, i : usize, j: usize, shogai: &[HashSet<usize>]) -> usize {
    let mut p = j + 1;
    while p < w && !shogai[i].contains(&p) {
        p += 1;
    }
    return p - j - 1;
}

fn check_down(h: usize, i : usize, j: usize, shogai: &[HashSet<usize>]) -> usize {
    let mut p = i + 1;
    while p<h && !shogai[p].contains(&j) {
        p += 1;
    }
    return p - i - 1;
}

fn is_left_shogai_or_kabe(i: usize, j: usize, shogai: &[HashSet<usize>]) -> bool {
    if j == 0 {
        return true;
    }
    return shogai[i].contains(&(j-1));
}

fn is_up_shogai_or_kabe(i: usize, j: usize, shogai: &[HashSet<usize>]) -> bool {
    if i == 0 {
        return true;
    }
    return shogai[i-1].contains(&j);
}

Measured memory_bytes: 219388
#include <cstdio>
#include <iostream>
using namespace std;
#define maxn 500005
#define sentinel 2000000000

int L[maxn/2+2],R[maxn/2+2];
long long cnt;

void _merge(int a[],int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;++i)
        L[i]=a[left+i];
    for(int i=0;i<n2;++i)
        R[i]=a[mid+i];
    L[n1]=R[n2]=sentinel;
    int i=0,j=0;
    for(int k=left;k<right;++k)
    {
        cnt++;
        if(L[i]<=R[j])
        {
            a[k]=L[i++];
            //cout<<a[k]<<endl;
        }

        else
        {
            a[k]=R[j++];
            //cout<<a[k]<<endl;
        }

    }
}
void mergesort(int a[],int n,int left,int right)
{
    if(left+1<right)
    {
        int mid=(left+right)>>1;
        mergesort(a,n,left,mid);
        mergesort(a,n,mid,right);
        _merge(a,left,mid,right);
    }
}
int a[maxn],n;
int main()
{
    cin>>n;
    for(int i=0;i<n;++i)
        cin>>a[i];
    mergesort(a,n,0,n);
    for(int i=0;i<n;++i)
    {
        if(i) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
long long int con(int n)
{
	long long int a=0,b=1;
	for(int i=1;i<=n;i++)
	{
		long long int s=a;
		a=a+b;
		b=s;
		a%=1000000007;
	}
	return a;
}
int main()
{
	int n,m;
	cin>>n>>m;
	int a[m+2];
	for(int i=1;i<=m;i++)
		cin>>a[i];
	a[0]=-1; a[m+1]=n+1;
	long long int res=1;
	for(int i=1;i<m+2;i++)
	{
		res*=con(a[i]-a[i-1]-1);
		res%=1000000007;	
	}
	cout<<res;
}

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

int main(int argc, char *argv[])
{
	unsigned long i, j;
	unsigned long a[1000], b[1000];
	unsigned long gcd, lcm;

	for (i = 0; i < 1000; i++)
		if (scanf("%d %d", &a[i], &b[i]) == EOF)
			break;

	for (j = 0; j < i; j++) {
		
		{
			unsigned int ta = a[j];
			unsigned int tb = b[j];
			while (ta != tb) {
				if (ta < tb)
					tb = tb - ta;
				else
					ta = ta - tb;
			}

			gcd = ta;
		}
	
		lcm = (a[j] / gcd) * (b[j] /gcd) * gcd;

		printf("%d %d\n", gcd, lcm);
	}

	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<set>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long h,w;
long long n;
long long b[100006];
long long a[100006];
set<P> st;
long long Count;
set<P> used;
long long da[3]={-1,0,1};
long long db[3]={-1,0,1};
long long ans[11];
int main()
{
	cin>>h>>w;
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		cin>>b[i];
		st.insert(P(a[i],b[i]));
	}
	rep(i,n)
	{
		rep(j,3)rep(k,3)
		{
			long long aa=a[i]+da[j];
			long long bb=b[i]+db[k];
			if(!(2<=aa&&aa<=h-1&&2<=bb&&bb<=w-1))continue;
			if(used.find(P(aa,bb))!=used.end())continue;
			used.insert(P(aa,bb));
			Count=0;
			rep(r,3)rep(l,3)
			{
				if(st.find(P(aa+da[r],bb+db[l]))!=st.end())
				{
					Count++;
				}
			}
			ans[Count]++;
		}
	}
	ans[0]=(h-2)*(w-2);
	rep2(i,1,10)
	{
		ans[0]-=ans[i];
	}
	rep(i,10)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 64256
#include <stdio.h>

int main(void) {
    int n, a, b, c, tmp;

    scanf("%d", &n);
    while (n>0) {
        scanf("%d %d %d", &a, &b, &c);
        if (a>b) tmp=a, a=b, b=tmp;
        if (b>c) tmp=b, b=c, c=tmp;
        if (a>b) tmp=a, a=b, b=tmp;

        if (a*a+b*b==c*c) printf("YES\n");
        else printf("NO\n");
        n--;
    }
    
    return 0;
}



Measured memory_bytes: 2036
import sys
import numpy as np
import networkx as nx

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = 1 << 30

N, K = map(int, readline().split())
A = np.array(read().split(), np.int64).reshape(N, N)

G = nx.DiGraph()
G.add_nodes_from(range(N + N + 2))
source, sink = N + N, N + N + 1
G.nodes[source]['demand'] = -N * K
G.nodes[sink]['demand'] = N * K
for i in range(N):
    G.add_edge(source, i, capacity=K, weight=0)
    G.add_edge(N + i, sink, capacity=K, weight=0)
    G.add_edge(source, sink, capacity=N*K, weight=X)  # K個ずつ使わなくてもよい
for i in range(N):
    for j in range(N):
        G.add_edge(i, N + j, capacity=1, weight=X - A[i, j])

mcf = nx.min_cost_flow(G)
mcf_cost = nx.cost_of_flow(
    G,
    mcf,
)

mat = np.zeros((N, N), np.int8)
for i in range(N):
    for to, f in mcf[i].items():
        mat[i, to - N] = f

print(N * K * X - mcf_cost)
for row in mat:
    print(''.join(map('.X'.__getitem__, row)))

Measured memory_bytes: 54700
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let k: usize = parse!(it);
    let nums = vec![
        vec![0, 1],
        vec![0, 1, 2],
        vec![1, 2, 3],
        vec![2, 3, 4],
        vec![3, 4, 5],
        vec![4, 5, 6],
        vec![5, 6, 7],
        vec![6, 7, 8],
        vec![7, 8, 9],
        vec![8, 9],
    ];
    let decode = |x: &Vec<usize>| {
        let mut ret = vec![x[x.len() - 1]];
        for i in 0..(x.len() - 1) {
            let prev = ret[i];
            ret.push(nums[prev][x[x.len() - i - 2]]);
        }
        ret.reverse();
        ret
    };

    let succ = |x: &mut Vec<usize>| {
        let mut i = 0;
        let dec = decode(x);
        while i < x.len() - 1 {
            let d = &nums[dec[i + 1]];
            if x[i] < d.len() - 1 {
                x[i] += 1;
                return;
            }
            x[i] = 0;
            i += 1;
        }
        if x[i] == 9 {
            x[i] = 0;
            x.push(1);
        } else {
            x[i] += 1;
        }
    };
    let mut x = vec![1];
    let mut k = k - 1;
    while k > 0 {
        succ(&mut x);
        k -= 1;
    }
    let mut ret = 0;
    let dec = decode(&x);
    for i in 0..dec.len() {
        ret += dec[i] * 10usize.pow(i as u32);
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        100000
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
 
int solve(int, int);
 
int n, A[2000];
 
int main(){
   
  int q, M[2000], i;
   
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &A[i]);
   
  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &M[i]);
 
 
  for(i = 0; i < q; i++){
    if(solve(0, M[i]) == 1)   printf("yes\n");
    else                      printf("no\n");
  }
 
  return 0;
}
 
int solve(int i, int m){
  int res;
 
  if(m == 0)    return 1;
  if(i >= n)    return 0;
   
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
 
 
  return res;
}

Measured memory_bytes: 588
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
typedef long double ld;
const ld EPS = 10e-9;

struct point {

	ld x, y;
	ld d;
	int id;

	bool operator<(const point& rhs) const {
		return (d + EPS < rhs.d);
	}


};
struct line {
	point s, t;
	int o, l;
};

int solve();
ld dist(point a, point b) {
	ld x, y;
	x = a.x - b.x;
	y = a.y - b.y;
	return x*x + y*y;
}
point getIntersection( const line l[2] ) {

	point ret;
	ret.d = -1.0f;
	ld a[2], b[2], c[2], det, M[2], m[2];
	
	for (int i = 0; i < 2; i++) {
		a[i] = -(l[i].s.y - l[i].t.y);
		b[i] = l[i].s.x - l[i].t.x;
		c[i] = l[i].s.x*l[i].t.y - l[i].s.y*l[i].t.x;
	}

	det = a[0] * b[1] - a[1] * b[0];

	// two lines are parallel
	if (abs(det) < EPS){ return ret; }

	ret.x = b[1] * c[0] - b[0] * c[1];
	ret.y = -a[1] * c[0] + a[0] * c[1];
	ret.x /= det; ret.y /= det;

	m[0] = max(min(l[0].s.x, l[0].t.x), min(l[1].s.x, l[1].t.x));
	M[0] = min(max(l[0].s.x, l[0].t.x), max(l[1].s.x, l[1].t.x));

	m[1] = max(min(l[0].s.y, l[0].t.y), min(l[1].s.y, l[1].t.y));
	M[1] = min(max(l[0].s.y, l[0].t.y), max(l[1].s.y, l[1].t.y));

	if (m[0] <= ret.x && ret.x <= M[0]
		&& m[1] <= ret.y && ret.y <= M[1]) {
		ret.d = dist(l[0].s, ret);
	}

	return ret;

}
int isUnderground(const int o, const int l) {
	if (o) { return l; }
	else { return 1 - l; }
}


int main(void) {

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
		solve();

	return 0;

}

int solve() {

	int n, flg, ans = 0;
	line l;
	vector<line> v;
	vector<point> ps;

	//input
	cin >> l.s.x >> l.s.y >> l.t.x >> l.t.y;

	cin >> n;
	v.resize(n);
	
	for (int i = 0; i < n; i++) {

		cin >> v[i].s.x >> v[i].s.y >> v[i].t.x >> v[i].t.y >> v[i].o >> v[i].l;
		
	}
	
	//get intersection points
	for (int i = 0; i < n; i++) {
		line m[] = { l, v[i] };
		point p = getIntersection(m);
		if ( p.d > EPS ) {
			p.id = i;
			ps.push_back(p);
		}
	}

	//sort intersection points
	sort(ps.begin(), ps.end());

	if (ps.size() > 0) {

		int index = ps[0].id;
		flg = isUnderground(v[index].o, v[index].l);

		for (int i = 1; i < ps.size(); i++) {
			int nind = ps[i].id;
			int nflg = isUnderground(v[nind].o, v[nind].l);
			if (flg!=nflg){ ans++; }
			flg = nflg;
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main()
{
	ll p[3][3],i,j,a[3][3];
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			cin>>p[i][j];
			a[i][j]=0;
		}
	}
	ll n,f=0;
	cin>>n;
	while(n--)
	{
		ll x;
		cin>>x;
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				if(p[i][j]==x)
					a[i][j]=1;
			}
		}
		if(a[0][1]==1 && a[0][2]==1 && a[0][0])
			f=-1;
		else if(a[1][0] && a[1][1] && a[1][2])
			f=-1;
		else if(a[2][0] && a[2][1] && a[2][2])
			f=-1;
		else if(a[0][0] && a[1][0] && a[2][0])
			f=-1;
		else if(a[0][1] && a[1][1] && a[2][1])
			f=-1;
		else if(a[0][2] && a[1][2] && a[2][2])
			f=-1;
		else if(a[0][0] && a[1][1] && a[2][2])
			f=-1;
		else if(a[0][2] && a[1][1] && a[2][0])
			f=-1;
	}
	if(f==-1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vi a(k);
    forn(i, k) cin >> a[i];
    int m = *max_element(all(a));
    cout << max(0, m - (n - m) - 1) << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	/*
	スケジューリング問題は、右端（終点）の昇順（左から）ソートをするのが肝！！！
	つまり、右端が一番左にあるものから順にソートする。
	（その中で、左端も一番左にあるものから見ていく（同様に昇順ソート））

	cf, Array.SortはStructuralComparisons.StructuralComparerを入れることで、
	（矩形）ジャグ配列を自動的にソートしてくれる
	*/

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		int N = int.Parse(S[0]);
		int M = int.Parse(S[1]);

		//初期化
		int[][] demandArr = new int[M][];
		for(int i=0; i<M; i++){
			string[] line = Console.ReadLine().Split(' ');
			//右端bを優先してソートする為、順番を便宜上入れ替える
			demandArr[i] = new int[2]{int.Parse(line[1])-1,int.Parse(line[0])-1};
		}

		//ソート（右端bを優先してソート）
		Array.Sort(demandArr,StructuralComparisons.StructuralComparer);

		/*debag
		foreach(int[] arr in demandArr){
			Console.WriteLine("{0},{1}", arr[0], arr[1]);
		}
		*/

		//取り壊す橋のうち、現在の右端の橋
		int right = -1;
		int ans = 0;

		//各要望を処理
		foreach(int[] arr in demandArr){
			//入れ替えて配列に格納してあるので注意
			int a = arr[1];
			int b = arr[0];

			//左端aが壊す橋より右でないかチェック
			if(a <= right){
				//範囲内の場合、取り壊す必要なし
				continue;
			}
			else{
				//右端ギリギリの橋を取り壊す
				right = b - 1;
				ans++;
			}
		}

		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 23908
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)
V = []
D = 0
for i in range(N):
  if len(G[i]) % 2:
    print('No')
    break
  D = max(len(G[i]), D)
  if len(G[i]) == 4:
    V.append(i)
else:
  if D >= 6:
    print('Yes')
  elif len(V) != 2:
    print('Yes' if len(V) > 2 else 'No')
  else:
    s = V[0]
    for i in range(3):
      t = G[s].pop()
      G[t].pop(G[t].index(s))
      while t not in V:
        d = G[t].pop()
        G[d].pop(G[d].index(t))
        t = d
      if s == t:
        print('Yes')
        break
      else:
        s = t
    else:
      print('No')

Measured memory_bytes: 21168
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  ll A, B; cin >> A >> B;

  vector<bool> is_prime(10000001, true);
  is_prime[0] = is_prime[1] = false;
  if (A > B) {
    ll tmp = A;
    A = B;
    B = tmp;
  }
  ll ans = 1;
  for (ll i = 2; i * i <= A; ++i) {
    if (!is_prime[i])
      continue;
    for (ll j = i * 2; j * j <= A; j += i)
      is_prime[j] = false;
    if (A % i == 0) {
      if (B % i == 0)
        ++ans;
      while (A % i == 0) A /= i;
      while (B % i == 0) B /= i;
    }
  }
  if (A != 1) {
    if (B % A == 0) ++ans;
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 1536
x,n = map(int,input().split())

if n == 0:
    print(x)
    exit()

P = [*map(int,input().split())]
P.sort()

D = set()
for i in range(n):
    D.add(abs(P[i]-x))

# print(x,n)
# print(P)
# print(D)

ans = 10000000000

if 0 in D:
    # for d in D:
    for d in range(100+10):
        if x-d not in P:
            # print('not x-d', x-d)
            # print('abs(ans-x) < abs((x-d)-x)', abs(ans-x), abs((x-d)-x))
            if abs(ans-x) > abs((x-d)-x):
                ans = x-d
        elif x+d not in P:
            # print('not x+d', x+d)
            # print('abs(ans-x) < abs((x+d)-x)', abs(ans-x), abs((x+d)-x))
            if abs(ans-x) > abs((x+d)-x):
                ans = x+d
else:
    ans = x
print(ans)


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

int main(){
    int K, a, b; cin >> K >> a >> b;
    for (int i = 1; i <= 1000; i++)
    {
        if(i*K>=a && i*K<=b) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    
    return 0;
    
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
struct UnionFind{
public:
    vector<int> par;
    vector<int> rank;
    vector<int> s;
    int cnt;
 
    UnionFind(int n){
        rep(i,n){
            par.push_back(i);
            rank.push_back(0);
            s.push_back(1);
        }
        cnt=n;
    }
 
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
 
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            s[y]+=s[x];
        }else{
            par[y]=x;
            s[x]+=s[y];
            if(rank[x]==rank[y]) rank[x]++;
        }
        cnt--;
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    int size(int x){
        return s[find(x)];
    }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<set<int>> g(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].insert(b);
        g[b].insert(a);
    }
    for(auto v:g[0]){
        if(g[v].count(n-1)){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 28416
#include<bits/stdc++.h>
#define ll unsigned long long
#define f(a,b) for(int i=a;i<b;i++)
#define nitro cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define mod 1000000001
using namespace std;
long long dp[100009][5];
long long solve(int arr[],int brr[],int crr[],int sel,int n,int idx)
{
    if(idx==n)
        return dp[idx][sel]=0;
    if(dp[idx][sel]!=-1)
        return dp[idx][sel];
    if(sel==1)
        return dp[idx][sel]=max(brr[idx]+solve(arr,brr,crr,2,n,idx+1),crr[idx]+solve(arr,brr,crr,3,n,idx+1));
    if(sel==2)
        return dp[idx][sel]=max(arr[idx]+solve(arr,brr,crr,1,n,idx+1),crr[idx]+solve(arr,brr,crr,3,n,idx+1));
    if(sel==3)
        return dp[idx][sel]=max(arr[idx]+solve(arr,brr,crr,1,n,idx+1),brr[idx]+solve(arr,brr,crr,2,n,idx+1));
    else
        return dp[idx][sel]=max(max(arr[idx]+solve(arr,brr,crr,1,n,idx+1),brr[idx]+solve(arr,brr,crr,2,n,idx+1)),crr[idx]+solve(arr,brr,crr,3,n,idx+1));
}
int main()
{
    int n;
    cin>>n;
    int arr[n],brr[n],crr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i]>>brr[i]>>crr[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(arr,brr,crr,0,n,0)<<endl;
}


Measured memory_bytes: 19488
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int a,b,k;
	cin >> a >> b >> k;

	for(int i=0;i<k;i++){
		if(i%2==0){
			if(a%2==1){
				a--;
			}
			b+=a/2;
			a/=2;
		}else{
			if(b%2==1){
				b--;
			}
			a+=b/2;
			b/=2;
		}
	}
	cout << a << " " << b << "\n";
	return 0;
}

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

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    string u;
    cin >> u;

    if (s == u)
    {
        cout << a-1 << endl;
        cout << b << endl;
    }
    else
    {
        cout << a << endl;
        cout << b-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int [] arr =new int[n-1];
	     for(int i=0;i<arr.length;i++){
	    	 arr[i]=scn.nextInt();
	    	 
	     }
	     int [] res= new int[n];
	     for(int i=0;i<arr.length;i++){
	    	 res[arr[i]-1]++;
	     }
	     for(int i=0;i<res.length;i++){
	    	 System.out.println(res[i]);
	     }

	}

}

Measured memory_bytes: 62032
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;
 
int main()
{
	int a,b,c;
	char d;
	int rec=0,rho=0;
	while(cin>>a>>d>>b>>d>>c){
		if(a*a+b*b==c*c) rec++;
		else if(a==b) rho++;
	}

	cout<<rec<<endl<<rho<<endl;


	return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a,b,c;
		cin >> a >> b >> c;
		if(a * a == b * b + c * c || b * b == c * c + a * a || c * c == a * a + b * b)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);
#define debug(x , y) cerr << #x << " = " << x << y ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

ll a , b , c , d ;

int main(){

 cin >> a >> b >> c >> d ;
 ll lc = c * ( d / __gcd( c , d ) ) ;
 ll ans = 0 ;
 ll l_ans = b / lc - a / lc ;
 ans += b / c - a / c ;
 ans += b / d - a / d ;
 if( a % d == 0 ) ans++ ;
 if( a % c == 0 ) ans++ ;
 if( a % lc == 0 ) l_ans++ ;
 ans -= l_ans ;
 cout << ( b - a + 1 ) - ans ;

 return 0 ;
}


/*
A B C D
try to solve A , B in 30 min as possible
If their is subtask try to solve the second one first if the constraints are only differ
Read all Problem so you could find an ex that you can solve fast
A -- don't write big code focus again
B -- greedy , math , bit mask , tricks , DP
C -- solve A , B first then solve C but fast as possible
greedy
DP
binary search
DFS , BFS , DSU
bit mask
number theory , math
meet in the middle
focus on the problem and constraints.
*/



Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>

using namespace std;

struct edge{int to,cost;};
typedef pair<int,int> P; //?????¢?????????

const int MAX_V=100000;
vector<vector<edge> > G;
int d[MAX_V];
const int INF=100000000; // 10^8
void dijkstra(int from){
	priority_queue<P,vector<P>,greater<P> > q;
	fill(d,d+G.size(),INF);
	d[from]=0;
	q.push(P(0,from));

	while(!q.empty()){
		P p=q.top(); q.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
		
	}
}

int main(){
	int n,m;
	cin>>n>>m;
	G.resize(n);
	for(int i=0;i<m;i++){
		int a,b,c,dd;
		scanf("%d,%d,%d,%d",&a,&b,&c,&dd);
		a--; b--;
		G[a].push_back(edge{b,c});
		G[b].push_back(edge{a,dd});
	}
	
	int a,b,c,dd;
	scanf("%d,%d,%d,%d",&a,&b,&c,&dd);	
	a--; b--;
	int res=c-dd;
	dijkstra(a);
	res-=d[b];
	dijkstra(b);
	res-=d[a];
	cout<<res<<endl;
	
	return 0;
}

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

int a, b, c;

int main()
{
    cin >> a >> b >> c;

    int cnt = 0;

    while (1) {
        if (a == b && a == c) break;
        cnt++;

        if (a == b && a > c && b > c) {
            if (a % 2 == c % 2) c += 2;
            else a++, b++;
        }
        else if (a == c && a > b && c > b) {
            if (a % 2 == b % 2) b += 2;
            else a++, c++;
        }
        else if (b == c && b > a && c > a) {
            if (b % 2 == a % 2) a += 2;
            else b++, c++;
        }

        else if (a > b && a > c) b++, c++;
        else if (b > a && b > c) a++, c++;
        else if (c > a && c > b) a++, b++;

    }

    cout << cnt << endl;
}


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

char alp[] = { 'a', 'b', 'c' };
int check[3];

int main(void) {
	char c[4];
	cin >> c;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (c[i] == alp[j]) {
				check[j]++;
			}
		}
	}
	if (check[0] * check[1] * check[2] == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	//system("pause");
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int n, ac=0, wa=0, tle=0, re=0;
    char stat[100];
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++){
        scanf("%s", stat);
        if(stat[1] == 'C'){
            ac++;
        }
        else if(stat[1] == 'A'){
            wa++;
        }
        else if(stat[1] == 'L'){
            tle++;
        }
        else if(stat[1] == 'E'){
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5;
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        c-=b;
        if(c<=0)break;
        a-=d;
    }
    if(a>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int D[101010];
int C[101010];
ll mo=998244353;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>D[i];
		if(i==0 && D[i]!=0) return _P("0\n");
		if(i && D[i]==0) return _P("0\n");
		
		C[D[i]]++;
	}
	
	ll ret=1;
	for(i=1;i<=101000;i++) {
		FOR(j,C[i]) ret=ret*C[i-1]%mo;
		
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<ll, str> pllstr;
typedef pair<str, ll> pstrll;
typedef pair<str, str> pstr;
typedef pair<db, db> pdb;

typedef vector<ll> vll;
typedef vector<db> vdb;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvstr;
typedef vector<vector<db>> vvdb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<pll>> vvpll;
typedef vector<vector<pllstr>> vvpllstr;
typedef vector<vector<pstrll>> vvpstrll;
typedef vector<vector<pstr>> vvpstr;
typedef vector<vector<pdb>> vvpdb;
typedef map<ll, ll> mll;
typedef map<ll, str> mllstr;
typedef map<str, ll> mstrll;
typedef map<str, str> mstr;
typedef map<double, double> md;

#define ff first
#define ss second
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front 
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace back
#define lb lower_bound
#define ub upper_bound

#define FOR(i, a, b) for (int i = a; i <= b; i++) 
#define ROF(i, a, b) for (int i = b; i >= a; i--)
#define trav(a, x) for (auto &a : x)
#define pcount __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
#define gcd __gcd

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

#define ts to_string
str ts(const str &s) { return '"' + s + '"'; }
str ts(const char *s) { return ts((str) s); }
str ts(bool b) { return (b ? "true" : "false"); }
str ts(vb v) {
  bool sep = false;
  str res = "";
  res += '{';
  FOR (i, 0, sz(v) - 1) {
    if (sep) { res += ", "; }
    res += ts(v[i]);
    sep = true;
  }
  res += '}';
  return res;
}
template <size_t N> 
str ts(bitset<N> v) {
  str res = "";
  FOR(i, 0, N - 1) {
    res += (char) ('0' + v[i]);
  }
  return res;
}

template <typename A> 
str ts(A v) {
  bool sep = false;
  str res = "";
  res += '{';
  trav(x, v) {
    if (sep) { res += ", "; }
    res += ts(x);
    sep = true;
  }
  res += '}';
  return res;
}

template <typename A, typename B> 
str ts(pair<A, B> p) { return "(" + ts(p.ff) + ", " + ts(p.ss) + ")"; }
template <typename A, typename B, typename C>
str ts(tuple<A, B, C> p) {
  return "(" + ts(get<0>(p)) + ", " + ts(get<1>(p)) + ", " + ts(get<2>(p)) + ")";
}

void dbg() { cerr << endl; }
template <typename H, typename... T> 
void dbg(H h, T... t) { cerr << " " << ts(h); dbg(t...); }

#ifdef LOCAL
#define DBG(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  mstrll mp;
  FOR(i, 0, n - 1) {
    str s;
    cin >> s;
    mp[s] = 1;
  }
  cout << sz(mp) << '\n';
  return 0;
}

Measured memory_bytes: 19260
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n;

	cin>> n;

	while (n >= 0) {
		if (n % 4 == 0 || n % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
		n -= 7;
	}

	cout<< "No" << endl;


}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
// 約数列挙
template <class T>
vector< T > divisor(T n) {
    vector< T > ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int a,b,k;
double ans;
void input(){
    cin>>a>>b>>k;
}
void src(){
    auto v=divisor(gcd(a,b));
    cout<<v[v.size()-k];
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>


using namespace std;

#define fto(i,a,b) for (int i = (a); i <= b; i++)
#define fdw(i,a,b) for (int i = (a); i >= b; i--)
#define rep(i,a) for(int i = 0; i < a; i++) 
#define read(a) cin >> a
#define read2(a, b) cin >> a >> b
#define read3(a, b, c) cin >> a >> b >> c
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define write(a) cout << a << " "
#define writeln(a) cout << a << "\n"

#define PI 3.14159265
#define oo 1000000000
#define debug(a) cout << #a << " = " << a << endl

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define next thongdeptrai
#define prev thongbachuthegioi
#define y1 thongsieucapvutru
#define y0 thongnotgay

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

#define maxn 100005

using namespace std;

int n, a[maxn];
int res, t;
bool isPos;

int main() {
	//#ifndef ONLINE_JUDGE
  //  	freopen("in.inp", "r", stdin);
  //  #endif

    read(n);

    int t = 1;  res = 1;
    for(int i = 1; i <= n; i++) {
    	read(a[i]);

		//code too ambiguous, not clear on each state
    	if (i == 1) continue;
    	if (t == 1) {
    		if (a[i] - a[i - 1] != 0) {
    			if (a[i] - a[i - 1] < 0) isPos = false;
    			else isPos = true;
    			t++;
    		}
    	}
    	else if (t == 2) {
    		if (isPos && a[i] - a[i - 1] < 0) {
    			t = 1;
    			res++;
    		}
    		if (!isPos && a[i] - a[i - 1] > 0) {
    			t = 1;
    			res++;
    		}
    	}

    }

    write(res);

 //	#ifndef ONLINE_JUDGE
 //   	cout << endl;
 //   	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
//	#endif
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,m,ans = 0,count = 0;
    string s[110],t[110];
    cin >> n;
    for(int i = 0;i < n;i++){cin >> s[i];}
    cin >> m;
    for(int i = 0;i < m;i++){cin >> t[i];}
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < n;j++)
        {
            if(s[i] == s[j]){count++;}
        }
        for(int j = 0;j < m;j++)
        {
            if(s[i] == t[j]){count--;}
        }
        ans = max(ans,count);
        count = 0;
    }
    cout << ans << endl;
    return 0;
}

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;

int main() {
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') cout << "A\n";
    else cout << "a\n";
}

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


int cal(int r,int d,int x){
	return r*x - d;
}


int main(){
	int r,d,x;
	cin >> r >> d >> x;
	int t = r*x - d;
	cout << t << endl;
	for(int i = 0;i < 9;i++){
		t = cal(r,d,t);
		cout << t << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
*a, = map(int, input().split())
MOD = 10**9+7

dp = [0]*(K+1)
sums = [0]*(K+2)

dp[0] = 1

for i in range(1, N+1):
    sums[0] = 0
    for j in range(1, K+2):
        sums[j] = (dp[j-1]+sums[j-1]) % MOD

    for j in range(1, K+1):
        sj = max([0, j-a[i-1]])
        dp[j] = (sums[j+1]-sums[sj]+MOD) % MOD
print(dp[K])


Measured memory_bytes: 43612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using ll = unsigned long long;
using namespace std;

int main(void) {
    int a,b;
    cin >> a >> b;

    // if (b < a) {
    //     int tmp = 0;
    //     tmp = b;
    //     b = a;
    //     a = tmp;
    // }

    // for ( int k = a; k <= b; ++k) {
    //     cout << a << ":"<< b <<":" << k << endl;
    //     if (abs(a-k)==abs(b-k)) {
    //         cout << k << endl;
    //         return 0;
    //     }
    // }

    if ((a+b)%2 != 0) {
    cout << "IMPOSSIBLE" << endl;
    }
    else {
        cout << (a+b)/2 << endl;
    }
    
    return 0;
}

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

void solve(long long N, long long M, std::vector<long long> A) {
    long long sum = 0;
    for (long long i = 0; i < M; i++) {
        sum += A[i];
    }
    if (N - sum < 0) {
        cout << -1 << endl;
    } else {
        cout << N - sum << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

int main() {
  string s,t; cin>>s>>t;
  bool flag=true;
  if(s.size()+1!=t.size()){
    flag=false;
  }else{
    for(int i=0;i<s.size();i++){
      if(s[i]!=t[i]){
        flag=false;
        break;
      }
    }
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  int d[n];
  int i;
  i = 0;
  while (i < n)
  {
    scanf("%d",&d[i]);
    i++;
  }
  i = 0;
  int j;
  int sum;
  sum = 0;
  while (i < n)
  {
    j = i + 1;
    while (j < n)
    {
      sum += d[i] * d[j];
      j++;
    }
    i++;
  }
  printf("%d",sum);
}

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

int main() {
	int h, w;
	
	while (cin >> h >> w) {
		if (h == 0 and w == 0) break;
		for (int i = 0; i < h; i++) {
			cout << string(w, '#') << '\n';
		}
		cout << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3088
N = int(input())
x = [''] * N
u = [''] * N
for i in range(N):
	x[i], u[i] = [i for i in input().split()]

ans = sum([int(x[i]) for i in range(N) if u[i] == 'JPY'])
ans += sum([float(x[i])*380000.0 for i in range(N) if u[i] == 'BTC'])
print(ans)

Measured memory_bytes: 3064
//--------------------------------------------------
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//--------------------------------------------------
#include <bits/stdc++.h>
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <stack>
#include <cstring>
//--------------------------------------------------
#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, n) for(int i = n-1; i >= 0; --i)
#define forns(i, n, s) for(int i = s; i < n; i++)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//----------------------------------------------------
using namespace std;
//----------------------------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<ll> lnum;
typedef complex<ld> comp;
//----------------------------------------------------
const ll mod = 1e9 + 7, mod2 = 998244353;
const ld eps = 1e-6;
const ll inf = 1e18;
const int base = 1e9;
const ld PI = 3.1415926;
//----------------------------------------------------
//#define endl '\n';
#ifdef MY_DEBUG
void deb(ld x) { cerr << x << endl; };
#else
void deb(ld x){};
#endif
//----------------------------------------------------
//----------------------------------------------------
int n;
vector<int> v;
map<int, int> m;
ll ans = 0;
//----------------------------------------------------
unsigned int bitcount(ull val) { return __builtin_popcount(val) + __builtin_popcount(val >> 32); }

void local() {
    freopen("test.in", "r", stdin);
}

void remote() {
}

void read() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    v.resize(n);
    forn(i, n) cin >> v[i], m[v[i]]++;
}


int main() {
#ifdef MY_DEBUG
    local();
#else
    remote();
#endif
    read();

    auto it = m.begin();
    while(it != m.end()){
        if(it->y > 1) ans += 1ll * it->y * (it->y-1)/2;
        it++;
    }

    forn(i, n){
        int val = v[i];
        ll tmp = ans;
        if(m[val] > 1){
            tmp -= 1ll * m[val] * (m[val]-1)/2;
            if(m[val] > 2) tmp += 1ll * (m[val]-1)*(m[val]-2)/2;
        }
        cout << tmp << endl;
    }

}

Measured memory_bytes: 9728