akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(string, s, t);
	IN(int, a, b);
	IN(string, u);
	if(u == s) { a--; }
	if(u == t) { b--; }
	OUT(a, b);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int[] ia = new int[n];
		for (int i = 0; i < n; i++) {
			ia[i] = readNum();
		}
		Arrays.sort(ia);
		int ans = 1;
		for (int i = 1; i < n; i++) {
			if (ia[i - 1] != ia[i]) {
				ans++;
			}
		}
		pln(ans);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21204
h,w = map(int,input().split())
s = [input() for i in range(h)]
ans = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            a = ""
            b = ""
            if i==h-1:
                a = s[i-1][j]
            elif i==0:
                a = s[i+1][j]
            else:
                a = s[i+1][j]+s[i-1][j]
            if j==0:
                b = s[i][j+1]
            elif j==w-1:
                b = s[i][j-1]
            else:
                b = s[i][j-1]+s[i][j+1]
            if not "#" in a+b:
                ans="No"
            
print(ans)

Measured memory_bytes: 3064
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int in[5005]={};
vector<int>edge[5005];
queue<int>que;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		edge[x].pb(y);
		in[y]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(!in[i]) que.push(i);
	}
	int mul=0;
	while(!que.empty())
	{
		if(que.size()>=2) mul=1;
		int r=que.front(); que.pop();
		printf("%d\n",r);
		for(int i=0;i<edge[r].size();i++)
		{
			int x=edge[r][i];
			in[x]--;
			if(!in[x]) que.push(x);
		}
	}
	printf("%d\n",mul);
}

Measured memory_bytes: 1884
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare(const void *a, const void *b) {
	char *pa = *(char **) a;
	char *pb = *(char **) b;

	return strcmp(pa, pb);
}

