akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace XYZ
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            int[] ans = new int[n];
            for (int i = 1; i <= 100; i++)
            {
                for (int j = 1; j <= 100; j++)
                {
                    for (int k = 1; k <= 100; k++)
                    {
                        int x = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (i * k);
                        if (x <= n)
                            ans[x - 1]++;
                    }
                }
            }
            foreach (var x in ans)
            {
                Console.WriteLine(x);
            }
        }
    }

}


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


int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n+1);
  ll sum=0,b;
  ll tmp;
  rep(i, n+1) cin >> a[i];
  rep(i, n+1) sum+=a[i];
  
  rep(i, n){
    cin >> b;
    if(a[i]>b){
      a[i]-=b;
    }else if(a[i+1]+a[i]<b){
      a[i]=0;
      a[i+1]=0;
    }else{
      a[i+1]-=b-a[i];
      a[i]=0;
    }
   // cout << a[i] << " " << a[i+1]<< " " << b << endl;
  }
  ll res=0;
  rep(i,n+1) res+= a[i];
  cout << sum - res << endl;
}	


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int num,i,min,max=0,n;
    long sum=0;
    scanf("%d",&num);
    scanf("%d",&n);
    min=max=sum=n;
    for(i=0;i<num-1;i++){
        scanf("%d",&n);
        sum+=n;
        if(min > n)
            min=n;
        if(max < n)
            max=n;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 600
// 再提出

#include <stdio.h>
#include <string.h>
 
int main(void) {
	int i;
	int len;
	char str[51];
 
	scanf("%s%n", str, &len);
 
	for (i = 0; i < len - 8; i++)
		putchar(str[i]);
 
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
#define INF (1 << 30)
#define INFL (1ll << 60ll);
#define mod 1000000007

int N, ans, mn = INFL;
bool flag;

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        if(b < a){
            mn = min(mn, b);
            flag = true;
        }
        else if(a < b){
            flag = true;
        }
        ans += b;
    }
    if(flag)cout << ans - mn << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
S = input()

if(N % 2 != 0):
   print("No")
   sys.exit() 

S_len = len(S)
half_len = int(S_len/2)
#print(S[half_len:])
if(S[0:half_len] == S[half_len:]):
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3060
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<Int> Divisor(Int n) {
    vector<Int> ret;
    for(Int i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

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

    vector<Int> div = Divisor(a[0]);
    vector<int> cnt(div.size());
    vector<Int> div2 = Divisor(a[1]);
    vector<int> cnt2(div2.size());
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < div.size(); j++) {
            if (a[i] % div[j] == 0) {
                cnt[j]++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < div2.size(); j++) {
            if (a[i] % div2[j] == 0) {
                cnt2[j]++;
            }
        }
    }
    Int ans = 1;
    for (int i = 0; i < cnt.size(); i++) {
        if (cnt[i] >= N-1) ans = max(ans, div[i]);
    }
    for (int i = 0; i < cnt2.size(); i++) {
        if (cnt2[i] >= N-1) ans = max(ans, div2[i]);
    }    
    cout << ans << endl;

}



Measured memory_bytes: 1024
n, k = gets.split.map(&:to_i)
destinations = gets.split.map(&:to_i)

teleporters = [1]
loop_start = nil
loop_end = nil
arrived = [0]

1.upto(2000000) do |i|
  next_destination = destinations[teleporters.last - 1]
  if arrived[next_destination - 1]
    loop_start = arrived[next_destination - 1]
    loop_end = i - 1
    break
  else
    teleporters << next_destination
    arrived[next_destination - 1] = i
  end
end

answer = nil

if k < loop_start
  answer = teleporters[k]
else
  teleporters.shift(loop_start)
  answer = teleporters[(k - loop_start) % (loop_end - loop_start + 1)]
end

puts answer


Measured memory_bytes: 30628
def prime_factorization(n)
  s = Math.sqrt(n).floor
  primes = Hash.new { |h, k| h[k] = 0 }
  while n % 2 == 0
    primes[2] += 1
    n /= 2
  end

  3.step(s, 2) do |i|

    while n % i == 0
      primes[i] += 1
      n /= i
    end

    break if n == 1
  end

  primes[n] = 1 if s < n
  primes
end

a, b = gets.split.map(&:to_i)
c = a.gcd(b)

primes = prime_factorization(c)
puts 1 + primes.keys.count


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

ans = sum(a)
nums = [0]*(10**5+1)
for i in a: nums[i] += 1

for _ in range(q):
  b,c = map(int, input().split())
  if nums[b] > 0:
    ans -= b*nums[b]
    nums[c] += nums[b]
    ans += c*nums[b]
    print(ans)
    nums[b] = 0
  else:
    print(ans)


Measured memory_bytes: 21068
using System;
class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int a = (int)Math.Floor(Math.Log(n, 2));
        //Console.WriteLine(a);
        if (Math.Pow(2, a + 1) <= n)
            Console.WriteLine(Math.Pow(2, a + 1));
        else
            Console.WriteLine(Math.Pow(2, a));
    }
}

