akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// graph template
template<typename T>
class Edge{
    public:
        int src, to; T cost;

        Edge(int to, T cost): src(-1), to(to), cost(cost){}
        Edge(int src, int to, T cost): src(src), to(to), cost(cost){}
};
template<typename T>
using Edges = vector<Edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

vector<int> color(100000, -1);
vector<vector<int>> G(100000);

bool dfs(int v){
    for(int next: G[v]){
        if(color[v] == color[next]){
            return false;
        }else if(color[v] == (color[next]^1)){
            continue;
        }else if(color[next] == -1){
            color[next] = (color[v]^1);
            if(dfs(next) == false) return false;
        }
    }
    return true;
}

int main(void){
    int N, M;
    cin >> N >> M;
    
    Edges<int> es;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        es.emplace_back(Edge<int>(a, b, 1));
    }

    ll res = 0;
    color[0] = 0;
    if(dfs(0)){
        ll b = 0, w = 0;
        for(int i = 0; i < N; i++){
            if(color[i] == 0) w++;
            else if(color[i] == 1) b++;
        }
        res = w * b;
        res -= M;
      }else{
        res = (ll)N * (N - 1) / 2;
        res -= M;
    }

    cout << res << '\n';

    return 0;
}

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

int main(){
	int a,b,c;
	char op;
	
	while(1){
		scanf("%d%s%d",&a,&op,&b);
		if( op == '+' ){
			c=a+b;
		}else if( op == '-' ){
			c=a-b;
		}else if( op == '*' ){
			c=a*b;
		}else if( op == '/' ){
			c=a/b;
		}else if( op == '?' ){
			break;
		}

		cout << c << "\n";

	}
	
	
	return 0;
	
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    cout << t+s << endl;
    return 0;
}

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

#define USE_SET 0
#define USE_BUCKET 1 - USE_SET

using namespace std;

int main(){
  int N, M;
  int a[51] = {};
  int b[51] = {};

  cin >> N; cin >> M;
  for(int i = 0; i < M; i++){
    cin >> a[i]; cin >> b[i];
  }

  int roads[55] = {};

  if(USE_BUCKET){
    int i, j;

    for(i = 0; i < M; i++){
      roads[a[i]] ++;
      roads[b[i]] ++;

    }
    //cout << "result" << endl;                                        
    for(i = 1; i <= N; i++){
      cout << roads[i] << endl;
    }
  }
	
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    int mx = -1001001001;
    int mn = 1001001001;
    int mxi, mni;
    rep(i, n){
        if(mx < a[i]){
            mx = a[i];
            mxi = i;
        }
        if(mn > a[i]){
            mn = min(mn, a[i]);
            mni = i;
        }
    }

    if(mn >= 0){
        cout << n - 1 << endl;
        rep(i, n - 1){
            cout << i+1 << ' ' << i+2 << endl;
        }
    }else if(mx <= 0){
        cout << n - 1 << endl;
        rep(i, n - 1){
            cout << n-i << ' ' << n-1-i << endl;
        }
    }else if(mx >= -mn){
        cout << 2 * n - 1 << endl;
        rep(i, n)cout << mxi+1 << ' ' << i+1 << endl;
        rep(i, n - 1)cout << i+1 << ' ' << i+2 << endl;
    }else{
        cout << 2 * n - 1 << endl;
        rep(i, n)cout << mni+1 << ' ' << i+1 << endl;
        rep(i, n - 1)cout << n-i << ' ' << n-1-i << endl;
    }
    
}

Measured memory_bytes: 256
from sys import stdin

S = input()
T = input()

ans  =10000
# 全探索を実施
for i in range(len(S) - len(T) + 1):
    # 不一致だった文字数
    mat = 0
    # i番目からTの長さ分の文字列が入る
    U = S[i:i + len(T)]
    for j in range(len(T)):
        # 一文字ずつアンマッチかを確認する
        if U[j] != T[j]:
            mat += 1
    # 小さいほうが入る
    ans = min(ans, mat)

print(ans)

Measured memory_bytes: 9036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 200005;
int n, a, b, q, p[MX], ans[MX];
vector<int> G[MX];
bool used[MX];
void dfs(int v, int x){
	used[v] = true;
	x += p[v];
	ans[v] = x;
	for(int t: G[v]) if(!used[t]) dfs(t, x);
}

