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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int a, b;
    cin >> a >> b;
    cout << max(0ll, a - 2 * b) << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

if len(S) == 1:
    if S == T:
        print(0)
    else:
        print(1)

else:
    l = []
    for i in range(len(S) - len(T) + 1):
        A = S[i:i + (len(T))]
        # print(A)
        count = 0
        for j in range(len(A)):
            if A[j] == T[j]:
                count += 1
                # print(count)
        l.append(count)

    # print(l)
    if len(l) > 0:
        a = len(T) - max(l)
        print(a)
    else:
        a = 1
        print(a)


Measured memory_bytes: 9148
#include<stdio.h>
int main()
{
    int i,j,h,w;
    while(1){
        scanf("%d%d",&h,&w);
        if(h == 0 && w == 0)    break;
        for(i=0;i<w;i++)
            putchar('#');
        putchar('\n');
        for(j=0;j<h-2;j++){
            putchar('#');
            for(i=0;i<w-2;i++)
                putchar('.');
            puts("#");
 
        }
        if(h>1){
            for(i=0;i<w;i++)
                putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 588
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a_li = LI()  # 3N

    a_li.sort()

    a_li = a_li[N::2]
    print(sum(a_li))


    # print('Hello world!')



main()

Measured memory_bytes: 37084
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)

int main()
{
	fast();

	using P = pair<int, int>;

	// d[0] : うえ, d[1] : みぎ, d[2] : した, d[3] : ひだり
	int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> grid(H);
	vector<vector<vector<P>>> d(H);

	int sx, sy, gx, gy;

	cin >> sx >> sy >> gx >> gy;
	sx--, sy--, gx--, gy--;

	for (int i = 0; i < H; i++)
	{
		cin >> grid[i];
	}

	for (int i = 0; i < H; i++) // init
	{
		d[i] = vector<vector<P>>(W, vector<P>(4, P(inf, inf)));
	}

	// (x, y), dir
	deque<pair<P, int>> que;
	for (int i = 0; i < 4; i++)
	{
		d[sx][sy][i] = P(1, 0);
		que.push_back({P(sx, sy), i});
	}

	while (!que.empty())
	{
		auto v = que.front();
		que.pop_front();
		int vx = v.first.first, vy = v.first.second, dir = v.second;

		for (int i = 0; i < 4; i++) // 向きを変える
		{
			if (i == dir)
				continue;
			P ncost = make_pair(d[vx][vy][dir].first + 1, 0);

			if (d[vx][vy][i] <= ncost)
				continue;

			d[vx][vy][i] = ncost;

			que.push_back({P(vx, vy), i});
		}

		// 直進する
		int nx = vx + dx[dir], ny = vy + dy[dir];

		if (nx < 0 || nx >= H || ny < 0 || ny >= W) // grid の外
			continue;
		if (grid[nx][ny] == '@') // 行き止まり
			continue;

		int df = d[vx][vy][dir].first, ds = d[vx][vy][dir].second;
		P ncost = make_pair(df + (ds + 1) / (K + 1), ds % K + 1);
		if (d[nx][ny][dir] <= ncost)
			continue;
		d[nx][ny][dir] = ncost;

		if (ds >= K)
			que.push_back({P(nx, ny), dir});
		else
			que.push_front({P(nx, ny), dir});
	}

	int min_cost = (*min_element(d[gx][gy].begin(), d[gx][gy].end())).first;

	cout << (min_cost == inf ? -1 : min_cost) << "\n";
}


Measured memory_bytes: 79160
n = int(input())
s = input()
ss = list(s)[::-1]

white = 0
black = 0
w = [0] * n
b = [0] * n

for i in range(n):
    if s[i] == '#':
        black += 1
    if ss[i] == '.':
        white += 1
    b[i] = black
    w[-i-1] = white

ans = 10**9

for i in range(n):
    if b[i] + w[i] < ans:
        ans = b[i] + w[i]

print(ans-1)

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

using namespace std;
set<int> table;

int main() {
  ios::sync_with_stdio(false);
  for(int i = 1; i <= 9; ++i) {
    for(int j = 1; j <= i; ++j) {
      table.insert(i*j);
    }
  }
  int target;
  cin >> target;
  if(table.find(target) != table.end()) cout << "Yes";
  else cout << "No";


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...);}
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 9223372036854775800;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 62;
const long double PI = 3.141592653589793;
const int DIGITSIZE = 18;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
int x8[] = {1, 1, 1, -1, -1, -1, 0, 0};
int y8[] = {1, 0, -1, 1, 0, -1, 1, -1};
bool takeTestCases = 0;
bool printCaseNo = 0;

void getac(int T) {
	int n;
	cin >> n;
	int count1 = 0;
	bool ans = false;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (x == y) {
			count1++;
		} else {
			count1 = 0;
		}
		if (count1 >= 3) {
			ans = true;
		}
	}
	if (ans) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

}
int  main()
{

	fastio;
	int t = 1;
	if (takeTestCases) { cin >> t; }
	int t_t = 1;
	while (t--) {
		if (printCaseNo)
		case (t_t);
		getac(t_t);
		t_t++;
	}
	cerr << "Total time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
	return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;
int x;
void solve(){
	
} 
int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	//solve();
	scanf("%d",&x);
	int a=x/500;
	x%=500;
	int b=x/5;
	printf("%d",1000*a+5*b);

    return 0;
}




Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    ss <- getLine
    let as = nub . filter (`elem` "CF") $ dropWhile (/= 'C') ss
    case take 2 as of
        "CF" -> putStrLn "Yes"
        _    -> putStrLn "No"