Measured memory_bytes: 13140
<?php
$n = trim(fgets(STDIN));

$sum = 0;
$i = 0;
while($i < $n){
    $m = trim(fgets(STDIN));
    if($m % 10 == 0){
        $sum += $m;
    }else{
        $a[] = $m;
    }
    ++$i;
}
if(isset($a)){
    $n = array_sum($a);

    if($n % 10 != 0){
        echo $sum + $n;
    }else{
        $m = min($a);
        echo $sum + $n - $m;
    }
}else{
    echo 0;
}
?>

Measured memory_bytes: 3828
#include <iostream>
using namespace std ;
int main(){
string a ;cin >> a ;
if(a.size() == 3 && (a[0] == 'S' ||a[0] == 'R' ) && (a[1] == 'S' ||a[1] == 'R') && (a[2] == 'S' ||a[2] == 'R')  ){
if(a[0] == 'R' && a[1] == 'R' && a[2] == 'R')
cout << 3 ;
else if((a[0] == 'R' && a[1] == 'R' ) || ( a[2] == 'R' && a[1] == 'R' ))
cout << 2 ;
else if(a[0] == 'R' || a[1] == 'R' || a[2] == 'R')
cout << 1 ;
else
cout << 0 ;
cout << endl ;
}else
	return 0 ;
}


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

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

int main(){
  int x;
  scanf("%d", &x);
  if(x){
    printf("0\n");
  }else{
    printf("1\n");
  }
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
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;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;

    const auto a = N % 10;
    string ans;
    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) ans = "hon";
    else if (a == 0 || a == 1 || a == 6 || a == 8) ans = "pon";
    else ans = "bon";

    cout << ans << endl;
}


Measured memory_bytes: 3628
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N, M = map(int, input().split())
A = [0]*N
B = [0]*M

for i in range(N):
	A[i] = input()
for i in range(M):
	B[i] = input()

ans = False
for sy in range(N-M+1):
	for sx in range(N-M+1):
		flag = True
		for iy in range(M):
			if B[iy] != A[sy+iy][sx:sx+M]:
				flag = False
				break
		if flag:
			ans = True
			break

if ans:
	print("Yes")
