akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void solve() {
    int m, n;
    cin >> m >> n;
    vector<string> a(m);
    for (int i = 0; i < m; ++i)
        cin >> a[i];
    queue<int> q;
    vector<int> d(m * n, m * n + 10);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            if (a[i][j] == '#') {
                int id = i * n + j;
                d[id] = 0;
                q.push(id);
            }
        }
    }
    int res = 0;
    while (!q.empty()) {
        int id = q.front();
        q.pop();
        int x = id / n, y = id % n;
        for (int i = 0; i < 4; ++i) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if ((xx >= 0) && (xx < m) && (yy >= 0) && (yy < n)) {
                int id2 = xx * n + yy;
                if (d[id2] == m * n + 10) {
                    d[id2] = d[id] + 1;
                    q.push(id2);
                    res = max(res, d[id2]);
                }
            }
        }
    }
    cout << res << endl;

}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

#define NIL -1
#define MAX_N 25

struct Node {
  int parent, left, right;
};
Node T[MAX_N + 5];

int findRoot(int n) {
  rep(i, n) {
    if (T[i].parent == NIL) return i;
  }
  return NIL;
}

void preorder(int i) {
  cout << " " << i;
  if (T[i].left != NIL) preorder(T[i].left);
  if (T[i].right != NIL) preorder(T[i].right);
}

void inorder(int i) {
  if (T[i].left != NIL) inorder(T[i].left);
  cout << " " << i;
  if (T[i].right != NIL) inorder(T[i].right);
}

void postorder(int i) {
  if (T[i].left != NIL) postorder(T[i].left);
  if (T[i].right != NIL) postorder(T[i].right);
  cout << " " << i;
}

int main() {
  int n;
  cin >> n;
  rep(i, n) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  rep(i, n) {
    int pid, left, right;
    cin >> pid >> left >> right;
    T[pid].left = left;
    T[pid].right = right;
    if (left != NIL) T[left].parent = pid;
    if (right != NIL) T[right].parent = pid;
  }
  int root_id = findRoot(n);

  cout << "Preorder" << endl;
  preorder(root_id);
  cout << endl;

  cout << "Inorder" << endl;
  inorder(root_id);
  cout << endl;

  cout << "Postorder" << endl;
  postorder(root_id);
  cout << endl;
  return 0;
}



Measured memory_bytes: 3088
#!/usr/bin/env python3

def prime_factor(n):
    ret, p = [], 2
    while p*p <= n:
        if n % p != 0:
            p += 1
            continue
        exp_v = 0
        while n%p == 0:
            exp_v += 1
            n //= p
        ret.append( [p, exp_v] )
        p += 1
    if n != 1: ret.append( [n, 1] )
    return ret


def extgcd(a, b):
    if b == 0:
        return [1, 0, a]
    x, y, g = extgcd(b, a%b)
    return [y, x - a//b * y, g]


def mod_inverse(a, m):
    x, y, _ = extgcd(a, m)
    return (m+x%m) % m


n = int(input())
a = [ int(x) for x in input().split() ]

MOD = 10**9 + 7

primes = {}
for aa in a:
    t = prime_factor(aa)
    for tt in t:
        v, e = tt
        primes[v] = max(e, primes.get(v, 0))

prod = 1
for k, v in primes.items():
    prod *= pow(k, v, MOD)
    prod %= MOD

ans = 0
for aa in a:
    ans += prod*mod_inverse(aa, MOD)
    ans %= MOD

print(ans%MOD)


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

bool load(vector<int> w, int k, int p)
{
    bool loadable = false;
    vector<int> capa(k, p);
    int next = 0;
    for (int i = 0; i < w.size(); ++i)
    {
        for (int j = next; j < k; ++j)
        {
            if (w[i] <= capa[j])
            {
                capa[j] -= w[i];
                loadable = true;
                break;
            }
            else
            {
                loadable = false;
                next = j + 1;
            }
        }
    }
    return loadable;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> w(n);
    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> w[i];
        sum += w[i];
    }
    int p = sum / k + ((sum % k == 0) ? 0 : 1);
    for (; p < sum; ++p)
    {
        if (load(w, k, p))
            break;
    }
    cout << p << endl;
    return 0;
}



