akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[,] conf = new int[n, n];
        for (int i = 0; i < n; i++)
        {
            int a = int.Parse(Console.ReadLine());
            for (int j = 0; j < a; j++)
            {
                var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
                conf[i, xy[0] - 1] = xy[1] == 1 ? 1 : -1;
            }
        }
        int max = 0;
        for (int state = 0; state < (1 << n); state++)
        {
            bool[] isGood = Enumerable.Range(0, n).Select(x => (state & (1 << x)) != 0).ToArray();
            for (int i = 0; i < n; i++)
            {
                if (!isGood[i]) continue;
                for (int j = 0; j < n; j++)
                {
                    if (conf[i, j] == 0) continue;
                    if ((conf[i, j] == 1) == isGood[j]) continue;
                    goto end;
                }
            }
            max = Max(max, isGood.Count(x => x));
        end:;
        }
        Console.WriteLine(max);
    }
}

Measured memory_bytes: 17480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = ReadInts();
            if (ab[0] + ab[1] >= 10) WriteLine("error");
            else WriteLine(ab[0] + ab[1]);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int main()
{
	ll n,m,q,k=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		ll x;
		cin>>x;
		k+=x;
	}
	n-=k;
	if(n>=0) cout<<n;
	else cout<<-1;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << P + Q + R - max({P, Q, R}) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		String[] inputS = new String[2];
		Integer n, k = 0;
		String ans = "NO";
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
			inputS = br.readLine().split(" ");
			n = Integer.valueOf(inputS[0]);
			k = Integer.valueOf(inputS[1]);
		}
		if (n % 2 != 0) {
			n += 1;
		}
		if((n / 2) >= k) {
			ans = "YES";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<string>

using namespace std;

int main() {
	int n, k;
	string s;
	char c;

	cin >> n;
	cin >> s;
	cin >> k;

	c = s[k - 1];
	for (int i = 0; i < n; i++) {
		if (s[i] != c) {
			s[i] = '*';
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "432" ].parse.expand.solve == "400" );
	assert( [ "1079" ].parse.expand.solve == ":(" );
	assert( [ "1001" ].parse.expand.solve == "927" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	for( auto i = 0L; i <= n; i++ )
	{
		if( cast( long )( i * 1.08 ) == n ) return i.to!( string );
	}
	return ":(";
}


Measured memory_bytes: 256
package main

import(
	"fmt"
)

func main() {
	var day string
	fmt.Scan(&day)
	
	s := map[string]int {
		"SUN":7,
		"MON":6,
		"TUE":5,
		"WED":4,
		"THU":3,
		"FRI":2,
		"SAT":1,
	}
	
	fmt.Println(s[day])
}


Measured memory_bytes: 512
/*
[abc132] D - Blue and Red Balls
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2000;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int extgcd(int a, int b, int& x, int& y) {
        int d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    static int mod_inv(int a, int m) {
        int x, y;
        extgcd(a, m, x, y);
        return (m + x) % m;
    }
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator-(const gf x) const { return gf((n - x.n + MOD) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf operator/(const gf x) const { return *this * x.inv(); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
    gf& operator-=(const gf x) { return *this = (*this - x); }
    gf& operator*=(const gf x) { return *this = (*this * x); }
    gf& operator/=(const gf x) { return *this = (*this / x); }
    gf inv() const { return gf(mod_inv(n, MOD)); }
    gf pow(ll e) const {
        gf a = *this;
        gf x = 1;
        for (; e > 0; e >>= 1) {
            if (e & 1) {
                x = x * a;
            }
            a = a * a;
        }
        return x;
    }
};

int N, K;
gf fact[MAX_N + 1];

gf c(int n, int k) {
    return (n < 0 || k < 0 || n - k < 0) ? 0
                                         : fact[n] / (fact[k] * fact[n - k]);
}

void solve() {
    if (N == K) {
        cout << 1 << endl;
        for (int i = 2; i <= K; i++) {
            cout << 0 << endl;
        }
        return;
    }

    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
        fact[i] = fact[i - 1] * i;
    }

    for (int i = 1; i <= K; i++) {
        gf b = c(K - 1, i - 1);
        gf r = c(N - K - 1, i - 2) + c(N - K - 1, i - 1) * 2 + c(N - K - 1, i);
        cout << (b * r).n << endl;
    }
}

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

    solve();

    return 0;
}


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

#define NMAX 100001
#define MAX(a, b) (a > b ? a : b)

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int age, cost;

int main()
{
    cin >> age >> cost;
    if(age >= 13) cout << cost << '\n';
    else if(age >= 6 && age <= 12) cout << cost / 2 << '\n';
    else if(age <= 5) cout << 0 << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if(op.equals("?")){
                break;
            }else{
                    if(op.equals("+")){
                        System.out.println(a + b);
                    }else if(op.equals("-")){
                        System.out.println(a - b);
                    }else if(op.equals("*")){
                        System.out.println(a * b);
                    }else if(op.equals("/")){
                        if(b != 0){
                        System.out.println(a / b);
                        }
                    }   
            }   
        }
        sc.close();
    }
}


Measured memory_bytes: 26144
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n,a,b,c,d[1001]={};
   cin>>a>>b;
   int ans=0;
   if(a>b){
     ans+=a;
     a--;
   }else{
     ans+=b;
     b--;
   }
   cout<<ans+max(a,b)<<endl;
   return 0;
}



Measured memory_bytes: 256
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])

fast, cnt, ans = 0, 0, 0
for i in t:
    if fast + k < i or cnt == c:
        cnt = 0
    if cnt == 0:
        ans += 1
        fast = i
    cnt += 1
print(ans)


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

string s;
int n,k;
vector<pair<int,bool>> v;
vector<int> sv;

int main(){
    cin >> n >> k >> s;
    int cnt=0,ans=0;
    for(int i = 0;i < n;i ++){
        bool b = s[i]-'0';
        int j = 1;
        while(i<n-1&&s[i]==s[i+1]){
            i ++;
            j ++;
        }
        v.push_back(make_pair(j,b));
    }
    if(v[0].second==0)v.insert(v.begin(),make_pair(0,1));
    if(v.back().second==0)v.push_back(make_pair(0,1));
    for(int i = 0;i < v.size();i ++){
        if(i)sv.push_back(sv[i-1]+v[i].first);
        else sv.push_back(v[0].first);
    }
    if(sv.size()<=2*k+1) ans = n;
    else{
        for(int i = 0;2*k+i < sv.size();i += 2){
            ans = max(sv[2*k+i]-(i?sv[i-1]:0),ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,K; cin >> N >> K;
  ll cnt = 0;
  if( K==0){ cout << N*N << endl; return 0;}
  for(ll b = 1; b <= N; b++){
    if( K >= b){ continue;} 
    ll m = (N+1)/b; cnt += (b-K)*m;
    ll r = N-m*b; if(K<=r && r <= b-1){ cnt += r-K+1;}

  }
  
  cout << cnt << endl; return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <map>
#include <bitset>
#include <string.h>
#include <cmath>
#include <queue>
#include <algorithm>
#define N 100005
#define P pair<int,int>
#define ll long long
#define mk(a, b) make_pair(a, b)
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
int inf = 0x3f3f3f3f;
int n, m, pre[N];
struct ac{
	int v;
	double c;
};
void init() {
	for (int i = 1; i <N; ++i) {
		pre[i] = i;
	}
}
int find(int x) {
	if (x == pre[x])	return x;
	else 	return pre[x] = find(pre[x]);
}
void join(int x, int y) {
	int fx = find(x);
	int fy = find(y);
	if (fx == fy)	return;
	else if (fx < fy)	pre[fy] = fx;
	else 	pre[fx] = fy;
}
double sum;
bool vis[N];
double dis[N];
vector<P> a(N);
vector<ac> g[N];
void prime(int x) {
	mem(dis, 0);
	mem(vis, false);
	dis[x] = 1;
	for (int i = 1; i <= n; ++i) {
		double MAX = 0;
		int u = -1;
		for (int j = 1; j <= n; ++j) {
			if (vis[j])	continue;
			if (dis[j] > MAX) {
				MAX = dis[j];
				u = j;
			}
		}
		if (u == -1)	return;
		vis[u] = true;
		if (u == x)	MAX = 0;
		sum += MAX;
		// cout << "u = " << u << " " << MAX << endl;
		for (int j = 0; j < g[u].size(); ++j) {
			ac t = g[u][j];
			if (vis[t.v])	continue;
			if (dis[t.v] < t.c ) {
				dis[t.v] = t.c;
			}
		}
	}



}

int main(){
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
// #endif
	ios::sync_with_stdio(false);
	while (cin >> n >> m) {
		init();
		for (int i = 1; i <= n; ++i) {
			cin >> a[i].first >> a[i].second;
		}
		double ans = 0;
		for (int i = 0; i < m; ++i) {
			int u, v;
			cin >> u >> v;
			int dx = a[u].first - a[v].first;
			int dy = a[u].second - a[v].second;
			double temp = sqrt(dx * dx + dy * dy);
			// cout << "temp = " << temp << endl;
			ans += temp;
			g[u].push_back((ac){v, temp});
			g[v].push_back((ac){u, temp});
			join(u, v);
		}
		// cout << ans << endl;
		for (int i = 1; i <= n; ++i) {
			if (pre[i] == i) {
				sum = 0;
				prime(i);
				ans -= sum;
				// cout << i << "::" << sum << endl;
			}
		}
		// ans += 1;
		// cout << ans << endl;
		printf("%.3lf\n",ans);
		for (int i = 1; i <= n; ++i) {
			g[i].clear();
		}
	}



	return 0;
}



Measured memory_bytes: 9020
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
#define INF ( 1 << 30 )
#define fr first
#define sc second
typedef pair < int , int > Pi;
typedef pair < Pi , Pi > Pii;
const int dy[] = { 0, 1, -1, 0}, dx[] = { 1, 0, 0, -1};
int h, w, Sx, Sy, Gx, Gy;
vector< Pi > hoge[5];
int dp[5][1000], num;
char c;
int dis(Pi x1,Pi x2){
  return abs(x1.fr - x2.fr) + abs(x1.sc - x2.sc);
}
int rec(int now,int java){
  if(dp[now][java]) return dp[now][java];
  int ret = INF, next = ( now + 1 ) % 5;
  if(now == num) ret = dis(hoge[now][java],Pi(Gy,Gx));
  else for(int i = 0 ; i < hoge[next].size() ; i++ ){
    ret = min( ret, rec( next, i) + dis(hoge[now][java],hoge[next][i]));
  }
  return dp[now][java] = ret;
}
int main(){
  while(cin >> w >> h , w){
    for(int i = 0 ; i < 5 ; i++ ) hoge[i].clear();
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> c;
        if(c == 'S') Sy = i, Sx = j;
        else if(c == 'G') Gy = i, Gx = j;
        else if(c != '.') hoge[c-'1'].push_back(Pi(i,j));
      }
    }
    Pi ret = Pi(INF,INF);
    for(int i = 0 ; i < 5 ; i++ ){
        for(int j = 0 ; j < 5 ; j++ )
          for(int k = 0 ; k < 1000 ; k++ ) dp[j][k] = 0;
      num = ( i + 4 ) % 5;
      int next = ( i + 1 ) % 5, tmp = INF;
      for(int j = 0 ; j < hoge[next].size() ; j++ ){
        ret = min( ret, Pi(rec( next, j) + dis(Pi(Sy,Sx),hoge[next][j]), i+1));
      }
    }
    if( ret.fr == INF ) cout << "NA" << endl;
    else cout << ret.sc << " " << ret.fr << endl;
  }
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

ll n,x,t;
cin>>n>>x>>t;
int ans=t;
n-=x;
while(n>0)
{
    n-=x;
    ans+=t;
}
cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <iostream>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

const int M = 13;

string s;
ll t = 1, ans;
ll dp[2][13];
int ho = 0, ge = 1;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    dp[ho][0] = 1;
    for (int i = (int)s.size()-1; i >= 0; i--) {
        rep(j,M) dp[ge][j] = 0;
        if (s[i] != '?') {
            int x = t*(s[i]-'0')%M;
            rep(j,M) {
                if (x == M) x -= M;
                dp[ge][x++] = dp[ho][j];
            }
        } else {
            rep(j,10) {
                int x = t*j%M;
                rep(k,M) {
                    if (x == M) x -= M;
                    dp[ge][x++] += dp[ho][k];
                }
            }
            rep(j,M) dp[ge][j] %= MOD;
        }
        t = t * 10 % M;
        swap(ho,ge);
    }
    cout << dp[ho][5] << endl;
}


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

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

  int c;
  if (a >= 13) {
    c = b;
  } else if (a >= 6) {
    c = b / 2;
  } else {
    c = 0;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int A[N];
  int num, i, j, minj, temp;
  int count = 0;

  scanf("%d", &num);
  
  for(i = 0; i < num; i++){
    scanf("%d", &A[i]);
  }
  
  for(i = 0; i < num; i++){
    minj = i;
    for(j = i; j < num; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    
    if(i != minj){
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      
      count++;
    }
  }
  for(i = 0; i < num-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[num-1]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string a,b,c;
    cin>>a>>b>>c;

    cout << a[0] << b[0] << c[0] << endl ;
    
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=[]

if A[0]>0:
    num=A[0]
    for i in range(1,N-1):
        ans.append([num,A[i]])
        num-=A[i]
    ans.append([A[-1],num])
    print(A[-1]-num)
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])
elif A[-1]<0:
    A.sort(reverse=True)
    num=A[0]
    for i in range(1,N):
        ans.append([num,A[i]])
        num-=A[i]
    print(num)
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])
else:
    M=A[-1]
    m=A[0]
    for i in range(1,N-1):
        if A[i]<0:
            ans.append([M,A[i]])
            M-=A[i]
        else:
            ans.append([m,A[i]])
            m-=A[i]
    ans.append([M,m])
    print(M-m)
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])

Measured memory_bytes: 68180
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,M;
int main(){
    cin >> N >> M;
    vector<int> k(N),p(M);
    int s[N+1][M+1];
    rep(i,N){
        cin >> k[i];
        rep(j,k[i]) cin >> s[i][j];
    }
    rep(i,M) cin >> p[i];
    
    int ans = 0;
    for (int bit = 0; bit < (1<<N); ++bit){
        string str(bitset<10>(bit).to_string<char, std::char_traits<char>, std::allocator<char> >());
        reverse(ALL(str));
        bool flag = true;
        rep(i,M){
            int ct = 0;
            rep(j,k[i]){
                ct += str[s[i][j]-1];
            }
            if(ct%2 != p[i]) flag = false;
        }
        if(flag) ans++;
    }
    print(ans);
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i, t;	

	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)break;
		for (i = 0; i < W; i++){
			printf("#");
		}
		printf("\n");
		for ( i = 0; i < H - 2; i++){
			for (t = 0; t < W; t++){
				if ((t == 0) || (t + 1 == W)){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		for (i = 0; i < W; i++)
		{
			printf("#");
		}
		printf("\n\n");
	}
	return 0;
}


Measured memory_bytes: 2044
index = 1

while True:
    n = int(input())
    if n == 0:
        break
    else:
        area = 0
        X = []
        Y = []
        for i in range(n):
            x, y = map(int, input().split())
            X.append(x)
            Y.append(y)
        for i in range(1, n-1):
            area += ((X[i] - X[0]) * (Y[i+1] - Y[0]) - (X[i+1] - X[0]) * (Y[i] - Y[0])) / 2
    if area < 0:
        print("{0} {1}".format(index, -area))
    else:
        print("{0} {1}".format(index, area))
    blank = input()
    index += 1


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<ll> A(N + 1);
    vector<ll> sum(N + 2, 0);
    rep(i, N + 1){
        cin >> A[i];
        sum[i + 1] += sum[i] + A[i];
    }
    ll ans = 1;
    ll f_node = 1;
    if(N == 0 && A[0] == 1){
        cout << 1 << endl;
        return 0;
    }else if(A[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    for(int i = 1; i < N + 1; i++){
        // cout << f_node << " " << sum[N + 1] - sum[i] << endl;
        ll node = min(f_node*2, sum[N + 1] - sum[i]);
        if(node - A[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        f_node = node - A[i];
        ans += node;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;

int solve(int K) {
	deque<ii> dq;
	vector<int> vis(K, 0);

	dq.push_front(ii(1, 1)); // num(%K), cost
	while (!dq.empty()) {
		ii p = dq.front(); dq.pop_front();
		int curr = p.first, cnt = p.second;
		if (curr == 0) return cnt;

		vis[curr] = 1;
		int next = (curr + 1) % K;
		if (vis[next] == 0)
			dq.push_back(ii(next, cnt + 1));

		next = (curr * 10) % K;
		if (vis[next] == 0)
			dq.push_front(ii(next, cnt));
	}
}

int main() {
	int K; cin >> K;
	cout << solve(K) << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
char n[200001];
int main()
{
    long long sumb=0,ans=0;
    scanf("%s",n);
    for(int i=0;i<strlen(n);i++)
    {
        if(n[i]=='B')
            sumb++;
        else if(n[i]=='W')
            ans+=sumb;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

template<class T> 
ostream& operator<<(ostream &os, vector<T> input) {
    os << "[ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "]";
}

template<class T> 
ostream& operator<<(ostream &os, set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, unordered_map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

#define ll long long
const int MAXN = 100005;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

class TaskB {
private:

public:
	void solveOne(int it){
		int n;
		cin >> n;
		vector<bool> equal(n, false);
		for(int i = 0; i < n; i++) {
			int x1, x2;
			cin >> x1 >> x2;
			if(x1 == x2) {
				equal[i] = true;
			}
		}
		for(int i = 0; i+ 3 <= n; i++) {
			if(equal[i] && equal[i+1] && equal[i+2]) {
				cout << "Yes\n";
				return;
			}
		}
		cout << "No\n";
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin.ignore();
    getline(cin,s);
    stack<char> st;
    int cnt;
    for(int i=0;i<n;i++)
    {
        st.push(s[i]);
    }
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
            st.pop();
    }
    cnt=st.size();
    cout<<cnt;

}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        if (N == 1) {
            System.out.println("Hello World");
        } else {
            int A = scan.nextInt();
            int B = scan.nextInt();
            System.out.println(A+B);
        }
    }
}


Measured memory_bytes: 21076
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	string N;
	long long S;
	cin >> N >> S;
	int i=0;
	while(N[i]=='1')
		i++;
	
	if(S<=i)
		cout << 1 << endl;
	else
		cout << N[i] << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k; cin >> n >> k;
    if (k == 1) cout << 0 << '\n';
    else cout << n-k << '\n';
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

//高速な素因数分解
//前処理O(N*logN), クエリO(Q*log(x_i))
template<typename T>
vector<T> smallest_prime_factors(T n) {
    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;
    for (T i = 2; i * i <= n; i++) {
    // 素数だったら
        if (spf[i] == i) {
            for (T j = i * i; j <= n; j += i) {
            // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }
    return spf;
}

template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
    vector<T> ret;
    while (x != 1) {
        ret.push_back(spf[x]);
            x /= spf[x];
        }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    
    auto spf = smallest_prime_factors(1000010);

    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    map<int, int> mii;
    rep(i,n){
        set<int> si;
        for(auto u : factolization(v[i],spf)){
            si.insert(u);
        }
        for(auto u : si){
            mii[u]++;
        }
    }
    bool ok = 1;
    int cnt = 0;
    for(auto u : mii){
        if(u.second > 1){
            ok = 0;
        }
        chmax(cnt, u.second);
    }
    if(ok){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    if(cnt==n){
        cout << "not coprime" << endl;
        return 0;
    }
    cout<<"setwise coprime"<<endl;
    return 0;
}


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

 main()
{
	long long n,sum=0,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0)
			continue;
		else
			sum+=i;
	}
	cout<<sum;
}

Measured memory_bytes: 3596
/*
LINES :
* //WHAT?
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

// #define OJ
#define pb push_back
#define F first
#define S second
#define N '\n'

#define WLL(t) while(t--)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define STF(i, a, b) for(size_t i = a; i < b; i++)
#define RFOR(i, a, b) for(int i = a; i >= b; i--)
#define SRF(i, a, b) for(size_t i = a;i >= b;i--)

#define ALL(v) v.begin(),v.end()
#define FPRECISE(x) cout<<fixed<<setprecision(x)
#define PRECISE(x) cout<<setprecision(x)
#define BOOL cout<<boolalpha
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define MOD 1000000007

#define TO(v, type) static_cast<type>(v)
int main()
{
#ifdef OJ
	READ;
	WRITE;
#endif
	FASTIO;
	int n{};
	cin>>n;
	int d1[n], d2[n];
	for(int i= 0;i<n;i++){
		cin>>d1[i]>>d2[i];
	}
	int count {0};
	for(int i=0;i<n;i++){
		if(d1[i] == d2[i]){
			count++;
		}
		else{
			count = 0;
		}
		if(count>=3){
			cout<<"Yes"<<N;
			return 0;
		}
	}
	cout<<"No"<<N;
	return 0;
}


Measured memory_bytes: 3652
x,y=map(int,raw_input().split())
a=0
if x<y:
	x,y=y,x

while True:
	a=x%y
	if a==0:
		a=y
		break
	elif x%a==0 and y%a==0:
		break
	x=y
	y=a
	
print a


Measured memory_bytes: 4640
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

vector<ll> p;
vector<ll> o;
vector<ll> memo(1000001, INF);

ll cal(ll n) {
	if(memo[n] != INF) return memo[n];
	else {
		ll ans = INF;
		ll i = o.size() - 1;
		while(i >= 0) {
			if(n - o[i] > 0)
			ans = min(ans, 1 + cal(n - o[i]));
			--i;
		}
		return memo[n] = ans;
	}
}

int main(void) {

	for(ll i = 0; i * (i + 1) * (i + 2) / 6 <= 1000000; ++i) {
		p.pb(i * (i + 1) * (i + 2) / 6);
		if((i * (i + 1) * (i + 2) / 6) % 2 == 1) o.pb(i * (i + 1) * (i + 2) / 6);
	}
	vector<P> nf;
	map<ll, ll> nb;
	REP(i, p.size()) {
		REP(j, p.size()) {
			if(p[i] + p[j] > 1000000) continue;
			nf.pb(P(p[i] + p[j], (ll)(p[i] != 0) + (ll)(p[j] != 0)));
			REP(k, p.size()) {
				if(nb.count(p[i] + p[j] + p[k]) != 0)
				nb[p[i] + p[j] + p[k]] = min(nb[p[i] + p[j] + p[k]], (ll)(p[i] != 0) + (ll)(p[j] != 0) + (ll)(p[k] != 0));
				else
				nb[p[i] + p[j] + p[k]] = (ll)(p[i] != 0) + (ll)(p[j] != 0) + (ll)(p[k] != 0);
			}
		}
	}
	memo[0] = 0;
	REP(i, o.size()) {
		memo[o[i]] = 1;
	}
	while(true) {
		ll n;
		cin>>n;
		if(n == 0) break;
		ll ans1 = INF, ans2 = INF;
		REP(i, nf.size()) {
			if(nb.count(n - nf[i].first) != 0) {
				ans1 = min(ans1, nf[i].second + nb[n - nf[i].first]);
			}
		}
		ans2 = cal(n);
		cout<<ans1<<" "<<ans2<<endl;
	}
}

Measured memory_bytes: 52452
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y, z;
  cin>>x>>y>>z;
  int t = x;
  x = y;
  y = t;
  t = x;
  x = z;
  z = t;
  cout<<x<<" "<<y<<" "<<z<<endl;
  return 0;
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N,K;
    cin >> N >> K;
    
    ll ans = 1;
    REP(i,N){
        ll ans1 = ans * 2, ans2 = ans + K;
        if ( ans1 > ans2 ) ans = ans2;
        else ans = ans1;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
  int n, m;
  std::cin >> n >> m;
  vector<bool> visit(n + 1, false);
  for (int i = 0; i < m; i++) {
    int l, r;
    std::cin >> l >> r;
    for (int j = l; j < r; j++) {
      visit[j] = true;
    }
  }
  int ans = n + 1;
  for (int i = 0; i < visit.size(); i++) {
    ans += 2*visit[i];
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3124
n=int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"

n_rem = n
ans = ""

while True:
    x = n_rem%26
    if x == 0:
        x = 26
    ans += chars[x]

    n_rem -= x

    if n_rem == 0:
        break

    n_rem //=26

print(ans[::-1])


Measured memory_bytes: 9136
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s,b,c;
    cin>>s>>b>>c;
    transform(s.begin(), s.end(), s.begin(), ::toupper);
	cout<<s[0];
    transform(b.begin(), b.end(), b.begin(), ::toupper);
    cout<<b[0];
    transform(c.begin(), c.end(), c.begin(), ::toupper);
    cout<<c[0];
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int h,w;
	int i,j;
	scanf ("%d %d",&h,&w);
	char s[101][101];
	int Linetobeblank[101]={0};
	int Columntobeblank[101]={0};
	for(i=0;i<h;i++){
		scanf("%s",s[i]);
	}
	//行から削っていく
	for(i=0;i<h;i++){
		int flag = 0;
		for(j=0;j<w;j++){
			if(s[i][j]=='.'){
				flag ++;
			}
		}
		if(flag==w){
			//そのi行は空白にする
			Linetobeblank[i]=1;
		}
	}
	//次に列を見ていく
	for(i=0;i<w;i++){
		int flag = 0;
		for(j=0;j<h;j++){
			if(s[j][i]=='.'){
				flag ++;
			}
		}
		if(flag==h){
			//そのi行は空白にする
			Columntobeblank[i]=1;
		}
	}
	/*
	printf("空白にすべき行は\n");
	for(i=0;i<h;i++){
		if(Linetobeblank[i]==1){
			printf("%d行目\n",i);
		}
	}
	printf("空白にすべき列は\n");
	for(i=0;i<w;i++){
		if(Columntobeblank[i]==1){
			printf("%d行目\n",i);
		}
	}
	*/
	for(i=0;i<h;i++){
		if( Linetobeblank[i]!=1){
			for(j=0;j<w;j++){
				if(Columntobeblank[j]!=1){
					printf("%c",s[i][j]);
				}
				
			}
			if(i<(h-1)){
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(a+b>=a-b){
    if(a+b>=a*b) cout << a+b;
    else cout << a*b;
  }else{
    if(a-b>=a*b) cout << a-b;
    else cout << a*b;
  }
  return 0;
}

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

int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty ;
  for (int i=0; i<tx-sx ; i++){
    cout << "R" ;
  }
  for (int i=0; i<ty-sy ; i++){
    cout << "U" ;
  }
  for (int i=0; i<tx-sx ; i++){
    cout << "L" ;
  }
  for (int i=0; i<ty-sy+1 ; i++){
    cout << "D" ;
  }
  
  for (int i=0; i<tx-sx+1 ; i++){
    cout << "R" ;
  }
  for (int i=0; i<ty-sy+1 ; i++){
    cout << "U" ;
  }
  cout << "L" << "U";
  for (int i=0; i<tx-sx+1 ; i++){
    cout << "L" ;
  }
  for (int i=0; i<ty-sy+1 ; i++){
    cout << "D" ;
  }
  cout << "R" << endl;
  

}


Measured memory_bytes: 256
k=int(input())

q=[1,2,3,4,5,6,7,8,9]

for i in range(k):
    l=q.pop(0)
    if l%10!=0:
        q.append(10*l+l%10-1)
    q.append(10*l+l%10)
    if l%10!=9:
        q.append(10*l+l%10+1)
    
print(l)


Measured memory_bytes: 18580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,K;
  cin >> A >> B >> K;
  int ans;
  for (int i=min(A,B);i>=1;i--){
    if (A%i==0&&B%i==0){
      K--;
      ans=i;
    }
    if (K==0){
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int x, n;
	cin >> x >> n;
	vector<int> a(102);
	rep(i,102) a[i] = i;
	rep(i,n){
		int p;
		cin >> p;
		a.erase(remove(all(a), p), a.end());
	}
	pair<int, int> ans(9999, -1);
	rep(i,a.size()){
		int dif = abs(x-a[i]);
		ans = min(ans, pair<int, int>(dif, a[i]));
	}
	cout << ans.second << endl;
	return 0;
}

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

int main() {
    long long n, k;
    cin >> n >> k;
    long long count = 0;
    vector<long long> h(n);
    for (long long i = 0; i < n; ++i) {
        cin >> h[i];
    } 
    for (long long i = 0; i < n; ++i) {
        if (h[i] >= k) {
            count += 1;
        }
    } 
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 998244353;
ll fact[210200];
ll invfact[210200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

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

    ll h[101000], dp[101000];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    h[N] = 1e9+7;
    h[N+1] = 1e9+7;

    fill(dp, dp+101000, 1e9+7);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        dp[i+1] = min(dp[i+1], abs(h[i+1] - h[i]) + dp[i]);
        dp[i+2] = min(dp[i+2], abs(h[i+2] - h[i]) + dp[i]);
    }

    cout << dp[N-1] << endl;


    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S = to_string(N);
  int n = S.size();
  int res = 0;
  REP(i, n){
    res += S[i]-'0';
  }
  if(N%res == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
string w;
long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,ww,x,y,z;
int main(){
   cin>>w;
   sort(w.begin(),w.end());
   for(int i=0;i<w.size();i++){
    if(w[i]=='a')a++;
    if(w[i]=='b')b++;
    if(w[i]=='c')c++;
    if(w[i]=='d')d++;
    if(w[i]=='e')e++;
    if(w[i]=='f')f++;
    if(w[i]=='g')g++;
    if(w[i]=='h')h++;
    if(w[i]=='i')i++;
    if(w[i]=='j')j++;
    if(w[i]=='k')k++;
    if(w[i]=='l')l++;
    if(w[i]=='m')m++;
    if(w[i]=='n')n++;
    if(w[i]=='o')o++;
    if(w[i]=='p')p++;
    if(w[i]=='q')q++;
    if(w[i]=='r')r++;
    if(w[i]=='s')s++;
    if(w[i]=='t')t++;
    if(w[i]=='u')u++;
    if(w[i]=='w')ww++;
    if(w[i]=='x')x++;
    if(w[i]=='v')v++;
    if(w[i]=='y')y++;
    if(w[i]=='z')z++;

   }
   if(a%2==0&&b%2==0&&c%2==0&&d%2==0&&e%2==0&&f%2==0&&g%2==0&&h%2==0&&i%2==0&&j%2==0&&
      t%2==0&&s%2==0&&r%2==0&&q%2==0&&p%2==0&&o%2==0&&n%2==0&&m%2==0&&l%2==0&&k%2==0&&
      u%2==0&&v%2==0&&ww%2==0&&x%2==0&&y%2==0&&z%2==0)cout<<"Yes";
        else cout<<"No";


return 0;}




Measured memory_bytes: 3564
import java.util.*;
import java.io.*;
public class Main { //atcoder ABC128E -
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int q = Integer.parseInt(st.nextToken());
		Rw[] rws = new Rw[n];
		for(int i = 0; i < n; i++){
			st = new StringTokenizer(br.readLine());
			int s = Integer.parseInt(st.nextToken());
			int t = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			rws[i] = new Rw(s, t, x);
		}
		Arrays.sort(rws);
		TreeSet<Ped> set = new TreeSet<>();
		for(int i = 0; i < q; i++) {
			set.add(new Ped(Integer.parseInt(br.readLine()), i));
		}
		int[] dead = new int[q]; Arrays.fill(dead, -1);
		for(Rw r: rws){
			Ped comp = new Ped(r.s - r.x, 0);
			Ped p = set.ceiling(comp);
			while(p != null){
				if(p.d < r.t - r.x){
					set.remove(p);
					dead[p.ind] = r.x;
					p = set.ceiling(comp);
				}
				else break;
			}
		}
		for(int i = 0; i < q; i++){
			System.out.println(dead[i]);
		}
	}
	static class Rw implements Comparable<Rw>{
		int s, t, x;
		public Rw(int s, int t, int x){
			this.s = s; this.t = t; this.x = x;
		}
		@Override
		public int compareTo(Rw r){
			return x - r.x;
		}
		public String toString(){
			return s+"-"+t+","+x;
		}
	}
	static class Ped implements Comparable<Ped>{
		int d, ind;
		public Ped(int d, int ind){
			this.d = d; this.ind = ind;
		}
		@Override
		public int compareTo(Ped p){
			return d - p.d;
		}
		public String toString(){
			return ind+":"+d;
		}
	}
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,k;cin >>n>>k;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    bool flg=true;
    for (int j = 0; j < k; ++j) {
    vector<ll>b(n+1,0);
        ll sum=0;
            for (int i = 0; i < n; ++i) {
                b[max(0LL, i - a[i])]++;
                b[min(i + a[i] + 1, n)]--;
                sum +=min(a[i],(ll)i);
                sum +=min(a[i],(ll)n-i-1);
                sum++;
            }
            for (int i = 0; i < n; ++i) {
                b[i + 1] += b[i];
                a[i]=b[i];
            }
        if(sum>=n*n){
            break;
        }
//        cout <<sum<<endl;
    }
    for (int i = 0; i < n; ++i) {
        cout <<a[i]<<" ";
    }
    cout <<endl;
    return 0;
}

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

using namespace  std;

int main() {
  int a , b , c; cin>>a>>b>>c;
  string ans = "No";
  if(a == b && a != c)ans = "Yes";
  else if(b == c && b != a)ans = "Yes";
  else if(a == c && a != b)ans = "Yes";
  cout<<ans<<endl;
}

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

def solve(A: int, B: int, N: int):
    result1 = int(A*(B-1)/B) - A * int((B-1) / B)
    result2 = int(A*N/B) - A*int(N/B)
    if N <= B-1:
        print(min(result1, result2))
    else:
        print(result1)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9060