else:
	print("No")

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    set<string> said;
    string prev;
    int N;
    cin >> N;
    cin >> prev;
    said.insert(prev);
    for(int i=1;i<N;i++){
        string W;
        cin >> W;
        if(said.count(W)>0 || prev[prev.size()-1]!=W[0]){
            cout << "No" << endl;
            return 0;
        }
        said.insert(W);
        prev=W;
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main{
    static long MOD = 1000000007;
    static long dp[] = new long[1 << 21];
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        //int t = sc.nextInt();
        int t = 1;
        while(t -- > 0)
        {
            long n = sc.nextLong(), k = sc.nextLong(), min = 0l;
            n %= k;
            min = Math.min(n, k - n);
            out.println(min);
            //for(int ii = 0; ii <= n; ii++) System.out.println(Arrays.toString(dp[ii]));
        }
        out.close();
    }
    public static int solve(int x, int[] a){
        int max = 0, n = a.length - 1;
        for(int i = 1; i <= n; i++)
            if(a[i] > max) max = a[i];
        return 0;
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int L=0;
  for (int i=0; i<N; i++){
    int x;
    cin >> x;
    if (x < K-x){
      L+=x*2;
    }
    else{
      L+=(K-x)*2;
    }
  }
  cout << L << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int M = 2e6 + 10;
const int N = 2e6;
ll fac[M], inv[M], f[M];
ll quick_mod(ll k, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1) ans = ans * k % mod;
        k = k * k % mod;
        b >>= 1;
    }
    return ans;
}
void init() {
	fac[0] = 1;
	for (int i = 1; i <= N; i++) fac[i] = fac[i - 1] * i % mod;
	inv[N] = quick_mod(fac[N], mod - 2);
	for (int i = N - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
ll C(int n, int m)
{
    if(m == 0) return 1;
    return (fac[n] * inv[n - m] % mod) * inv[m] % mod;
}
int main()
{
    int x, y;
    init();
    scanf("%d%d", &x, &y);
    x++, y++;
    if((x + y - 2) % 3 != 0)
    {
        printf("0\n");
        return 0;
    }
    int m = (x + y - 2) / 3;
    int n = m + 1;
    m = y - m;
    //printf("n = %d m = %d\n", n, m);
    if(m < 0 || m > n)
    {
        printf("0\n");
        return 0;
    }
    ll ans = C(n - 1, m - 1);
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
  string s;
  int q;
  cin >>s >>q;
  int F = 0;
  vector<string> a(2, "");
  rep(i,q){
    int t; cin >>t;
    if(t==1) F = 1-F;
    else {
      int f; char c;
      cin >>f >>c;
      a[(F+f-1)%2]+=c;
    }
  }
  reverse(a[F].begin(), a[F].end());
  if(F==1) reverse(s.begin(), s.end());
  cout << a[F] << s << a[1-F] << endl;
  return 0;
}

Measured memory_bytes: 3948
N,A,B = map(int, input().split())


X = [0]*10100
for i in range(len(X)):
  S = str(i)
  a = 0
  for c in S:
    a += int(c)

  X[i] = a

# print( X )

ans = 0
for i,x in enumerate(X[:N+1]):
  if A<=x and x<=B:
    ans += i
    # print(i, ans)

print(ans)


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

using namespace std;

typedef long long lint;
const lint N = 1e5+100;
lint n, h[N], cost[N];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld", &n);

	for (int i = 1; i <= n; i++)
		scanf("%lld", &h[i]);

	h[0] = h[1];
	cost[1] = 0;

	for (int i = 2; i <= n; i++){
		cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));
	}

	printf("%lld\n", cost[n]);

	return 0; 
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; ++i)
    {
        if (!(i % 3 == 0 || i % 5 == 0)) ans += i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

class info{
public:
  int cost, start, freq;
  info(int c, int s, int f) : cost(c), start(s), freq(f){}
};

int main(){
  FAST_IO  
  
  int N; cin >> N;
  vector<info> station;

  for(int rep = 0; rep < N - 1; ++rep){
    int cost, start, freq;
    cin >> cost >> start >> freq;
    station.EB(cost, start, freq);
  }
  
  function<int(int, int)> util;
  util = [&](int idx, int t){
    if(idx == N - 1) return 0;
    int c = station[idx].cost, s = station[idx].start, f = station[idx].freq;
    int cur = c;
    if(s > t){
      cur += s - t;
      t = s;
    }
    if(t % f){
      cur += f - t % f;
      t += f - t % f;
    }

    return cur + util(idx + 1, t + c);
  };

  for(int st = 0; st < N - 1; ++st){
    cout << station[st].start + util(st, station[st].start) << "\n";
  }
  cout << "0\n";


  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int x,y,z,a,b,c;
int main(){
	scanf("%d %d %d",&a,&b,&c);
	printf("%d\n",max(a*10+b+c,max(a+b*10+c,a+b+c*10)));
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main {
static long[][] memo;
static int N,W;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   N=sc.nextInt();
	   W=sc.nextInt();
	   w=new int[N];
	   v=new int[N];
	   for(int i=0;i<N;i++) {
		   w[i]=sc.nextInt();
		   v[i]=sc.nextInt();
	   }
	   memo=new long[N][W+1];
	   for(long[]a:memo)
		   Arrays.fill(a, -1);
	   
	//   for(int[]a:memo)
		//   System.out.println(Arrays.toString(a));
	   System.out.println(dp(0,W));
	}
	static int [] w,v;
	static long dp(int i,int remW) {
		if(remW<0)
			return -inf;
		if(N==i)
			return 0;
		if(memo[i][remW]!=-1)
			return memo[i][remW];
		long leave=dp(i+1,remW);
		long take=0;
	//	if(remW>w[i])
		 take=dp(i+1,remW-w[i])+v[i];
		//System.out.println(take);
		return memo[i][remW]=Math.max(take, leave);
	}
	static final long inf=(long) 1e18;
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 125140
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

int read() {
  int f = 0;
  char ch;
  while (!isdigit(ch = getchar()));
  do f = 10 * f + (ch ^ '0');
  while (isdigit(ch = getchar()));
  return f;
}

const int N_MAX = 100003, mod = 1e9 + 7;
char s[N_MAX];
int dp[N_MAX];
void add(int &x, const int &y) {
  x += y - mod;
  x += x >> 31 & mod;
}

int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1), lst = n + 1, sum = 0;
  dp[n + 1] = 1;
  for (int i = n; i > 0; --i) {
    sum = (sum + s[i] - 'a' + 1) % 3;
    if (s[i] == s[i + 1])
      lst = i + 1;
    dp[i] = (dp[i + 1] + dp[lst + 1] + (sum == 0)) % mod;
  }
  printf("%d\n", lst <= n ? (dp[1] - (sum == 0) + mod) % mod : 1);
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N, i;
  cin >> N >> i;
  cout << N - i + 1 << rt;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int pieceNum = sc.nextInt();
		int goalNum = sc.nextInt();
		int[] nums = new int[goalNum];
        for(int i = 0; i < goalNum; i++)nums[i] = sc.nextInt();
        Arrays.sort(nums);
        int[] diffs = new int[goalNum-1];
        for(int i = 0; i < goalNum-1; i++)diffs[i] = Math.abs(nums[i+1]-nums[i]);

        Arrays.sort(diffs);
        int ans = 0;

        for(int i = 0; i < goalNum - pieceNum; i++)ans += diffs[i];

		System.out.println(ans);
	}
}

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