int main(){
	scanf("%d%d", &n, &q);
	rep(i,n-1){
		scanf("%d%d", &a, &b);a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i,q){
		scanf("%d%d", &a, &b); a--;
		p[a] += b;
	}
	dfs(0,0);
	rep(i,n) printf("%d%c", ans[i], i == n-1 ? '\n' : ' ');
}

Measured memory_bytes: 21120
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

double dfs(int v, int s, vector<ll> &x, vector<ll> &y){
	int n = x.size();
	int k = 0;
	for(int i=0; i<n; i++) if((s>>i)&1) k++;
	ll f = 1;
	for(int i=0; i<n-k-1; i++) f*=i+1;
	double ret = 0;
	for(int i=0; i<n; i++){
		if((s>>i)&1) continue;
		ret += dfs(i, s|(1<<i), x, y);
		ret += f*sqrt((x[v]-x[i])*(x[v]-x[i])+(y[v]-y[i])*(y[v]-y[i]));
	}
	return ret;
}

int main() {
	long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }

	double sum = 0;
	ll fact = 1;
	for(int i=0; i<N; i++){
		sum += dfs(i, 1<<i, x, y);
		fact *= i+1;
	}
	cout << setprecision(20) << sum/fact << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    combination c(2010);
    for (int i = 1; i <= k; ++i) {
        mint ans = c(n-k+1, i) * c(k-1, i-1);
        cout << ans << endl;
    }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int n;
int p[100000];
int cnt=0;

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

	cin>>n;
	REP(i,n) cin>>p[i];
	REP(i,n-1) {
		if(p[i]==i+1) {
			swap(p[i],p[i+1]);
			cnt++;
		}
	}
	if(p[n-1]==n) cnt++;
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    int n, d;
    cin >> n >> d;
    vi x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    int ans = 0;

    rep(i, n){
        if(sqrt(x[i]*x[i] + y[i]*y[i]) <= d) ans++; 
    }

    cout << ans << endl;
}

Measured memory_bytes: 6484
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var answer = 0;

			for (var i = 1; i <= n; i += 2)
			{
				var count = 0;

				for (var j = 1; j <= i; j++)
				{
					if (i % j == 0)
					{
						count++;
					}
					if(count == 9)
					{
						break;
					}
				}

				if (count == 8)
				{
					answer++;
				}
			}
			
			Console.WriteLine(answer);
		}
	}
}


Measured memory_bytes: 13140
// AOJ Volume 1 Problem 0109

#include <stdio.h>
#include <string.h>

int expression(char **form);
int term(char **form);
int factor(char **form);

int main(void)
{
	char formula[101];
	int n;
	int i;
	char *p;
	int result;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%s", formula);

		p = formula;
		result = expression(&p);
		printf("%d\n", result);
	}
	
	return (0);
}

int expression(char **form)
{
	int result;

	result = term(form);
	
	while (1){
		if (**form == '+'){
			(*form)++;
			result += term(form);
		}
		else if (**form == '-'){
			(*form)++;
			result -= term(form);
		}
		else if (**form == '='){
			(*form)++;
			break;
		}
		else {
			break;
		}
	}

	return (result);
}

int term(char **form)
{
	int result;
	

	result = factor(form);
	
	while (1){
		if (**form == '*'){
			(*form)++;
			result *= factor(form);
		}
		else if (**form == '/'){
			(*form)++;
			result /= factor(form);
		}
		else {
			break;
		}
	}
	return (result);
}

