akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[100005];
int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&a[i]);
	sort(a,a+n);
	if(n%2 == 0){
		vector<ll>vec;
		vec.pb(1); vec.pb(-1);
		rep(i,n/2-1) {vec.pb(2); vec.pb(-2); }
		SORT(vec);
		ll ans = 0;
		rep(i,n) ans += vec[i]*1LL*a[i];
		cout << ans << endl;
	}
	else{
		vector<ll>vec,vec2;
		vec.pb(-1); vec.pb(-1);
		rep(i,n/2-1) vec.pb(-2);
		rep(i,n/2) vec.pb(2);
		
		vec2.pb(1); vec2.pb(1);
		rep(i,n/2-1) vec2.pb(2);
		rep(i,n/2) vec2.pb(-2);
		SORT(vec); SORT(vec2);
		ll ans = 0,ans2 = 0;
		rep(i,n){
			ans += vec[i]*1LL*a[i];
			ans2 += vec2[i]*1LL*a[i];
		}
		cout << max(ans,ans2) << endl;
	}
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cin >> N >> M;
	vector< vector<int> > G(N);
	vector<cat> A(N), B(N);
	for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
	for(int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		G[--u].push_back(--v);
		G[v].push_back(u);
	}
	vector< pair<cat, int> > Vs(N);
	for(int i = 0; i < N; i++) {
		Vs[i].ff = max(0LL, A[i]-B[i]);
		Vs[i].ss = -i;
	}
	sort(begin(Vs), end(Vs));

	vector< vector<int> > comp(N);
	for(int i = 0; i < N; i++) comp[i].resize(1, i);
	vector<int> inC(N);
	for(int i = 0; i < N; i++) inC[i] = i;
	vector<bool> live(N, false);
	vector<cat> sumB(N, 0), W(N);
	cat ans = 0;

	for(int i = 0; i < N; i++) {
		int c = -Vs[i].ss;
		vector<int> comp_adj;
		ALL_THE(G[c], it) if(live[*it])
			comp_adj.push_back(inC[*it]);
		sort(begin(comp_adj), end(comp_adj));
		auto cae = unique(begin(comp_adj), end(comp_adj));
		int sz = cae - begin(comp_adj);
		comp_adj.resize(sz);

		// aspon A[c] + sumB[susedia okrem j]: viem sa pohybovat hocikde
		// aspon B[c] + sumB[susedia okrem j] + W[j]: viem vyplatit j, c
		// viem vyplatit zvysne?
		cat s = 0, m = 0;
		for(int k = 0; k < sz; k++) {
			s += sumB[comp_adj[k]];
			m = max(m, W[comp_adj[k]]);
		}
		W[c] = max(m, max(A[c]+s, B[c]+s));
		for(int j = 0; j < sz; j++) {
			s -= sumB[comp_adj[j]];
			W[c] = min(W[c], max(m, max(A[c]+s, B[c]+s+W[comp_adj[j]])));
			s += sumB[comp_adj[j]];
		}

		sumB[c] = B[c];
		for(int j = 0; j < sz; j++) {
			int a = inC[c], b = comp_adj[j];
			if(comp[a].size() > comp[b].size()) swap(a, b);
			ALL_THE(comp[a], it) {
				comp[b].push_back(*it);
				inC[*it] = b;
			}
			sumB[b] += sumB[a];
		}
		ans = W[inC[c]] = W[c];
		live[c] = true;
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 19964
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> P;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    rep(i,n)
    {
        cin>>a>>b;
        if(a==b){
            sum++;
        }else{
            sum=0;
        }
        if(sum>=3) f=1;
    }
    if(f) Yes;
    else No;

    return 0;
}


Measured memory_bytes: 3648
while(True):
    count=0
    n,x=list(map(int,input().split()))
    if n==0 and x==0:exit()
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    count+=1
    print(count)