Measured memory_bytes: 3820
#include<stdio.h>
int main(){
    int n;
    char s[100];
    scanf("%d",&n);
    scanf("%s",s);
    if(n%2==1){
        printf("No\n");
        return 0;
    }
    int i;
    for(i=0;i<n/2;i++){
        if(s[i]==s[i+n/2]){

        }
        else{
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 200001
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll N,A[SIZE];
    ll A_SUM[SIZE];
    ll ans=0;
    cin >> N ;
    for(int i = 1 ; i <= N ; i++){
        cin >> A[i];
    }
    for(int i = N-1 ; i >= 0 ; i--){
        if(i == N-1){
            A_SUM[N-1] = A[N];
        }else{
            A_SUM[i] = (A_SUM[i+1] + A[i+1]) % MOD;
        }
    }
    for(int i = 1 ; i <= N-1 ; i++){
        ans += (A[i]*A_SUM[i]) % MOD;
    }
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

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

int main(){
	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D;
	cin >> S;

	A--;
	B--;
	C--;
	D--;

	if(C < B){
		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;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}

	if (C < D) {
		for (int i = A; i < D; i++)
		{
			if(S[i] == '#' && S[i+1] == '#')
			{
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}

	for(int i = A; i < C; i++)
	{
		if(S[i] == '#' && S[i+1] == '#')
		{
			cout << "No" << endl;
			return 0;
		}
	}

	bool sss = false;
	for (int i = B - 1; i < D; i++) {
		if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
			sss = true;
			break;
		}
	}

	if(!sss)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int modpow(int x, int n, const int mo) {
	int res = 1;
	while (n > 0) {
		if (n & 1) (res *= x) %= mo;
		(x *= x) %= mo;
		n >>= 1;
	}
	return res;
}

int inverse(int x, const int mo) {
	return modpow(x, mo - 2, mo);
}

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

	int N;
	cin >> N;
	cout << N + N * N + N * N*N << endl;
	
	return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*

for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}

using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}

int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
*/
int main(void){
  ll N, M, A, B, C, D, E, F, G, K,L, W, H, P, Q, R, V, X, Y;
  string S, T;
  cin >> N;
  S = to_string(N);
  if (S[0] == '7' || S[1] == '7' || S[2] == '7') cout << "Yes" << endl;
  else cout << "No" << endl;

}



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

int main(){

    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int x = i;
        if(x % 3 == 0){
            printf(" %d", i);
            continue;
        }
        while(x){
            if(x % 10 == 3){
                printf(" %d", i);
                break;
            }
            x /= 10;
        }
    }
    cout << endl;

    return 0;
}


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

signed main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=v[0]/2;
  for(int i=1;i<N;i++){
    if(v[i-1]%2&&v[i]){
      ans++;
      v[i]--;
    }
    ans+=v[i]/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string N = Console.ReadLine ();

            long ans = 0;

            for (int i = 0; i < N.Length; i++)
            {
                ans += int.Parse (N[i].ToString ());
            }

            if (ans % 9 == 0)
            {

                Console.WriteLine ("Yes");
            }
            else
            {
                Console.WriteLine ("No");

            }
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 32980
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin >> s;
	string t = "CODEFESTIVAL2016";
	int ans = 0;
	for (int i = 0; i < 16; i++)if (s[i] != t[i])ans++;
	printf("%d\n", ans);
}

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

int main(){

int n = 0, ba = 0;
char card; 

	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		int temochi[n];
		for(int i = 0 ; i < n; i++){
			temochi[i] = 0; 
		}
		ba = 0;
		for(int i = 0 ; i < 100; i++ ){
			cin >> card;	
			if(card == 'M'){
			temochi[i % n]++;
			}

			else if(card == 'S'){
			ba = ba + temochi[i % n] + 1;
			temochi[i % n]	= 0;		
			}

			else{
			temochi[i % n] = temochi[i % n] + ba + 1;
			ba = 0;			
			}

		}	

		sort(temochi, temochi + n);
		for(int i = 0 ; i < n; i++){
			cout << temochi[i] << " "; 
		}
	cout << ba << endl;
	}

return 0;
}

Measured memory_bytes: 1184
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
#define GETIN2MACRO(_1, _2, NAME, ...) NAME
#define GETIN3MACRO(_1, _2, _3, NAME, ...) NAME
#define GETIN4MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define GETIN5MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
#define GETIN6MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define GETIN7MACRO(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
#define INPUT1(n) \
  ll n;           \
  cin >> n
#define INPUT2(a, b) \
  ll a, b;           \
  cin >> a >> b
#define INPUT3(n, a, b) \
  ll n, a, b;           \
  cin >> n >> a >> b
#define INPUT4(n, m, a, b) \
  ll n, m, a, b;           \
  cin >> n >> m >> a >> b
#define INPUT(...)                                         \
  GETIN4MACRO(__VA_ARGS__, INPUT4, INPUT3, INPUT2, INPUT1) \
  (__VA_ARGS__)
#define INPUTARR(n, a) \
  ll n;                \
  cin >> n;            \
  ll a[n];             \
  REP(i, n) { cin >> a[i]; }
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

// search max depth
ll dfs(vector<vector<ll>>& tree, ll parent, ll now, ll depth) {
  ll d = depth;
  for (auto i : tree[now]) {
    if (i == parent) continue;
    d = max(d, dfs(tree, now, i, depth + 1));
  }
  return d;
}

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  //solve
  INPUT(a, b, k);
  cout << (a > k ? a - k : 0) << " " << (a > k ? b : (a+b-k>0?a+b-k:0));

  return;
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
A = list([int(x) for x in input().split()])

count = 0
ironbar = list(accumulate(A))

min_value = ironbar[-1]
for i in range(N):
    bet = abs(ironbar[i] - (ironbar[-1] - ironbar[i]))

    if min_value > bet:
        min_value = bet
    else:
        print(min_value)
        exit()


Measured memory_bytes: 30992
#include <stdio.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <limits.h>


using namespace std;

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

//    int total = 0;
    uint64_t total = 0;
    int *A = new int[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        total += A[i];
    }

    uint64_t *lTable = new uint64_t[N];
    uint64_t *rTable = new uint64_t[N];
    uint64_t lr[2] = {0, 0};
    for (int i = 0; i < N; i++) {
        lr[0] += A[i];
        lTable[i] = lr[0];
        lr[1] += A[N-i-1];
        rTable[N-i-1] = lr[1];
    }

    uint64_t m = UINT64_MAX;
    for (int i = 0; i < N-1; i++) {
//        if (A[i] < 2)
//            continue;
        uint64_t n = (lTable[i] > rTable[i+1] ? lTable[i] - rTable[i+1] : rTable[i+1] - lTable[i]);
        if (m > n) {
            m = n;
        } else {
            break;
        }
    }

    delete []lTable;
    delete []rTable;

    printf("%llu", m);
}


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

