akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 100
#define White 0
#define Black 2
#define Gray 1


int GX[N][N],x,color[N],time,d[N],f[N];

void visit(int u){
  int v;
  color[u]=Gray;
  d[u]=++time;
  for(v=0;v<x;v++){
    if(GX[u][v]==0) continue;
    if(color[v]==White) visit(v);
  }
  color[u]=Black;
  f[u]=++time;
}

void dfs(){
  int u;
  for(u=0;u<x;u++) color[u]=White;
  time=0;
  for(u=0;u<x;u++){
    if(color[u]==White) visit(u);
  }
  for(u=0;u<x;u++) printf("%d %d %d\n",u+1,d[u],f[u]);
}

int main(){

  int i,j,a,b,c,v,g;

  scanf("%d",&x);

  for(i=0;i<x;i++){
    for(j=0;j<x;j++){
      GX[i][j]=0;
    }
  }

  for(i=0;i<x;i++){
    scanf("%d",&v);
    scanf("%d",&g);
    v--;
    for(j=0;j<g;j++){
      scanf("%d",&a);
      a--;
      GX[v][a]=1;
    }
  }

  dfs();
  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    double N, K;
    cin >> N >> K;

    double ans = 0;
    for (int i = 1; i <= N; i++) {
        int j = i;
        double p = 1;
        while (K > j) {
            j *= 2;
            p *= 0.5;
        }
        ans += p;
    }

    ans /= N;
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=input()
s=map(int,raw_input().split())
q=input()
t=map(int,raw_input().split())
ct=0
for i in t:
    l=0
    r=n
    while r>l:
        m=(r+l)/2
        if s[m]==i:
            ct+=1
            break
        elif i<s[m]:
            r=m
        else:
            l=m+1
print(ct)
            

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	cout.precision(10);
	cout<<fixed;
	cout<<2*M_PI*(double)n;
    return 0;
}

Measured memory_bytes: 3804
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef long long int ll;
const ll MOD=1000000007;

ll n,k;
ll C[2001][2001]={};

int main(){
	scanf("%lld %lld",&n,&k);
	for(int i=0;i<2001;i++){
		C[i][0]=1;
		C[i][i]=1;
		for(int j=1;j<i;j++){
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
		}
	}
	printf("%lld\n",C[n+k-1][n]);
}


Measured memory_bytes: 25852
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int N;
long long int A[100005], B[100005];

vector<pair<long long int,long long int> > V;

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= N; i++) {
		V.push_back(pair<long long int, long long int>(A[i] + B[i], A[i]));
	}

	sort(V.rbegin(), V.rend());

	long long int val_T = 0, val_A = 0;

	for (int i = 0; i < N; i++) {
		long long int sum = V[i].first;
		long long int a = V[i].second;
		long long int b = sum - a;
		if (i % 2 == 0) {
			val_T += a;
		}
		else {
			val_A += b;
		}
	}

	cout << val_T - val_A << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 3956