int factor(char **form)
{
	int result;
	
	if (**form == '('){
		(*form)++;
		result = expression(form);
		(*form)++;		// skip ')'
	}
	else {
		result = 0;
		while ('0' <= **form && **form <= '9'){
			result = result * 10 + **form - '0';
			(*form)++;
		}
	}
	
	return (result);
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    ll ans = 0;
    pair<ll, int> P[N];
    rep(i, N){
        cin >> P[i].first >> P[i].second;
    }
    sort(P, P+N);
    int rem = M;
    rep(i, N){
        if(rem < P[i].second){
            ans += P[i].first*rem;
            break;
        }
        else{
            rem -= P[i].second;
            ans += P[i].first*P[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
<?php
  list($N) = explode(" ", trim(fgets(STDIN)));

  $A = explode(" ", trim(fgets(STDIN)));

  $mCount = 0;
  $mSum = 0;
  $absMin = PHP_INT_MAX;
  for($i=0; $i<$N; $i++){
    if($A[$i] < 0){
        $mCount++;
    }
    $mSum += abs($A[$i]);
    $absMin = min($absMin, abs($A[$i]));
  }

  if($mCount % 2 == 0){
    echo $mSum;
  }else{
    echo $mSum - 2* $absMin;
  }

Measured memory_bytes: 24172
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        
        int plus = A + B;
        int minus = A - B;
        int kake = A * B;
        
        
        int max = Math.max(plus, minus);
        max = Math.max(max, kake);
        
        
        System.out.println(max);
        
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 110;
const int maxv = 100100;
ll dp[maxn][maxv], n, w;
ll weight[maxn], value[maxn];

ll recursion(ll i, ll j) {
    if(i == 0 && j != 0) return (1LL << 45);
    if(j == 0) return 0LL;
    if(dp[i][j] != -1) return dp[i][j];

    dp[i][j] = recursion(i-1, j);
    if(j - value[i] >= 0) {
        dp[i][j] = min(dp[i][j], recursion(i-1, j-value[i]) + weight[i]);
    }
    return dp[i][j];
}

int main() {
    cin>>n>>w;
    int sumv = 0;
    for(int i=1;i<=n;i++) {
        cin>>weight[i]>>value[i];
        sumv += value[i];
    }
    memset(dp,-1,sizeof(dp));
    // dp[i][j] - select some number of items from the first i items with value j such that their weight is minimized
    ll result = 0LL;
    for(int i=0;i<=sumv;i++) {
        recursion(n, i);
        if(dp[n][i] != LLONG_MAX && dp[n][i] <= w) result = i;
    }
    cout<<result<<"\n";
    return 0;
}


Measured memory_bytes: 86272
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

bool grid[109][109];
bool need1[109];
bool need2[109];

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

	int H, W; cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char tmp; cin >> tmp;
			if (tmp == '.') grid[i][j] = true;
		}
	}

	for(int i = 0; i < H; i++) {
		bool need = false;
		for (int j = 0; j < W && !need; j++) {
			if (!grid[i][j]) need = true;
		}
		if (need) need1[i] = true;
	}
	for (int j = 0; j < W; j++) {
		bool need = false;
		for (int i = 0; i < H && !need; i++) {
			if (!grid[i][j]) need = true;
		}
		if (need) need2[j] = true;
	}

	for (int i = 0; i < H; i++) {
		if (need1[i]) {
			for (int j = 0; j < W; j++) {
				if (need2[j]) {
					if (grid[i][j]) cout << ".";
					else cout << "#";
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
	int x, y;
	
	 while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		if(x<=y) 
			printf("%d %d\n",x,y);
	  	else
			printf("%d %d\n",y,x);
	}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++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 FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}


int main()
{
	int n;
	vector<deque<int>> a(1000);
	cin >> n;
	REP(i, n) {
		REP(j, n - 1) {
			int b;
			cin >> b;
			a[i].push_back(--b);
		}
	}
	//*
	int cnt = 0;
	int preCnt = 0;
	int dayCnt[1000] = { 0 };
	int sCnt[1000] = { 0 };
	while (cnt < n*(n - 1) / 2) {
		//cout << cnt << endl;
		REP(i, n) {
			while (sCnt[i]<n-1) {
				int from = i;
				int to = a[i].front();
				if (a[to].front()==from) {
					int day = max(dayCnt[from], dayCnt[to]) + 1;
					sCnt[from]++; sCnt[to]++;
					dayCnt[from] = day; dayCnt[to] = day;
					a[from].pop_front(); a[to].pop_front();
					cnt++;
					continue;
				}
				break;
			}
		}
		if (preCnt == cnt) {
			cout << -1 << endl;
			return 0;
		}
		preCnt = cnt;
		//cout << "fin" << endl;
	}
	int ans = 0;
	REP(i, n) {
		chmax(ans, dayCnt[i]);
	}
	cout << ans << endl;
	//*/
}

Measured memory_bytes: 4736
S = input()
if (S == 'SSS'):
  print(0)
if (S == 'SSR'):
  print(1)
if (S == 'SRS'):
  print(1)
if (S == 'SRR'):
	print(2)
if (S == 'RSS'):
  print(1)
if (S == 'RSR'):
  print(1)
if (S == 'RRS'):
  print(2)
if (S == 'RRR'):
  print(3)
 

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5, MAXLOG = 19;

int x[MAXN];
int ind_l[MAXN][MAXLOG], ind_r[MAXN][MAXLOG];

vi vv;

int dp_l[1 << MAXLOG], dp_r[1 << MAXLOG];

int dp_seg[MAXN];

void solve(){
	int n, v;
	scanf("%d%d", &n, &v);
	REP(i, 0, n) {
		scanf("%d", &x[i]);
	}
	
	for(; v; v /= 2) {
		vv.pb(v);
	}
	vv.pb(0);
	reverse(BE(vv));
	int logv = SZ(vv);
	
	REP(j, 0, logv) {
		v = vv[j];
		for(int i = 0; i < n; ) {
			int to;
			for(to = i + 1; to < n && x[to] - x[to - 1] <= v; to++);
			for(int cur = i; cur < to; cur++) {
				ind_l[cur][j] = i;
				ind_r[cur][j] = to - 1;
			}
			i = to;
		}
	}
	
	REP(i, 0, 1 << logv) {
		dp_l[i] = -1;
		dp_r[i] = n;
	}
	
	REP(i, 0, logv) {
		dp_l[1 << i] = ind_r[0][i];
		dp_r[1 << i] = ind_l[n - 1][i];
	}

	REP(i, 1, 1 << logv) {
		int nxt = dp_l[i] + 1;
		REP(j, 0, logv) {
			if (!(i & (1 << j))) {
				if (nxt < n) {
					dp_l[i | (1 << j)] = max(dp_l[i | (1 << j)], ind_r[nxt][j]);
				} else {
					dp_l[i | (1 << j)] = n - 1;
				}
			}
		}
		
		nxt = dp_r[i] - 1;
		REP(j, 0, logv) {
			if (!(i & (1 << j))) {
				if (nxt >= 0) {
					dp_r[i | (1 << j)] = min(dp_r[i | (1 << j)], ind_l[nxt][j]);
				} else {
					dp_r[i | (1 << j)] = 0;
				}
			}
		}
	}
	
	REPN(i, 0, n) {
		dp_seg[i] = n;
	}
	
	REP(i, 1, 1 << (logv - 1)) {
		//printf("%d %d %d\n", i, dp_l[i], dp_r[i]);
		
		int ind = dp_l[i];
		dp_seg[ind] = min(dp_seg[ind], dp_r[(1 << (logv - 1)) - 1 - i]);
	}
	
	for(int i = n - 1; i >= 0; i--) {
		dp_seg[i] = min(dp_seg[i], dp_seg[i + 1]);
		//printf("%d %d\n", i, dp_seg[i]);
	}
	
	REP(i, 0, n) {
		
		int l = ind_l[i][logv - 1], r = ind_r[i][logv - 1];
		//printf("%d %d %d\n", i, l, r);
		if (   l != 0 && r != n - 1 && dp_seg[l - 1] <= r + 1 
			|| l == 0 && r != n - 1 && dp_r[(1 << (logv - 1)) - 1] <= r + 1
			|| l != 0 && r == n - 1 && dp_l[(1 << (logv - 1)) - 1] >= l - 1
			|| l == 0 && r == n - 1) {
			printf("Possible\n");
		} else {
			printf("Impossible\n");
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 37760
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main()
{
	int A,B;

	cin >> A >> B;

	if (((A >= 1) && (A <= 9)) && ((B >= 1) && (B <= 9))) {
		cout << (A * B) << endl;
	}
	else {
		cout << -1 << endl;
	}
	

	return 0;
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))
c4 = 0
c2 = 0

for i in range(N):
    if a[i] % 4 == 0:
        c4 += 1
    elif a[i] % 2 == 0:
        c2 += 1
if c4 * 2 + 1 >= N or c4 * 2 + c2 >= N:
    print("Yes")
else:
    print("No")


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

using namespace std;

void solve(int s) {
  vector<long> a;
  a.emplace_back(s);
  int m = 1;
  while (count(a.cbegin(), a.cend(), a.back()) == 1) {
    if (a.back() % 2)
      a.emplace_back(3 * a.back() + 1);
    else
      a.emplace_back(a.back() / 2);
    m++;
  }
  cout << m << endl;
}

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

  int s;
  cin >> s;
  solve(s);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
};
int main(){
    ll n,m,k;cin>>n>>m>>k;
    mint ans=0;
    combination c(220000);
    rep(i,m){
        ans+=i*(m-i)*n*n;
    }
    rep(i,n){
        ans+=i*(n-i)*m*m;
    }
    ans*=c(n*m-2,k-2);
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 3712
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,i,a[131072],x=1,r=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++){scanf("%d",&a[i]);
        x*=3;
        if(a[i]%2 == 0){r*=2;}
    }
    printf("%d\n",x-r);
    return 0;
}

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

int main() 
{
   int X, A, B;
   cin >> X >> A >> B;

   if (B - A <= 0)
      cout << "delicious" << endl;
   else if (B - A <= X)
      cout << "safe" << endl;
   else
      cout << "dangerous" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            // 一個の電源タップの口の数
            int A = intArray[0];
            // 必要な未使用口の数
            int B = intArray[1];
            int tap = 1;
            int cnt = 0;
            while (B > tap)
            {
                tap += -1 + A;
                cnt++;
            }
            Console.WriteLine(cnt);
        }
    } 
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27980
#include <bits/stdc++.h>
#define NO_SOLUTION { cout << "-1\n"; exit(0); }

using namespace std;

const int Nmax = 707;

int x, y, n, m, i, j, A, B, Sz, color[Nmax];
bool edge[Nmax][Nmax], dp[Nmax];
vector<int> v[Nmax];

void dfs(int node)
{
    if(color[node] == 1) ++A;
        else ++B;

    for(auto it : v[node])
        if(!color[it])
        {
            color[it] = 3 - color[node];
            dfs(it);
        }
        else if(color[it] + color[node] != 3) NO_SOLUTION;
}

void add_to_sol(int x, int y, int Sz)
{
    int i;
    for(i=Sz; i>=0; --i)
        if(dp[i])
        {
            dp[i] = 0;
            dp[min(i+x, Sz-i+y)] = 1;
            dp[min(i+y, Sz-i+x)] = 1;
        }
}

int main()
{
   // freopen("input", "r", stdin);
   // freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for(i=1; i<=m; ++i)
    {
        cin >> x >> y;
        edge[x][y] = edge[y][x] = 1;
    }

    for(i=1; i<=n; ++i)
        for(j=1; j<=n; ++j)
            if(i!=j && !edge[i][j])
                v[i].push_back(j);

    dp[0] = 1;
    for(i=1; i<=n; ++i)
        if(!color[i])
        {
            A = 0; B = 0;
            color[i] = 1;
            dfs(i);
            add_to_sol(A, B, Sz);

            Sz += A + B;
        }

    for(i=n/2; i>=0; --i)
        if(dp[i])
        {
            cout << i*(i-1)/2 + (n-i)*(n-i-1)/2 << '\n';
            return 0;
        }
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(string N){
    if(N[0] == N[2]) cout<<YES<<endl;
    else cout<<NO<<endl;
}

int main(){
    string N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
 
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()
 
ll n, k, m, M = 1e9 + 7;
 
ll gcd(ll a, ll b) {
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int n, a, b;
    cin >> n >> a >> b;

    string s;
    cin >> s;

    int pass = 0, apass = 0;
    rep(i, n) {
        if(s[i] == 'a') {
            if(pass < a + b) {
                cout << "Yes" << endl;
                pass++;
            } else {
                cout << "No" << endl;
            }
        } else if(s[i] == 'b') {
            if(pass < a + b && apass < b) {
                cout << "Yes" << endl;
                pass++;
                apass++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3692
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n=sc.nextInt();

      int s1 = 0;
      int s2 = 0;
      int[] t = new int[n-1];

      int[] w = new int[n];
      for(int i=0;i<n;i++){
        w[i]=sc.nextInt();
      }

      for(int T=0;T<n-1;T++){
        for(int j=0;j<T+1;j++){
          s1 += w[j];
        }
        for(int j=T+1;j<n;j++){
          s2 += w[j];
        }
        t[T] = Math.abs(s1 - s2);
        s1 = 0;
        s2 = 0;
      }

      int ans = t[0];
      for(int j=1;j<n-1;j++){
        if(t[j]<ans){
          ans=t[j];
        }
      }



      System.out.println(ans);

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
	int A,B;
	cin >> A >> B;
	if (A-2*B <= 0)
	{
		cout << 0 << endl;
	}
	else cout << A-2*B << endl;

	return 0;
}

Measured memory_bytes: 384
#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 < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { ll N;
  cin >> N;
  vector<ll> wa(N);
  ll a1;
  cin >> a1;
  wa[0] = a1;
  REP(i, N - 1) { ll an;
    cin >> an;
    wa[i + 1] = wa[i] + an;
  }
  ll mn = 1e17;
  REP(i, N - 1) { ll snuke = wa[i], alyguma = wa[N - 1] - wa[i];
    mn = min(mn, abs(snuke - alyguma));
   }
   cout << mn << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    
    int i;
    int recieve;
    
    i=0;
    
    while(1){
        i++;
        scanf("%d",&recieve);
        if(recieve==0){
           break;
        }
        printf("Case %d: %d\n",i,recieve);
   }
    return 0;
}

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

using namespace std;

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

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

const int MX = 1e5 + 5, MOD = 1000000007;
int n, k;
vvi adj(MX);

ll dfs(int node, int p, int lvl, int choices) {
	ll ret = choices;
	ll nxtChoices = k - 1;
	if (lvl)
		--nxtChoices;
//	db2(node, nxtChoices);
	for (auto& child : adj[node]) {
		if (child != p)
			ret = (ret * dfs(child, node, lvl + 1, nxtChoices--)) % MOD;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n >> k;
	int u, v;
	for (int i = 0; i < n - 1; ++i) {
		cin >> u >> v;
		adj[u].pb(v), adj[v].pb(u);
	}
	cout << dfs(1, 1, 0, k) << '\n';
	return 0;
}


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

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()

#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;

ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

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

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}

void solve()
{
    ll n,m;
    cin>>n>>m;

    ll height[n+1];
    For(i,1,n+1)
        cin>>height[i];

    ll graph[n+1]={0};

    For(i,0,m)
    {
        ll a,b;
        cin>>a>>b;

        graph[a]=max(graph[a],height[b]);
        graph[b]=max(graph[b],height[a]);
    }

    ll ans=0;
    For(i,1,n+1)
    {
        if(graph[i]<height[i])
            ans++;
    }
    cout<<ans<<endl;
}

signed main() 
{
    fast_cin();
    // #ifndef ONLINE_JUDGE
    // freopen("C:/IO/in.txt", "r", stdin);
    // freopen("C:/IO/out.txt", "w", stdout);
    // #endif
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 5212
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main (void)
{
  int a,n;
  in("%d\n%d\n",&n,&a);
  out("%d\n",n*n-a);
  
  return 0;
}


Measured memory_bytes: 128
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<long long> a;
	int k = 0;
	for (int i = 0; i < n; ++i) {
		int buf;
		cin >> buf;
		if (buf % 2 == 0) {
			a.push_back(buf / 2);
			k++;
		}
	}
	while (!a.empty()) {
		vector<long long> b;
		for (auto itr = a.begin(); itr != a.end(); ++itr) {
			if (*itr % 2 == 0) {
				b.push_back(*itr / 2);
				k++;
			}
		}
		a = b;
	}
	cout << k;
}

Measured memory_bytes: 588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
#define MAX_N 100005

//Union-Findtree
struct UF {
	int par[MAX_N];//親
	int Rank[MAX_N];//木の深さ

	//初期化
	void init(int n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			Rank[i] = 0;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;//すでに同じ集合に属している

		if (Rank[x] < Rank[y]) {//高さが小さい方を下に
			par[x] = y;
		}
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;//同じだとrankが変わらないままになるので増やす（それ以外は大きい方のrankが採用される）
		}
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main() {
	int n, m;
	int ans = 0;
	cin >> n >> m;
	vector<int>p(n);
	repp(i, 0, n)cin >> p[i];
	vector<int>x(m), y(m);
	repp(i, 0, m)cin >> x[i] >> y[i];
	UF tree;
	tree.init(n);
	repp(i,0,m)tree.unite(x[i], y[i]);
	repp(i, 0, n) {
		if (tree.same(i + 1, p[i]))++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>
#include <climits>

using namespace std;

long long merge(deque<int>& A, int left, int mid, int right) {
    long long result = 0;
    int n1 = mid - left;
    int n2 = right - mid;

    // L[0...n1], R[0...n2] を生成
    deque<int> L;
    deque<int> R;
    for (int i = 0; i < n1; ++i) {
        L.push_back(A[left + i]);
    }
    for (int j = 0; j < n2; ++j) {
        R.push_back(A[mid + j]);
    }

    int current = left;
    int j = 0;
    for (int i = 0; i < n1; ++i) {
        while ((j < n2) && (L[i] > R[j])) {
            A[current] = R[j];
            ++j;
            ++current;
        }
        A[current] = L[i];
        ++current;
        result += j;
    }
    while ((j < n2)) {
        A[current] = R[j];
        ++j;
        ++current;
    }

#if 0
    L.push_back(INT_MAX);
    R.push_back(INT_MAX);
    for (int i = 0; i < n2; ++i) {  // R[i]
        for (int j = 0; j < n1; ++j) {  // L[j]
            if (R[i] < L[j]) {
                ++result;
                //cout << " " << R[i] << " " << L[j] << endl;
            }
        }
    }
    int i = 0;
    int j = 0;
    for (int k = left; k < right; ++k) {
        cout << "   " << R[i] << " " << L[j] << endl;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            ++i;
        }
        else {
            A[k] = R[j];
            ++j;
            ++result;
            cout << " " << R[i] << " " << L[j] << endl;
        }

    }
#endif

    return result;
}

long long numberOfInversions(deque<int>& a, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        long long l = numberOfInversions(a, left, mid);
        long long r = numberOfInversions(a, mid, right);
        long long m = merge(a, left, mid, right);
        return l + r + m;
    }
    else {
        return 0;
    }
}

int main(int argc, char* argv[]) {
    deque<int> a;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    cout << numberOfInversions(a, 0, n) << endl;
#if 0
    cout << a[0];
    for (int i = 1; i < n; ++i) {
        cout << " " << a[i];
    }
    cout << endl;
#endif
    return 0;
}



Measured memory_bytes: 4620
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				String str = sc.next();
				if(str.equals("-")) {
					break;
				}
				int m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					int h = sc.nextInt();
					str = str.substring(h) + str.substring(0,h);
				}
				System.out.println(str);
			}
		}
	}
}



Measured memory_bytes: 26216
# vim: set fileencoding=utf-8:


def main():
    N, T = map(int, raw_input().split())
    ans = 9999999

    for idx in xrange(N):
        c, t = map(int, raw_input().split())
        if t <= T:
            ans = min(c, ans)

    if ans == 9999999:
        print("TLE")
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,p[110]={},dp[102][4][4]={};
  cin>>n>>t;
  for(int i=0;i<t;i++){
    int a,b;
    cin>>a>>b;
    p[a]=b;
  }
   
  if(p[1]&&p[2])dp[3][p[2]][p[1]]=1;
  else if(p[2])for(int i=1;i<4;i++)dp[3][p[2]][i]=1;
  else if(p[1])for(int i=1;i<4;i++)dp[3][i][p[1]]=1;
  else
    for(int i=1;i<4;i++)
      for(int j=1;j<4;j++)dp[3][i][j]=1;
 
  for(int i=3;i<=n;i++)
    for(int j=1;j<4;j++) //1
      for(int k=1;k<4;k++){//2
    if(p[i]==j&&j==k)continue;
    if(p[i])dp[i+1][p[i]][j]=(dp[i+1][p[i]][j]+dp[i][j][k])%10000;
    else
      for(int l=1;l<4;l++){
        if(j==k&&k==l)continue;
        dp[i+1][l][j]=(dp[i+1][l][j]+dp[i][j][k])%10000;
      }
      }
  int ans=0;
  for(int i=1;i<4;i++)
    for(int j=1;j<4;j++)ans+=dp[n+1][i][j];
  cout<<ans%10000<<endl;
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cmath>
#define ll unsigned long long
using namespace std;
set <int> st;
    vector <ll> vec;
ll qkpow(ll x, ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n&1)
            res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}
int main(void)
{
    int n;
    cin>>n;
    while(n--)
    {
        int num;
        cin>>num;
        st.insert(num);
    }
    cout<<st.size()<<endl;
    return 0;
}




Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void){
    char S[100], T[100];
    int i, cnt=0;

    scanf("%s", &S);
    scanf("%s", &T);

    for(i=0; i<strlen(S); i++){
        if(S[i]!=T[i]){
            cnt++;
        }
    }

    if((strlen(S)+1==strlen(T))&&(cnt==0)){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1736