akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

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

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
	out << '(' << a.fi << ", " << a.se << ')';
	return out;
}
}



int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	int sx, sy;
	rep(i, h) rep(j, w) if (s[i][j] == 'S') sx = j, sy = i;
	vector<vector<int> > used(h, vi(w));
	auto isOutOfRange = [](int h, int w, int H, int W) {
		return h < 0 || h >= H || w < 0 || w >= W;
	};
	queue<pair<pii, int>> q;
	q.push({{sy, sx}, 0});
	used[sy][sx] = 1;
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int x = p.fi.se, y = p.fi.fi, cnt = p.se;
		if (cnt >= k) continue;
		dump(mp(y, x));
		rep(i, 4) {
			int nx = x + dx[i], ny = y + dy[i];
			if (isOutOfRange(ny, nx, h, w) || s[ny][nx] == '#' || used[ny][nx]) continue;
			used[ny][nx] = 1;
			q.push({{ny, nx}, cnt + 1});
		}
	}
	int ans = 1e9;
	rep(i, h) if (used[i][0] || used[i][w - 1]) ans = 1;
	rep(i, w) if (used[0][i] || used[0][h - 1]) ans = 1;
	rep(i, h) rep(j, w) if (used[i][j]) ans = min({ans, (min(i, h - 1 - i) + k - 1) / k + 1, (min(j, w - 1 - j) + k - 1) / k + 1});
	cout << ans << endl;

	LINE;
#ifdef DEBUG_MODE
	//DEBUG_2D
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) printf("%3d", used[i][j]);
		printf("\n");
	}
#endif
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct Es {
  lli c, h, v;
};
bool operator<(const Es& e, const Es& f) { return e.c < f.c; }

lli w, h, p[100001], q[100001];
vector<Es> es;
int main() {
  cin >> w >> h;
  for (lli i=0; i<w; ++i) {
    lli c; cin >> c;
    es.push_back({ c, -1, i });
  }
  for (lli i=0; i<h; ++i) {
    lli c; cin >> c;
    es.push_back({ c, i, -1 });
  }
  sort(begin(es), end(es));

  lli ans = 0, ver = w + 1, hol = h + 1;
  for (const Es& e : es) {
    if (e.h >= 0) {
      ans += ver * e.c;
      --hol;
    } else {
      ans += hol * e.c;
      --ver;
    }
    cerr << e.c << ' ' << ans << endl;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 8560
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    long long int N;
    cin >> N;
    vector<long long int> A(N+1);
    for(int i = 0; i < N; i++ )
    {
        cin >> A[i];
    }
    A[N] = 0;
    long long int money = 1000;
    long long int stock = 0;
    for(int i = 0; i < N; i++ )
    {
        // buy
        if(A[i]<A[i+1]&&A[i]<=money){
            stock = money / A[i];
            money = money % A[i];
            //cout << i<<" : buy" << endl;
            //cout << "meney : "<<money <<"  stock: "<< stock << endl;
        }
        // sell
        else if (A[i] > A[i + 1])
        {
            money += stock * A[i];
            stock = 0;
            //cout << i << " : sell" << endl;
            //cout << A[i] << ":" << A[i+1] << endl;
            //cout << "meney : " << money << "  stock: " << stock << endl;
        }
    }
    if(stock!=0){
        money += stock * A[N - 1];
    }
    cout << money << endl;
    return 0;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100111];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    vector<pair<int, int> > H[2];
    REP (t, 2) {
	VI v;
	for (int i=t; i<N; i+=2) v.push_back(A[i]);
	sort(v.begin(), v.end());
	for (int i=0; i<(int)v.size(); ) {
	    int j = i;
	    while (j < (int)v.size() && v[i] == v[j]) j++;
	    H[t].emplace_back((int)v.size() - (j-i), v[i]);
//	    eprintf("%d %d\n", H[t].back().first, H[t].back().second);
	    i = j;
	}
	H[t].emplace_back((int)v.size(), t-1000);
	sort(H[t].begin(), H[t].end());
    }

    int ans = N;
    REP (a, min(2, (int)H[0].size())) REP (b, min(2, (int)H[1].size())) {
	if (H[0][a].second != H[1][b].second) {
	    amin(ans, H[0][a].first + H[1][b].first);
	}
    }

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

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2100
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())
S, T = map(str, input().split())

ans = ""
for i in range(N):
    ans += S[i] + T[i]

print(ans)

Measured memory_bytes: 77476
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    ll cnt=0;
    for(int b=1;b<n+1;b++){
        cnt+=max(0,b-k)*(n/b);
        cnt+=max(0,n%b-k+1);
        if(k==0) cnt--;
    }
    cout<<cnt<<endl;
}


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