Measured memory_bytes: 508
#include<iostream>
using namespace std;
struct Card{char suit, value;};

void bubble(struct Card A[], int N){
  int i,j;
  for(i = 0; i<N;i++){
    for(j = N-1; j>= i+1; j--){
      if(A[j].value < A[j - 1].value){
	Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[],int N){
  int i,j;
  for(i = 0; i<N; i++){
    int minj = i;
    for(j = i; j < N; j++){
      if(A[j].value < A[minj].value) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N){
  int i;
  for(i = 0; i<N; i++){
    if(i > 0) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
  int i;
  for(i = 0; i<N; i++){
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main(){
  Card C1[100],C2[100];
  int N,i;
  char ch;

  cin >> N;
  for(i = 0; i<N; i++){
    cin >> C1[i].suit >> C1[i].value;
  }
  for(i = 0; i<N;i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 0
    for A in range(1, N+1):
        ans += (N-1) // A
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62712
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll unsigned long long
#define int long long
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second

int32_t main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	int n, k;
	cin >> n >> k;
	vi dp(n, INT_MAX);
	vi arr(n);
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	dp[0] = 0;
	for(int i = 1; i <  n; i++){
		for(int j = i - 1; j >= 0 && i - j <=k; j--){
			dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
		}
	}
	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];
 
inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}
 
inline ll add(ll a, ll b){
    return take_mod(a+b);
}
 
inline ll sub(ll a, ll b){
    return take_mod(a-b);
}
 
 
inline ll mul(ll a, ll b){
    return take_mod(a * b);
}
 
inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}
 
ll mod_inv(ll x){
    return pow(x, mod-2);
}
 
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}
 
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}
 
ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}
 
ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}
     
int main(){
  ll N, M;

  cin >> N >> M;

  ll ss[N];
  ll ts[M];
    
  for(int i = 0; i < N; i++){
    cin >> ss[i];
  }

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

#ifdef DEBUG
  for(int i = 0; i < N; i++){
    cout << ss[i] << " ";
  }
  cout << endl;

  for(int i = 0; i < M; i++){
    cout << ts[i] << " ";
  }
  cout << endl;  
#endif

  ll dp[N+1][M+1];

  for(int i = 0; i < N + 1; i++){
    for(int j = 0; j < M + 1; j++){
      if(i == 0 || j == 0){
	dp[i][j] = 0;
      } else if(ss[i-1] == ts[j-1]){
	dp[i][j] = add(add(dp[i-1][j], dp[i][j-1]), 1);
      } else {
	dp[i][j] = sub(add(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]);	
      }
    }
  }

  cout << add(dp[N][M], 1) << endl;
  
  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    if(t >= 30)
        cout << "Yes";

    else
        cout << "No";
    
    return 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    int K; cin >> K;
    vector<int> H(N);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
        if (H[i] >= K) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 888
n,m=map(int,input().split())
if m==0:
    print(0)
    exit()
ans=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    ans[a-1].append((b-1))
    ans[b-1].append((a-1))
v=[]#全ての点を訪問済み
def dfs(now,visited=[]):
    global v
    if len(visited)==n:
        v.append([visited])
        return
    for j in ans[now]:
        if j not in visited:
            dfs(j,visited+[j])
dfs(0,[0])
print(len(v))


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

ll mod(double a, double b){
	return a - floor(a / b) * b;
}

int main(){
	IOS;
	double n;
	cin >> n;
	double a, b, c;
	for(a = 1;a <= 3500;a++){
		for(b = 0;b <= 3500;b++){
			if(4 * a * b - n * (a + b) == 0)continue;
			c = n * a * b / (4 * a * b - n * (a + b));
			if(floor(c) == ceil(c) && c >= 1){
				cout << (ll)a << " " << (ll)b << " " << (ll)c << endl;
				return 0;
			} 
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
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 N;
long long W, weight[110], value[110]; // 少し余裕を持たせてサイズ110で用意

// DP table
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DP
    for (int i = 0; i < N; ++i) {
      for (int sum_w = 0; sum_w <= W; ++sum_w) {
        // i番目の品物を選び場合
        if (sum_w - weight[i] >= 0) {
          chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
        }
        // i番目の品物を選ばない場合
        chmax(dp[i+1][sum_w], dp[i][sum_w]);
      }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include <stdio.h>

int main(void)
{
	int x,y,d;
	scanf("%d%d",&x,&y);
	if(y>x){
		d=x;
		x=y;
		y=d;
	}
	while(y>0){
		d=x%y;
		x=y;
		y=d;
	}
	printf("%d\n",x);
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
		cout << "Yes" <<endl;
	}
	else cout << "No" <<endl;
}

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

const int MAX = 200;
const int base = 100;

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<string> A(N);
  vector<vector<long long>> den(MAX + 1, vector<long long>(MAX + 1, 0));
  for(int i = 0; i < N; i++){
    cin >> A[i];
    long long a = 0;
    long long ten = 0;
    for(int j = 0; j < (int)A[i].size(); j++){
      if(A[i][j] != '.'){
        a = a * 10 + (A[i][j] - '0');
        if(ten) ten *= 10;
      }else ten = 1;
    }
    
    if(!ten) ten = 1;
    
    long long p = ten / gcd(a, ten);
    int two = 0, five = 0;
    while(p % 2 == 0){
      --two;
      p /= 2;
    }
    while(p % 5 == 0){
      --five;
      p /= 5;
    }
    
    p = a / gcd(a, ten);
    while(p % 2 == 0){
      ++two;
      p /= 2;
    }
    while(p % 5 == 0){
      ++five;
      p /= 5;
    }
    
    if(two + base < 0 || five + base < 0 || two + base > MAX || five + base > MAX) exit(1);
    ++den[two + base][five + base];
  }
  
  for(int i = MAX; i >= 0; i--){
    for(int j = MAX; j >= 0; j--){
      if(i < MAX) den[i][j] += den[i + 1][j];
    }
  }
  
  for(int j = MAX; j >= 0; j--){
    for(int i = MAX; i >= 0; i--){
      if(j < MAX) den[i][j] += den[i][j + 1];
    }
  }
  
  long long pairs = 0;
  
  for(int i = 0; i < N; i++){
    long long a = 0;
    long long ten = 0;
    for(int j = 0; j < (int)A[i].size(); j++){
      if(A[i][j] != '.'){
        a = a * 10 + (A[i][j] - '0');
        if(ten) ten *= 10;
      }else ten = 1;
    }
    
    if(!ten) ten = 1;
    
    long long p = ten / gcd(a, ten);
    int two = 0, five = 0;
    while(p % 2 == 0){
      --two;
      p /= 2;
    }
    while(p % 5 == 0){
      --five;
      p /= 5;
    }
    
    p = a / gcd(a, ten);
    while(p % 2 == 0){
      ++two;
      p /= 2;
    }
    while(p % 5 == 0){
      ++five;
      p /= 5;
    }
    
    pairs += den[-two + base][-five + base];
    if(two >= 0 && five >= 0) pairs--;
  }
  
  cout << pairs / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 9852
n, x, y = map(int, input().split())
ans = [0 for _ in range(n-1)]
for i in range(1, n):
  for j in range(i+1, n+1):
    a = min(j-i, abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1)
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

bool g[101][101];

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

    int odd_num = 0;
    REP(i,N){
        int a;
        cin >> a;
        if(a%2==1) odd_num++;
    }

    YES(odd_num%2==0)

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif
ll A, B, N;

ll f(ll i) {
    return (i * A) / B - A * (i / B);
}


void solve() {
    cin >> A >> B >> N;
    ll ans = 0;
    if (B - 1 <= N) {
        ans = f(B - 1);
    }
    ans = max(ans, f(N));
    ans = max(ans, f(0));
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3648
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
    ll a, b; cin >> a >> b;
    if(a > b) swap(a, b);
    
    if( (b-a)% 2 == 0){
        cout << (b+a)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}
    


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

int main(){
  vector<int> a(9);
  for(int i=0;i<9;i++){
    cin >> a.at(i);
  }
  
  int n,cnt=0;
  cin >> n;
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  vector<int> x(101);
  for(int i=0;i<n;i++){
    x.at(b.at(i))++;
  }
  
  if(x.at(a.at(0)) == 1 && x.at(a.at(1)) == 1 && x.at(a.at(2)) == 1) cnt++;
  if(x.at(a.at(3)) == 1 && x.at(a.at(4)) == 1 && x.at(a.at(5)) == 1) cnt++;
  if(x.at(a.at(6)) == 1 && x.at(a.at(7)) == 1 && x.at(a.at(8)) == 1) cnt++;
  if(x.at(a.at(0)) == 1 && x.at(a.at(3)) == 1 && x.at(a.at(6)) == 1) cnt++;
  if(x.at(a.at(1)) == 1 && x.at(a.at(4)) == 1 && x.at(a.at(7)) == 1) cnt++;
  if(x.at(a.at(2)) == 1 && x.at(a.at(5)) == 1 && x.at(a.at(8)) == 1) cnt++;
  if(x.at(a.at(0)) == 1 && x.at(a.at(4)) == 1 && x.at(a.at(8)) == 1) cnt++;
  if(x.at(a.at(2)) == 1 && x.at(a.at(4)) == 1 && x.at(a.at(6)) == 1) cnt++;
  
  if(cnt >0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

num_four = len([i for i in range(n) if a[i]%4==0])
num_even = len([i for i in range(n) if a[i]%4==2])
num_odd  = len([i for i in range(n) if a[i]%2!=0])

if num_even==0:
    if num_odd <= num_four+1: print('Yes')
    else: print('No')
else:
    if num_odd<=num_four: print('Yes')
    else: print('No')

Measured memory_bytes: 63640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);

    int n;

    cin >> n;

    cout << (n % 10 == 7 || n / 10 % 10 == 7 || n / 100 == 7 ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,a[N];
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
bool check(){
	int tot=n&1;
	for (int i=1;i<=n;i++)
		tot^=a[i]&1;
	for (int i=1;i<=n;i++)
		if (a[i]==1)
			return tot;
	int o=0;
	for (int i=1;i<=n;i++)
		o+=a[i]&1;
	if (o>1)
		return tot;
	for (int i=1;i<=n;i++)
		if (a[i]&1)
			a[i]--;
	int g=a[1];
	for (int i=2;i<=n;i++)
		g=gcd(g,a[i]);
	for (int i=1;i<=n;i++)
		a[i]/=g;
	return !check();
}
int main(){
	n=read();
	for (int i=1;i<=n;i++)
		a[i]=read();
	puts(check()?"First":"Second");
	return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a-b)<=d&&abs(b-c)<=d) || abs(a-c) <= d)cout<< "Yes"<<endl;
else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int result = 0;
		int count = 0;

		for(int i = 0; i <= A; i++) {
			for(int j = 0; j <= B; j++) {
				for(int k = 0; k <= C; k++){
					 result = (500 * i) + (100 * j) + (50 * k);
					 if(result == X) {
						 count++;
					 }
				}
			}
		}

		System.out.println(count);

	}

}

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

#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r){bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r){bool a=l<r;if(a)l=r;return a;}
template <typename T>istream& operator>>(istream &is,vector<T> &v){for(auto &it:v)is>>it;return is;}

constexpr char ln = '\n';
constexpr int mod = 1e9+7;
const string ok = "Yes";
const string ng = "UNRESTORABLE";
const char inf='z'+1;

bool check(string s,string t){
    int n=s.size();
    REP(i,n)if(s[i]=='?'||s[i]==t[i]);else return false;
    return true;
}
int main(){
    string s,t;
    cin>>s>>t;
    auto y=s;
    int n = s.size();
    int m = t.size();
    bool f=false;
    REP(i,n)if(y[i]=='?')y[i]=inf;
    REP(i,n-m+1){
        auto u =s.substr(i,m);
        
        if(!check(u,t))continue;
        f=true;
        u=s.substr(0,i)+t+s.substr(i+m,n-i+m);
        REP(j,n)if(u[j]=='?')u[j]='a';
        chmin(y,u);
    }
    if(!f)y=ng;
    cout<<y<<endl;
    
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	string s;
  	cin >> s;
 	vector<bool> alphabet(26,false);
  	rep(i,s.size()){
    	alphabet[s[i]-'a'] = true;
    }
  	rep(i,26){
      	if(!alphabet[i]){
  			cout << (char)('a'+i) << endl;
        	return;
        }
    }	
  	cout << "None" << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 512
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int a , b , c ;
	cin >>a >> b >> c ;
	cout << c << " "<< a << " " << b << endl ;

}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
	string ans[] = { "No", "Yes" };
	long long int q, left = 0;
	cin >> q;
	for(int i = 0; i < q; i++) {
		char ch;
		long long int a, b;
		cin >> a >> ch >> b;
		if( ch == '(' )
			left += b;
		else
			left -= b;
		cout << ans[left == 0] << endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n,x,c;
        cin>>n>>x>>c;

        ll ans=n/x;
        ans+=(n%x!=0)?1:0;

        cout<<ans*c;
    }
}

Measured memory_bytes: 3640
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]
cc = inputs[0][2]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p aa, bb, cc
end

puts [cc-(aa-bb), 0].max


Measured memory_bytes: 1788
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int dp[n + 1][4][4][4];
	for (int i = 3; i <= n; i++)
		for (int j = 0; j < 4; j++)
			for (int k = 0; k < 4; k++)
				for (int l = 0; l < 4; l++)
					dp[i][j][k][l] = 0;
		
	for (int j = 0; j < 4; j++)
		for (int k = 0; k < 4; k++)
			for (int l = 0; l < 4; l++) {
				if (j == 0 && k == 1 && l == 2) continue;
				if (j == 0 && k == 2 && l == 1) continue;
				if (j == 1 && k == 0 && l == 2) continue;
				dp[3][j][k][l] = 1;
			}
	
	for (int i = 3; i < n; i++)
		for (int j = 0; j < 4; j++)
			for (int k = 0; k < 4; k++)
				for (int l = 0; l < 4; l++) {
		
		for (int m = 0; m < 4; m++) {
			if (m == 2) {
				if (j == 0 && l == 1) continue;
				if (j == 0 && k == 1) continue;
				if (k == 1 && l == 0) continue;
				if (k == 0 && l == 1) continue;
			} else if (m == 1) {
				if (k == 0 && l == 2) continue;
			}
			dp[i + 1][k][l][m] += dp[i][j][k][l];
			if (dp[i + 1][k][l][m] >= 1000000007)
				dp[i + 1][k][l][m] -= 1000000007;
		}
	}
	int res = 0;
	for (int j = 0; j < 4; j++)
		for (int k = 0; k < 4; k++)
			for (int l = 0; l < 4; l++) {
				res += dp[n][j][k][l];
				if (res >= 1000000007)
					res -= 1000000007;
			}
	
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int arr[] = new int[3];
        for (int i = 0; i < arr.length; i++){
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
    }
}


Measured memory_bytes: 26312
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int H, A[MAX+1];

void maxHeapify(int i)
{
    int l, r, largest;
    l = 2*i;
    r = 2*i + 1;
    if(l<=H && A[l]>A[i]) largest = l;
    else largest = i;
    if(r<=H && A[r]>A[largest]) largest = r;
    if(largest != i)
    {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract()
{
    int maxv;
    if(H<1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key)
{
    if(key < A[i]) return ;
    A[i] = key;
    while(i>1 && A[i/2]<A[i])
    {
        swap(A[i], A[i/2]);
        i = i/2;
    }
}

void insert(int key)
{
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main()
{
    int key;
    char com[10];
    while(1)
    {
        scanf("%s", com);
        if(com[0] == 'e' && com[1] == 'n') break;
        if(com[0] == 'i')
        {
            scanf("%d", &key);
            insert(key);
        }
        else printf("%d\n", extract());
    }
    return 0;
}


Measured memory_bytes: 6488
#include<iostream>

using namespace std;

int main(){

  int a,b;
  char op;
  for ( ; ; ){
    cin>> a >> op >> b;
    if( op=='?' ) break;
    if( op=='+' ){
      cout<< a+b << endl;
    }if( op=='-'){
      cout << a-b << endl;
    }if( op=='*'){
      cout << a*b << endl;
    }if( op=='/'){
      cout << a/b << endl;
    }
  }
  return 0;
  }

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
int ans=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=1;i<n-1;i++)
{
if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]>a[i+1] && a[i]<a[i-1]))
{
ans++;
}
}
cout<<ans<<endl;
}


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

using namespace std;

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



vector<int> a(n);
vector<int> b(n);

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

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

int max1 = a[n-1];
int max2 = a[n-2];


for (int i = 0; i < n ; ++i)
{
	if(b[i] == max1){
		cout << max2 <<endl;
	}
	else{
		cout << max1 <<endl;

	}
}
return 0;

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

typedef std::vector<int> Poly;
typedef std::pair<int,int> Pair;
typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;

const int maxn = 100000, maxm = 2000, MAX = 1e6 + 5, mod = 1000000;
//template{{{
const long double Pi = 3.14159265358979323846l, Eps = 1e-4;
template <class T> inline bool equal(T x, T y) { return fabs(x - y) < Eps; }
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y, int Mod = mod) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = (ll) ans * x % Mod;
		x = (ll) x * x % Mod, y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;
ll d[maxn + 5];
int size[maxn + 5];
std::map<ll, int> id;
std::pair<ll, int> p[maxn + 5];
std::vector<int> T[maxn + 5];
int fa[maxn + 5];

ll distance;

void dfs(int u, ll dis) {
	distance += dis;
	for (int v : T[u])
		dfs(v, dis + 1);
}

bool check() {
	dfs(p[1].se, 0);
	return distance == d[p[1].se];
}

signed main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	n = read;
	for (int i = 1; i <= n; ++i) {
		p[i].fi = d[i] = read;
		p[i].se = id[d[i]] = i;
		size[i] = 1;
	}

	std::sort(p + 1, p + n + 1);
	for (int i = n; i > 1; --i) {
		ll df = p[i].fi - n + size[p[i].se] * 2;
		if (df >= p[i].fi) return puts("-1"), 0;
		fa[p[i].se] = id[df], size[fa[p[i].se]] += size[p[i].se];
		if (!fa[p[i].se]) return puts("-1"), 0;
		T[fa[p[i].se]].push_back(p[i].se);
	}

	if (!check()) return puts("-1"), 0;

	for (int i = 1; i <= n; ++i)
		if (fa[i]) printf("%d %d\n", i, fa[i]);
	return 0;
}