int main() {
	static char **cc;
	int n, l, i;

	scanf("%d%d", &n, &l);
	cc = malloc(n * sizeof *cc);
	for (i = 0; i < n; i++) {
		cc[i] = malloc((l + 1) * sizeof *cc[i]);
		scanf("%s", cc[i]);
	}
	qsort(cc, n, sizeof *cc, compare);
	for (i = 0; i < n; i++)
		printf("%s", cc[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int ans = 1000;
    for (int i = 0; i + 2 < s.size(); i++) {
        ans = min(ans, abs(100 * (s[i] - '0') + 10 * (s[i+1] - '0') + s[i+2] - '0' - 753));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

ll gcd(ll a, ll b) {
	return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

// 10 40
// 6 12 18 24 30 36
// 8 16 24 32 40

// 4 9
// 4 6 8
// 6 9
int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	
	ll ans = B - A + 1;
	ans -= (B / C - A / C + (A%C == 0)) + (B / D - A / D + (A%C==0));
	ans += (B / lcm(C, D) - A / lcm(C, D) + (A%C == 0))*1;
	cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);

    for (auto i = 0; i < n; i++)
    {
        long long ai, bi;
        cin >> ai >> bi;
        a[i] = ai;
        b[i] = bi;
    }

    long long index = -1;
    long long point = -1;

    for (auto i = 0; i < n; i++)
    {
        if(index < a[i]){
            index = a[i];
            point = b[i];
        }
    }

    cout << index + point << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
const int M=102,N=100020,Inf=1<<20;
char c[M][M];
int n,m,S,T,i,j,k=1;
int h[N],t[N],v[N],w[N],l[N];
int q[N],s,e,g[N],d[N],flw;
void add(int a,int b,int c){
	//printf("%d %d %d\n",a,b,c);
	t[++k]=h[a];h[a]=k;v[k]=b;w[k]=c;
	t[++k]=h[b];h[b]=k;v[k]=a;w[k]=0;
}
void init(){
	scanf("%d%d",&n,&m);
	S=1;T=1+n+m+1;
	for(i=1;i<=n;i++){
		scanf("%s",c[i]+1);
		for(j=1;j<=m;j++){
			if(c[i][j]=='S'){
				add(S,1+i,Inf);
				add(S,1+n+j,Inf);
			}
			if(c[i][j]=='T'){
				add(1+i,T,Inf);
				add(1+n+j,T,Inf);
			}
			if(c[i][j]=='o'){
				add(1+i,1+n+j,1);
				add(1+n+j,1+i,1);
			}
		}
	}
}
int min(int x,int y){
	return x<y?x:y;
}
int dfs(int i,int p){
	if(i==T)return p;
	int f=0;
	for(int &j=l[i],x;j;j=t[j])
		if(w[j]&&d[i]==d[v[j]]+1){
			x=dfs(v[j],min(w[j],p));
			p-=x;f+=x;
			w[j]-=x;w[j^1]+=x;
			if(p==0)return f;
		}
	if(!--g[d[i]])d[S]=T+1;
	g[++d[i]]++;l[i]=h[i];
	return f;
}
void work(){
	for(i=1;i<=T;i++)
		l[i]=h[i];
	g[d[q[s=e=0]=T]=1]++;
	while(s<=e)
		for(j=h[i=q[s++]];j;j=t[j])
			if(!d[v[j]])
				g[d[v[j]]=d[i]+1]++,q[++e]=v[j];
	do
		flw+=dfs(S,Inf);
	while(d[S]<=T);
	printf("%d",flw>2000?-1:flw);
}
int main(){
	init();
	work();
//	while(1);
}

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

int main() {
    int n, x, count;
    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        count = 0;
        for (int i = 1; i <= n-2; i++) {
            for (int j = i+1; j <= n-1; j++) {
                for (int k = j+1; k <= n; k++) {
                    if (i + j + k == x) count += 1;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int64 Solve() {
  int64 n, x, m;
  cin >> n >> x >> m;
  if (n < 1E6) {
    vector<int64> xs(n);
    xs[0] = x;
    for (int i = 1; i < n; i++) {
      xs[i] = xs[i - 1] * xs[i - 1] % m;
    }

    int64 sum = 0;
    for (int i = 0; i < n; i++) {
      sum += xs[i];
    }
    return sum;
  }


  vector<int64> xs(2 * m, -1);
  vector<int> indexes(m, -1);
  xs[0] = x;
  indexes[x] = 0;
  for (int i = 1 ; i < 2 * m; i++) {
    // cout << "i: " << i << endl;
    xs[i] = xs[i - 1] * xs[i - 1] % m;
    if (indexes[xs[i]] == -1) {
      indexes[xs[i]] = i;
    } else {
      int64 a = indexes[xs[i]];
      // cout << "a: " << a << endl;
      int64 c = i - a;
      int64 q = (n - a) / c;
      int64 r = (n - a) % c;

      int64 sum = 0;
      for (int i = 0; i < a; i++) {
        sum += xs[i];
      }
      int64 cycle_sum = 0;
      for (int i = a; i < a + c; i++) {
        cycle_sum += xs[i];
      }
      sum += cycle_sum * q;
      for (int i = a; i < a + r; i++) {
        sum += xs[i];
      }
      return sum;
    }
  }
}

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

  cout << Solve() << endl;
}

Measured memory_bytes: 10760
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
typedef long long ll;
using namespace std;

int n, a[200000], l, r;
ll ans, mem;

int main() {
	cin >> n;
	lp(n)
		cin >> a[i];
	ans = l = 0;
	r = -1;
	mem = 0;
	while (r != n - 1) {
		if (mem + a[r + 1] == (mem ^ a[r + 1])) {
			mem += a[r + 1];
			r++;
		}
		else {
			ans += r - l + 1;
			mem -= a[l];
			l++;
		}
	}
	ans += ll (r - l + 1)*ll (r - l + 2) / 2;
	cout << ans << endl;
	return 0;
}


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

int main() {
    string s;
    cin>>s;

    int count=0;
    for(int i=1;i<s.size();i++){
        if(s.at(i-1)==s.at(i)){
            count++;
            if(s.at(i)=='0'){
                s.at(i)='1';
            }else{
                s.at(i)='0';
            }
        }
    }
    cout<<count<<endl;

    return 0;



}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;


const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

int main2() {
  int S = nextLong();
  ll ans = 0;
  for (int k = 1; k <= S; k++) {
    ll s = S - 3*k;
    if (s >= 0) {
      ans += choose(s + k-1, k-1);
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 11084
import math
n, *a = map(int, open(0).read().split())

y1 = math.ceil(sum(a)/n)
y2 = sum(a)//n
ans1 = 0
ans2 = 0

for i in range(n):
    ans1 += (a[i] - y1) ** 2
    ans2 += (a[i] - y2) ** 2

print(min(ans1,ans2))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
int main(){
 int a,b,c;
 cin >> a >> b >> c;
 vi d(3);
 d[0]=abs(b-a);d[1]=abs(c-a); d[2]=abs(c-b);
 sort(ALL(d));
 cout << d[0]+d[1] << endl;
}


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

ll gcd(int a, int b) {
	int c = a%b;
	if(c==0LL) return b;
	return gcd(b,c);
}

int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	a--;
	ll e = c*d/gcd(c,d);
	ll f = (b/c)-(a/c);
	ll g = (b/d)-(a/d);
	ll h = (b/e)-(a/e);
	/*
	cout << f << endl;
	cout << g << endl;
	cout << h << endl;
	*/
	cout << (b-a-(f+g-h)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& el: v) cin >> el;
    long long money = 1000;
    for(int i = 1; i < n; ++i) {
    	if(v[i] > v[i - 1]) {
    		long long st = money / v[i - 1];
    		money -=  st * v[i - 1];
    		money += st * v[i]; 
    	}
    }
    cout << money << "\n";
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>

using namespace std;

int main(){
	long n;
	cin >> n;
	vector<pair<long,long>> vp(n);
	long a,b,cnt=0,start=-1e9+1;
	
	for(int i=0;i<n;i++){
		cin >> a >> b;
		vp[i].first=a-b;
		vp[i].second=a+b;
	}
	
	sort(vp.begin(),vp.end(),[](pair<long,long> a,pair<long,long> b) {return a.second < b.second;});
	
	/*
	for(int i=0;i<n;i++){
		cout << vp[i].first << " " << vp[i].second << endl;
	}
	*/
	
	for(int now=0;now<n;now++){
		if(start>vp[now].first)continue;
		cnt++;
		start=vp[now].second;
	}	
	
	cout << cnt << endl;
	
	return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;

int N;
vector<pii> P;

bool cmp(pii a, pii b) {
    return a.first + a.second < b.first + b.second;
}

ll dp[2][5002];

int main() {
    scanf("%d", &N);

    P.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &P[i].first, &P[i].second);
    }

    sort(P.begin(), P.end(), cmp);

    for(int i = 0; i < 5002; i++) dp[1][i] = 1e18;
    dp[1][0] = 0;
    for(int i = 0; i < N; i++) {
        dp[i&1][0] = 0;
        for(int j = 1; j <= N; j++) {
            dp[i&1][j] = 1e18;
            dp[i&1][j] = min(dp[i&1][j], dp[(i&1) ^ 1][j]);
            dp[i&1][j] = min(dp[i&1][j], dp[(i&1) ^ 1][j - 1] <= P[i].first? dp[(i&1) ^ 1][j - 1] + P[i].second : (ll)1e18);
        }
    }
    int ans = 0;
    for(int i = 0; i <= N; i++) if(dp[(N - 1) & 1][i] != 1e18) ans = i;
    printf("%d", ans);
}


Measured memory_bytes: 384
from collections import Counter
from itertools import combinations
import numpy as np

# 引用元
# https://note.nkmk.me/python-prime-factorization/
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def get_list(counter, index):
    ans = []
    for key, val in sorted(counter.items()):
        if val >= index:
            ans.append(key)
    return ans

def choice_min_data(counter, min_num):
    temp = sum(counter.values())
    temp_min_num = 10**12
    co_index = None
    for index in range(1, temp+1):
        # flag = False
        exp_list = get_list(counter, index)
        # print(exp_list)
        if not exp_list:
            break
        for ex in exp_list:
            ex_2 = ex ** index
            if temp_min_num > ex_2 > min_num:
                co_index = [ex, index]
                temp_min_num = ex_2
                # flag = True
                break

        # 最小を新たに更新せず = 終了
        # if co_index is not None and flag == False:
        #     break

    if co_index is None:
        return None, -1
    else:
        # print(co_index, temp_min_num)
        counter[co_index[0]] -= co_index[1]
        return counter, temp_min_num

def main():
    # ルール
    # 素数p, 整数e: z == p ** e
    # N / z = int(x)
    # zは被らない
    # N を N/zに置き換える
    N = int(input())

    if N <= 1:
        print(0)
        return

    counter = Counter(prime_factorize(N))
    # print(counter)
    ans = 0
    min_num = 0
    while counter is not None:
        counter, min_num = choice_min_data(counter, min_num)
        if min_num == -1:
            break
        ans += 1
    
    print(ans)

if __name__ == "__main__":
    main()


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

typedef struct choice
{
	int x;
	struct choice *next;
}Choice;


void generate(Choice **head)
{
	for (int i = 0; i < 3; ++i)
	{
	Choice *node = (Choice *) malloc(sizeof(Choice));
	node->x = i+1;
	node->next = NULL;

	if (*head == NULL){
		*head = node;
	}

	else{
		Choice *p = *head;
		while(p->next != NULL)
		{
			p = p->next;
		}
		p->next = node;
	}

	}
}

void delete(Choice **head, int x)
{
	Choice *p = *head;
	Choice *pre = *head;
	if (p == NULL)
	{
		return;
	}

	if (p->x == x)
	{
		*head = p->next;
		free(p);
	}

	else{
		while(p != NULL)
	{
		if(p->x == x)
		{
			pre->next = p->next;
			free(p);
			break;
		}
		pre = p;
		p = p->next;
	}
	}
	
}

void print(Choice *head)
{
	Choice *p = head;
	while(p != NULL)
	{
		printf("%d", p->x);
		p = p->next;
	}
}

int main(int argc, char const *argv[])
{
	Choice *head = NULL;
	generate(&head);
	// print(head);

	int A,B;

	// printf("\n");
	scanf("%d", &A);
	scanf("%d", &B);

	delete(&head,A);
	delete(&head,B);

	printf("%d\n",head->x);
 	
	return 0;
}

Measured memory_bytes: 128
def solution1():

    # 入力
    n = int(input())
    s = [int(i) for i in input()]
    cnt = 0
    for c in range(1000):
        # 100の桁、１０の桁、１の桁に分解
        candidate = [c//100, (c//10)%10, c%10]
        f = -1
        for j in range(n):
            if s[j] == candidate[f]:
                f += 1
            if f == 2:
                break
        if f == 2:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    solution1()

Measured memory_bytes: 40560
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int n;
int main()
{
	re(n);
	for(int nx=0,ny=0,t,x,y;n--;)
	{
		re(t),re(x),re(y);
		int w=abs(x-nx)+abs(y-ny);
		if(t<w || (t+w)&1)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

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

using namespace std;

int mp[110][110],w,h,n,x,y,te,ans;

int main()
{
	scanf("%d%d%d",&w,&h,&n);
	while(n--)
	{
		scanf("%d%d%d",&x,&y,&te);
		if(te==1)
		{
			for(int i=0; i<x; i++)
			{
				for(int j=0; j<h; j++)mp[i][j]=1;
			}
		}
		else if(te==2)
		{
			for(int i=x; i<w; i++)
			{
				for(int j=0; j<h; j++)mp[i][j]=1;
			}
		}
		else if(te==3)
		{
			for(int i=0; i<w; i++)
			{
				for(int j=0; j<y; j++)mp[i][j]=1;
			}
		}
		else if(te==4)
		{
			for(int i=0; i<w; i++)
			{
				for(int j=y; j<h; j++)mp[i][j]=1;
			}
		}
	}
	for(int i=0; i<w; i++)for(int j=0; j<h; j++)ans+=!mp[i][j];
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
 
int main(){
	
  	int A,B;	
  
	cin >> A;
  	cin >> B;
  
  	if(A>B){
    	if((A-B)%2==0){
          cout<<(A-B)/2+B;
        }else{
          cout<<"IMPOSSIBLE";
        }      
    }else if(A<B){
    	if((B-A)%2==0){
          cout<<(B-A)/2+A;
        }else{
          cout<<"IMPOSSIBLE";
        }    
    }
  
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    lint n, k;

    scanf("%lld", &n);
    scanf("%lld", &k);

    std::vector<lint> x(n);

    for (int i = 0; i < n; ++i)
    {
        lint x_e;
        scanf("%lld", &x_e);
        x[i] = x_e;
    }

    auto zero = std::lower_bound(x.begin(), x.end(), 0);

    lint neg_num = zero - x.begin();
    lint pos_num = x.end() - zero;

    std::vector<lint> dist_pos, dist_neg;
    dist_pos.push_back(0);
    dist_neg.push_back(0);

    for (auto iter = zero; iter != x.end(); iter++)
    {
        dist_pos.push_back(*iter);
    }

    for (auto iter = zero - 1; iter != x.begin() - 1; iter--)
    {
        dist_neg.push_back(-1 * *iter);
    }

    lint min = -1;

    for (int i = 0; i <= k; ++i)
    {
        if (i > neg_num)
            break;
        if (k - i > pos_num)
            continue;
        lint cand = std::min(2 * dist_pos[k - i] + dist_neg[i],
                             dist_pos[k - i] + 2 * dist_neg[i]);
        if (min < 0)
            min = cand;
        else
            min = std::min(min, cand);
    }

    printf("%lld", min);

    return 0;
}


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

int main(void)
{
    IOS
    int n; cin >> n;
    double ans;
    ans =  (double)((n+1) / 2) / n;
    std::cout << std::fixed;
    std::cout << std::setprecision(8) << ans << endl; 

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3
# -*- coding: UTF-8 -*-

n,k=map(int,input().split())
d={}
l=[]
for i in range(n):
    u,v=map(int,input().split())
    if u in d:
        d[u]+=v
    else:
        d[u]=v
        l.append(u)
l.sort()
for i in l:
    k-=d[i]
    if k<=0:
        print(i)
        break

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

int main() {

  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    char c; cin >> c;
    if (c == 'Y') {
      cout << "Four\n";
      return 0;
    }
  }
  cout << "Three\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> v(3);
    REP(i,3) cin >> v[i];
    sort(ALL(v));
    ll ans = (v[0]%2==0 || v[1]%2==0 || v[2]%2==0 ? 0 : v[0]*v[1]);
    cout << ans << endl;
    return 0;
}

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

int main(){

    int n; scanf("%d",&n);

    list<int> l;
    auto idx = l.end();

    for (int i = 0; i < n; i++)
    {
        int b; scanf("%d",&b);
        if(b == 0){
            int c; scanf("%d",&c);
            idx = l.insert(idx,c);
        }
        else if(b == 1){
            int c; scanf("%d",&c);
            for (int j = 0; j< abs(c); j++)
            {
                if(c>0) ++idx;
                else    --idx;
            }
        }
        else{
            idx = l.erase(idx);
        }
    }
    for (auto ele: l){
        printf("%d\n",ele);
    }
    
    

}


Measured memory_bytes: 18756
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k = map(int, input().split())
    if n == 1:
        print(k)
        sys.exit()
    r = k
    r *= pow(k - 1, n - 1)
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9096
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

k = int(readline())
a, b = map(int, readline().split())
for i in range(a, b + 1):
    if i % k == 0:
        print('OK')
        exit()
print('NG')


Measured memory_bytes: 61612
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int x;
  	cin>>x;
	if (x < 1200){
		cout << "ABC" << endl;
	}
	else{
		cout << "ARC" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
ll p[10000005];
const int mn=1000005;
void pre(ll n) {
    p[0] = 0; p[1] = 1;
    if(p[2] != 0) return;
    for(ll i = 2; i <= n; i += 1) {
        if(p[i] == 0) {
            p[i] = 2;
            for(ll j = i+i; j <= n; j += i) {
                if(p[j] == 0) p[j] = 1;
                ll tmp = j;
                ll cnt = 0;
                while(tmp % i == 0) {
                    cnt += 1;
                    tmp /= i;
                }
                p[j] *= (cnt + 1);
            }
        }
    }
   
}

//ll least_prime[10000005]; 

int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while ( t--)  
{
 ll n;
 cin>>n;
 pre(n);
 ll ans=0;
 for(ll i=0;i<=n;i++)
 {
     ans+=i*p[i];
 }
 cout<<ans<<"\n";
}

 return 0;
}

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

using namespace std;

int main()
{
    long long int a, b, c, d, jav = 0;
    cin >> a >> b >> c >> d;
    long long int a100 = 0, a200 = 0;

    a100 = min(4 * a, min (2 * b, c));
    a200 = min(8 * a, min (4 * b, min(2 * c, d)));

    int n;
    cin >> n;

    jav += a200 * (n / 2);
    jav += a100 * (n % 2);

    cout << jav << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d;
    for (int i=0; i<N; i++) {
        int input;
        cin >> input;
        d.push_back(input);
    }

    sort(d.begin(), d.end());

    cout << d[N/2] - d[N/2-1] << endl;

    return 0;
}


Measured memory_bytes: 892
f = open(0)
R, C = map(int, f.readline().split())
ans = [0]*(C+1)
res = []
for line in f.readlines():
    *D, = map(int, line.split())
    for i, v in enumerate(D):
        ans[i] += v
    s = sum(D)
    ans[-1] += s
    res.append(line.strip())
    res.append(" %d\n" % s)
res.append(" ".join(map(str, ans)))
res.append("\n")
open(1, 'w').writelines(res)


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

int main(){
  int n,a,b,c,d; cin >>n >>a >>b >>c >>d;
  string s; cin >>s;
  s = "#"+s+"#";
  for(int i = a; i<c; i++){
    if(s[i]=='#' && s[i+1]=='#') {
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = b; i<d; i++){
    if(s[i]=='#' && s[i+1]=='#') {
      cout << "No" << endl;
      return 0;
    }
  }
  if(c<d) {
    cout << "Yes" << endl;
    return 0;
  }
  for(int i = b; i<=d; i++){
    if(s[i]=='.' && s[i-1]=='.' && s[i+1]=='.'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3860
def readinput():
    a,b,c,d=map(int,input().split())
    return a,b,c,d

def main(a,b,c,d):
    while True:
        c-=b
        if c<=0:
            return 'Yes'
        a-=d
        if a<=0:
            return 'No'


if __name__=='__main__':
    a,b,c,d=readinput()
    ans=main(a,b,c,d)
    print(ans)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
typedef  long long int lli;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inf (1000*1000*1000+5)
const int NODE =1e4+9;

const int mod=1e9+7;
const lli num=2000000;

void init(){

}


int main()
{
   boost;
   int t=1;
   //cin>>t;
   init();
   while(t--){
      int n,k;
      cin>>n>>k;
      int a[n];
      for(int i=0;i<n;i++)cin>>a[i];
      lli dp[n];
      memset(dp,inf,sizeof(dp));
      dp[0]=0;
      for(int i=0;i<n;i++){
         for(int j=1;j<=k;j++){
             if(i-j<0)break;
             dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
         }
      }
      cout<<dp[n-1]<<endl;
   }
   return 0;
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n,m; cin >> n >> m;

  if(abs(n-m) >= 2) {
    cout << "0\n";
    return 0;
  }

  lint ans=1;
  if(n == m) { ans = ((P(n,n)*P(m,m)%1000000007)*2)%1000000007; }
  else { ans = (P(n,n)*P(m,m))%1000000007; }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define ll long long
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<endl;
#define trace(a) cout<<#a<<": "<<a<< endl
#define int ll
int a[N];
signed main() {
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int i,j,k,l,m,n,t;
	cin >> n;
	set<pair<double,int>> se;
	for(i = 1;i < 10;i++) {
		int val = i;
		int sum = 0;
		while(val) {
			sum += val%10;
			val /= 10;
		}
		double an = i;
		an /= sum;
		se.insert({an,i});
	}
	int ma = 0;
	// for(auto it : se) {
	// 	if(it.second > ma)
	// 		cout << it.second << endl;
	// 	ma = max(ma,it.second);
	// }
	vector<int> v;
	int val = 9;
	for(int iter = 0;iter < 16;iter++) {
		for(i = 1;i <= 1000;i++) {
			// cout << i*(val+1) + val << endl;
			int val2 = i*(val+1) + val;
			int sum = 0;
			while(val2) {
				sum += val2%10;
				val2 /= 10;
			}
			double an = i*(val+1) + val;
			an /= sum;
			se.insert({an,i*(val+1) + val});
		}
		val *= 10;
		val += 9;
	}
	ma = 0;
	int cnt = 0;
	for(auto it : se) {
		if(cnt == n) break;
		if(it.second > ma) {
			cnt++;
			cout << it.second << endl;
		}
		ma = max(ma,it.second);
		// trace(ma);
	}
}

Measured memory_bytes: 1152
from fractions import gcd

n = int(input())
a_list = [int(i) for i in input().split()]

l_list = [a_list[i] for i in range(n)]
r_list = [a_list[i] for i in range(n)]
r_list.reverse()

for i in range(1, n):
    l_list[i] = gcd(a_list[i], l_list[i-1])
for i in range(1, n):
    r_list[i] = gcd(r_list[i-1], a_list[n-i-1])

gcd_list = [0]
if n > 2:
    gcd_list = [gcd(l_list[i-1], r_list[n-i-2]) for i in range(1, n-1)]
gcd_0 = r_list[n-2]
gcd_n = l_list[n-2]
ans = max(max(max(gcd_list), gcd_0), gcd_n)
print(ans)

Measured memory_bytes: 16144
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 1000000007;
#define int ll
int n;
pi a[10];
double ans;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n; i++){
		cin>>a[i].x>>a[i].y;
	}
	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			ans+=2*(double)sqrt(double((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)))/n;
		}
	}
	cout<<fixed<<setprecision(7)<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib> 

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int N, M;
    std::cin >> N >> M;
    
    int *a, *b, *c, *d;
    a = new int[N];
    b = new int[N];
    c = new int[M];
    d = new int[M];
    
    for(int i = 0; i < N; i++){
        std::cin >> a[i] >> b[i];
    }
    
    for(int j = 0; j < M; j++){
        std::cin >> c[j] >> d[j];
    }
    
    for(int i = 0; i < N; i++){
        int index = 0;
        long mind = abs(c[0] - a[i]) + abs(d[0] - b[i]);
        for(int j = 1; j < M; j++){
            long distance = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if(distance < mind){
                index = j;
                mind = distance;
            }
        }
        std::cout << index + 1 << "\n";
    }
}


Measured memory_bytes: 256
#include <cstdio>

long long A[100010], B[100010];

int main(){
  int N; scanf("%d", &N);
  for(int i = 1; i <= N; i++) scanf("%lld%lld", &A[i], &B[i]);

  long long ans = 0;

  for(int i = N; i >= 1; i--){
    long long a = A[i] + ans;

    long long v = a % B[i];
    if(v == 0) continue;

    ans += B[i] - v;
  }

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


Measured memory_bytes: 1792
N,M=map(int,input().split())
List = []
for i in range(M):
  L=list(map(int,input().split()))
  List.append(L)

on = list(map(int,input().split()))
  
n = N
anscnt = 0
arr = [0 for i in range(N+1)]

for i in range(2 ** n):
  arr = [0 for i in range(N+1)]
  for j in range(n):  # このループが一番のポイント
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      arr[j+1] = 1
  ok = 1

  for k in range(M):
    a = List[k][0]
    cnt = 0
    for l in range(1,a+1):
      if arr[ List[k][l] ] == 1:
        cnt += 1
    if cnt%2 == on[k]:
      continue
    else:
      ok = 0
  if ok == 1:
    anscnt += 1
      
print(int(anscnt))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000
#define N5 100007
#define ll long long int
int A,B;
string S,T,U;
ll w[N5],v[N5],dp[101][N5];

int main()
{

	cin >>S >> T >> A >> B >> U;
	if(U == S){
		cout << A-1 << " " << B;
	}else{
		cout << A << " "<< B-1;
	}


}



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

// 入力
int H, W;
vector<vector<int>> field(H, vector<int>(W, 0));

// 探索
void dfs(int h, int w)
{
    field[h][w] = 0;

    // 八方向を探索
    for (int dh = -1; dh <= 1; ++dh)
    {
        for (int dw = -1; dw <= 1; ++dw)
        {
            int nh = h + dh, nw = w + dw;

            // 場外アウトしたり、0 だったりはスルー
            if (nh < 0 || nh >= H || nw < 0 || nw >= W)
                continue;
            if (field[nh][nw] == 0)
                continue;

            // 再帰的に探索
            dfs(nh, nw);
        }
    }
}

int main()
{
    // 入力受け取り
    while (cin >> W >> H)
    {
        if (H == 0 || W == 0)
            break;
        field.assign(H, vector<int>(W, 0));
        for (int h = 0; h < H; ++h)
            for (int w = 0; w < W; ++w)
                cin >> field[h][w];

        // 探索開始
        int count = 0;
        for (int h = 0; h < H; ++h)
        {
            for (int w = 0; w < W; ++w)
            {
                if (field[h][w] == 0)
                    continue; // 残島じゃなかったらスルー
                dfs(h, w);
                ++count;
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,h,w,a,b,c,d;
string str;

signed main(){

  char gl;
  cin >> gl;
  switch(gl){
  case 'a':
  case 'i':
  case 'u':
  case 'e':
  case 'o':
    cout <<"vowel\n";
    break;
  default :
    cout <<"consonant\n";
  }
                         
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	char dif = 'A' - 'a';
	cout << (char)(s1[0] + dif) << (char)(s2[0] + dif) << (char)(s3[0] + dif) << endl;
	return 0;
}

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

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vector<pii> cb(m);
    REP(i,m) {
        cin >> cb[i].second >> cb[i].first;
    }
    sort(ALL(a));
    sort(RALL(cb));
    int i = 0, j = 0;
    ll ans = 0;
    while(j < m) {
        REP(k,cb[j].second) {
            if (i >= n || cb[j].first <= a[i]) {
                j = m;
                break;
            }
            ans += cb[j].first;
            i++;
        }
        j++;
    }

    ans = accumulate(a.begin()+i,a.end(),ans);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,x[11][11],ans=0,a;
	int sum = 0;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>x[i][j];
		}
	}
	for(int c=0;c<n;c++)
	{
		for(int e=c+1;e<n;e++)
		{
			sum = 0;
			for(int f=0;f<d;f++)
			{
				sum+=(x[c][f]-x[e][f])*(x[c][f]-x[e][f]);
			}
			a=floor(sqrt(sum)+0.5);
			if(a*a==sum)
			{
				ans++;
			}
		}
	} 
	cout<<ans;
	return 0;
}

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

int main(){

    int N, W; cin >> N >> W;
    vector<int> w(N);
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }

    vector<vector<int> > dp(N + 1, vector<int> (W + 1, 0));

    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){

            //tale
            if(j + w[i] <= W) dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);

            //no
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;

}


Measured memory_bytes: 6832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = int(a); i <= int(b); i++)
int n;
int L[105];
bool Check(int x, int y, int z) {
	int a[3];a[0] = x, a[1] = y, a[2] = z;
	sort(a, a + 3);
	if(a[0] + a[1] > a[2])return 1;
	return 0;
}
bool Dif(int x, int y, int z) {
	return x != y && x != z && y != z;
}
int main() {
	cin >> n;
	int Ans = 0;
	rep(i, 1, n)cin >> L[i];
	rep(i, 1, n) {
		rep(j ,i + 1, n) {
			rep(k, j + 1, n) {
				if(Dif(L[i], L[j], L[k]) && Check(L[i], L[j], L[k])) {
					++Ans;
//					cout << i << ' ' << j << ' ' << k << '\n';
				}
			}
		}
	}
	cout << Ans << endl;
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

constexpr ll INF = TEN(18);
const int MX = 3010;

ll dp[MX][MX][4];
ll v[MX][MX];

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    rep(i, K) {
        int r, c, val;
        cin >> r >> c >> val;
        --r, --c;
        v[r][c] = val;
    }

    rep(i, MX) rep(j, MX) rep(k, 4) dp[i][j][k] = -INF;
    dp[0][0][0] = 0;

    rep(i, R) {
        rep(j, C) {
            for (int k = 2; k >= 0; --k) {
                if (dp[i][j][k] >= 0) {
                    chmax(dp[i][j][k + 1], dp[i][j][k] + v[i][j]);
                }
            }
            rep(k, 4) {
                if (dp[i][j][k] >= 0) {
                    if (i + 1 < R) {
                        chmax(dp[i + 1][j][0], dp[i][j][k]);
                    }
                    if (j + 1 < C) {
                        chmax(dp[i][j + 1][k], dp[i][j][k]);
                    }
                }
            }
        }
    }

    ll ans = -INF;
    rep(k, 4) chmax(ans, dp[R - 1][C - 1][k]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 357192
M,D = map(int,input().split())
count = 0
for m in range(1,M+1):
  for d in range(20,D+1):
    d_10 = d//10
    d_1 = d-10*d_10
    if d_10>=2 and d_1>=2 and d_10*d_1 == m:
      count += 1
print(count)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	int n,m;
	void solve(){
		scanf("%d%d",&n,&m);
		for(int i=1;i<=m;++i){
			int ai;
			scanf("%d",&ai);
			n-=ai;
		}
		if(n>=0)printf("%d",n);
		else printf("-1"); 
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

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

main() {
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  bool ans = false;
  ll X = B - A;
  rep(i, N) {
    ll minX = (N - 1 - i) * C - i * D;
    ll maxX = (N - 1 - i) * D - i * C;
    if (minX <= X && X <= maxX) {
      ans = true;
      break;
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

char s[100001];

int main() {
    int n, c = 1, i, j;
    vector <int> v;
    vector <pair<int, int>> w;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    if (s[0] != '1' || s[n - 1] != '0') {
        puts("-1");
        
        return 0;
    }
    
    for (i = 0; i < n - 1; i++) {
        if (s[i] != s[n - i - 2]) {
            puts("-1");
            
            return 0;
        }
        
        if (s[i] == '1') v.push_back(i + 1);
    }
    
    w.push_back(make_pair(0, 1));
    
    for (i = 0; i + 1 < v.size(); i++) {
        int x = v[i + 1] - v[i];
        
        for (j = 0; j < x; j++) w.push_back(make_pair(c, c + j + 1));
        
        c += x;
    }
    
    for (i = 0; i < w.size(); i++) printf("%d %d\n", w[i].first + 1, w[i].second + 1);
    
    return 0;
}


Measured memory_bytes: 2804