int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(a==0)
    {
        cout<<0<<"\n";
        return 0;
    }
    else
    {
      if(n<=a+b)
      {
          cout<<min(n,a)<<"\n";
      }
      else
      {
          long long m = (n/(a+b))*a,p=0;
          if(n%(a+b)!=0)p=n%(a+b);
          cout<<m+min(p,a)<<"\n";
      }
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int N;
		string S;
		cin >> N >> S;

		string l, r;
		int a = 0;
		int b = 0;
		for( int i = 0; i < N; ++i ) {
			if(      S[i] == '(' ) { a += 1; }
			else if( S[i] == ')' ) { b += 1; }

			if( a < b ) {
				l += '(';
				b -= 1;
			}
		}
		for( int i = 0; i < a-b; ++i ) { r += ')'; }

		cout << l << S << r << endl;
	}
};

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


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int a;
    int sum = 0;
    for (int i = 0; i < m; i++) {
        cin >> a;
        sum += a;
    }
    if (sum > n) {
        cout << -1;
    } else {
        cout << n - sum;
    }
}


Measured memory_bytes: 3664
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  
  int array[100001];
  int i;
  for (i = 0; i < 100001; ++i)
  {
    array[i] = 0;
  }
  
  long int count = 0;
  for (i = 0; i < n; ++i)
  {
    int temp;
    scanf("%d", &temp);
    ++array[temp];
    count += temp;
  }
  
  int q, b, c;
  scanf("%d", &q);
  for (i = 0; i < q; ++i)
  {
    scanf("%d %d", &b, &c);
    array[c] += array[b];
    count += (c - b) * array[b];
    array[b] = 0;
    printf("%ld\n", count);
  }
  
  return 0;
}