#define vi push_back
#define vo pop_back
#define mp make_pair
#define fe first
#define se second
typedef long long ll;
const int MXN = 2e5 + 20;

int n, m;
vector <pair<int, int> > ab;
vector <int> Boats[MXN];

void Input () {
	int tmpa, tmpb;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> tmpa >> tmpb;
		ab.vi(mp(tmpa, tmpb));
	}
	for (int i = 0; i < m; i++)
		Boats[ab[i].fe].vi(ab[i].se);
}

void Check (int x) {
	if (count(Boats[x].begin(), Boats[x].end(), n) > 0) {
		cout << "POSSIBLE\n";
		exit(0);
	}
}

void Solve () {
	for (int j = 0; j < (int) Boats[1].size(); j++)
		Check(Boats[1][j]);
}

void Output () {
	cout << "IMPOSSIBLE\n";
}

int main () {
	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();
	Input();
	Solve();
	Output();
	return 0;
}



Measured memory_bytes: 10096
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())
t = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            t += gcd(i, j, k)
print(t)

Measured memory_bytes: 74912
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int  n = sc.nextInt();
			int cnt = 0;
			if(n == 0) break;
			while (n != 1){
				if(n%2 == 0){
					n = n/2;
					cnt++;
				}else{
					n = 3*n + 1;
					cnt++;
				}
			}
			System.out.println(cnt);
		}
		
		sc.close();
	}

}