int main(){
    int n, C;
    int T[31][100010] = {{}};
    int tmax = 0;
    cin >> n >> C;
    for(int i=0;i<n;i++){
        int s, t, c;
        cin >> s >> t >> c;
        //s, t => 1-index 
        T[c][s-1] += 1;
        T[c][t] += -1;
        tmax = max(t, tmax);
    }
    for (int i=1;i<=C;i++){
        for(int j=0;j<=tmax;j++) T[i][j] += T[i][j-1];
    }
    int ans = 0;
    for(int i=0;i<=tmax;i++){
        int now = 0;
        for(int j=1;j<=C;j++){
            if(T[j][i] == 1) now++;
        }
        ans = max(now, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12416
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SENTINEL 1000000000
int main(void){
int n,A[200005];
int count;
int flag=0;
int count2;
int count3;
int i;
scanf("%d",&n);
for(count=0;count<n;count++){
scanf("%d",&A[count]);
}
  mergeSort(A,0,n);
 
for(count=0;count<n;count++){
if(A[count]==A[count+1]){printf("NO"); return 0;}
}
 printf("YES");
  
}
 
 
 
 
 
void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
 
 
 
void merge(int A[],int left,int mid,int right){
    int count;
  int n1,n2,i,j,k;
  int *L,*R;
  n1=mid-left;
  n2=right-mid;
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
   if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}

Measured memory_bytes: 1908
from collections import deque

n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    e[a].append(b)
    e[b].append(a)

l = deque([1])
visit = [0]*(n+1)
visit[1] = 1
while True:
    check = True
    for nex in e[l[-1]]:
        if visit[nex]:
            continue
        l.append(nex)
        visit[nex] = 1
        check = False
        break
    if check:
        break
while True:
    check = True
    for nex in e[l[0]]:
        if visit[nex]:
            continue
        l.appendleft(nex)
        visit[nex] = 1
        check = False
        break
    if check:
        print(len(l))
        print(*l)
        exit()

Measured memory_bytes: 28320
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
int t0[10]={1,4,5,1,1,7,6,5},t1[10]={2,3,6,2,1,2,6,5};
string s;
ll dp[10][2];
int main(){
	cin>>s;dp[0][0]=1;
	for (int i=0,p=0;i<s.length();i++,p^=1){
		if (s[i]!='1')for (int j=0;j<=7;j++)dp[t0[j]][p^1]+=dp[j][p];
		if (s[i]!='0')for (int j=0;j<=7;j++)dp[t1[j]][p^1]+=dp[j][p];
		for (int j=0;j<=7;j++)dp[j][p]=0,dp[j][p^1]%=mo;
	}
	cout<<(dp[2][1]+dp[6][1])%mo<<endl;
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}


int main() {
    double r;
    cin>>r;

    cout<<fixed<<setprecision(20);
    cout<<r*6.28318530717958623200<<endl;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    int ans = LLINF;
    int pat1 = abs(A1 - A2);
    int pat2 = abs(A1 - A3);
    int pat3 = abs(A2 - A3);

    ans = min(ans, pat1 + pat2);
    ans = min(ans, pat1 + pat3);
    ans = min(ans, pat2 + pat3);

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


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

int n,k;

int f(int x,vector<int>v){
  int ans=0;
  for(int i=min(x-1,n-1);i>=0;i--){
    int res=0;
    int p=x-1-i;
    vector<int> t(i+1);
    rep(j,i+1) t[j]=v[j];
    sort(t.begin(),t.end());
    rep(j,i+1){
      if(p>0&&t[j]<0){
        p--;
      }else res+=t[j];
    }
    ans=max(ans,res);
  }
  return ans;
}

int main(){
  cin>>n>>k;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  
  vector<int> u(n);
  rep(i,n) u[i]=v[i];
  reverse(u.begin(),u.end());
  
  int ans=0;
  if(k>=n){
    ans=f(k,u);
  }else{
    rep(i,k){
   	  ans=max(f(i,u)+f(k-i,v),ans);
    }
  }
  cout<<ans<<endl;
}

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

int main(){
    int N, i = 0;
    cin >> N;
    vector<int> L(N);
    for(i; i < N; ++i){
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for(int b = 0; b < N; ++b){
        for(int a = 0; a < b; ++a){
            int ab = L[a]+L[b];
            int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
            int l = b + 1;
            ans += max(0,r-l);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import bisect
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
d = []
cnt = 1
for i in range(n-1):
    if a[i+1] == a[i]:
        cnt += 1
    else:
        d.append([a[i], cnt])
        cnt = 1
d.append([a[n-1], cnt])


for i in range(m):
    b, c = [int(i) for i in input().split()]
    d.append([c, b])
d.sort(reverse=True)
ans = 0
j = 0
for i in range(n):
    if d[j][1] > 0:
        ans += d[j][0]
        d[j][1] -= 1
    if d[j][1] == 0:
        j += 1
print(ans)

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

int main(void){
    ll a, b, count = 0;
    ll c, d;

    cin >> a >> b >> c >> d;
    if(c < d)
        swap(c, d);

//    for(ll i = (a - 1) / c + 1; i * c <= b; i++)
//        count++;
//    for(ll i = (a - 1) / d + 1; i * d <= b; i++)
//        count++;
//
//    int x = c * d;
//    int r = c % d;
//    while(r != 0){
//        c = d;
//        d = r;
//        r = c % d;
//    }
//
//    for(ll i = (a - 1) / (x / d) + 1; i * (x / d) <= b; i++)
//        count--;

//    for(ll i = a; i <= b; i++){
//        if(i % c != 0){
//            if(i % d != 0){
//                count++;
//            }
//        }
//    }

    count += b / c - (a - 1) / c;
    count += b / d - (a - 1) / d;
    ll x = c * d;
    ll r = c % d;
    while(r != 0){
        c = d;
        d = r;
        r = c % d;
    }
    count -= b / (x / d) - (a - 1) / (x / d);
    cout << b - a + 1 - count << endl;
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  int N, K;
  int T = 0;

  scanf("%d%d", &N, &K);
  vector<int> e(K);

  for (int i = 0; i < K; ++i) {
    scanf("%d", &e[i]);
  }

  set<int> U;

  for (int i = 0; i < (1<<K); ++i) {
    int ans = 0;
    for (int j = 0; j < K; ++j) {
      if(i & (1<<j)) ans |= (1 << e[j]);
    }
    U.insert(ans);
  }

  for (int e : U) {
    printf("%d:", e);
    for (int i = 0; i < N; ++i) {
      if (e & (1<<i)) printf(" %d", i);
    }
    puts("");
  }

}




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

#define int long long

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

int dis(int x, int y){ return x * x + y * y; }

signed main()
{
	int n = read(), d = read(), ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		int x = read(), y = read();
		if (dis(x, y) <= d * d) ++ans;
	}
	printf("%d\n", ans);
	
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll a[3], b[3];
    ll mas[3][3];
    rep(i, 3) rep(j, 3) cin >> mas[i][j];
    a[0] = mas[0][0];
    a[1] = mas[1][0];
    a[2] = mas[2][0];
    b[0] = 0;
    b[1] = mas[0][1] - a[0];
    b[2] = mas[0][2] - a[0];
    if(a[1] + b[1] == mas[1][1] && a[2] + b[1] == mas[2][1] && a[1] + b[2] == mas[1][2] && a[2] + b[2] == mas[2][2]) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in).useDelimiter("");
		int s[] = new int[3];
		s[0] = scan.nextInt();
		s[1] = scan.nextInt();
		s[2] = scan.nextInt();
		int ans = 0;
		for (int i = 0 ; i < 3 ; i ++ ){
		if(s[i]==1){ans++;} ;}
		// 出力
		System.out.println(ans);
	}
}

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

max1 = 0
max2 = 0
dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
    
for key, value in dic.items():
    if value >= 4:
        max1 = max(max1, key)
        max2 = max(max2, key)
    elif value >= 2:
        if key > max1:
            max2 = max1
            max1 = key
        elif key > max2:
            max2 = key

print(max1*max2)

Measured memory_bytes: 67736
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [ [] for i in range(N) ], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << N):
    price_combi, exp_combi, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range(N):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ cnt_ls.append(x) for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

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


void exchange( int& x, int& y )
{
    int tmp;

    tmp = x;
    x = y;
    y = tmp;
}

int main()
{
    int w, n;                           //w縦線の数, n横線の数

    cin >> w;
    cin >> n;

    int vline[w];                       //縦線を格納する配列

    for( int i = 0; i < w; i++ )        //引数0から1,2,3という数字が入る
    {
        vline[i] = i + 1;
    }

    for( int i = 0; i < n; i++ )
    {
        int from, to;                   //fromからtoへ。int型のみ受け付けたい。
        char extra;                      //','は余分な入力

        cin >> from >> extra >> to;

        exchange( vline[from-1]  , vline[to-1] );
    }

    for( int i = 0; i < w; i++)
        cout << vline[i] << endl;

    return 0;

}


Measured memory_bytes: 3012
const main = (input) => {
  const n: number = input.split('\n')[0];
  const a: number = input.split('\n')[1].split(' ');
  let flg:boolean = true;
  let cnt:number = 0;

  while (flg) {
    for (let i = 0; i < n; i++) {
      if (a[i] % 2 != 0) {
        flg = false;
      }
      a[i] = a[i]/2;
    }
    cnt++;
  }
  console.log(cnt -1);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define inf 0x3f3f3f3f
typedef long long ll;
int n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	for(int i=1;i<=5;i++){
		char x;
		cin >> x;
		if(x=='0'){
			cout << i << '\n'; return 0;
		}
	}
}


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

char resChar(char c, int i) {
    int j = (c - 'A' + i) % 26;
    char d = 'A' + j;
    return d;
}

int main(void) {
    int n;
    std::string s;

    std::cin >> n;
    std::cin >> s;

    for(char c : s) {
        char d = resChar(c, n);
        std::cout << d;
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll dp[500][500];
ll prefix[500];
int n,a[500];
ll recurs(int start,int end)
{
	if(start==end) return 0;
	if(start>end) return (1e12);
	if(dp[start][end]!=-1) return dp[start][end];
	ll ans=(1e16);
	for (int i = start; i <end; ++i)
	{
		ans=min(ans,recurs(start,i)+recurs(i+1,end)+prefix[i]+prefix[end]-prefix[start-1]-prefix[i]);
	}
	dp[start][end]=ans;
//	cout<<start<<" "<<end<<" "<<dp[start][end]<<"\n";
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    cin>>n;
    memset(dp,-1,sizeof(dp));
    prefix[0]=0;
    for (int i = 1; i <=n; ++i)
    {
    	cin>>a[i];
    	if(i==1) prefix[i]=a[i];
    	else prefix[i]=prefix[i-1]+a[i];
    }
    ll ans=recurs(1,n);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int x,n;
  cin >> x >> n;
  int k[n];
  rep(i,n)cin >> k[i];
  int ans=10000;
  int cnt=0;
  rep(i,102){
    int u=0;
    rep(j,n){
      if(k[j]==i)u++;
    }
    if(u==0){
      if(abs(x-i)<ans){
        ans=abs(x-i);
        cnt=i;
      }
    }
  }
  cout << cnt << endl;
}   


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

#define ll long long
#define endl "\n"

int main ()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
	
	int n;
	cin >> n;
	vector <int> nums(n+1, 0);
	
	for (int i=1; i<=n; i++) cin >> nums[i];

	vector <vector <int> > dp(n+1, vector <int> (n+1, 0));
	
	for (int left = n; left >= 1; left--){
		for (int right = 1; right <= n; right++){
			if (right < left) continue;
			if (left == right){
				dp[left][left] = nums[left];
				continue;
			}

			dp[left][right] = max(-dp[left][right-1] + nums[right], nums[left] - dp[left+1][right]);
		}
	}

	cout << dp[1][n] << endl;

	return 0;
	
}

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

int main()
{
	long long int n, m;
	cin >> n >> m;
	if(n > m) swap(n, m);
	long long int point = 0;
	long long int liner = 0;
	long long int inner = 0;
	if(n == 1 && m == 1){
		point = 1;
	}else if(n == 1){
		liner = m - 2;
	}else{
		inner = (n - 2) * (m - 2);
	}
	cout << point + liner + inner << endl;
	return 0;
}

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

int main(){
    long long int n,r=0,g=0,b=0,ans=0;
    string s;
    cin>>n>>s;
   for(int i=0; i<n; i++){
       if(s[i]=='R')
           r++;
       if(s[i]=='G')
           g++;
       if (s[i]=='B')
           b++;       
   } 
  
   ans=r*g*b;
   for(int i=0;i<n;i++)
       for(int j=1;i+2*j<n;j++)
           if(s[i]!=s[i+j]&&s[i+2*j]!=s[i]&&s[i+2*j]!=s[i+j])
               ans=ans-1;
  
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size() - 2; i++) {
        if (char(s[i]) == char(s[i + 1]) || char(s[i]) == char(s[i + 2]) || char(s[i + 2]) == char(s[i + 1])) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    
    if (s.size() == 2) {
        if (char(s[0]) == char(s[1])) {
            cout << "1 2" << endl;
            return 0;
        }
    }
    
    cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int X, Y;
    cin >> X >> Y;

    for(int i = 0; i <= X; ++i){
        int kame = i;
        int tsuru = X-i;
        if(kame * 4 + tsuru * 2 == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;




    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int n;cin>>n;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			if(i*4+j*7==n){
				puts("Yes");return 0;
			}
		}
	}
	puts("No");
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int H,W;
    int i,j;

    while(1){
        scanf("%d %d",&H,&W);

        if(H == 0 && W == 0){
            break;
        }else{

            for(i = 0; i < H; i++){
                for(j = 0; j < W; j++){
                    if(i % 2 == 0 && j % 2 == 0 ||
                        i % 2 == 1 && j % 2 == 1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }                           //end H
                printf("\n");
            } 
            printf("\n");                   //end W

        }                                   //end if


    }                                       //end while

    return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
   int N;
   cin >> N;
   if(0 < N && 1000 > N) print("ABC");
   if(999 < N && 1999 > N) print("ABD");

 }

Measured memory_bytes: 256
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b,h;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b>>h;
	cout<<((a+b)*h)/2;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
const int N=2000,M=1000000007;
long long n,m,dp[N][N];
bool check[N][N];
char s[N][N];
int pro(int x,int y){
	if(y>=m) return 0; if(x>=n) return 0;
	if(s[x][y]=='#') return 0;
	if(check[x][y]) return dp[x][y];
	if(x==n-1&&y==m-1) return dp[x][y]=1;
	check[x][y]=true;
	return dp[x][y]=(pro(x+1,y)+pro(x,y+1))%M;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;++i) for(int j=0;j<m;++j){
		check[i][j]=false;
		cin>>s[i][j];
	}
	if(s[n-1][m-1]=='#'){
		cout<<0;
		return 0;
	}
	cout<<pro(0,0);
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
void low(char &c){
c=tolower(c);
}
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
        cout << n << " ";
}
#include <iostream>
using namespace std;
void fast();
map<int,int> M;
map<string,ll> M1;
vector<int> pos;
vector<int> nig;

int main() {
fast();
long long int q,l,r;
    ll int mn=999999;
cin >> l >> r;
if(r-l>=2019){
    cout << 0;
    return 0;
}else{
    for(ll i=l;i<=r;i++){
        for(ll j=i+1;j<=r;j++){
            mn =min(mn, (i%2019*j%2019)%2019);
        }
    }
}
cout << mn;
}


void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256