Measured memory_bytes: 2124
{-# LANGUAGE BangPatterns #-}
import           Control.Monad (replicateM)
import           Data.List     (foldl')

main :: IO ()
main = do
  s <- getLine
  q <- readLn
  qs <- replicateM q getQuery
  putDoubleListLn $ solve s qs

data Query = Reverse | Add Bool Char

getQuery :: IO Query
getQuery = do
  (t:xs) <- words <$> getLine
  if t == "1"
    then return Reverse
    else let [f, c] = xs in return $ Add (f == "1") (head c)

solve :: String -> [Query] -> DoubleList Char
solve s qs = foldr g (fromList s) (reverse qs)
  where g Reverse xs   = rev xs
        g (Add f c) xs = add c f xs

data DoubleList a = DoubleList ![a] ![a] Bool
  deriving Show

putDoubleListLn :: DoubleList Char -> IO ()
putDoubleListLn (DoubleList xs ys True) = do
  putStr xs
  putStrLn $ reverse ys
putDoubleListLn (DoubleList xs ys False) = do
  putStr ys
  putStrLn $ reverse xs

fromList :: [a] -> DoubleList a
fromList xs = DoubleList xs [] True

toList :: DoubleList a -> [a]
toList (DoubleList xs ys True)  = xs ++ reverse ys
toList (DoubleList xs ys False) = ys ++ reverse xs

rev :: DoubleList a -> DoubleList a
rev (DoubleList xs ys f) = DoubleList xs ys $ not f

add :: a -> Bool -> DoubleList a -> DoubleList a
add x True (DoubleList xs ys True)   = DoubleList (x:xs) ys True
add x True (DoubleList xs ys False)  = DoubleList xs (x:ys) False
add x False (DoubleList xs ys True)  = DoubleList xs (x:ys) True
add x False (DoubleList xs ys False) = DoubleList (x:xs) ys False


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

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

    int ans = 0;
    for(int i = 1; i <= N; i++){
        int count = 0;
        if(i % 2 != 0){
            for(int j = 1; j <= N; j++){
                if(i % j == 0) count++;
            }
        }
        if(count == 8)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include<string>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+4;
int main(){
    int x;
    while(cin>>x){
    	cout<<x/2*((x+1)/2)<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void koch(double, double, double, double, int);

int main(){
    int n;
    double x1 = 0.0, x2 = 100.0;
    double y1 = 0.0, y2 = 0.0;

    scanf("%d", &n);
    printf("%f %f\n", x1, y1);
    koch(x1, y1, x2, y2, n);
    return 0;
}

void koch(double x1, double y1, double x2, double y2, int n){
    double ax, ay, bx, by, cx, cy;

    if(n != 0){

        ax = (x2 - x1) / 3 + x1;
        ay = (y2 - y1) / 3 + y1;
        bx = 2 * (x2 - x1) / 3 + x1;
        by = 2 * (y2 - y1) / 3 + y1;

        cx = ((bx - ax)* cos(M_PI/3) - (by - ay)* sin(M_PI/3)) + ax;      // ６０度回転
        cy = ((bx - ax)* sin(M_PI/3) + (by - ay)* cos(M_PI/3)) + ay;

        koch(x1, y1, ax, ay, n-1);
        koch(ax, ay, cx, cy, n-1);
        koch(cx, cy, bx, by, n-1);
        koch(bx, by, x2, y2, n-1);
    }
    else {
        printf("%f %f\n", x2, y2);

    }
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define mo 1000000007
int main(){   ios_base::sync_with_stdio(false);   cin.tie(0);     long long  n;   cin>>n;   long long a[n];   long long pro=0,sum=0,sum1=0;   for(long long i=0;i<n;++i){      cin>>a[i];      sum1+=a[i];      }   for(int i=0;i<n;++i){     pro+=a[i];   sum+=((a[i]%mo)*((sum1-pro)%mo))%mo;   sum%=mo;   }   cout<<sum;   return 0;   }

Measured memory_bytes: 5212
#include <cstdio>
int main()
{
int s,t,d,n;
scanf("%d",&n);
while(n--){
scanf("%d %d",&s,&t);
d=(t<s&&s<6)?-1:1;
while(t!=s){
printf("%d ",s);
s+=d;
if(s==10){
d=-1;
s=5;
}else if(s==0){
d=1;
}
}
printf("%d\n",t);
}	
return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

int main(int argc, char const* argv[])
{
    int n, m;
    std::cin >> n >> m;

    auto sw_info = std::vector<std::vector<int>>(m);
    auto is_on = std::vector<int>(m);
    for(auto &l: sw_info) {
    //for (int i = 0; i < m; ++i) {
        int k;
        std::cin >> k;

        //auto& l = sw_info[i];

        for (int j = 0; j < k; ++j) {
            int tmp;
            std::cin >> tmp;
            l.push_back(tmp - 1);
        }
    }
    for (auto &io: is_on) {
    //for(int i=0; i<m; ++i) {
        //int p;
        //std::cin >> p;
        //is_on[i] = p;
        std::cin >> io;
    }

    auto all_on_pattern = 0;

    for (int i = 0; i < (1 << n); ++i) {
        auto on_switches = std::vector<int>();
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) {
                //std::cout << j;
                on_switches.push_back(j);
            }
        }
        //std::cout << std::endl;

        auto is_all_on = true;
        for (int j = 0; j < m; ++j) {
            auto& sw = sw_info[j];

            auto on_num = 0;
            auto on_index = 0;
            for (auto s : sw) {
                for(auto on_s: on_switches)
                {
                    if(s == on_s)
                    {
                        on_num++;
                    }
                }
                /*
                if(on_switches.size() <= on_index)
                {
                    break;
                }
                while(true)
                {
                    if(s == on_switches[on_index])
                    {
                        on_index++;
                        on_num++;
                        break;
                    }
                    if(s > on_switches[on_index])
                    {
                        on_index++;
                    }
                    if(s < on_switches[on_index])
                    {
                        break;
                    }
                }
                */
            }

            //std::cout << on_num % 2 << " : " << is_on[j] << std::endl;
            if ((on_num % 2) != is_on[j]) {
                is_all_on = false;
                break;
            }
        }

        if (is_all_on) {
            all_on_pattern++;
        }
    }

    std::cout << all_on_pattern << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
unordered_map<int, vector<int>> e;
map<pair<int, int>, int> ans;

void dfs(int node, int par, int use_c) {
    int color = 1;
    // cout << "traverse: " << node << endl;
    for(int child: e[node]) {
        if (child != par) {
            if (color == use_c)
                color++;
            ans[{child, node}] = color;
            ans[{node, child}] = color;
            dfs(child, node, color++);
        }
    }
}

int main() {
    int n, a, b;
    vector<vector<int>> arr;
    cin >> n;
    size_t max_color = 0;
    for(int i = 0; i < n-1; i++) {
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
        max_color = max({max_color, e[a].size(), e[b].size()});
        arr.push_back({a, b});
    }
    cout << max_color << endl;
    dfs(1, 0, 0);

    for(int i = 0; i < n-1; i++) {
        cout << ans[{arr[i][0], arr[i][1]}] << endl;
    }
    return 0;
}

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

int main() {
    int n;
    int r;
    cin >> n;
    cin >> r;
    int count = 0;
    for (int x=0; x<n; x++){
        int j;
        cin >> j;
        if (j>=r){
            count ++;
        }
    }
    cout << count;
}

Measured memory_bytes: 256
#include <stdio.h>

#define WIDTH 12
#define HEIGHT 12

void deleteIsland( int, int );

int field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int main( void ) {
	int x, y, island;

	do {
		for ( y = 0; y < HEIGHT; y++ ) {
			for ( x = 0; x < WIDTH; x++ )
				scanf( "%c", &field[ x ][ y ] );
			scanf( "%*c" );
		}

		island = 0;
		for ( x = 0; x < WIDTH; x++ )
			for ( y = 0; y < HEIGHT; y++ )
				if ( field[ x ][ y ] == '1' ) {
					deleteIsland( x, y );

					island++;
				}

		printf( "%d\n", island );
	} while ( scanf( "%*c" ) != EOF );

	return 0;
}

void deleteIsland( int x, int y ) {
	int i;

	field[ x ][ y ] = '0';

	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ] == '1' )
			deleteIsland( nx, ny );
	}
}

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

int main(void)
{
    string s;
    int cnt=0;

    cin >> s;
    
    if(s[0] == '1') cnt++;
    if(s[1] == '1') cnt++;
    if(s[2] == '1') cnt++;
    cout << cnt << endl;

    return 0;
    
}

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

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < ll > graph[2003];
ll dist[2003];
ll ans[2003];
bool vis[2003];

void bfs(ll st)
{
    queue < ll > qq;

    qq.push(st);

    memset(dist,0,sizeof dist);
    memset(vis,0,sizeof vis);

    vis[st] = 1;
    while(!qq.empty())
    {
        ll top = qq.front();
        qq.pop();

        for(ll xx = 0; xx < graph[top].size(); xx++)
        {
            ll i = graph[top][xx];

            if(vis[i]) continue;

            dist[i] = dist[top] + 1;

            if(i > st)
            {
                ans[dist[i]]++;
            }

            vis[i] = 1;

            qq.push(i);
        }
    }
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(n);
    ll x, y;

    slld(x);
    slld(y);

    for(i = 1; i < n; i++)
    {
        graph[i].push_back(i + 1);
        graph[i + 1].push_back(i);
    }

    graph[x].push_back(y);
    graph[y].push_back(x);

    for(i = 1; i <= n; i++)
    {
        bfs(i);
    }

    for(i = 1; i < n; i++)
    {
        cout << ans[i] << endl;
    }

}





Measured memory_bytes: 384
#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 = 2e4 + 10;
const int OFFSET = 1e4 + 5;

vi vv[2];
string s;

int tt[2][MAXN], sum[2];

bool check(int ind, int val){
	if (val < 0){
		val = -val;
	}
	if ((val + sum[ind]) % 2){
		return false;
	}
	if (val > sum[ind]){
		return false;
	}
	int a = (val + sum[ind]) / 2;
	int b = a - val;
	//printf("%d %d %d %d %d\n", ind, sum[ind], val, a, b);
	if (tt[ind][a] || tt[ind][b]){
		return true;
	}
	return false;
}

void solve(){
	int n, cntt = 0, cntf, x, y;
	cin >> s >> x >> y;
	int ind;
	for(ind = 0; ind < (int)s.length(); ind++){
		if (s[ind] == 'T'){
			break;
		}
		x--;
	}
	
	//printf("%d %d\n", x, y);
	
	
	cntf = 0;
	for(; ind < (int)s.length(); ind++){
		if (s[ind] == 'T'){
			if (cntf){
				//printf("%d %d\n", cntt, cntf);
				vv[cntt & 1].pb(cntf);
				cntf = 0;
			}
			cntt++;
		} else {
			cntf++;
		}
	}
	if (cntf){
		//printf("%d %d\n", cntt, cntf);
		vv[cntt & 1].pb(cntf);
		cntf = 0;
	}
	REP(k, 0, 2){
		tt[k][0] = 1;
		REP(i, 0, SZ(vv[k])){
			int add = vv[k][i];
			sum[k] += add;
			for(int j = MAXN - 1; j >= add; j--){
				if (tt[k][j - add]){
					tt[k][j] = 1;
				}
			}
		}
	}
	if (check(0, x) && check(1, y)){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	/*REP(k, 0, 2){
		tt[k][OFFSET] = 1;
		REP(i, 0, SZ(vv[k])){
			int add = vv[k][i];
			for(int j = add; j < MAXN; j++){
				if (tt[k][j]){
					tt[k][j - add] = 1;
				}
			}
			for(int j = MAXN - 1 - add; j >= 0; j--){
				if (tt[k][j]){
					tt[k][j + add] = 1;
				}
			}
		}
	}*/
	/*if (x + OFFSET >= 0 && x + OFFSET < MAXN 
		&& y + OFFSET >= 0 && y + OFFSET < MAXN 
		&& tt[0][x + OFFSET] && tt[1][y + OFFSET]){
		printf("Yes\n");
	} else {
		printf("No\n");
	}*/
}   


int main(){

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


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

struct RMQ{
	int n = 1, inf = 1 << 30;
	vector<int> tree;

	RMQ(int n_){
		while((n *= 2) < n_);
		tree.assign(2 * n, inf);
	}

	void update(int k, int x){
		tree[k += n] = x;
		while(k){
			k /= 2;
			tree[k] = min(tree[2 * k], tree[2 * k + 1]);
		}
	}

	int rmq(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return inf;
		if(a <= l && r <= b) return tree[k];
		return min(rmq(a, b, 2 * k, l, (l + r) / 2), rmq(a, b, 2 * k + 1, (l + r) / 2, r));
	}

	int rmq(int a, int b){
		return rmq(a, b, 1, 0, n);
	}
};

int main(){
	int n;
	cin >> n;
	int p[n], puni[n + 1];
	for(int &i:p) cin >> i;
	for(int i = 0; i < n; i++) puni[p[i]] = i;
	RMQ a(n), b(n);
	for(int i = 0; i < n; i++) (i % 2 ? b : a).update(i, p[i]);
	auto rmq = [&](int l, int r){return (l % 2 ? b : a).rmq(l, r);};
	priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
	pq.push(make_pair(rmq(0, n), make_pair(0, n)));
	while(!pq.empty()){
		pair<int, pair<int, int>> pp = pq.top();
		pq.pop();
		pair<int, int> p = pp.second;
		if(p.first >= p.second) continue;
		int x = (p.first % 2 ? b : a).rmq(p.first, p.second);
		int y = (p.first % 2 ? a : b).rmq(puni[x], p.second);
		cout << x << ' ' << y << ' ';
		pq.push(make_pair(rmq(p.first, puni[x]), make_pair(p.first, puni[x])));
		pq.push(make_pair(rmq(puni[x] + 1, puni[y]), make_pair(puni[x] + 1, puni[y])));
		pq.push(make_pair(rmq(puni[y] + 1, p.second), make_pair(puni[y] + 1, p.second)));
	}
	cout << endl;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int D, N;
    cin >> D >> N;
    int start = pow(100, D);
    int index = 1;
    int cnt = 0;
    int ans;
    while (cnt != N) {
        int tmp = start + pow(100, D) * (index - 1);
        int tmptmp = tmp;
        int div = 0;
        while (tmp % 100 == 0) {
            tmp /= 100;
            div++;
        }
        if (div == D) {
            ans = tmptmp;
            cnt++;
        }
        index++;
    }
    print(ans);
}

signed main() {
    solve();
}


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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

bool sortbysecond(ii a,ii b) {
  if (a.second != b.second) {
    return a.second<b.second;
  } else {
    return a.first<b.first;
  }
}

void solve()
{
  int n,m;
  cin>>n>>m;
  vector<int> a(n, 0);
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  vector<ii> q;
  for (int i=0; i<m; i++) {
    int b,c;cin>>b>>c;
    q.push_back(ii(b,c));
  }
  sort(q.begin(),q.end(), sortbysecond);
  int k=0;
  for (int i=m-1; i>=0; i--) {
    int b = q[i].first;
    int c = q[i].second;
    for (int j=0; j<b; j++) {
      if (a[k]>=c) break;
      a[k] = c;
      k++;
    }
  }

  ll sum=0;
  for (int i=0; i<n; i++) {
    sum += a[i];
  }
  cout << sum << endl;
}

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


Measured memory_bytes: 1784
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

bool proc2() {
	LOAD(int, N);
	LOADVEC(int, A, N);
	if (N == 1) {
		return true;
	}
	std::vector<int>B(N);
	int sum = A[0];
	for (int i = 1; i < N; ++i) {
		B[i] = A[i] - A[i - 1];
		sum += A[i];
	}
	B[0] = A[0] - A[N - 1];
	int M = N * (N + 1) / 2;
	if (sum%M != 0) {
		return false;
	}
	int k = sum / M;
	for (int i = 0; i < N; ++i) {
		int tmp = k - B[i];
		if (tmp % N != 0 || tmp < 0) {
			return false;
		}
	}
	return true;
}

void proc() {
	if (proc2()) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}


#endif


Measured memory_bytes: 1792
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    INF=10^9+1
    n,q=intLine()
    N0=2^length(bin(q-1))
    data=fill(INF,2*N0)
    t=[intLine() for i in 1:n]
    d=zeros(Int32,q)
    for i in 1:q
        d[i]=int(input())
    end
    for i in 1:n
        t[i][1]=searchsortedfirst(d,t[i][1]-t[i][3])+N0-1
        t[i][2]=searchsortedfirst(d,t[i][2]-t[i][3])+N0-1
    end
    sort!(t,by=x->-x[3])
    for i in 1:n
        l::Int32,r::Int32,x::Int32=t[i]
        while l<r
            if r&1==1
                r-=1
                data[r]=x
            end
            if l&1==1
                data[l]=x
                l+=1
            end
            l>>=1
            r>>=1
        end
    end
    for k in N0-1:q+N0-2
        s=INF
        while k>=0
            s=min(s,data[k+1])
            k=(k-1)>>1
        end
        if s==INF
            println(-1)
        else
            println(s)
        end
    end
end
main()

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

using namespace std;
const int MAXN=3e5+5;
int arr[MAXN];
int dp[MAXN];
struct mx
{
    int x=0,y=0;
    void update(int r)
    {
        if(r>x)swap(r,x);
        if(r>y)swap(r,y);
    }
};

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".in","r",stdin);
    int n;
    cin>>n;
    for(int i=0; i<(1<<n); i++)
        cin>>arr[i];
    for(int i=1; i<(1<<n); i++)
    {
        dp[i]=dp[i-1];
        mx temp;
        for(int sm=i; sm>0; sm=i&(sm-1))
            temp.update(arr[sm]);
        temp.update(arr[0]);
        dp[i]=max(dp[i],temp.x+temp.y);
        cout<<dp[i]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 5120
# -*- coding: utf-8 -*-
"""
A - CODEFESTIVAL 2016
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_a

"""
import sys


def solve(s):
    return '{} {}'.format(s[:4], s[4:])


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            Integer p[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                p[i] = Integer.parseInt(in.next());
            }
            int ans = 0;

            Arrays.sort(p, Comparator.reverseOrder());

            for (int i = 0; i < n; i++) {
                if (i == 0) {
                    ans += p[0] / 2;
                } else {
                    ans += p[i];
                }
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
int N;
int a[MAX_N+2];
int main(void){
	cin >> N;
	a[0] = 0;
	for(int i=1; i<N+1; i++) cin >> a[i];
	a[N+1] = 0;
	int path = 0;
	for(int i=1; i<N+2; i++) path += abs(a[i] - a[i-1]);
	for(int i=1; i<N+1; i++){
		if((a[i-1] - a[i] > 0) && (a[i+1] - a[i] > 0)) cout << path - 2*abs(min(a[i-1], a[i+1]) - a[i]) << endl;
		else if((a[i-1] - a[i] < 0) && (a[i+1] - a[i] < 0)) cout << path - 2*abs(max(a[i-1], a[i+1]) - a[i]) << endl;
		else cout << path << endl;
	}
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  vector<tuple<int,int,int>> v;
  bool zero = false;
  for (int i = 0; i < N; i++) {
    int tmpx, tmpy, tmph;
    cin >> tmpx >> tmpy >> tmph;
    v.emplace_back(tmph, tmpx, tmpy);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = 0; i < N; i++) {
    h[i] = get<0>(v[i]);
    x[i] = get<1>(v[i]);
    y[i] = get<2>(v[i]);
  }

  for (int cx = 0; cx <= 100; cx++) for (int cy = 0; cy <= 100; cy++) {
    int ch = -1;
    bool ok = true;
    for (int i = 0; i < N; i++) {
      if (ch == -1) {
        ch = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
      } else {
        if (h[i] == 0) {
          int newch = ch - (abs(cx - x[i]) + abs(cy - y[i]));
          if (newch > 0) {
            ok = false;
            break;
          }
        } else {
          int newch = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
          if (newch != ch) {
            ok = false;
            break;
          }
        }
      }
    }
    if (ok) {
      cout << cx << " " << cy << " " << ch << endl;
      break;
    }
  }

  return 0;
}

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

int main(){
	int a,b,ans=0;
  cin >> a >> b;
  for(int i=0; i<=a; i++){
  	if(i*2+(a-i)*4 == b) {
      ans++;
      break;
    }
  }
  if(ans == 0) cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 3632
a,b,k = map(int, input().split())

if a == b:
    print(a)
    quit()
if b-a < 2*k:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)


Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h> 
#include <iostream>
#include <map>
#include <cmath>
#include<set>
#include <vector>
#include<bitset>
#include <string>
#include<queue>
#include <algorithm>
#include<set>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define vl vector<long long >;
//typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,int>ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;
const int N=3000;//const int NN=1000000001;
//int A[N];int B[N];
#define INF 1e18L+5
//int dp[2][NN];
//int dp[N][N][N]={0};
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//int dp[N][N];
/*void show(vi v,int valeur){
    int count=0;
    
    rep(i,0,(int)v.size()){
        ++count;
        cout<<v[i]<<" " ;
        if(count==valeur){cout<<"\n";count=0;}
    }
}*/
 int main() {
        ios_base::sync_with_stdio(false); cin.tie(NULL);int n,c;
  string s,t;
  //vector<char> ans;
  cin>>s>>t;
   int tt=t.size();int ss=s.size();
  s="#"+s;t="@"+t;
  //cout<<s;
 
  vvi dp(ss+1,vi(tt+1,0));
  int index=0;
  for(int i=1;i<=ss;++i){
      for(int j=1;j<=tt;++j){
          if(s[i]==t[j]){
             dp[i][j]=1+dp[i-1][j-1];
            
          }
          else{
              int aa=dp[i-1][j];
              int bb=dp[i][j-1];
              dp[i][j]=max(aa,bb);
          }
          // cout<<"Pour i "<< i<<" pour j "<<j <<" "<<dp[i][j] <<"\n";
      }
     //cout<<dp[i][tt-1]<<"\n";
  }
 
  //cout<<dp[ss][tt];
  if(dp[ss][tt]==0){
      cout<<" ";return 0;
  }
  vector<char> v;
  int i=ss;int j=tt;
  while(i>0&&j>0){
      if(s[i]==t[j]){v.eb(s[i]);--i;--j;}
      else if(dp[i][j-1]>dp[i-1][j]){
          --j;
      }
      else{
          --i;
      }
  }
  reverse(v.begin(),v.end());int nn=v.size();rep(i,0,nn)cout<<v[i]<<"";
 // cout<<t;*/
   return 0;
 }



Measured memory_bytes: 38508
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll w, h, x, y ;
int main()
{
    IO
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(10)<<(1.0*w*h/2.0)<<" ";
    if((w%2==0 && x==w/2)&& (h%2==0 && y==h/2))
        cout<<1;
    else
        cout<<0;
}


Measured memory_bytes: 3800
#include<iostream>
using namespace std;
int main()
{
    string s;
    int l,i,c=0,ma=0;
    cin>>s;
    l=s.length();
    for(i=0;i<l;i++)
    {
        if(s[i]=='R')
           {
                c++;

           }
        else
        {
            ma=max(ma,c);
            c=0;
        }
    }
    cout<<max(ma,c)<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int,int>pii;
int main(){
    int n,m;
    while(scanf("%d%d",&n,&m),n||m){
        vector<pii>V(n);
        for(int i=0;i<n;i++){
            int d,p;
            scanf("%d%d",&d,&p);
            V[i]=pii(p,d);
        }
        sort(V.rbegin(),V.rend());
        int ans=0;
        for(int i=0;i<n;i++){
            int val=min(V[i].second,m);
            V[i].second-=val;
            m-=val;
            ans+=V[i].first*V[i].second;
        }
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 1112
#include <stdio.h>

void leap_year(int x, int y);

int main(void)
{
    while (1) {
        static int first_or_not = 0;//二回目以降空行を入れるため.
        int op, ed;
        scanf("%d %d", &op, &ed);
        if (op == 0 && ed == 0) {
            break;
        } else {
            if (first_or_not != 0) {
                printf("\n");
            }
            leap_year(op, ed);
            first_or_not = 1;
        }
    }
    return 0;
}

void leap_year(int op, int ed)
{
    int i;
    int count = 0;
    for (i = op; i <= ed; i++) {
        if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0)) {
            printf("%d\n", i);
            count++;
        }
    }
    if (count == 0) {
        printf("NA\n");
    }
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int n,x;
    cin>>n>>x;
    vector<int> L(n);
    REP(i,n){
        cin>>L[i];
    }
    int i=1;
    int sum=L[0];
    while(sum<=x){
        if(i==n){
            i++;
            break;
        }
        sum+=L[i];
        i++;
    }
    OUT(i);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll H, W;
  cin >> H >> W;
  ll N;
  cin >> N;
  vl a(N);
  rep(i, N) cin >> a[i];

  vvl c(H, vl(W, 0));
  ll h = 0, w = 0, d = 1;
  rep(i, N){
    rep(j, a[i]){
      c[h][w] = i + 1;

      if(d == 1){
	if(w == W - 1){
	  h++;
	  d = -1;
	} else{
	  w++;
	}
      } else{
	if(w == 0){
	  h++;
	  d = 1;
	} else{
	  w--;
	}
      }
    }
  }

  rep(i, H){
    rep(j, W){
      cout << c[i][j] << ' ';
    }
    cout << endl;
  }
  
  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    long int N,ans=0,A;
    cin >> N;
    cin >> A;
   

      cout << N*N-A << "\n";


  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[201010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
bool flag[100];
vector<ll> Prime{2,3,5,7,11,13,17,19,23,29,31};


int main() {
	cin>>A>>B>>K;
	ll count=0;
	urep(i,min(A,B),1){
		if(A%i ==0 && B%i==0){
			count++;
		}
		if(count==K){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()





int main() {
    string s;
    cin >> s;
    int ctr = 0;
    int ans = 0;
    rep (i, 3) {
        if (s[i] == 'R') {
            ctr++;
            chmax(ans, ctr);
        } else {
            ctr = 0;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3588
// キャンディーと2人の子供
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]+a[1]==a[2]) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int answer = 0;
  for (int i = 0; i < N; i++) {
    int L, R;
    cin >> L >> R;
    answer += R - L + 1;
  }
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll fact[101001];
vector<ll> prime_list;

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

ll modinv(ll x){
	return modpow(x, MOD-2);
}

void prime_fact(ll x){
	ll temp = x;
	for (int i = 2; i*i <= x; i++){
		if (temp % i == 0){
			ll coun = 0;
			while (temp % i == 0){
				coun++;
				temp /= i;
			}
			prime_list.push_back(coun);
		}
	}
	if (temp != 1){
		prime_list.push_back(1);
	}
	return;
}

int main(){
	ll n, m;
	cin >> n >> m;
	fact[0] = 1;
	for (int i = 1; i<= 101000; i++){
		fact[i] = fact[i-1]*i;
		fact[i] %= MOD;
	}
	prime_fact(m);
	ll ans = 1;

	for (auto x : prime_list){
		ans *= ((fact[(x+n-1)]*modinv(fact[x]))%MOD*modinv(fact[n-1]))%MOD;
		ans %= MOD;
	}

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

Measured memory_bytes: 4296
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

ll b[101] = {};
int main() {
	ll n; cin >> n;
	repe(i, 1, n)cin >> b[i];

	vector<ll> v;
	ll k = n;

	while (1) {
		bool update = false;
		rep_re(i, 1, k) {
			if (i == b[i]) {
				v.push_back(i);
				rep(j, i, n) {
					b[j] = b[j + 1];
				}
				update = true;
				break;
			}
		}
		if (!update) {
			cout << -1 << endl;
			return 0;
		}
		k--;
		if (v.size() == n)break;
	}

	reverse(v.begin(), v.end());
	rep(i, 0, n) {
		cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
var
 n,i,t,x,y:longint;
begin
 readln(n);
 for i:=1 to n do
  begin
   readln(t,x,y);
   if x+y>t then
    begin
     writeln('No');
     halt;
    end;
   if ((x+y) mod 2=0) and (odd(t)) then
    begin
     writeln('No');
     halt;
    end;
   if ((x+y) mod 2=1) and (t mod 2=0) then
    begin
     writeln('No');
     halt;
    end;
  end;
 writeln('Yes');
end.

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

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> p,q,r;
    rep(i,a){
        int tmp;cin>>tmp;p.push_back(tmp);
    }
    rep(i,b){
        int tmp;cin>>tmp;q.push_back(tmp);
    }
    rep(i,c){
        int tmp;cin>>tmp;r.push_back(tmp);
    }
    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());
    priority_queue <int,vector<int>,greater<int> > que;

    rep(i,x){
        que.push(p[i]);
    }
    rep(i,y){
        que.push(q[i]);
    }

    rep(i,c){
        int tmp = que.top();
        if(tmp<r[i]){
            que.pop();
            que.push(r[i]);
        }else{
            break;
        }
    }
    ll ans =0;
    while(!que.empty()){
        int tmp = que.top();que.pop();
        ans+=tmp;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2552
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());

	int[][] M = new int[N+1][10];
	for (int i = 1; i < 10; i++) {
	    M[0][i] = -1;
	}
	
	for (int i = 1; i <= N; i++) {
	    int w = Integer.parseInt(scan.next());
	    for (int j = 0; j < 10; j++) {
		int index = mod(j-w, 10);
		int tmp = (M[i-1][index] > -1 ? w + M[i-1][index] : -1);
		M[i][j] = max(M[i-1][j], tmp);		
	    }
	}
	int ans = 0;
	for (int i = 1; i < 10; i++) {
	    ans = (M[N][i] > ans ? M[N][i] : ans);
	}

	System.out.println(ans);
	scan.close();
    }

    private static int max(int x, int y) {
	return x > y ? x : y;
    }

    private static int mod(int x, int y) {
	return x >= 0 ? x % y : mod(x+y, y);
    }
}


Measured memory_bytes: 22996