Measured memory_bytes: 17188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());
		
		double ans = 0.0;
		for(int i = 0; i < N; i++)
		{
			string[] args = Console.ReadLine().Split(' ');
			double x = Double.Parse(args[0]);
			ans += (args[1] == "JPY") ? x : x * 380000.0;			
		}
			
		Console.WriteLine(ans);
	}	
}





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

#define int long long

using namespace std;


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


    int n, k;
    cin >> n >> k;
    vector<int> dp(k + 1, -1);
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
        dp[x[i]] = 1;
    }
    for(int i = 0; i < x[0]; i++){
        dp[i] = 2;
    }   
    for(int val = 0; val <= k; val++){
        if(dp[val] == -1){
            bool ok = false;
            for(int i = 0; i < n; i++){
                if(val - x[i] >= 0){
                    if(dp[val - x[i]] == 2){
                        ok = true;
                        break;
                    }
                }
            }
            if(ok) dp[val] = 1;
            else dp[val] = 2;
        }
    }

    int cnt = 0;

    while (k >= x[0]){
        if(dp[k] == 1){
            for(int i = 0; i < n; i++){
                if(k - x[i] >= 0){
                    if(dp[k - x[i]] == 2){
                        k -= x[i];
                        break;
                    }
                }
            }
        }
        else{
            k -= x[0];
        }
        cnt++;
    }
    cout << (cnt % 2 == 1 ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 3968
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

// 入力
int N;
double x[101], y[101], v[101];

// 2点間の距離
double dist(double x1, double y1, double x2, double y2){
	return sqrt( (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2) );
}

// (x_,y_) => (x[i],y[i]) (0 <= i < N)の移動時間で最大のものを返す.
double g(double x_, double y_){
	double t = 0;
	for(int i=0 ; i < N ; i++ ){
		double d = dist( x_ , y_ , x[i] , y[i]);
		t = max( t , d / v[i] );
	}
	return t;
}

// x が与えられた時, y について三分探索 (0 <= y <= 100)
double f(double x, double low=0, double high=100){
	for (int i = 0 ; i < 100 ; i++ ){
		double a = (low * 2 + high) / 3;
		double b = (low + high * 2) / 3;
		if( g(x, a) < g(x, b) ){
			high = b;
		}else{
			low = a;
		}
	}
	return g(x, (low + high) / 2);
}

// x について三分探索 (0 <= x <= 100)
double search(double low=0, double high=100){
	for (int i = 0 ; i < 100 ; i++ ){
		double a = (low * 2 + high) / 3;
		double b = (low + high * 2) / 3;
		if( f(a) < f(b) ){
			high = b;
		}else{
			low = a;
		}
	}
	return f((low + high) / 2) ;
}

int main(){
	while( scanf("%d", &N) ){
		if( N == 0 ) break;
		
		for(int i=0 ; i <N ; i++ ){
			scanf("%lf %lf %lf", &x[i], &y[i], &v[i]);
		}
		double ans = search();
		printf("%.8f\n", ans);
	}
}

Measured memory_bytes: 1088
# coding: utf-8

n,a,b = map(int,input().split())
sum_all = 0
for i in range(1,n+1):
    now = i
    keta_sum = 0
    while(1):
        keta_sum += now%10
        now //= 10
        if now == 0:
            break
    if a <= keta_sum and keta_sum <= b:
        sum_all += i
print(sum_all)

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<'\n'

int main(){
    int r;
    cin >> r;
    COUT(2*r*M_PI);
    return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <unordered_map>
#include <algorithm>
 
#define ll long long
 
using namespace std;
int n, ans = 1;
string s;
 
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
 
    cin >> n>>ans;
    cout<<(ans>n?0:(n-ans));
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    vector<int> A(N);
    for(int i=0; i<N; ++i){
        cin >> A[i];
    }

    int ans = X;
    for (int i = 0; i < N; ++i)
    {
        int tmp = (D - 1) / A[i] + 1;
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/07/21.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    ll s;
    cin >> s;
    ll p=s/IINF;
    ll q=s%IINF;
    if(q==0){
        cout << 0 SP 0 SP IINF SP 1 SP 0 SP p << endl;
    }else{
        cout << 0 SP 0 SP IINF SP 1 SP IINF-q SP p+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
S = B-A
 
if S % 2 ==0:
  C = S // 2
else:
  D = min(N-A,B-1)
  if A-1 <= N-B:
    E = A + (S-1)//2
  else:
    E = N-B+1 + (S-1)//2
  C = min(D,E)
 
print(int(C))

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

int main(){
	int n;
	scanf("%d", &n);
	set<int> s;
	for(int i = 0; i < n; i++) {
		int id, x;
		scanf("%d%d", &id, &x);
		if(id == 0) {
			s.insert(x);
			printf("%lu\n", s.size());
		}else if(id == 1) {
			printf("%lu\n", s.count(x));
		}else if(id == 2) {
			s.erase(x);
		}
	}
}



Measured memory_bytes: 12552
/*
***************************************************************************
 name  : ITP1_11_A.cpp
 title : Dice Ⅰ
 make  : 2018/09/19 tanabe
***************************************************************************
*/

// Library
#include <iostream>  // standard input output object
#include <cstring>   // character functions
#include <algorithm> // algorithm functions

// Class
class Dice{
public:
  int num[6];                 // dice surface
  void Roll(int n[6],char d); // roll the dice in any direction

};

main(void){
  Dice dice;       // dice
  std::string dir; // direction
  int len;         // length of dir
  int i,j;         // index

  for(i = 0;i < 6;i++){
    std::cin >> dice.num[i]; // input "dice.num[i]"
  }

  std::cin >> dir;    // input "dir"
  len = dir.length(); // length of dir

  for(i = 0;i < len;i++){
    dice.Roll(dice.num,dir[i]);
  }

  std::cout << dice.num[0] << std::endl; // output "dice.num[0]"

}

// +---------------------------------------------+
// | name       : Dice::Roll                     |
// | obtain     : int n[6],char d                |
// | return     : none                           |
// | processing : roll the dice in any direction |
// +---------------------------------------------+
void Dice::Roll(int n[6],char d){
  int temp;           // temporary
  int r[3];           // roll
  int N[3] = {4,5,1}; // north
  int E[3] = {2,5,3}; // east
  int S[3] = {1,5,4}; // south
  int W[3] = {3,5,2}; // west
  int i;              // index

  switch(d){
    case 'N': r[0] = N[0]; r[1] = N[1]; r[2] = N[2]; break;
    case 'E': r[0] = E[0]; r[1] = E[1]; r[2] = E[2]; break;
    case 'S': r[0] = S[0]; r[1] = S[1]; r[2] = S[2]; break;
    case 'W': r[0] = W[0]; r[1] = W[1]; r[2] = W[2]; break;
  }

  for(i = 0;i < 3;i++){
    temp = n[0];
    n[0] = n[r[i]];
    n[r[i]] = temp;
  }
}



Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class M>
struct LazySegmentTree{
    using T = typename M::T;
    using L = typename M::L;
    int sz, height{};
    vector<T> seg; vector<L> lazy;
    explicit LazySegmentTree(int n) {
        sz = 1;
        while(sz < n) sz <<= 1, height++;
        seg.assign(2*sz, M::e());
        lazy.assign(2*sz, M::l());
    }

    void set(int k, const T &x){
        seg[k + sz] = x;
    }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[2*i], seg[2*i+1]);
    }

    T reflect(int k){ return lazy[k] == M::l() ? seg[k] : M::g(seg[k], lazy[k]); }

    void eval(int k){
        if(lazy[k] == M::l()) return;
        lazy[(k<<1)|0] = M::h(lazy[(k<<1)|0], lazy[k]);
        lazy[(k<<1)|1] = M::h(lazy[(k<<1)|1], lazy[k]);
        seg[k] = reflect(k);
        lazy[k] = M::l();
    }
    void thrust(int k){ for (int i = height; i; --i) eval(k>>i); }
    void recalc(int k) { while(k >>= 1) seg[k] = M::f(reflect((k<<1)|0), reflect((k<<1)|1));}
    void update(int a, int b, const L &x){
        thrust(a += sz); thrust(b += sz-1);
        for (int l = a, r = b+1;l < r; l >>=1, r >>= 1) {
            if(l&1) lazy[l] = M::h(lazy[l], x), l++;
            if(r&1) --r, lazy[r] = M::h(lazy[r], x);
        }
        recalc(a);
        recalc(b);
    }

    T query(int a, int b){ // [l, r)
        thrust(a += sz);
        thrust(b += sz-1);
        T ll = M::e(), rr = M::e();
        for(int l = a, r = b+1; l < r; l >>=1, r>>=1) {
            if (l & 1) ll = M::f(ll, reflect(l++));
            if (r & 1) rr = M::f(reflect(--r), rr);
        }
        return M::f(ll, rr);
    }

    T operator[](const int &k) const { // 0-indexed
        return seg[k + sz];
    }
};

struct Monoid{
    using T = pair<ll, ll>;
    using L = ll;
    static T f(T a, T b) { return {a.first+b.first, a.second+b.second}; }
    static T g(T a, L b) {
        if(b == l()) return a;
        else return {b*a.second, a.second};
    }
    static L h(L a, L b) { if(b == l()) return a; else return b; }
    static T e() { return {0, 0}; }
    static L l() { return INF<int>; }
};

int main() {
    int n, q;
    cin >> n >> q;
    LazySegmentTree<Monoid> seg(n);
    for (int i = 0; i < n; ++i) {
        seg.set(i, {0, 1});
    }
    seg.build();
    for (int i = 0; i < q; ++i) {
        int v;
        scanf("%d", &v);
        if(v == 0){
            int s, t; ll x;
            scanf("%d%d%lld", &s, &t, &x);
            seg.update(s, t+1, x);
        }else {
            int a, b;
            scanf("%d%d", &a, &b);
            printf("%lld\n", seg.query(a, b+1).first);
        }
    }
    return 0;
}





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

int main(){

    int K,A,B;
    cin >> K >> A >> B;

    for(int i = K; i<=1000;i+=K){
        if(i>=A && i<=B){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int isprime(int);
int main(){
  int a,i,n,cnt=0;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&a);
  
    if(isprime(a)){
      cnt++;
    }
    
  }
  printf("%d\n",cnt);




  return 0;
}
int isprime(int a){
  int x;
  static int i; 
  if (a < 2)
    return 0;
  else if(a==2)return 1;
    
  if(a%2==0){
    return 0;
  }
  for(i=3;i*i<=a;i++){
    if(a%i==0) return 0;
  }
  return 1;
}

  

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

int main() {
  string S;
  cin >> S;
  if(S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  int uc = 0;
  for(int i = 1; i < S.size(); ++i) {
    if(S[i] == 'C') {
      if(i < 2 || S.size() - 2 < i) {
        cout << "WA" << endl;
        return 0;
      }
      uc++;
      if(uc > 1) {
        cout << "WA" << endl;
        return 0;
      }
    } else if(!('a' <= S[i] && S[i] <= 'z')) {
      cout << "WA" << endl;
      return 0;
    }
  }
  if(uc == 0) {
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}

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

int main()
{
  std::random_device seed_gen;
  std::mt19937 engine(seed_gen());

  for (int i = 0; i < 365; ++i) {
    std::uint32_t result = engine();
    std::cout << result%26+1 << std::endl;
  }
}

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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> A >> B >> C;

    cout << A*B/2 << endl;

//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/
 
#define lowbit(x) (x)&(-x)
 
const int maxn=(int)(3e5)+5;
int a[maxn],C[maxn],res[maxn];
int n,m;
 
struct node {
    int x,ty,r,sgn,id;
    node() {x=ty=r=id=sgn=0;}
} p[maxn*22];
 
inline bool operator < (node a,node b) {
    if(a.x!=b.x) return a.x<b.x;return a.ty<b.ty;
}
 
inline void add(int x,int v) {
    for(;x<=m;x+=lowbit(x)) C[x]+=v;
}
 
inline int sum(int x) {
    int res=0;
    for(;x;x-=lowbit(x)) res+=C[x];
    return res;
}
 
int main() {
    int tot=0;
    read(n);read(m);
    REP(i,1,n) {
        int l,r;
        read(l);read(r);
        ++tot;p[tot].x=l;p[tot].ty=0;p[tot].r=r;p[tot].id=i;
    }
    REP(i,1,m) {
        int tmp=0;
        for(int j=0;j*i<=m;j++) a[++tmp]=j*i;if(a[tmp]!=m) a[++tmp]=m+1;
        REP(j,2,tmp) {
            int l=a[j-1],r=a[j];
            if(l+1<=r-1) {
                l++;r--;
                ++tot;p[tot].x=l-1;p[tot].ty=1;p[tot].sgn=-1;p[tot].r=r;p[tot].id=i;
                ++tot;p[tot].x=  r;p[tot].ty=1;p[tot].sgn= 1;p[tot].r=r;p[tot].id=i;
            }
        }
    }
    sort(p+1,p+tot+1);
    REP(i,1,tot) {
        if(p[i].ty==0) add(p[i].r,1);
        else res[p[i].id]+=p[i].sgn*sum(p[i].r);
    }
    REP(i,1,m) printf("%d\n",n-res[i]);
    return 0;
}

Measured memory_bytes: 130944
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for(int i=0; i<m; i++)
    {
        int tmp;
        cin >> tmp;
        sum += tmp;
    }

    if(sum <= n)
    {
        cout << (n - sum) << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
map < int , int > is[1<<20];
int main(){
    int n , m;
    scanf("%d %d",&n,&m);
    for(int j = 1 ; j<= m ; j++){
        int a , b;
        cin>>a>>b;
        is[a][b] =1;
    }
    for(int j = 1 ; j <= n ; j++){
        if(is[1][j] && is[j][n]){
            puts("POSSIBLE");
            return 0;
        }
    }
    puts("IMPOSSIBLE");
}


Measured memory_bytes: 68096
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

const int mod = 1000 * 1000 * 1000 + 7;
int add(int a, int b) {
    return (a + b >= mod ? a + b - mod : a + b);
}

int sub(int a, int b) {
    return (a >= b ? a - b : mod + a - b);
}


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n = input<int>();
    vector<int> seq(n);
    input_seq(ALL(seq));
    
    vector<int> dp(n + 1);
    dp[0] = 1;

#if 0
    for (int i = 0; i != n; ++i) {
        for (int j = 0; j <= i; ++j)
            if (seq[j] == seq[i] and (j == 0 or seq[j - 1] != seq[j]))
                dp[i + 1] = add(dp[i + 1], dp[j]);
    }
    
#else
    
    vector<int> sum_by_val(int(2.1e5));
    for (int i = 0; i != n; ++i) {
        if (i == 0 or seq[i - 1] != seq[i])
            sum_by_val[seq[i]] = add(sum_by_val[seq[i]], dp[i]);

        dp[i + 1] = sum_by_val[seq[i]];
    }
    
#endif
    
    cout << dp.back() << "\n";
    
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
struct UnionFind{
    vl par;
    UnionFind(ll N):par(N,-1){}
    void init(ll N){par.assign(N,-1);}
    ll root(ll x){
        if(par[x]<0)return x;
        return par[x]=root(par[x]);
    }
    bool issame(ll x,ll y){
        return root(x)==root(y);
    }
    bool merge(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return false;
        if(par[x]>par[y])swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    ll size(ll x){
        return -par[root(x)];
    }
};
int main(){
    ll N,M;cin>>N>>M;
    int a[M],b[M];
    rep(i,M)cin>>a[i]>>b[i],a[i]--,b[i]--;
    UnionFind tree(N);
    vl ans;
    ll now=N*(N-1)/2;
    ans.push_back(now);
    rep(i,M){
        ll p=a[M-1-i],q=b[M-1-i];
        if(!tree.issame(p,q)){
            now-=tree.size(p)*tree.size(q);
            tree.merge(p,q);
        }
        ans.push_back(now);
    }
    for(int i=0;i<M;i++)cout<<ans[M-1-i]<<endl;
    return 0;
}

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

int main(void){
    int a=1,b=1,count=0,judge=0;

    cin >> a >> b;
    

    for(int i=0;i<=3;i++){// keta wo kazoeru
        if(b>=pow(10,i)){count=i;}
    }

    int ans=a*pow(10,count+1)+b;


    for(int j=1;j<=10000;j++){
        if(j*j==ans){
            judge=1;
            j+=1000;
        }
    }

    if(judge==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
/**** debug
    cout << "ans::::" << ans << endl;//debug
    cout << "count::" << count << endl;//debug
    cout << "judge::" << judge << endl;//debug
    cout << "ans==" << a << "X(10^" << count << ")+" << b << endl;//debug
*/
    return 0;
    
}

Measured memory_bytes: 4012
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        
        Console.WriteLine("{0} {1} {2:f5}", n[0]/n[1] , n[0] % n[1] , (double)n[0] / n[1]);
    }
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int CoinHub = A + B;
    if(CoinHub >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 500;

int main(){
    
    ll n,k;
    priority_queue<ll> que;
    ll num[maxn];
    ll sum = 0;
    
    cin >> n>>k;
    rep(i,n){
        cin >> num[i];
        sum+=num[i];
    }
    
    for(ll i=1;i*i<=sum;i++){
        if(sum%i==0){
            que.push(i);
            que.push(sum/i);
        }
    }
    
    while(!que.empty()){
        vector<ll> ar;
        ll ps=0,ms=0;//ds 差分の和 ps 正のdにするための差分の和
        ll ans = que.top();
        que.pop();
        
        rep(i,n){
            if(num[i]%ans!=0){
                ar.push_back(num[i]%ans);
                ps+=(ans-num[i]%ans);
            }
        }
        
        sort(all(ar));
        
        rep(i,ar.size()){
            ps = ps - (ans-ar[i]);
            ms += ar[i];
            if(ps<=k&&ps==ms){
                cout << ans<<endl;
                return 0;
            }
        }
    }
    
    cout << 1<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define ls rt << 1
#define rs rt << 1 | 1
#define sz(x) (int)(x).size()
#define ALL(x) (x).insgin(), (x).end()
#define vi vector<int>
#define N 1010
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n = 2, m;
int a[110][110];
int main()
{
	m = read();
	rep(i, 1, n)
		rep(j, 1, m)
			a[i][j] = read();
	rep(i, 1, n)
		rep(j, 1, m)
			a[i][j] += max(a[i - 1][j], a[i][j - 1]);
	cout << a[n][m];
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
unsigned long long dp[101];
unsigned long long dfs(int i){
  if(dp[i]!=-1) return dp[i];
  if(i==0) return 2;
  else if(i==1) return 1;
  return dp[i]=dfs(i-1)+dfs(i-2);
}
int main(){
  memset(dp,-1,sizeof(dp));
  cin>>n;
  cout<<dfs(n)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)


signed main(){
  int h,w,s,t;
  cin>>h>>w>>s>>t;
  if(h==1){
    if(t==1||t==w){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
    return 0;
  }
  if(w==1){
    if(s==1||s==h){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
    return 0;
  }
  if(w%2==0||h%2==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  if((s+t)%2==1){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
  return 0;
}




Measured memory_bytes: 3100
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int N, M; cin >> N >> M;
	vector<int> H(N);
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}
	vector<vector<int>> road(N);
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b;
		a--; b--;
		road[a].push_back(b);
		road[b].push_back(a);
	}
	vector<bool> check(N, true);
	for(int i = 0; i < road.size(); ++i) {
		int p = i;
		for (int j = 0; j < road[i].size(); ++j) {
			int q = road.at(i).at(j);
			if (H[p] <= H[q]) {
				check[p] = false;	
				break;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < check.size(); ++i) {
		if (check[i] == true) ans++;
	}
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 8772
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

int n, r[MAXN];

void solve(){
	cin >> n;

	for(int i = 1, x; i <= n; ++i){
		cin >> x;
		r[x] = i;
	}

	for(ll i = 1; i <= n; ++i){
		cout << 20001 * i << ' ';
	}

	cout << '\n';

	for(ll i = 1; i <= n; ++i){
		cout << 20001 * (n - i) + r[i] << ' ';
	}

}

int main(){

	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

Measured memory_bytes: 768