from math import sqrt, ceil
n = int(input())
def solve(n):
    ans = len(str(n))
    for i in range(3, ceil(sqrt(n))+1):
        if n % i == 0:
            ans = min(ans, max(len(str(i)), len(str(n//i))))
    return ans
print(solve(n))


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	static String input = new String();
	static String syori(char num,char target){
		String a="";
		int n=Integer.parseInt(num+"");
		for(int i=0;i<n;i++)a+=target;
		return a;
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			input = in.next();
			String result = "";
			for(int s=0;s<input.length();s++){
				if(input.charAt(s)!='@')result+=input.charAt(s);
				else{
					result+=syori(input.charAt(s+1),input.charAt(s+2));
					s+=2;
				}
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int s; cin >> s;
    int h = s / 3600;
    s -= h * 3600;
    int m = s / 60;
    s -= m * 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3204
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		double A  = keyboard.nextInt();
		double B  = keyboard.nextInt();
		
		if(((A+B)/2) % 1 == 0.0) {
			System.out.println((int)(A+B)/2);
		}else{
			System.out.println("IMPOSSIBLE");
		}
		keyboard.close();	
	}
}

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

using namespace std;

int main(){
	string a,b, c;
	int temp = 0, i;

	cin >> a >> b;

	c = a + b;

	for(i=0; i < c.length(); i++){
		temp = temp*10 + (c[i] - '0');
	}

	int rs = sqrt(temp);

	if(rs * rs - temp == 0.0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}

int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    vector<long> a(n);
    bool jud = true;
    long ans = 1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            jud = false;
            ans = 0;
            break;
        }
    }
    long num = 1000000000000000000;
    
    if(jud){
        for(int i = 0; i < n; i++){
            num /= a[i];
            if(num <= 0){
                jud = false;
                ans = -1;
                break;
            }
        }
    }
    
    if(jud){
        for(int i = 0; i < n; i++){
            ans *= a[i];
        }
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 3984
#include <cstdio>
#include <vector>
#include <algorithm>

const int P = 1000000007;

using namespace std;

vector<pair<int, int> > a[303];
int d[2][303][303];

int main() {
	int (*p)[303], (*q)[303];
	int i, j, k, l, m, n, r = 0;
	scanf("%d%d", &n, &m);
	while (m--) {
		scanf("%d%d%d", &i, &j, &k);
		a[j].emplace_back(i, k);
	}
	p = d[0];
	q = d[1];
	p[0][0] = 1;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= i; j++) for (k = 0; k <= j; k++) {
			for (auto &r : a[i]) {
				if (r.second == 1 && r.first <= j) {
					p[j][k] = 0;
					break;
				}
				if (r.second == 2 && (r.first > j || r.first <= k)) {
					p[j][k] = 0;
					break;
				}
				if (r.second == 3 && r.first > k) {
					p[j][k] = 0;
					break;
				}
			}
			if (p[j][k]) {
				if (i == n) {
					r += p[j][k];
					if (r >= P) r -= P;
					continue;
				}
				q[j][k] += p[j][k];
				if (q[j][k] >= P) q[j][k] -= P;
				q[i][k] += p[j][k];
				if (q[i][k] >= P) q[i][k] -= P;
				q[i][j] += p[j][k];
				if (q[i][j] >= P) q[i][j] -= P;
				p[j][k] = 0;
			}
		}
		swap(p, q);
	}
	printf("%d", r);
	return 0;
}


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

struct BinaryIndexedTree {
  BinaryIndexedTree() { init(); }
  BinaryIndexedTree(int n) : n(n + 1), v(n + 2, 0) { init(); }

  vector<int> v;
  int n, r;

  void init() {
    r = 1;
    while (2 * r <= n)
      r *= 2;
  }

  int sum(int i) {
    ++i;
    int ret = 0;
    while (i) {
      ret += v[i];
      i -= i & -i;
    }
    return ret;
  }

  void add(int i, int x) {
    ++i;
    while (i <= n) {
      v[i] += x;
      i += i & -i;
    }
  }

  int lower_bound(int w) {
    int idx = 0;
    for (int k = r; k > 0; k /= 2) {
      if (idx + k <= n && v[idx + k] < w) {
        w -= v[idx + k];
        idx += k;
      }
    }

    return idx;
  }

  void debug() {
    int m = 0;
    for (int i = 1; i < n; ++i) {
      int s = sum(i);
      cerr << s - m << (i + 1 == n ? "\n" : " ");
      m = s;
    }
  }
};

struct segtree {
  segtree() {}
  segtree(int n, vector<char> v) : n(n) { init(v); }

  pair<char, int> id = make_pair('{', -1);
  int n;
  vector<pair<char, int>> node;

  void init(vector<char> v) {
    int n_ = n;
    n = 1;
    while (n < n_)
      n *= 2;

    node.assign(2 * n - 1, id);
    for (int i = 0; i < v.size(); ++i) {
      int idx = i + n - 1;
      node[idx] = make_pair(v[i], i);
    }
    for (int i = n - 2; i >= 0; --i) {
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }
  }

  pair<char, int> find(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a)
      return id;
    if (a <= l && r <= b)
      return node[k];

    return min(find(a, b, 2 * k + 1, l, (l + r) / 2),
               find(a, b, 2 * k + 2, (l + r) / 2, r));
  }

  pair<char, int> find(int a, int b) { return find(a, b, 0, 0, n); }

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

int main() {
  string s;
  int k;

  cin >> s >> k;
  vector<char> v(s.size());
  for (int i = 0; i < s.size(); ++i)
    v[i] = s[i];

  BinaryIndexedTree bit(s.size());
  segtree seg(s.size(), v);

  for (int i = 0; i < s.size(); ++i)
    bit.add(i, 1);

  string ans;
  for (int i = 0; i < s.size(); ++i) {
    int r = bit.lower_bound(k + 1);
    pair<char, int> c = seg.find(0, r + 1);
    seg.update(c.second);
    bit.add(c.second, -1);
    k -= bit.sum(c.second);

    ans.push_back(c.first);
  }

  cout << ans << endl;
}

Measured memory_bytes: 8772
L=input()
length=len(L)
inf=10**9+7
a=2
b=1
for i in range(1,len(L)):
	if L[i]=="0":
		b=b*3%inf
		continue
	else:
		b=(b*3+a)%inf
		a=a*2%inf
print((a+b)%inf)


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

using namespace std;

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  
  vector<string> s(H);
  for(int i = 0; i < H; i++) cin >> s[i];
  
  vector<int> count(H, 0);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] == '#') count[i]++;
    }
  }
  
  vector<vector<int>> A(H, vector<int>(W, 0));
  int k = 1;
  for(int i = 0; i < H; i++){
    if(count[i] == 0){
      continue;
    }
    int c = 0;
    for(int j = 0; j < W; j++){
      if(j == 0){
        A[i][j] = k;
        if(s[i][j] == '#') c++;
      }else if(s[i][j] == '#' && c != 0){
        k++;
        A[i][j] = k;
      }else if(s[i][j] == '#'){
        c++;
        A[i][j] = k;
      }else{
        A[i][j] = k;
      }
    }
    k++;
  }
  
  int i = 0;
  while(count[i] == 0) i++;
  for(;i + 1 < H; i++){
    if(count[i + 1] == 0){
      for(int j = 0; j < W; j++){
        A[i + 1][j] = A[i][j];
      }
    }
  }
  
  i = 0;
  while(count[i] == 0) i++;
  for(; i > 0; i--){
    for(int j = 0; j < W; j++){
      A[i - 1][j] = A[i][j];
    }
  }
  
  for(i = 0; i < H; i++){
    for(int j = 0; j < W - 1; j++){
      cout << A[i][j] << ' ';
    }
    cout << A[i][W - 1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int k,x;
	cin >> k >>x;
	for (int i = x-k+1; i< x+k;i++) {
		if (i >=-1000000 && i <= 1000000) {
			cout << i << ' ';
		}
	}
	cout << endl;
	return 0;
}


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

int main(int argc, char const *argv[])
{
	int h, m, s;
	cin >> s;

	h = s / 3600;
	s %= 3600;
	m = s / 60;
	s  %= 60;

	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

int main() {
  int r;
  cin >> r;
  if (r < 1200) cout << "ABC" << endl;
  else if (r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}

Measured memory_bytes: 3536
{-# LANGUAGE FlexibleContexts #-}

module Main where

-- import Debug.Trace
import Data.List
import qualified Data.Set as Set
import qualified Data.Sequence as Seq
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
-- import Data.Array.IO
import Data.Maybe
import qualified Data.Map as M
-- import Control.Monad.ST
-- import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

data Vertex = Vt Int Int deriving (Eq, Show) -- Vt <ID> <Distance>
instance Ord Vertex where
    compare (Vt ia da) (Vt ib db) =
        case (ia ,da, ib, db) of
         _  | ia == ib -> EQ 
            | ia >  ib -> GT 
            | ia <  ib -> LT

solve :: Int -> [[Int]] -> [Vertex]
solve n lst = iter Set.empty initialQ where
    iter r q 
        | Set.null q = Set.toAscList r
        | otherwise = iter r' q' where
            r' = Set.insert v r
            q' = iter restQ (adjacencyList!i) where
                    iter q [] = q
                    iter q ((j, d):rest) = case Set.lookupGE (Vt j 0) q of
                        Just (Vt k c')
                            | j == k -> iter (Set.insert (Vt j (min (c+d) c')) q) rest
                            | otherwise -> iter q rest
                        Nothing -> iter q rest
            v@(Vt i c) = Set.foldl minCost (Vt n maxBound) q where
                minCost a@(Vt ia ca) b@(Vt ib cb) = if ca < cb then a else b
            restQ = Set.delete v q
            
    initialQ = Set.fromList $ [Vt 0 0] ++ [Vt x maxBound | x <- [1..n-1]]

    adjacencyList = array (0, n-1) (setupAL [] lst)
    setupAL al [] =  al
    setupAL al ((u:_:vcs):lines) = setupAL ((iter [] vcs):al) lines where
        iter av [] = (u, av)
        iter av (v:c:rest) = iter ((v,c):av) rest

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print' :: Vertex -> IO ()
print' (Vt x y) = putStrLn $ show x ++ " " ++ show y

main :: IO() 
main = do
    n  <- readIntLn
    l <- replicateM n readIntList
    mapM_ print' $ solve n l



Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)

typedef long long int LL;
typedef pair< int, int> ii;
const int mod = 1e9 + 7;
const int mx = 1e6;
const int i27 = 1 << 27;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	int n, a; cin >> n;
	int mxa = -1, mna = 1001;
	while(n--) {
	    cin >> a;
	    if(a > mxa) mxa = a;
	    if(a < mna) mna = a;
	}
	cout << mxa - mna;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

bool check_keyence(int i, int l, string &s){
	string t = s.substr(0, i) + s.substr(i+l, s.size()-(i+l));
//	out(t);
	if(t=="keyence") return true;
	else return false;
}

int main(void) {
	string s; cin >> s;
	bool flg = false;
	rep(i,s.size()){
		rep(l,s.size()-i) flg = flg||check_keyence(i,l,s);
	}
	if(flg) out("YES");
	else out("NO");
}




Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include "string.h"
using namespace std;
int main() {
	float s;
	cin >> s;
	int f2 = s / 100.0;
	int l2 = (int)s % 100;
	int count_yy_mm = 0;
	int count_mm_yy = 0;
	if (f2 >= 0 && f2 <= 99)count_yy_mm++;
	if (f2 >= 1 && f2 <= 12)count_mm_yy++;
	if (l2 >= 1 && l2 <= 12)count_yy_mm++;
	if (l2 >= 0 && l2 <= 99)count_mm_yy++;
	if ((count_yy_mm == 2 )&& (count_mm_yy  == 2))cout << "AMBIGUOUS" << endl;
	else if (count_yy_mm == 2)cout << "YYMM" << endl;
	else if (count_mm_yy == 2)cout << "MMYY" << endl;
	else cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long X, long long A);

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

void Main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
}

void solve(long long X, long long A){
    if(X<A){
        cout << 0 << el;
    }else{
        cout << 10 << el;
    }
}



Measured memory_bytes: 256
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    #define see(x) cout<<#x<<" = "<<x<<endl
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    int main()
    {   
         IOS;
         ll n,m,i,j,k;
         cin>>n;
         for(i=1;i<=50000;i++)
         {
           if(floor((ld)1.08*(ld)i)==n)
            return cout<<i,0;
         }
         cout<<":(";
        

         
         cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
    }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

vector<ll>path[101010];
ll MN[101010];
ll MX[101010];
ll No = 0;

void dfs(ll mn, ll mx, ll idx, ll from = -1){
    ll flg = 0;
    if(from == -1)flg = 1;
    if(MX[idx] == INF){
        MN[idx] = mn;
        MX[idx] = mx;
        flg = 1;
    }
    if(MN[idx] < mn){
        MN[idx] = mn;
        flg = 1;
    }
    if(MX[idx] > mx){
        MX[idx] = mx;
        flg = 1;
    }
    if(flg == 0)return;
    if(mn > mx){
        No = 1;
        return;
    }
    rep(i, path[idx].size()){
        ll to = path[idx][i];
        dfs(MN[idx] - 1, MX[idx] + 1, to, idx);
    }
}

ll check(ll rt, ll b){
    vector<ll>flg(101010, -1);
    flg[rt] = b;
    queue<ll>Q;
    Q.push(rt);
    while(!Q.empty()){
        ll idx = Q.front();
        Q.pop();
        ll nxt_flg = flg[idx] ^ 1;
        rep(i, path[idx].size()){
            ll to = path[idx][i];
            if(flg[to] >= 0)continue;
            if(MX[to] == INF){
                Q.push(to);
                flg[to] = nxt_flg;
            }
            else if(nxt_flg != (MX[to] % 2)){
                return 1;
            }
            else{
                Q.push(to);
                flg[to] = nxt_flg;
            }
        }
    }
    return 0;
}

int main(){
    rep(i, 101010)MX[i] = INF;

    ll N, K;
    cin >> N;
    rep(i, N - 1){
        ll a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    cin >> K;
    vector<ll>v(K);
    rep(i, K){
        ll val;
        cin >> v[i] >> val;
        MN[v[i]] = val;
        MX[v[i]] = val;
    }    
    if(check(v[0], MN[v[0]] % 2)){
        cout << "No" << endl;
        return 0;
    }
    rep(i, K){
        ll idx = v[i];
        dfs(MN[idx], MX[idx], idx);
    }
    if(No){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    rep1(i, N)cout << MX[i] << endl;

    return 0;
}

Measured memory_bytes: 10600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a,b;
    cin >> a >> b ;
     if (a == b) cout << a+b << endl;
     else if(a > b) cout << a*2 - 1 << endl;
     else cout << 2*b - 1 << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,br;
  cin>>n>>br;
  int f=1;
  vector <bool> step(n+1,false);
  vector<int> b(br);
  for(int i=0;i<br;i++){
    cin>>b[i];
    step[b[i]]=true;
    if(i>=1&&b[i]-b[i-1]==1){f=0; break;}
  }
  vector<int> a(n+1);
  a[0]=1;
  a[1]=(step[1]?0:1);
  for(int i=2;i<=n;i++){
    if(step[i]){a[i]=0;}
    else if(step[i-1]){a[i]=a[i-2]%1000000007;}
    else{a[i]=a[i-1]%1000000007+a[i-2]%1000000007;}
  }
  if(f){cout<<a[n]%1000000007;}
  else{cout<<0;}
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
string Toupper(string s){
  string t=s;
  for(int i=0;i<s.size();i++){
    t[i]=toupper(s[i]);
  }
  return t;
}
int main(){
  string target,source;
  cin>>target;
  target=Toupper(target);
  int count=0;
  while(1){
    cin>>source;
    if(source=="END_OF_TEXT") break;
    source=Toupper(source);
    if(target==source) count+=1;
  }
  printf("%d\n",count);
  return 0;
}

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

string s;
int harga,telur,i;

int main(){
    ios_base::sync_with_stdio(false);

    cin>>s;
    telur=0; harga=700;
    for(i=0;i<s.length();i++){
        if(s[i]=='o'){telur++;}
    }
    cout<<harga+(telur*100)<<"\n";
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
sp = [S_LIST() for _ in range(n)]
sp = [[sp[i][0], -int(sp[i][1]), i + 1] for i in range(n)]
sp.sort(key=lambda x:(x[0], x[1]))
for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 59628
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = getIntList >>= \x ->
    print . length . group $ sort x

Measured memory_bytes: 380
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

#define N 10000

ll cost[N][N];

int main() {
  int n, m, r;
  cin >> n >> m >> r;

  vector<ll> R(r), A(m), B(m), C(m);
  rep(i, r) cin >> R[i];
  

  rep(i, m) {
    int a,b,c;
    cin >> A[i] >> B[i] >> C[i];
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i == j) cost[i][j] = 0;
      else cost[i][j] = INF;
    }
  }

  for (int i = 0; i < m; ++i) {
    cost[A[i]][B[i]] = C[i];
    cost[B[i]][A[i]] = C[i];
  }

  for (ll k = 1; k <= n; ++k) {
    for (ll i = 1; i <= n; ++i) {
      for (ll j = 1; j <= n; ++j) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }

  sorti(R);

  ll ans = INF;

  do {
    ll tmp = 0;
    for (int i = 0; i < r - 1; ++i) {
      tmp += cost[R[i]][R[i + 1]];
    }
    ans = min(ans, tmp);
  } while (next_permutation(R.begin(), R.end()));

  cout << ans << endl;
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    double arr[n];
    for (ll i = 0; i < n; i++)
    {
        ld temp;
        cin >> temp;
        arr[i] = (temp + (ld)1) / (ld)2;
    }
    ld maxi = 0;
    for (ll i = 0; i < k; i++)
    {
        maxi += arr[i];
    }
    ld sum = maxi;
    for (ll i = k; i < n; i++)
    {
        sum += arr[i];
        sum -= arr[i - k];
        maxi = max(maxi, sum);
    }
    cout << fixed << setprecision(7) << maxi << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50


struct UnionFind
{
    vector<int> par;
    vector<int> sizes;
    UnionFind(int n) : par(n), sizes(n, 1) {
        REP(i,n) par[i] = i;
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return sizes[find(x)];
    }
};


int main(){
    int N,K,L;
    cin>>N>>K>>L;
    UnionFind uf1(N);
    UnionFind uf2(N);
    REP(i,K){
        int p,q;
        cin>>p>>q;
        p--;q--;
        uf1.unite(p,q);
    }
    REP(i,L){
        int p,q;
        cin>>p>>q;
        p--;q--;
        uf2.unite(p,q);
    }
    map< int, map< int, int > > lnk;
    REP(i,N){
        lnk[uf1.find(i)][uf2.find(i)]++;
    }
    
    REP(i,N){
        cout<<lnk[uf1.find(i)][uf2.find(i)];
        if(i!=N-1)cout<<" ";
        else cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 29312
#include<iostream>
using namespace std;
int main()
{
	int N, r, t;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> r >> t;
		if (r % 100 == 0 && t % 30 == 0)
		{
			int a = r / 100 + (t / 30) * 5;
			cout << a << endl;
		}
		else if(r % 100 > 0 && t % 30==0)
		{
			int a = r / 100 + (t / 30) * 5;
			cout << a << " " << a + 1 << endl;
		}
		else if (r % 100 == 0 && t % 30 > 0)
		{
			int a = r / 100 + (t / 30) * 5;
			cout << a << " " << a + 5 << endl;
		}
		else
		{
			int a = r / 100 + (t / 30) * 5;
			cout << a << " " << a + 1 << " " << a + 5 << " " << a + 6 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

void solve(ll n){
	vector<string> s(n);
	vector<string> m(n);
	char pre;
	string temp;
	rep(i,n){
		cin>>s[i];
	}
	//?????¶??¨??????????????????????????¨??????????????????????????¨???
	rep(i,n){
		rep(j,s[i].size()){
			if(j==0){
				temp="";
				pre=s[i][0];
				temp+=s[i][0];
			}else if(s[i][j-1]=='a'||s[i][j-1]=='i'||s[i][j-1]=='u'||s[i][j-1]=='e'||s[i][j-1]=='o'){
				temp+=s[i][j];
			}
		}
		m[i]=temp;
	}
	bool flag=true;
	ll length=0;
	ll a=100000000;
	int ans=-1;
	sort(all(m));
	rep(i,n){
		// dbg(m[i]);
		if(length<m[i].size()){
			length=m[i].size();
			a=i;
		}
	}
	//?????????????????????,????????????????????????????????????.
	rep(i,length){
		flag=true;
		rep(j,n){
			FOR(k,j+1,n){
				//?????????????????????i????????§????§?????????£???????????????????¢??????????.
				if(m[j].substr(0,i+1)==m[k].substr(0,i+1)){
					//????????????????????£????????????
					flag=false;
					break;
				}
			}
			if(!flag){
				break;
			}
		}
		if(flag){
			ans=i+1;
			break;
		}
	}

	// rep(k,n){
	// 	rep(i,m[k].size()){
	// 		flag=true;
	// 		FOR(j,k+1,n){
	// 			if(j!=k){
	// 				dbg(m[k].substr(0,i+1));
	// 				dbg(m[j].substr(0,i+1));
	// 				if(m[k].substr(0,i+1)==m[j].substr(0,i+1)){
	// 					flag=false;
	// 					break;
	// 				}
	// 			}
	// 		}
	// 		if(flag){
	// 			ans=min(ans,i);
	// 			break;
	// 		}
	// 	}
	// }
	if(ans>=0){
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
	return;
}

int main(){
	ll n;
	while(cin>>n&&n){
		solve(n);
	}


    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

void dfs(int s, int p, vector<vector<pii>> &G, vector<int> &reached) {

    for(auto &nxt : G[s]) {
        if(nxt.first == p) continue;
        if (nxt.second % 2 == 0) reached[nxt.first] = reached[s];
        else reached[nxt.first] = 1 - reached[s];
        dfs(nxt.first, s, G, reached);
    }
}

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

    vector<vector<pii>> G(N);
    vector<int> reached(N, -1);

    for(int i = 0; i < N-1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(pii(v, w));
        G[v].push_back(pii(u, w));
    }

    reached[0] = 1;
    dfs(0, -1, G, reached);

    for(auto &e: reached) {
        cout << e << endl;
    }

    return 0;
}

Measured memory_bytes: 9728
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
D = iil()
sumD = sum(D)
ans = 0
for i in range(n):
    ans += D[i]*(sum(D)-D[i])
print(ans//2)

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

using namespace std;
typedef long long ll;

string s;
int N;
vector<int> v[10];

int main(){
    cin >> N;
    cin >> s;
    for(int i=0;i<s.size();i++){
        v[s[i]-'0'].push_back(i);
    }
    int c = 0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                if(v[i].size()==0) continue;
                int f = v[i][0];
                auto s_itr = upper_bound(v[j].begin(), v[j].end(), f);
                if(s_itr == v[j].end()) continue;
                int s = *s_itr;
                auto t_itr = upper_bound(v[k].begin(), v[k].end(), s);
                if(t_itr == v[k].end()) continue;
                c++;
            }
        }
    }
    cout << c << endl;
    return 0;
}

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

int main(){
  int a,b,cnt=0;
  int c[5];
  cin >> a >> b;
  
  
  for(int i=a;i<=b;i++){
    for(int j=1,k=0;k<5;j*=10,k++){
      c[k] = i/j%10;
    }
    if(c[0]==c[4] && c[1]==c[3])
      cnt++;
  }
  
  cout << cnt << endl;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

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

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    i64 N, M;
    cin >> N >> M;

    vector< pair< i64, i64 > > A(N);
    cin >> A;

    whole(sort, A);

    i64 ans = 0;
    int idx = 0;
    while (M) {
        ans += min(M, A[idx].second) * A[idx].first;
        M -= min(M, A[idx].second);
        idx++;

        if (M == 0) break;
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 1792
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args){
		try(Scanner scan = new Scanner(System.in)){
			long N = scan.nextLong();
			long M = scan.nextLong();
			
			if(M < (2 * N)){
				System.out.println(M/2);
				return;
			}
			
			long ans = N + ((M - (2 * N)) / 4);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 20820
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define myabs(a) ((a) >= 0 ? (a) : - (a))
inline char nc()
{
    return getchar();
    static char buf[100000], * l = buf, * r = buf;
    if(l == r) r = (l = buf) + fread(buf, 1, 100000, stdin);
    if(l == r) return EOF;
    return *l++;
}
template<class T> void readin(T & x)
{
    x = 0; int f = 1, ch = nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x *= f;
}
int n, a[100050], b[100050], vis[100050][2];
pair<int, int> s[200050];
int main()
{
    readin(n);
    long long s1 = 0, s2 = 0;
    for(int i = 1; i <= n; i++)
    {
        readin(a[i]), readin(b[i]);
        s[i] = make_pair(a[i], i);
        s[i + n] = make_pair(b[i], -i);
        s1 += a[i], s2 += b[i];
    }
    s1 = min(s1, s2), s2 = 0;
    sort(s + 1, s + n * 2 + 1);
    for(int i = 1; i <= n; i++)
    {
        s2 += s[i].first;
        vis[myabs(s[i].second)][s[i].second < 0] = 1;
    }
    for(int i = 1; i <= n; i++)
    {
        long long t = s2, c = n;
        if(!vis[i][0]) {while(myabs(s[c].second) == i) c--; t -= s[c--].first, t += a[i];}
        if(!vis[i][1]) {while(myabs(s[c].second) == i) c--; t -= s[c--].first, t += b[i];}
        s1 = min(s1, t);
    }
    cout << s1 << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = max(0ll, n*(n-1)/2) + max(0ll, m*(m-1)/2) ;
    cout << ans << endl;
}

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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

ll a[100001], vis[100001], cnt, b[100001], vis2[100001];
vector < ll > graph[100001];

void dfs(ll node, ll k) {
    a[node] = k;
    vis[node] = 1;
    cnt++;
    for(auto x:graph[node]) {
        if(vis[x]==0) {
            dfs(x,k);
        }
    }
}

void dfs2(ll node) {
    b[node] = cnt;
    vis2[node] = 1;
    for(auto x:graph[node]) {
        if(vis2[x]==0) {
            dfs2(x);
        }
    }
}


void solve() {
    ll n, m, k, i, j, p, q;
    cin>>n>>m>>k;
    Fo(i,1,n+1)a[i]=vis[i]=b[i]=vis2[i]=0;
    fo(i,m) {
        cin>>p>>q;
        graph[p].pb(q);
        graph[q].pb(p);
    }
    q = 1;
    Fo(p,1,n+1) {
        if(vis[p]==0) {
            cnt=0;
            dfs(p,q);
            q++;
            dfs2(p);
        }
    }
    fo(i,k) {
        cin>>p>>q;
        if(a[p]==a[q]) {
            b[p]--;
            b[q]--;
        }
    }
    Fo(i,1,n+1) {
        b[i] -= (ll)graph[i].size() + 1ll;
        cout<<b[i]<<" ";
    }
}

int main()
{
    ll t = 1;
    // cin>>t;
    while(t--) {
        solve();
    }
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin>>t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> dp(10001, 0);
		for (int i = 1; i < 500; i++) {
			for (int j = 1; j < 500; j++) {
				for (int k = 1; k < 500; k++) {
					ll val = i * i + j * j + k * k + i * j + j * k + i * k;
					if (val <= 10000) {
						dp[val]++;
					}
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			cout << dp[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	// 入力
	ll A, B;
	cin >> A >> B;

	if (B % A == 0) cout << A + B << endl;
	else cout << B - A << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    // while(cin>>n){
        int ans=0;
        for(int i=0; i<5; ++i){
            scanf("%d",a+i);
            if(a[i]==0)ans=i+1;
        }
        printf("%d\n",ans);
    // }
  return 0;
}




Measured memory_bytes: 3760
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<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);
}
//

#pragma endregion

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

int main() {
    string s;
    cin >> s;
    bool f1, f2;
    f1 = (s.substr(0, 2) <= "12" && s.substr(0, 2) != "00");
    f2 = (s.substr(2, 2) <= "12" && s.substr(2, 2) != "00");
    if(f1 && f2) cout << "AMBIGUOUS" << endl;
    else if(f1) cout << "MMYY" << endl;
    else if(f2) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}


Measured memory_bytes: 256