Measured memory_bytes: 17792
// https://atcoder.jp/contests/abc149/tasks/abc149_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M;
  cin >> N >> M;

  VL as(N);
  rep(i, N) cin >> as[i];

  sort(all(as));

  VL acc(N + 1);
  rep(i, N) acc[i + 1] = acc[i] + as[i];

  // 合計値 a が上位 M に含まれるか
  auto is_ok = [&](ll a) -> bool {
    ll a_over_ct = 0;

    rep(i, N) {
      ll pair_limit_i = upper_bound(all(as), a - as[i]) - as.begin();
      a_over_ct += N - pair_limit_i;
    }

    return a_over_ct < M;
  };

  ll ng = 0;
  ll ok = 2 * as[N - 1];

  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;

    if (is_ok(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  ll res = 0;
  ll added = 0;

  rep(i, N) {
    ll limit_i = lower_bound(all(as), ok - as[i]) - as.begin();
    ll ct = N - limit_i;
    added += ct;
    res += acc[N] - acc[limit_i];
    res += as[i] * ct;
  }

  res -= ok * (added - M);

  cout << res << endl;
}

// TODO: FFT を使った解法

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
int main(){  
    int k,x;
    cin>>k>>x;

    for (int i =k-1; i >= (-1)*k+1; i--)
    {
        cout<<x-i<<" ";
    }
    cout<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<string>
#include<sstream>
#include<algorithm>
using namespace std;
int main(){
  map<string, int> ans;
  queue<string> log;
  string f = "01234567";
  int dx[4] = {1,-1,4,-4};
  log.push(f);
  ans[f] = 0;
  while(!log.empty()){
    string s = log.front();
    int x = s.find("0");
    for(int i=0; i<4; i++){
      int nx=x+dx[i];
      if(nx>=0 && nx<=7 && !(x == 3 && nx == 4) && !(x == 4 && nx == 3)){
	string t = s;
	swap(t[x],t[nx]);
	if(ans.find(t) == ans.end()){
	  ans[t] = ans[s]+1;
	  log.push(t);
	}
      }
    }
    log.pop();
  }
  string n;
  while(getline(cin,n)){
    stringstream ss(n);
    string m;
    while(ss >>n)m+=n;
    cout <<ans[m]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int ans;
    if(a<=5){
        ans = 0;
    }else if(a<=12){
        ans = b/2;
    }else{
        ans = b;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input())
S = input()

dp = [[0] * N for _ in range(N)]

dp[-1] = [1 if s == S[-1] else 0 for s in S]
for i in range(N-2, -1, -1):
    dp[i][-1] = 1 if S[i] == S[-1] else 0
    for j in range(N-2, -1, -1):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(i+1, N):
        if dp[i][j] > 0:
            ans = max(ans, min(dp[i][j], j-i))

print(ans)


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

int main() {
  int n;
   cin>>n;
  for(int i=0;i<10;i++){
    if(i*111<n&&n<=(i+1)*111){
      cout<<(i+1)*111<<endl;
        break;
    }
  } 
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

string to_binString(int val)
{
    if( !val )
        return std::string("0");
    string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}

int main()
{
    ll n;
    cin >> n;
    vector<P> p(n);
    rep(i,n){
        ll a;
        cin >> a;
        p[i] = make_pair(a, i);
    }

    sort(all(p));

    rep(i,n)cout << p[i].second + 1 << " ";
    cout << endl;
    return 0;
}

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

int main(){
	int sum=0,s;
	for(int i=0;i<10;i++){ scanf("%d",&s); sum+=s;}
	printf("%d\n",sum);
}

Measured memory_bytes: 1188
#include<stdio.h>

int main(){
    int i,time,num[120000],pepnum=0;
    scanf("%d",&time);
    for(i=1;i<=time*2;i++){
        scanf("%d",&num[i]);
    }
    for(i=1;i<=time*2;i++){
        pepnum +=(num[i+1]-num[i]+1);
        i++;
    }
    printf("%d\n",pepnum);
return 0;
}

Measured memory_bytes: 128