Measured memory_bytes: 5596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = max(x, y);
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
//const int INF = 1 << 30;//10^9
const ll INF = INFL;
//ll MOD = 1000000007;
ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll get_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//約数の列挙O(√n)
vector<ll> divisor(ll n){
    vector<ll> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

//素因数列挙
vector<ll> MakePrimeList(ll x) {
    vector<ll> res;
    for(ll k=2; k*k<=x; k++) {
        if(x % k == 0) {
            res.pb(k);
            while(x % k == 0) x /= k;
        }
    }
    if(x > 1) res.push_back(x);
    return res;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


int main(){
  string S;
  cin >> S;
  if(S.size() == 2){
    cout << S << endl;
  }else{
    cout << S[2] << S[1] << S[0] << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

bool ok = false;
int fact[1000001], cnt[1000001];
// This factors can be optimized using prime sieve method
// void factors(int x) {
// 	if (ok)
// 		return;
// 	for (int i = 1; i * i <= x; i++) {
// 		if (x % i == 0) {
// 			int a = i, b = x / i;
// 			if (a == b) {
// 				a = i;
// 				b = 1;
// 			}
// 			if (a != 1) {
// 				if (fact[a]) {
// 					ok = true;
// 					return;
// 				}
// 				fact[a] = true;
// 			}
// 			if (b != 1) {
// 				if (fact[b]) {
// 					ok = true;
// 					return;
// 				}
// 				fact[b] = true;
// 			}
// 		}
// 	}
// }

void sieve() {
	int n = 1000000;
	for (int i = 1; i <= n; i++)
		fact[i] = i;

	// Here we would replace -1 with its smallest prime divisor and
	// prime numbers would have itself as its own divisor
	// if n = 38 print 2 which is in cell of 38 then 38 / 2 then 19 then
	// 19 has 19 in its cell then 19 / 19 which is 1 then exit we got our
	// prime factorization
	for (int i = 2; i <= n; i++) {
		if (fact[i] == i) {
			for (int j = i; j <= n; j += i)
				fact[j] = i;
		}
	}
}


int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	sieve();
	int n;
	cin >> n;
	int arr[n], maxx = 0;
	int gcd = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		maxx = max(arr[i], maxx);
		gcd = __gcd(gcd, arr[i]);
	}
	bool flag = false;
	for (int i = 0; i < n; i++) {
		set<int> cur;
		while (arr[i] != 1) {
			cur.insert(fact[arr[i]]);
			arr[i] /= fact[arr[i]];
		}
		for (auto c : cur) {
			cnt[c]++;
			if (cnt[c] > 1) {
				flag = true;
				break;
			}
		}
		if (flag)
			break;
	}
	if (!flag)
		cout << "pairwise coprime";
	else if (gcd == 1)
		cout << "setwise coprime";
	else
		cout << "not coprime";
	return 0;
}

Measured memory_bytes: 19824
import Control.Monad
import qualified Data.IntSet as IS

main :: IO()
main = do
	n <- readLn
	as <- replicateM n readLn
	print $ solve as IS.empty
        where
            solve as s = IS.size $ foldr f s as
            f a s = if IS.member a s then IS.delete a s else IS.insert a s 


Measured memory_bytes: 60796
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  bool flag;
  cin >> N;
  flag = 0;
  for(int i=1; i<10;i++){
for(int j=1; j<10; j++){
if(i*j==N){
  flag = 1;
  break;
}
}
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
//#define min(a,b) ((a)<(b)?(a):(b))

using namespace std;

int main(){
 long A,B,N;
  cin >> A>>B>>N;
  long x=min(B-1,N);
  cout << (A*x)/B-A*(x/B)<<endl;
  return 0;
}


Measured memory_bytes: 3616
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();

        int t = 0;
        for (int i = 1; i <= n; i++) {
            if (i % k == 0) {
                t++;
            }
        }
        int u = 0;
        if (k % 2 == 0) {
            for (int i = 1; i <= n; i++) {
                if (i % k == k / 2) {
                    u++;
                }
            }
        }

        BigInteger a = new BigInteger(String.valueOf(t));
        BigInteger b = new BigInteger(String.valueOf(u));
        a = a.multiply(a).multiply(a);
        b = b.multiply(b).multiply(b);
        a = a.add(b);

        out.println(a.toString());
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 22356
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 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 input()

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['TTT'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for p1, p2, p3, cur in product('ACGT', repeat=4):
            if p2 + p1 + cur in ['AGC', 'GAC', 'ACG']:
                continue
            if p3 + p1 + cur == 'AGC':
                continue
            if p3 + p2 + cur == 'AGC':
                continue
            new = p2 + p1 + cur
            old = p3 + p2 + p1
            dp[new] = (dp[new] + pre[old]) % MOD
    ans = sum(dp.values())

    return ans % MOD

print(main())

Measured memory_bytes: 3316
N = int(input())
SP = [(i + 1, input().split()) for i in range(N)]
P = [[0, 0, 0] for _ in range(N)]
for i in range(N):
    P[i][0] = SP[i][0]
    P[i][1] = SP[i][1][0]
    P[i][2] = int(SP[i][1][1])
P.sort(key=lambda x: x[2], reverse=True)
P.sort(key=lambda x: x[1])

for p in P:
    print(p[0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using G = vector<vector<int>>;

int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> mv(n,0);//移動先
    vector<pair<int,int>> st(n);
    vector<pair<int,int>> ch(m); 
    rep(i,n) cin >> st[i].first >> st[i].second;
    rep(i,m) cin >> ch[i].first >> ch[i].second;
    for(int i=0;i<n;i++){
        int m_s = 0;
        for(int j=0;j<m;j++){
            ll m_d = abs((ch[j].first)-(st[i].first)) + abs((ch[j].second)-(st[i].second));  
            if(j == 0) m_s = m_d;
            if(m_s >m_d) {
                m_s = m_d;
                mv[i] = j;
            }
        }
    }
    rep(i,n) cout << mv[i]+1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,M,Gmin;
void pro(int X)
{
    if(M/X>=N)
        Gmin=max(X,Gmin);
}
int main()
{
    cin>>N>>M;
    for(int i=1;i*i<=M;i++)
        if(M%i==0)
            pro(i),pro(M/i);
    cout<<Gmin;
}


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

long long int factorial(int n);

int main(){
	
    int i;
	
	cin >> i;
	
	cout << factorial(i) << endl;
	
	return 0;
}

long long int factorial(int n){

	if(n==1){
		return 1;
	}else{
		return n*factorial(n-1);
	}
}
	

Measured memory_bytes: 1156
#include<iostream>

using namespace std;

unsigned long long a,b,c,n;

int main(void)
{
    cin>>a>>b>>c;

    if(b >= a)
    {
        cout<<1<<endl;
        return 0;
    }
    
    if(c >= b)
    {
        cout<<-1<<endl;
        return 0;
    }
    
    if( ( a - b ) % ( b - c ) >= 1 )
		n=1;
    cout<<( ( a - b ) / ( b - c ) + n ) * 2 + 1<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys

l, r = map(int, input().split())
#dp = []
min = 1000000000000000000

if l <= 2019 < r:
    print(0)
    sys.exit()

for i in range(l, r):
    for j in range(i+1, r+1):
        ans = i * j % 2019
        if ans < min:
            min = ans

        if min == 0:
            print(0)
            sys.exit()

#        dp.append(i * j % 2019)
#        dp.append(i * j % 18)

#dp.sort()
#print(dp[0])
print(min)


Measured memory_bytes: 39536
# coding: utf-8

w, h, N = list(map(int, input().split()))

rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    rect[a - 1] = (lambda c, r, p: [r, c][p * (c - r) < 0])([x, y][a > 2], rect[a - 1], int(not a % 2) - int(a % 2))

length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))

Measured memory_bytes: 3064
import 'dart:async';
import 'dart:io';
import 'dart:convert';
import 'dart:math';

Stream<String> get lineStream =>
    stdin.transform(utf8.decoder).transform(const LineSplitter());

Future<List<String>> readLines() async {
  final lines = <String>[];
  await for (var line in lineStream) {
    lines.add(line);
  }
  return lines;
}

void main() async {
  final lines = await readLines();
  final n = int.parse(lines[0]);
  final a = lines[1].split(' ').map((e) => int.parse(e)).toList();
  var d = 0;
  var sum = 0;
  for (var i = 1; i < n; i++) {
    final diff = a[i] - a[i - 1];
    if (diff < 0) {
      sum += diff.abs();
      a[i] = a[i] + diff.abs();
    }
  }
  print(sum + d);
}


Measured memory_bytes: 31892
import java.util.Scanner;

class problemA{

  void solve(){
    int c1x=0, c1y=0, c1r=0;
    int c2x=0, c2y=0, c2r=0;
    int length = 0;//length of between center coordinate of c1 and c2
    int large = 0, small = 0;

    Scanner scan = new Scanner(System.in);
    c1x = scan.nextInt();
    c1y = scan.nextInt();
    c1r = scan.nextInt();

    c2x = scan.nextInt();
    c2y = scan.nextInt();
    c2r = scan.nextInt();

    large = c1r;
    small = c2r;
    if(large < small){
      large = c2r;
      small = c1r;
    }

    length = (int)(Math.sqrt((c2x-c1x)*(c2x-c1x) + (c2y-c1y)*(c2y-c1y)));

    if(length > (c1r + c2r)) System.out.println("4");
    else if (length < (c1r + c2r)){
        if(large == (length + small)) System.out.println("1");
        else if(large > (length + small))System.out.println("0");
        else System.out.println("2");
    }
    else System.out.println("3");
  }
}
public class Main {
  public static void main(String[] args){
    new problemA().solve();
  }
}



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


int main() {
  string S,T;
  cin >> S >> T;
  
  int N =S.size();
  int sum =0;
  
  if(S==T){
    cout << 0 <<endl;
  }
  else{
    for (int i = 0; i < N; i++) {
      
      if(S.at(i) != T.at(i)){
        sum ++;
      }
      else{
        sum +=0;
      }
    }
    cout << sum <<endl;
  }
}


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

int main()
{
    int n, k, x, y, v = 0;
    cin >> n >> k >> x >> y;
    for (int i = 0; i < n; i++)
    {
        if (i < k)
            v += x;
        else
            v += y;
    }
    cout << v;
}

Measured memory_bytes: 3604
#!/usr/bin/env ruby

N, M, X = gets.chomp.split(' ').map(&:to_i)

A = gets.chomp.split(' ').map(&:to_i)

i = 0
i += 1 while A[i] < X

cand1 = M - i
cand2 = i

puts [cand1, cand2].min


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>high(N);
  for(int i=0;i<N;i++){
    cin>>high[i];
  }
  vector<vector<int>>G(N);
  for(int i=0;i<M;i++){
    int x,y;
    cin>>x>>y;
    x--,y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int ans=0;
  for(int i=0;i<N;i++){
     int count=0;
    if(G[i].size()==0){
      ans++;
    }else{
      for(auto x:G[i]){
        if(high[i]>high[x]){
          count++;
        }
      }
      if(count==G[i].size()){
        ans++;
      }
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 8800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  int A[110];
  
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];
  
  int mx = 1,mn = 1000000000;

  for(int i=0; i<N; i++) {
 
    if( mx < A[i]) mx = A[i];
    if( mn > A[i]) mn = A[i];   
  }
  
  cout << mx - mn << endl;
  return 0;
}

Measured memory_bytes: 256
s = int(input())
nums = [s]
i = 1
for i in range(1, 10 ** 5):
    if nums[i - 1] % 2 == 0:
        n = nums[i - 1] // 2
    else:
        n = nums[i - 1] * 3 + 1 
    if n in nums:
        print(i + 1)
        break
    nums.append(n)



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

int main(){
  int N,ans=0;
  cin >> N;
  vector<vector<bool>> P(N,vector<bool>(N,false));
  vector<vector<bool>> A(N,vector<bool>(N,false));
  for(int i=0;i<N;i++){
    int a;cin >> a;
    for(int k=0;k<a;k++){
      int j,y;cin >> j >> y;
      j --;
      P[i][j] = true;
      A[i][j] = (y==1);
    }
  }
  for(int bit=0;bit<(1<<N);bit++){
    bool possible = true;
    //cout << bit << endl;
    for(int i=0;i<N;i++){
      if(bit&(1<<i)){
        for(int j=0;j<N;j++){
          if(P[i][j] && !(A[i][j] == ((bit&(1<<j))>0))){
            possible = false;
            //cout << "i = " << i << " , j = " << j << " (" << (bit&(1<<j)) << ")" << endl;
            break;
          }
        }
      }
      if(!possible){
        break;
      }
    }
    if(possible){
      int count = 0;
      for(int i=0;i<N;i++){
        if(bit&(1<<i)){
          count ++;
        }
      }
      ans = max(ans,count);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer(new ConsoleInput(Console.In, ' '));
	}
	public static void Answer(ConsoleInput cin)
	{
        var N = cin.ReadInt;
        Dictionary<int, int> dic = new Dictionary<int, int>();
        int overCnt = 0;
        for(int i = 0; i < N; i++)
        {
            var n = cin.ReadInt;
            if (dic.ContainsKey(n))
            {
                dic[n]++;
                if (n < dic[n])
                    overCnt++;
            }
            else
            {
                dic.Add(n, 1);
            }
        }
        int lackCnt = 0;
        foreach(KeyValuePair<int,int> kvp in dic)
        {
            if (kvp.Value < kvp.Key)
                lackCnt += kvp.Value;
            //lackCnt += (kvp.Key - kvp.Value);
        }
        WriteLine(overCnt+lackCnt);
	}
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 28764
num = int(input())
for _ in range(num):
    P = 0
    B = [0] * 3
    O = 0
    while True:
        s = input()
        if s == "OUT":
            O += 1
            if O > 2:
                break
        elif s == "HIT":
            P += B[2]
            B[2] = B[1]
            B[1] = B[0]
            B[0] = 1
        elif s == "HOMERUN":
            P += sum(B)
            P += 1
            B = [0] * 3
        else:
            pass

    if O > 2:
        print(P)
        continue
   


Measured memory_bytes: 5592
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
/*while(a)
    {
        if(a%2==0)
            dvi.push_back(0);
        else
            dvi.push_back(1);
        a/=2;
    }
    reverse(dvi.begin(),dvi.end());*/
#include<bits/stdc++.h>
using namespace std;
#define MAX 35000
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool divisible[1000001];
ll ccount[1000001];
int main()
{
    makefast__
    string str[100001];
    ll a,c,d,e,f,x,y,t,A=0,B=0,L,j,i,l,r,n,C=0,sum=0,sum1=0,m,k,b;
    vector<pair<ll,ll>>v;
    ll count[10001];
    set<ll>sl;
    vector<ll>ans;
    cin>>n;
    ll one=0;
    memset(ccount,0,sizeof(ccount));
    memset(divisible,true,sizeof(divisible));
    for(i=1; i<=n; i++)
    {
        cin>>aarray[i];
        ccount[aarray[i]]++;
        sl.insert(aarray[i]);
        divisible[aarray[i]]=false;
    }
    if(divisible[1]==false&&ccount[1]==1)
    {
        cout<<1<<endl;
        return 0;
    }
    if(divisible[1]==false&&ccount[1]>1)
    {
        cout<<0<<endl;
        return 0;
    }
    for(i=1; i<=n; i++)
    {
        ll fx=aarray[i];
        f=1;
        for(j=2; j*j<=fx; j++)
        {
            if(fx%j==0)
            {
                if(!divisible[j])
                {
                    f=0;
                    break;
                }
                ll kala=fx/j;
                if(!divisible[kala])
                {
                    f=0;
                    break;
                }
            }
            if(!f)
                break;
        }
        if(f&&ccount[fx]==1)
        {
            A++;
        }
    }
    cout<<A<<endl;




    return 0;
}




Measured memory_bytes: 26468
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0 ; i < n ; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            for (int j = i + 1 ; j < n ; j++) {
                for (int k = j + 1 ; k < n ; k++) {
                    if (l[n - 1 - i] < l[n - 1 - j] + l[n - 1 - k]) count++;
                }
            }
        }

        System.out.println(count);
    }

}

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

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


int nextInt() { int x; scanf("%d", &x); return x;}

ll a[312345];

int main2() {
  int N = nextInt();
  REP(i, 3*N) a[i] = nextInt();
  sort(a, a+3*N);
  reverse(a, a+3*N);
  ll ans = 0;
  REP(i, N) ans += a[2*i+1];
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

//#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

string input;
int a, b, c, d;
vector<string> t;

inline string decode_line(const string& in) {
    string ret;
    for (const char& c : in) {
        if (c == 'b') {
            ret.push_back('b');
        } else {
            const int m = c - '0';
            //dump(m);
            //dump(c);
            for (int i = 0; i < m; ++i) {
                //dump(i);
                ret.push_back('.');
            }
        }
    }
    debug(cout << ret << endl);
    return ret;
}

inline vector<string> decode(const string& in) {
    stringstream ss(input);
    string buf;
    vector<string> ret;
    debug(cout << "-- decode --" << endl;);
    while (getline(ss, buf, '/')) {
        ret.push_back(decode_line(buf));
    }
    return ret;
}

inline string encode_line(const string& in) {
    int cnt = 0;
    string ret;
    for (const char& c : in) {
        if (c == '.') {
            cnt++;
        } else {
            if (cnt) {
                ret.push_back('0' + cnt);
                cnt = 0;
            }
            ret.push_back('b');
        }
    }
    if (cnt) {
        ret.push_back('0' + cnt);
    }
    dump(ret);
    return ret;
}

inline string encode(const vector<string>& in) {
    string ret;
    debug(cout << "-- encode --" << endl);
    for (const string& s : in) {
        ret += encode_line(s);
        ret.push_back('/');
    }
    ret.pop_back();
    debug(cout << "-- output --" << endl);
    return ret;
}

int main() {
    while (true) {
        cin >> input;
        if (input[0] == '#') {
            break;
        }
        cin >> a >> b >> c >> d;
        t = decode(input);
        t[a-1][b-1] = '.';
        t[c-1][d-1] = 'b';
        cout << encode(t) << endl;
    }
    return 0;
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int calc(string s) {
   // debug(s)
   int ret = s[0] - '0';
   for (int i = 1; i < 7; i+=2) {
      if (s[i] == '+') {
         ret += s[i+1] - '0';
      } else {
         ret -= s[i+1] - '0';
      }
      // printf("%c%c\n", s[i], s[i+1]);
   }
   // cout << s << ", " << ret << endl;
   // line()
   return ret;
}

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

   int n = s.size();
   for (int mask = 0; mask < (1<<(n)); mask++) {
      string t = "";
      t.push_back(s[0]);
      repp (i, 1, n) {
         if ((mask>>(i-1))&1) {
            t.push_back('+');
         } else {
            t.push_back('-');
         }
         t.push_back(s[i]);
      }
      // debug(t)
      if (calc(t) == 7) {
         cout << t + "=7" << endl;
         break;
      }
   }

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359
using namespace std;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while (true) {
    c -= b;
    if (c<=0) {
      cout << "Yes";
      break;
    }
    a -= d;
    if (a<=0) {
      cout << "No";
      break;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll dp[200010][4];
int main(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    ll k=1+n%2;
    rep(i,200010){
        rep(j,4){
            dp[i][j]=-LINF;
        }
    }
    dp[0][0]=0;
    rep(i,n){
        rep(j,k+1){
            chmax(dp[i+1][j+1],dp[i][j]);
            ll now=dp[i][j];
            if((i+j)%2==0) now+=a[i];
            chmax(dp[i+1][j],now);
        }
    }
    ll ans=dp[n][k];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11180
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef vector<int> VI;

int main(void) {
  int n,m;
  for(;cin>>n>>m&&n+m;){
    VI a(n+m+1);
    REP(i,0,n+m)cin>>a[i];
    sort(a.begin(),a.end());
    int k=0;
    REP(i,0,a.size()-1)k=max(k,a[i+1]-a[i]);
    cout<<k<<"\n";
  }
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int n, k; cin >> n >> k;
	if ((n + 1) / 2 >= k) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

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

int main(void){
	int a, b, c;
	while( scanf(" %d %d %d", &a, &b, &c) != EOF){
		double area = sqrt(b*b - (a/2.0)*(a/2.0)) * (a/2.0);
		double y = (b+c)/2.0;
		area += sqrt(y*y - (b/2.0)*(b/2.0)) * (b/2.0) * 2;
	
		printf("%.10lf\n", area);
	}

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define updmax(dp,x) dp=(dp.first == 0 ? x : max(dp,x))

using P = pair<int,int>;

int main(void){
    int n;
    while(cin>>n, n){
        vector<int> p(n);
        rep(i,n) cin>>p[i];
        map<int,P> cur; // cur[coin] = <get,pay>
        cur[0] = P(0,0);
        rep(i,n){
            map<int,P> nxt;
            for(auto &itr : cur){
                int coin = itr.first;
                int k = itr.second.first;
                int pay = itr.second.second;
                updmax(nxt[coin], P(k,pay));
                pay -= p[i];
                coin += (1000-p[i]%1000)%1000;
                if(coin >= 500){
                    updmax(nxt[coin-500], P(k+1, pay));
                }else if(p[i]%1000){
                    updmax(nxt[coin], P(k,pay));
                }
            }
            cur = move(nxt);
        }

        P res = {0,0};
        for(auto itr : cur){
            res = max(res,itr.second);
        }
        cout<<res.first<<" "<<-res.second<<endl;
    }
    return 0;
}



Measured memory_bytes: 4920
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int N, M;
    cin >> N >> M;

    Graph G(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    bool ans = false;
    for (auto v : G[0]) {
        for (auto nv : G[v]) {
            if (nv == N - 1) {
                ans = true;
                break;
            }
        }
        if (ans) {
            break;
        }
    }

    if (ans) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 12776
#include <iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
using namespace std;
int n,k,a[2010],b[2010],dp[2010][2010],ans;
vector<int> adj[2010];
bool vis[2010];
void solve(int u){
	for(int i=0;i<adj[u].size();i++){
		if(!vis[adj[u][i]]){
			vis[adj[u][i]]=true;
			solve(adj[u][i]);
		}
	}
	for(int i=1;i<=k;i++){
		dp[u][i]=1;
	}
	dp[u][0]=0;
	for(int i=1;i<=k;i++){
		if(i<=(k+1)/2){
			for(int j=0;j<adj[u].size();j++){
				dp[u][i]+=dp[adj[u][j]][i-1];
			}
		}
		if(i>(k+1)/2){
				int suma=0;
				for(int h=0;h<adj[u].size();h++){
					suma+=dp[adj[u][h]][k-i];
				}
				for(int h=0;h<adj[u].size();h++){
				if(dp[u][i]<(suma-dp[adj[u][h]][k-i]+dp[adj[u][h]][i-1]+1)){
					dp[u][i]=suma-dp[adj[u][h]][k-i]+dp[adj[u][h]][i-1]+1;
				}	
				}
			if(dp[u][i]<dp[u][i-1]){
				dp[u][i]=dp[u][i-1];
			}
		}
	}
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=2;i<=n;i++){
		vis[i]=false;
	}
	vis[1]=true;
	k++;
	for(int i=1;i<=n-1;i++){
		scanf("%d%d",&a[i],&b[i]);
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}
	solve(1);
	ans=0;
	for(int i=1;i<=n;i++){
		if(dp[i][k]>ans){
			ans=dp[i][k];
		}
	}
	printf("%d",n-ans);
	return 0;
}

Measured memory_bytes: 16256
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
int main()
{
    Imposter
    
    int T=1;
    //cin>>T;
    while(T--)
    {
        int k;
        cin>>k;
        queue<ll>q;ll p;
        for(int i=1;i<=9;i++)
        q.push(i);
        f(k-1)
        {
            ll x=q.front();
            q.pop();
            if(x%10)
            {
                p=10*x + (x%10)-1;
                q.push(p);
            }
             p=10*x + x%10;
            q.push(p);
            if(x%10 != 9)
            q.push(p+1);
            //cout<<q.front()<<endl;
        }
        cout<<q.front()<<endl;
    }
    return 0;
}

Measured memory_bytes: 4764
// ABC086_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    string N, M;
    cin >> N >> M;
    
    N += M;
    ll num = stoll(N), num1;
    
    REPN(i, num) {
        if (i*i == num) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    
    cout << "No" << "\n";
    
    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 INF 1e9

int solve(bitset<15> b, bitset<15> goal){
    if(b.count() != goal.count())return INF;
    int cnt=0;
    rep(l,14)if(b[l]!=goal[l]){
        int r=l+1;
        while(b[l]==b[r]) r++;
        while(l<r){
            b[r].flip();
            r--;
            b[r].flip();
            cnt++;
        }
    }
    return cnt;
}

int main(void){
    int N,M,p,bit;
    cin>>N>>M;
    bitset<15> b,goal1,goal2;
    rep(i,N) cin>>bit, b[i]=bit;
    int index=0;
    rep(i,M) {
        cin>>p;
        rep(j,p){
            goal1[index] = (i%2==0);
            goal2[index] = (i%2!=0);
            index++;
        }
    }
    cout<<min(solve(b,goal1),solve(b,goal2))<<endl;
    return 0;
}

Measured memory_bytes: 3108
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>
#include <iomanip>
//#include <unordered_set>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
const double eps = 0.005;
const int maxn = 25000;
const ll mod = 1e9+7;
const int INF = 1e9;
const double pi = acos(-1);
typedef double Matrix[maxn][maxn];
int n;
ll a,b;
int main() {
    scanf("%d%lld%lld",&n,&a,&b);
    if (a > b || (n == 1 && a != b)) {
        printf("0");
        return 0;
    }
    ll mini = (n-1)*a+b;
    ll maxi = (n-1)*b+a;
    printf("%lld\n",maxi-mini+1);
    return 0;
}





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

int main() {
  int a;
 cin >> a;
  vector<int> vec(a);
  rep(i,a) {
    cin >> vec.at(i);
  }
 string b = "APPROVED";
  rep(i,a) {
    if (vec.at(i)%2 == 0 && vec.at(i)%3 != 0 && vec.at(i)%5 != 0) {
      b = "DENIED";
      break;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val inputs = readInputLine().split(" ").map { it.toLong() }
    
    val a = inputs[0]
    val b = inputs[1]
    val c = inputs[2]
    val d = inputs[3]
    
    val cdgcd = 
        if (c > d) {
            gcd(c, d)
        } else {
            gcd(d, c)
        }
    val cdlcm = c * d / cdgcd

    var res = b - a + 1

    if (b / c != a / c) {
        res -= b / c - a / c
    }
    if (a % c == 0L) {
        res--
    }
    
    if (b / d != a / d) {
        res -= b / d - a / d
    }
    if (a % d == 0L) {
        res--
    }
    
    if (b / cdlcm != a / cdlcm) {
        res += b / cdlcm - a / cdlcm
    }
    if (a % cdlcm == 0L) {
        res++
    }

    println("$res")
}
 
fun readInputLine(): String {
    return readLine()!!
}

fun gcd(a: Long, b: Long): Long {
    // a >= b とする
    if (b == 0L) {
        return a
    }
    return gcd(b, a % b)
}


Measured memory_bytes: 36148
import java.util.*;

class Main {
    
	
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        long sum = 0;
        
        for(int a=1; a <= K; a++) {
        	  for(int b=1; b <= K; b++) {
        		  for(int c=1; c <= K; c++) {
        		        sum += gcd(a, gcd(b,c));
        	        }
              	
              }
        	
        }


        System.out.print(sum);
        
       
	}
	
	
	private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
	
}
		
	


Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    int t; t = 1;
    while (t --){
        int x ; cin >> x;
        cout << 8 - (x - 400) / 200 << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
map<ll,int> mp;
using T=tuple<int,int,int>;
using PP=pair<int,P>;
int main(){
    int n,q;
    cin>>n>>q;
    multiset<int> v;
    
    vector<PP> line;
   for(int i=0;i<n;i++){
     int a,b,x;
     cin>>a>>b>>x;
     line.push_back(PP(a-x,P(-1,x)));
     line.push_back(PP(b-x-1,P(1,x)));
}
vector<ll> ans(q);
for(int i=0;i<q;i++){
  int a;cin>>a;
  line.push_back(PP(a,P(0,i)));
  }
  sort(all(line));
  for(int i=0;i<line.size();i++){
    ll a=line[i].fi,b=line[i].se.fi,c=line[i].se.se;
    if(b==-1)v.insert(c);
    else if(b==1)v.erase(v.find(c));
    else ans[c]=(v.empty()?-1:*v.begin());
}
for(int i=0;i<q;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 28392