akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
        bytes
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect()
    };
    input! {next,
        n: usize,
        k: usize,
    }
    let mut total = 0;
    for i in k..=n+1 {
        let ans = (n+1-i)*(i) + 1;
        total = (total + ans) % 1000000007;
    }
    println!("{}", total);
}


Measured memory_bytes: 2128
#include <stdio.h>

int main()
{
    int i;
    char arr[5];
    arr[3] = 'S';
    for(i=0;i<=3;i++)
    {
        scanf("%c",&arr[i]);
    }
    int cnt=0;
    int max=0;
    for(i=0;i<=3;i++)
    {
        if(arr[i]=='R')
        {
            cnt++;
        }
        else
        {
            if(max<cnt)
            {
                max=cnt;
            }
            cnt=0;
        }
    }
    printf("%d\n",max);
    return 0;
}


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

const int N = 200010;
using ll = long long;

int a[N];

int main(){
    int n;
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
    }
    std::sort(a, a + n);
    int left = n - 1;
    for (int i = n - 1; i >= 0; -- i){
        for (int j = 0; j < (i == n - 1 ? 1 : 2); ++ j){
            if (left){
                -- left;
                sum += a[i];
            }
        }
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 4624
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const int point[4] = { 0, 60, 70, 80 };
int field[5][5];
int memo[5][5][1 << 10];

inline int get_point(int x, int y, int rotate) {
  if (field[y][x] == 0) { return 0; }
  return point[(field[y][x] - 1 + rotate) % 4];
}

const int mask = (1 << 10) - 1;
int calc(int x, int y, int puse) {
  if (y == 5) { return 0; }
  if (memo[y][x][puse] != -1) { return memo[y][x][puse]; }
  if (x == 4) {
    int lup = 3 & (puse >> 8);
    int lbottom = 3 & (puse >> 0);
    int nuse = puse & ((1 << 8) - 1);
    return memo[y][x][puse] = calc(0, y + 1, nuse) + get_point(x, y, lup + lbottom);
  }
  int ret = 0;
  REP(rotate, 4) {
    if (y == 4 && rotate > 0) { break; }
    int nuse = ((puse << 2) & mask) | rotate;
    int lup = 3 & (puse >> 8);
    int rup = 3 & (puse >> 6);
    int lbottom = 3 & (puse >> 0);
    if (x == 0) { lbottom = 0; }
    ret = max(ret, calc(x + 1, y, nuse) + get_point(x, y, lup + rup + lbottom + rotate));
  }
  return memo[y][x][puse] = ret;
}

char str[1000];
int main() {
  int test;
  scanf("%d", &test);
  assert(test <= 100);
  while (test--) {
    MEMSET(memo, -1);
    REP(y, 5) REP(x, 5) {
      scanf("%d", &field[y][x]);
      assert(0 <= field[y][x] && field[y][x] <= 4);
    }
    printf("%d\n", calc(0, 0, 0));
  }
  assert(scanf("%s", str) == EOF);
}

Measured memory_bytes: 984
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

#define N 55
ll n;
ll a[N], b[N], as[N];
bool f[N][N][N];
ll g[N][N];

int main(){
	cin>>n;
	rep(i, n) cin>>a[i];
	rep(i, n) cin>>b[i];
	rep(i, N) rep1(j, N-1) rep(k, N) f[i][j][k] = i%j==k;
	rep(i, N) fill(g[i], g[i]+N, INF);
	rep(i, N) rep(k, N) rep(j, N) if(f[i][j][k]){ g[i][k] = j; break; }
	rep(i, N) g[i][i] = 0;
	rep(j, N) rep(i, N) rep(k, N) chmin(g[i][k], max(g[i][j], g[j][k]));
	rep(i, n) as[i] = 1LL<<a[i];
	ll res = 0;
	while(true){
		bool flag = true;
		ll mx = -1;
		rep(i, n){
			if(!(1&(as[i]>>b[i]))) flag = false;
			ll mx2 = INF;
			rep(j, N){
				if(1&(as[i]>>j)) chmin(mx2, g[j][b[i]]);
			}
			chmax(mx, mx2);
		}
		if(flag) break;
		if(mx==INF){
			res = -1;
			break;
		}
		rep(i, n) rep(j, N) if(1&(as[i]>>j)) as[i] |= 1LL<<(j%mx);
		res += 1LL<<mx;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]
# ''.join(s)

s = list(s())
s_deque = deque(s)
q = i()
query = ms(q)

cnt = 0
v = ["r", "l"]
vector = v[cnt]

for qu in query:
    if qu[0] == "1":
        cnt += 1
        vector = v[cnt % 2]
    else:
        if qu[1] == "1":
            if vector == "r":
                s_deque.appendleft(qu[2])
            else:
                s_deque.append(qu[2])
        elif qu[1] == "2":
            if vector == "r":
                s_deque.append(qu[2])
            else:
                s_deque.appendleft(qu[2])

print(''.join(s_deque)[::(-1) ** (cnt % 2)])

Measured memory_bytes: 129800
from bisect import*
n,d,a,*t=map(int,open(0).read().split())
c=[0]*-~n
z=sorted(zip(*[iter(t)]*2))
s=0
for i,(x,h)in enumerate(z):
    c[i]+=c[i-1]
    h-=c[i]
    t=-min(-h//a,0)
    c[i]+=t*a
    c[bisect(z,(x+d+d,10e9))]-=t*a
    s+=t
print(s)

Measured memory_bytes: 48852
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
typedef pair<char,char>PII;
map<PII,int>mp;
int Xiaobo()
{
	int n;
	char s[10]={0};
	cin>>n;
	for(int i=1;i<=n;i++) {
		memset(s,0,sizeof(s));
		sprintf(s,"%1d",i);
		int len=strlen(s);
		mp[{s[0],s[len-1]}]++;
	}
	int ans=0;
	for(auto item:mp) {
		char c1,c2;
		c1=item.first.first;
		c2=item.first.second;
		if(c1==c2) ans+=item.second*item.second;
		else ans+=item.second*mp[{c2,c1}];
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main() {
  int n, d;
  cin >> n >> d;
  int count = 0;
  while(n > 0) {
    n -= (2*d + 1);
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<set>
#include<cmath>
#define ll long long
#define pb(c, n) c.push_back(n);
using namespace std;
const int N = 101;
vector< vector<int> > g(N);
int main()
{
    int a, b, c;
    cin>>a>>b;
    if(a==1)
    {
        if(b==2) cout<<3;
        else cout<<2;
    }
    else if(a==2)
    {
        if(b==3) cout<<1;
        else cout<<3;
    }
    else
    {
        if(b==1) cout<<2;
        else cout<<1;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}

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

    vector<int> vec(n);

    REP(i,n){
        cin >> vec[i];
    }

    ll ans = INF;

    REP(i,100){
        ll sum = 0;
        REP(j,n){
            sum += (vec[j] - i) *(vec[j] - i); 
        }
        ans = min(ans,sum);
    }

    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
template<typename T> using Graph = vector<vector<T>>;

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

    int N, M, K;
    cin >> N >> M >> K;
    vi a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];

    int ans = -1;
    rep(s, 1 << N) {
        if (__builtin_popcount(s) != K) {
            continue;
        }
        vector<Pii> vp;
        rep(i, N) {
            if ((s >> i) & 1) {
                vp.emplace_back(a[i], b[i]);
            }
        }
        sort(all(vp));
        reverse(all(vp));
        int tmp = 0;
        int res = M;
        for (auto p : vp) {
            int a, b;
            tie(a, b) = p;
            tmp += a * min(res, b);
            res -= min(res, b);
        }
        ans = max(ans, tmp + res);
    }
    cout << ans << endl;
}

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

int main()
{
    int64_t h, w; cin >> h >> w;
    int64_t ans = 0,tmp;
    if(h == 1 || w == 1) ans = 1;
    else {
        if(h%2 == 0) {
            ans = w * h/2;
        } else {
            ans = w * (h-1)/2;
            if(w%2==0) {
                tmp = w/2;
            } else {
                tmp = w/2 + 1;
            }
            ans = ans + tmp;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> time(n, 0);
    for(int i=0; i<n-1; i++){
        int c,s,f;
        cin >> c >> s >> f;
        for(int j=0; j<=i; j++){
            if(time[j] < s) time[j] = s;
            time[j] = (time[j] +f-1)/f *f + c;
        }
    }
    for(int i=0; i<n; i++){
        cout << time[i] << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
	string str;
	map<char,int> count;
	
	while(getline(cin,str)){
		transform(str.begin(), str.end(), str.begin(), ::tolower);
		
		for(int i=0; i<str.size();i++) {
			char c= str[i];
			if (isalpha(static_cast<unsigned char>(c))) count[c]++;
		}
	}
	for(char c='a'; c <= 'z';c++)
		cout << c << " : " << count[c] << endl;
		
	return 0;
}


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

int main(){
	long i,j,n,m;
	char rend[65536][2],cash;
	while(1){
		cin >> n;
		if(!n) break;
		for(i=0;i<n;i++){scanf(" %c %c",&rend[i][0],&rend[i][1]);}
		cin >> m;
		for(j=0;j<m;j++){
			cin >> cash;
			for(i=0;i<n;i++){
				if(cash==rend[i][0]){cash=rend[i][1];break;}
			}
			cout << cash;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const ull mod1 = 2e18 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 3e5 + 5;
int t;

int main()
{
	//freopen("in.txt", "r", stdin);
	int l, r, d;
	while (cin >> l >> r >> d)
	{
		vector<int> v;
		for (int i = d;i <= 100;i += d)v.emplace_back(i);
		int ans = 0;
		for (auto I : v)
		{
			if (I >= l && I <= r)ans++;
		}
		cout<< ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 7;
ll cnt[maxn]= {0};
int main() {
	string s;
	cin >> s; 
	ll res = 0, ans = 0, r = 1ll;
	cnt[0]++;
	for(int i = s.size() - 1; i >= 0; i--) {  
		res = (res + (s[i] - '0') * r % 2019) % 2019; 
		//cout << res << endl;
		ans += cnt[res]++;
		r = r * (ll)10 % 2019;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3824
#include<stdio.h>

int main()
{
	int N;
	long sum = 0, a, b;
	scanf("%d", &N);
	while(N--)
	{
		scanf("%ld%ld", &a, &b);
		sum += b - a + 1;
	}	
	printf("%ld", sum);
	
	return 0;
}

Measured memory_bytes: 128
#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 mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll x,n;
    ll i,j;
    cin>>x>>n;
    ll a[n];
    set<ll> s;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
        
    }
    vll v;
    for(i=0;i<=200;i++)
    {
       v.pb(i);
    }

    ll res=INF;
    ll resi=-1;
    for(auto it:v)
    {
        if(s.find(it)!=s.end())continue;
        ll dif = llabs(it-x);
        if(res>dif)
        {
            res=dif;
            resi=it;
        }
    }
    cout<<resi<<"\n";
    

}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> v,c;
  v.resize(n);
  c.resize(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(v[i]>c[i]){
      sum+=v[i]-c[i];
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,count=0,i;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			count++;
		}
	}
	
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 2752
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	vector<long long int>v(N + 1);
	vector<long long int>w(M + 1);
	for (int i = 1; i <= N; i++)cin >> v[i];
	for (int i = 1; i <= M; i++)cin >> w[i];
	N++, M++;
	for (int i = 1; i < N; i++)v[i] += v[i - 1];
	for (int i = 1; i < M; i++)w[i] += w[i - 1];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		auto it = upper_bound(w.begin(), w.end(), K - v[i]);
		auto num = distance(w.begin(), it);
		//cout << num << " " << (int)num << endl;
		if (K >= v[i]) {
			ans = max(ans, i + (int)num - 1);
			//cout << i + (int)num - 1 << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;  
    int n,i;
    cin>>n;
    set<string> s;
    for(i=0;i<n;++i)
    {
        string t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size();
}

Measured memory_bytes: 19248
n=int(input())
a=[int(i) for i in input().split()]
if 0 in a:
    print(0)
    exit()
a.sort(reverse=True)
ans=1
x=10**18
for i in a:
    ans*=i
    if ans>x:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 84816
module CharSet = Set.Make (Char)

let () =
  let s = read_line () in
  let t = read_line () in
  let a = Array.make 26 CharSet.empty in
  let b = Array.make 26 CharSet.empty in
  let ix c = Char.code c - Char.code 'a' in
  for i = 0 to String.length s - 1 do
    a.(ix s.[i]) <- CharSet.add t.[i] a.(ix s.[i]);
    b.(ix t.[i]) <- CharSet.add s.[i] b.(ix t.[i])
  done;
  print_endline @@
  if 
    List.for_all (List.for_all (fun s -> CharSet.cardinal s <= 1)) @@
    List.map Array.to_list [a; b]
  then "Yes"
  else "No"


Measured memory_bytes: 3712
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, a, sum = 0;
    cin >> n;
    a = n;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    cout << (a % sum == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3640
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-05-17(Sun)
   note   
**********************************************************************/

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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int x = (h2-h1)*60 + (m2-m1);
  int ans = x - k;
  cout << x - k << endl;
  return 0; 
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			int x = i;
				if (x % 3 == 0) {
					System.out.print(" " + i);
				} else {
					while (x != 0) {
						if (x % 10 == 3) {
							System.out.print(" " + i);
							break;
						} else {
							x /= 10;
						}
					}
				}
			}
		System.out.println();
	}
}



Measured memory_bytes: 28544
a,b,c,x,y = map(int,input().split())

ans = 0
if a+b <= 2*c:
    ans = a*x+b*y
else:
    if x>y:
        ans += 2*c*y
        l = x-y
        r = a
    else:
        ans += 2*c*x
        l = y-x
        r = b
    if 2*c < r:
        ans += 2*c*l
    else:
        ans += l*r

print(ans)

Measured memory_bytes: 38384
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

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

#pragma endregion

int main() {
  string n = in<string>();
  bool flag = false;
  rep(i, n.size()) {
    if (n[i] == '7') {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	cout << ((N + 999) / 1000 * 1000 - N) << '\n';
	return 0;
}

Measured memory_bytes: 3596
import collections
N, A = [int(_) for _ in input().split()]
X = [int(_) for _ in input().split()]


def calc(W):
    #dp[m][s]=m枚のカードの和がsとなるような選び方の総数
    M = len(W)
    dp = [collections.defaultdict(int) for _ in range(M + 1)]
    dp[0][0] = 1
    for i, w in enumerate(W):
        for j in range(i, -1, -1):
            for k, v in dp[j].items():
                dp[j + 1][k + w] += v
    return dp


dpx = calc(X)
print(sum(dpx[i][i * A] for i in range(1, N + 1)))


Measured memory_bytes: 11224
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

    ll n,k,i,j=inf,dp[100005]={0},a[2000];

ll mex(set<ll> s)
{
    ll x=0;
    while(s.find(x)!=s.end())x++;
    return x;
}

int main()
{
    cin>>n>>k;
    rep(i,0,n-1)cin>>a[i],j=min(a[i],j);
    rep(i,0,j-1)dp[i]=0;
    sort(a,a+n);
    rep(i,j,k)
    {
        set<ll> s;
        rep(i1,0,n-1)
        {
            if(a[i1]>i)break;
            s.insert(dp[i-a[i1]]);
        }
        dp[i]=mex(s);
    }
    if(!dp[k])cout<<"Second";
    else cout<<"First";
    return 0;
}


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

string S;
int dp[200009][5];

int main() {
	cin >> S;
	for (int i = 0; i <= S.size(); i++) { for (int j = 0; j <= 5; j++) dp[i][j] = -(1 << 30); }

	dp[0][0] = 0;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 5; j++) {
			if (dp[i][j] < 0) continue;
			for (int k = 1; k <= min(4, (int)S.size() - i); k++) {
				string v1 = S.substr(i - j, j);
				string v2 = S.substr(i, k);
				if (v1 == v2) continue;
				dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
			}
		}
	}
	int maxn = 0; for (int i = 0; i <= 4; i++) maxn = max(maxn, dp[S.size()][i]);
	cout << maxn << endl;
	return 0;
}

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

int main()
{
	//freopen("A.in","r",stdin);
	long long a,b,c,k,ans;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0) ans = a - b;
	else ans = b - a;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	string s;
	cin >> s;
	int k;
	cin >> k;

	rep(i, s.size()) {
		if (s[i] != 'a') {
			int t = 'z' - s[i] + 1;
			if (t <= k) {
				s[i] = 'a';
				k -= t;
			}
		}
	}

	k = k % ('z' - 'a' + 1);
	while (k) {
		int i = s.size() - 1;
		s[i]++;
		if (s[i] == 'z' + 1) {
			s[i] = 'a';
		}
		k--;
	}
	cout << s << endl;

	return 0;
}








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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int ans = 0;
    int c[10][10];
    rep (i, 10) {
        rep (j, 10) {
            cin >> c[i][j];
        }
    }
    rep (k, 10) {
        rep (i, 10) {
            rep (j, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    rep (i, h) {
        rep (j, w) {
            int x;
            cin >> x;
            if (x > -1) ans += c[x][1];
        }
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    if op == "?": break
    a,b = int(a),int(b)
    if   op == "+": print(a + b)
    elif op == "-": print(a - b)
    elif op == "*": print(a * b)
    elif op == "/": print(a // b)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  int player[n];
  for(int i=0;i<n;i++)
    player[i] = k-q;
  for(int i=0;i<q;i++){
    int who;
    cin>>who;
    player[who-1]++;
  }
  
  for(int i=0;i<n;i++){
    if(player[i]>0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#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>

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 FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
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;

const int MAX = 110;
int N, M;
VI graph[MAX];
int cost[MAX][MAX];
int war[MAX][MAX];

int main(void) {
    scanf("%d%d", &N, &M);
    REP(i, MAX) REP(j, MAX) {
        cost[i][j] = war[i][j] = INF;
    }
    REP(i, M) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        a--;b--;
        graph[a].EB(b);
        graph[b].EB(a);
        cost[a][b] = cost[b][a] = c;
        war[a][b] = war[b][a] = c;
    }
    int ans = 0;
    REP(k, N) REP(i, N) REP(j, N) {
        chmin(war[i][j], war[i][k] + war[k][j]);
    }
    REP(i, N) FOR(j, i + 1, N) if (cost[i][j] != INF) {
        ans += (cost[i][j] != war[i][j]);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
    return 0;
}


Measured memory_bytes: 3312
#include <stdio.h>

int main(void)
{
  char str[30], ans[30];
  int i, j;
  i = 0;
  j = 0;

  scanf("%s", str);
  while(str[j] != 0){
    j++;
  }
  ans[j] = 0;
  j--;

  while(str[i] != 0){
    ans[j] = str[i];
    i++;
    j--;
  }

  printf("%s\n", ans);

  return(0);
}

Measured memory_bytes: 520
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <math.h>

int main(void){
    using namespace std;
    long long a;
    long long b;
    long long c;

    cin >> a;
    cin >> b;
    cin >> c;
    long long a_l[a];
    long long n_l[a];

    long long num = 200;

    cin >> num;
    long long sum = 0;

    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if (i*500+j*100+k*50 == num){
                    sum += 1;
                }
            }
        }

    }


    long long min_n;

    //cout << num << " " << l_a << endl;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    for(auto& e : s){
        int k;
        cin >> k;
        for(int i = 0;i < k;i++){
            int tmp;
            cin >> tmp;
            e.push_back(tmp);
        }
    }
    vector<int> p(m);
    for(auto& e : p) cin >> e;
    int ans = 0;
    for(int bit = 0;bit < (1 << n);bit++){
        bool flag = false;
        for(int i = 0;i < m;i++){
            int count = 0;
            for(auto& e : s[i]){
                if(bit & (1 << (e-1))) count++;
            }
            if(count % 2 != p[i]){
                flag = true;
                break;
            }
            if(i == m - 1){
                ans++;
            }
        }
        if(flag) continue;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
C=[[0]*(M+1)for _ in range(N)]

i=0
while i<N:
    C[i]=list(map(int,input().split()))
    i+=1

ans=10**9
for i in range(2 ** N):
    bag = [0]*M
    total=0
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            a=0    
            for k in C[j][1:]:
                bag[a]+=k
                a+=1
            total+=C[j][0]  # フラグが立っていたら bag に果物を詰める
    if all(b>=X for b in bag):
        ans=min(ans,total)
    
if ans==10**9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9240
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
int i,j;
char ans[100][100];
int a,b;
char max,min;
int maxn,minn;
max='#';
min='.';
minn=a;
maxn=b;
scanf("%d %d",&a,&b);
if(a>b){
min='#';
max='.';
minn=b;
maxn=a;
}
for(i=0;i<100;i++){
	for(j=0;j<50;j++){
		ans[i][j]='#';
	}
	for(j=50;j<100;j++){
		ans[i][j]='.';
	}
}
i=0;
j=0;
a=a-1;
while(a>0){
	ans[i][j]='.';
	j=j+2;
	if(j>=49){
		i=i+2;
		j=0;
	}
	a=a-1;
}
i=0;
j=51;
b=b-1;
while(b>0){
	ans[i][j]='#';
	j=j+2;
	if(j>=100){
		i=i+2;
		j=51;
	}
	b=b-1;
}

printf("100 100\n");
for(i=0;i<100;i++){
	for(j=0;j<100;j++){
		printf("%c",ans[i][j]);
	}
	printf("\n");
}

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    ll N, M;
    cin >> N >> M;
    ll ans = min(N, M / 2);
    M = max<ll>(M - 2 * ans, 0);
    ans += M / 4;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <valarray>
#include <string>
#include <algorithm>
#include <set>
typedef unsigned long long ull;
typedef long long ll;
#define fst first
#define snd second
#define rep(i,n) for(ull i = 0;i<(n);i++)
#define rep1(i,n) for(ull i = 1;i<=(n);i++)
#define revrep(i,n) for(ull i = (n-1);i>=0;i--)
#define all(n) (n).begin(),(n).end()
#define show(x) cout << "debug " << #x << ":" << x << endl;
#define showvec(x) cout << endl << "debug " << #x << ";" << endl; \
	for(ull __i = 0;__i < x.size();__i++){ \
		for(ull __j = 0;__j<x[0].size();__j++){ \
			cout << x[__i][__j] << " "; \
		} \
		cout << endl; \
	} \
	cout << endl;
using namespace std;

int V,E;
vector<int> G[100001];
bool visited[100001];
int prenum[100001];
int lowest[100001];
int parent[100001];

set<pair<int,int> > T;


int dfs(int vert){
	static int time = 1;
	visited[vert] = true;
	prenum[vert] = time;
	int lst = prenum[vert];
	time++;
	rep(v,G[vert].size()){
		int &e = G[vert][v];
		if(visited[e]){
			if(!T.count(make_pair(vert,e))){
				lst = min(lst,prenum[e]);
			}
			continue;
		}
		parent[e] = vert;
		T.insert(make_pair(vert,e));
		T.insert(make_pair(e,vert));
		lst = min(lst,dfs(G[vert][v]));
	}
	return lowest[vert] = lst;	
}

int main(){
	cin >> V >> E;
	rep(i,V){
		visited[i] = false;
	}
	rep(i,E){
		int a,b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	parent[0]=-1;
	dfs(0);
	int rcnt = 0;
	rep(i,G[0].size()){
		if(T.count(make_pair(0,G[0][i]))){
			rcnt++;
		}
	}
	vector<int> ansbag;
	if(rcnt>=2){
		ansbag.push_back(0);
	}
	rep1(i,V-1){
		int p = parent[i];
		if(p == -1 || p == 0) continue;
		if(prenum[p] <= lowest[i]){
			ansbag.push_back(p);
		}
	}
	sort(all(ansbag));
	ansbag.erase(unique(all(ansbag)),ansbag.end());
	rep(i,ansbag.size()){
		cout << ansbag[i] << endl;
	}
	cout << flush;
}

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

int main(){
    using namespace std;
    unsigned long X;
    cin >> X;
    unsigned long ureshisa{0};
    ureshisa += (X / 500) * 1000;
    X %= 500;
    ureshisa += (X / 5) * 5;
    X %= 5;
    cout << ureshisa << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P=pair<int,int>;

const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};

int main(){
  int h,w,sx,sy;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0;i<h;++i){
    cin >> s[i];
  }
  int ans=0;
  vector<vector<int>> dist(h,vector<int>(w,-1));
  queue<P> q;
  sx=0;
  sy=0;
  dist[sx][sy]=0;
  q.push(P(sx,sy));
  while(!q.empty()){
    int i=q.front().first;
    int j=q.front().second;
    q.pop();
    for(int dir=0;dir<4;++dir){
      int ni=i+di[dir];
      int nj=j+dj[dir];
      if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
      if(s[ni][nj]=='#'){
        continue;
      }else{
        if(dist[ni][nj]!=-1) continue;
        dist[ni][nj]=dist[i][j]+1;
        q.push(P(ni,nj));
      }
    }
  }
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(s[i][j]=='#'){
        ans++;
      }
    }
  }

  int cal=dist[h-1][w-1];
  if(cal==-1){
    ans=-1;
  }else{
    cal++;
    cal+=ans;
    ans=(h*w)-cal;
  }
  cout << ans << endl;
  return 0;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[] peak = new int[N];
        int a, b;
        
        for(int i = 0; i < M; i++) {
            a = scan.nextInt();
            peak[a - 1]++;
            
            b = scan.nextInt();
            peak[b - 1]++;
        }
        
        for(int i = 0; i < N; i++) {
            if(peak[i] % 2 == 1) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 66364
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	for(int i=0;i<y;i++){
		int a;
		cin>>a;
		x-=a;
	}
	if(x>=0)
		cout<<x;
	else
		cout<<-1;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    for (ll i = 1; i <= 10; i++)
        if (1000 * i >= n) {
            std::cout << 1000 * i - n << '\n';
            return;
        }
}


Measured memory_bytes: 3688
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Program
{

    void Solve()
    {
        var N = io.Long;
        WriteLine(
            Enumerable.Range(1, int.MaxValue)
            .Select(x => (long)x)
            .TakeWhile(x => x * x <= N)
            .Where(x => N % x == 0)
            .Select(x =>
            {
                var y = N / x;
                return x + y - 2;
            }).Min());
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();
    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mk make_pair
const int N=300010;

int n,m,a[N],X,Y;
int _abs(int x){
    if(x<0) return -x;
    return x;
}
int main()
{
    scanf("%d%d%d",&n,&X,&Y);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    if(n==1) printf("%d\n",_abs(Y-a[1]));
    else
    {
        int ans=max(_abs(Y-a[n]),_abs(a[n]-a[n-1]));
        printf("%d\n",ans);
    }
    
    return 0;
}

Measured memory_bytes: 3828
n,y=map(int, input().split())
y=y//1000
for i in range(1+y//10):
	if i>n:
		pass
	for j in range(1+(y-10*i)//5):
		if i+j>n:
			pass
		if y==10*i+5*j+(n-i-j):	
			print(i,j,n-i-j)
			exit()

print(-1,-1,-1)

Measured memory_bytes: 9072