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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int n,m;
    cin >> n >> m;

    VI a(n);
    REP(i, n) cin >> a[i];

    int sum = 0;
    REP(i,n){
        sum += a[i];
    }

    int result = 0;
    REP(i,n){
        if(a[i] >= ceil((double)sum/(4.0*m))){
            result ++;
        }
    }
    if(result >= m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

	return;
}

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

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

diff = abs(a-b)

if (diff%2 == 0):
    print(diff//2)
else:
    kouho = min(max(n-a,n-b),max(a-1,b-1))
    suku = min(n-a,n-b,a-1,b-1)
    kazu = (diff-1) //2
    print(min(kouho,suku+kazu+1))

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, R;

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

  std::cin >> N >> R;

  int R2 = R;
  
  if(N < 10){
      R2 += 100 * (10 - N);
  }

  std::cout << R2 << std::endl;
}


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

int ctoll(char a){
    return (ll)a-'0';
}

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

    ll n_sum[2020]={};
    ll n;
    ll a = 0;
    ll b=1;
    ++n_sum[0];
    rep(i,S.size()){
        n = ctoll(S[S.size()-1-i]);
        a += (n*b)%2019;
        a %=2019;
        ++n_sum[a];
        b*=10;
        b%=2019;
        // cout<<a<<"\n";
    }
    ll ans = 0;
    rep(i,2020){
        n = n_sum[i];
        ans +=n*(n-1)/2;
    }
    cout<<ans<<"\n";

	
	return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int M = 0;
  int index = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.at(i) = a;
    if (a > M) {
      M = a;
      index = i;
    }
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    if (i == index) cout << A.at(1) << endl;
    else cout << M << endl;
  }
}

Measured memory_bytes: 2432
n,k = map(int, input().split())
l = list(map(int, input().split()))
s = "POSSIBLE"
m = max(l)
a = l.pop()
for _ in range(n-1):
  b = l.pop()
  while b:
    a,b = b,a%b
if k>m or k%a:
  s = "IM" + s
print(s)

Measured memory_bytes: 14096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	

	
	ini(n);
	ini(k);
	vi morty(n);
	FOR(i,0,n)in(morty[i]);
	int gcd1 = 0;
	sort(all(morty));
	FOR(i,0,n){
		gcd1 = __gcd(gcd1,morty[i]);
	}
	if(morty[n-1]>=k and k%gcd1 == 0)out("POSSIBLE");
	else out("IMPOSSIBLE");








	return 0;
}


Measured memory_bytes: 1024
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b // gcd(a, b)

A, B, C, D = map(int, input().split(" "))

c_count = (B//C)-(-(-A//C))+1
# print(c_count)

d_count = (B//D)-(-(-A//D))+1
# print(d_count)

cd_lcm = lcm(C, D)
# print(cd_lcm)
cd_count = (B//cd_lcm)-(-(-A//cd_lcm))+1
# print((B//cd_lcm), (-(-A//cd_lcm)))


print(B-A+1 - c_count - d_count + cd_count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int A, B;
    cin >> A >> B;
    if(A<10 && B<10) cout << A*B;
    else cout << -1;
    
    return 0;
}

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

int n;
int a[100010]; 
int m,x,y;

int main()
{
	cin>>n>>m;
	for (int i=1;i<=m;i++)
	{
		cin>>x>>y;
		++a[x],++a[y];
	}
	for (int i=1;i<=n;i++) if (a[i]%2) return 0*puts("NO");
	return 0*puts("YES");
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c,x,y;
    ll cost=0;
    cin>>a>>b>>c>>x>>y;
    ll ans=INFINITY;
    rep(i,100001){
        cost=2*c*i+a*max(0,x-i)+b*max(0,y-i);
        ans=min(ans,cost);
    }
    cout<<ans;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] cou = new int[26];

        while(sc.hasNext()){
            String str = sc.next();
            char[] ch =str.toCharArray();
            int le = str.length();
            for(int i=0;i<le;i++){
                for(int k=0;k<26;k++){
                    if(ch[i]==(65+k) || ch[i]==97+k){
                        cou[k]++;
                    }
                }
            }

        }

        for(int i=0;i<26;i++){
            int c = 97+i;
            System.out.println((char)c+" : "+cou[i]);
        }

        sc.close();
    }
}



Measured memory_bytes: 26292
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
    }

    let mut primes = HashMap::new();
    for mut i in 2..=n {
        for p in 2..=n {
            let mut count = 0;
            while i % p == 0 {
                count += 1;
                i /= p;
            }
            if count > 0 {
                *primes.entry(p).or_insert(0) += count;
            }
        }
    }

    let mut ans = 0;
    ans += primes.values().filter(|v| **v >= 74).count();
    
    let v1 = primes.values().filter(|v| **v >= 24).count();
    let v2 = primes.values().filter(|v| **v >= 2).count() - 1;
    ans += v1 * v2;
    
    let v1 = primes.values().filter(|v| **v >= 14).count();
    let v2 = primes.values().filter(|v| **v >= 4).count() - 1;
    ans += v1 * v2;

    let v1 = primes.values().filter(|v| **v >= 4).count();
    let v1 = v1 * (v1 - 1) / 2;
    let v2 = primes.values().filter(|v| **v >= 2).count() - 2;
    ans += v1 * v2;
    println!("{}", ans);
}


Measured memory_bytes: 2144
fun main(arr:Array<String>) {
    val s = readLine()!!
    var aIndex  = -1
    var zIndex = -1
    for(i in (0 until s.length)) {
        if(s[i] == 'A') {
            if(aIndex < 0) {
                aIndex = i
            }
        } else if(s[i] == 'Z') {
            zIndex = i
        }
    }
    println(zIndex - aIndex + 1)
}

Measured memory_bytes: 38724
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;

void main()
{
    long[] a = readln.chomp.split(" ").to!(long[]);
    auto n = a[0];
    auto k = a[1];

    auto m = n % k;
    if (m != 0)
    {
        writeln(1);
    }
    else
    {
        writeln(0);
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    //Can't Wait for Holiday
    //又是最无聊的第一题, 呵呵
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        List<String> days = Arrays.asList("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT");
        int index = days.indexOf(s);
        System.out.println(7 - index);
        sc.close();
    }
}


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


int main() 
{ 
	int n;
	cin>>n;
	long long int ans=1;
	if(n%2==0){
		ans*=n;
		ans/=2;
		ans*=(n+1);
	}
	else{
		ans*=(n+1);
		ans/=2;
		ans*=n;
	}

	ans-=n;
	cout<<ans;
	
	return 0; 
} 


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        int[] a = new int[26];
        string s = Console.ReadLine();
        for(int i = 0; i < s.Length; i++)
        {
            a[s[i] - 'a']++;
        }
        for(int i = 0; i < 26; i++)
        {
            if (a[i] <= 1) { } else { Console.WriteLine("no"); break; }
            if (i == 25) { Console.WriteLine("yes"); }
        }Console.ReadLine();
    }
    public static Boolean uso() { return false; }
    public static int gcd(int a, int b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static int lcm(int a, int b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (int i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] Ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13140
#include <iostream>
#include <list>
#include <set>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

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

int main()
{
    int n, m;
    int l, r;
    int min = 0, max = 100001;
    cin >> n >> m;
    vector<int> x;

    rep(i, m)
    {
        cin >> l >> r;
        if (min < l)
        {
            min = l;
        }
        if (max > r)
        {
            max = r;
        }
    }
    if (max - min >= 0)
    {
        cout << max - min + 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
const main = (input) => {
  const [a, b] = input.split(' ').map(n => Number(n))
  let result = -1
  if (a < 10 && b < 10) {
    result = a*b
  }
  console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



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

    ll ans = max(a * c, max(a * d, max(b * c, b * d)));
    cout << ans << endl;
   
    return 0;

}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a+b>=c-1){
    printf("%d",b+c);
  }else{
    printf("%d",b+b+a+1);
  }
  return 0;
}


Measured memory_bytes: 128
#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>
#include <stdlib.h>

using namespace std;
 
typedef long long 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[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//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) {}
};

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

//-----end of template-----//

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int d;
	cin >> d;
	string s = "Christmas";
	for(int i = 0; i < 25 - d; ++i) s += " Eve";
	cout << s << endl;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]
costs=[]
for bit in range(1<<N):
    cost=0
    understand=[0]*M
    for digit in range(N):
        if (bit>>digit)&1:
            cost+=CA[digit][0]
            for m in range(M):
                understand[m]+=CA[digit][m+1]
    if all(understand[m]>=X for m in range(M)):
        costs.append(cost)
print(min(costs) if costs else -1)

Measured memory_bytes: 9224
# これは500点では？
import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))
a = np.array(a) # numpy の array で高速化
a.sort()

zero = np.count_nonzero(a == 0)
positive = a[a > 0] # numpy の特徴的な記法
negative = a[a < 0]

def count(x): # 積が x 以下のペアは何個あるか？
  ans = 0
  if x >= 0: # 片側が 0 の場合
    ans += n * zero
  ans += np.searchsorted(a, x // positive, side="right").sum() # 片側が正の場合
  ans += n * len(negative) - np.searchsorted(a, -(-x // negative), side="left").sum() # 片側が負の場合 切り上げは -(-a//b)
  ans -= np.count_nonzero(a * a <= x) # 同じもの2つは選べない
  return ans // 2

ok = 10**18
ng = -ok - 1
while ok - ng > 1: # 二分探索
  cen = (ok + ng) // 2
  if count(cen) >= k:
    ok = cen
  else:
    ng = cen
print(ok)

Measured memory_bytes: 32320
#include <stdio.h>
int main (void){
  while(1){
    int a,b,c,d,e,f;
    char op;
    scanf("%d %c %d", &a, &op, &b);

    if (op=='+'){
      c=a+b;
      printf("%d\n",c);
    } else if (op=='-'){
      d=a-b;
      printf("%d\n",d);
    } else if (op=='*'){
      e=a*b;
      printf("%d\n",e);
    } else if (op=='/'){
      f=a/b;
      printf("%d\n",f);
    } else if (op=='?'){
      break;
    }
  }
  return 0;
}
  

Measured memory_bytes: 1028
N, K, Q = map(int, input().split())
correct_count = [0 for _ in range(N)]

for _ in range(Q):
    ai = int(input())
    correct_count[ai - 1] += 1

for c in correct_count:
    if K - Q + c < 1:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 4672
a = gets.chomp.to_s
b = a.split(" ")
c = b[0].to_i
d = b[1].to_i
if c < d then
print ("a"),(" "),("<"),(" "),("b"),("\n")
elsif c > d then
print ("a"),(" "),(">"),(" "),("b"),("\n")
else 
print ("a"),(" "),("=="),(" "),("b"),("\n")
end

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

int n, m;
vector<int> s[11];
int k[11];
int p[11];
int on[11];
int ans = 0;

void comb(int t, int sw) {
	if (t==0) {
		for (int i = 1; i <= m; i++) {
			int count = 0;
			for (int j = 0; j < s[i].size(); j++) {
				if (on[s[i][j]] == 1) {
					count++;
				}
			}
			if (count % 2 != p[i]) return;
		}
		ans++;
		return;
	}
	on[t] = sw;
	comb(t - 1, 0);
	comb(t - 1, 1);
}


int main()
{
	cin >> n >> m;
	
	for (int i = 1; i <= m; i++) {
		cin >> k[i];
		for (int j = 1; j <= k[i]; j++) {
			int tmp;
			cin >> tmp; s[i].push_back(tmp);
		}
	}
	for (int i = 1; i <= m; i++) {
		cin>>p[i];
	}

	comb(n+1, 0);
	cout << ans/2 << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
edge=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
import sys
sys.setrecursionlimit(10**6)
dep=[-1 for i in range(n+1)]
color=[0 for i in range(n+1)]
def dfs(s,d,c):
    dep[s]=d
    color[s]=c
    for i in edge[s]:
        if dep[i]==-1:
            if not dfs(i,d+1,-c):
                return False
        else:
            if color[i]==c:
                return False
    return True
if dfs(1,0,1):
    print(color.count(1)*color.count(-1)-m)
else:
    print(n*(n-1)//2-m)

Measured memory_bytes: 213836
h, w = map(int, input().split())
field = [list(input()) for _ in range(h)]
direct = []
for i in range(-1, 2):
    for j in range(-1, 2):
        if i or j:
            direct.append((i, j))
def count(x, y):
    ret = 0
    for dx, dy in direct:
        xa = x + dx
        ya = y + dy
        if 0 <= xa < h and 0 <= ya < w and field[xa][ya] == '#':
            ret += 1
    return ret
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            print(count(i, j), end = '')
        else:
            print('#', end = '')
    print()

Measured memory_bytes: 3444
from sys import stdin
N = int(stdin.readline().rstrip())
for h in range(1,3501):
    for n in range(1,3501):
        if (4*h*n-N*h-N*n) != 0:
            w = (N*h*n)/(4*h*n-N*h-N*n)
        else:
            continue
        if w.is_integer() and w > 0:
            print(h,n,int(w))
            break
    else:
        continue
    break

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF (i64)(1e18)
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

struct UnionFind {
  vector<i64> par, sz;
  UnionFind(i64 n) : par(n), sz(n) {
    REP(i, n) {
      par[i] = i;
      sz[i] = 1;
    }
  }
  i64 root(i64 x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(i64 x, i64 y) {
    i64 rx = root(x), ry = root(y);
    if (rx == ry) return;
    if (size(rx) < size(ry)) swap(rx, ry);
    par[ry] = rx;
    sz[rx] += sz[ry];
  }
  i64 size(i64 x) {
    return sz[root(x)];
  }
  bool same(i64 x, i64 y) {
    return root(x) == root(y);
  }
};

int main() {
  i64 n, m;
  cin >> n >> m;
  vector<i64> a(m), b(m);
  REP(i, m) {
    cin >> a.at(i) >> b.at(i);
    a[i]--;
    b[i]--;
  }
  UnionFind uf(n);
  i64 memo = n*(n-1)/2;
  vector<i64> ans;
  RREP(i, m) {
    ans.push_back(memo);
    if (uf.same(a[i], b[i])) continue;
    memo -= uf.size(a[i])*uf.size(b[i]);
    uf.unite(a[i], b[i]);
  }
  reverse(ALL(ans));
  for(auto& x : ans) cout << x << endl;
  return 0;
}


Measured memory_bytes: 7412
lines = []

c1 = /\[[^\[\]\(\)]*\]/
c2 = /\([^\[\]\(\)]*\)/

while str = gets
  break if str == "." || str == ".\n"

  while true
    str = str
      .gsub(c1, "")
      .gsub(c2, "")
    if str.match(c1) || str.match(c2)
      next
    else
      break
    end
  end

  puts str.match(/[\[\(\)\]]/) ? "no" : "yes"
end

Measured memory_bytes: 6636
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 19, 2018, 10:55 AM
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */

int bubbleSort(
    int a[],
    int n
);

int main(int argc, char** argv) {
    int size, counter;
    int *A;
    
    scanf("%d", &size);
    A = (int *)malloc(sizeof(int) * size);
    for (int ix = 0; ix < size; ++ix) scanf("%d", &A[ix]);
    counter = bubbleSort(A, size);
    for (int ix = 0; ix < size; ++ix)
    {
        if (ix > 0) printf(" ");
        printf("%d", A[ix]);
    }
    printf("\n");
    printf("%d\n", counter);
    return (EXIT_SUCCESS);
}

int bubbleSort( int a[], int n )
{
    int counter = 0;
    for( int i = 1; i < n; ++i )
	{
            for( int j = n-1; j >= i; --j )
            {
                if( a[j] < a[j-1] )
                {
                    int copy;
                    copy = a[j];
                    a[j] = a[j-1];
                    a[j-1] = copy;
                    counter++;
                }
            }
	}
    return counter;
}




Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

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

  if(n == 0){
    cout << 0 << endl;
    return 0;
  }

  string ans = "";
  for(ll i=0; i<=32; i++){
    if(n % (1LL << (i+1))){
      ans = "1" + ans;
      n -= (ll)pow(-2, i);
    }
    else{
      ans = "0" + ans;
    }
  }

  int cnt = 0;
  for(int i=0; i<ans.length(); i++){
    if(ans[i] == '1'){
      cnt = i;
      break;
    }
  }

  cout << ans.substr(cnt, ans.length()-cnt) << endl;

  return 0;
}


Measured memory_bytes: 384
n,m = map(int,input().split())
A = list(map(int,input().split()))
pp = [0]*(n)
BC = []
for i in range(m):
    BC.append([int(i) for i in input().split()])
BC.sort(key=lambda x: x[1],reverse=True)
cnt = 0
for b,c in BC:
    if cnt+b<=n:
        for i in range(cnt,cnt+b):
            pp[i] = c
    elif cnt<=n:
        for i in range(cnt,n):
            pp[i] = c
    cnt += b
A.extend(pp)
A.sort(reverse=True)
print(sum(A[:n]))


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

using namespace std;

using ll = long long;

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

    int n, d, ans = 0;
    array<bool, 101> flag;
    fill(flag.begin(), flag.end(), false);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> d;
        if (!flag[d]) ++ans;
        flag[d] = true;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int m = n / 2;
    int ans = d[m] - d[m - 1];
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define vll vector<ll>
#define v2d vector<vll>
#define mll map<ll,ll>
#define f(i,a,n)  for(i=a;i<n;i++)
#define INF     LLONG_MAX
#define PI 3.14159265
#define spid    ios::sync_with_stdio(false);cin.tie(NULL);
#define s(x) sort(x.begin(),x.end())
#define y() cout<<"YES"<<endl
#define n() cout<<"NO"<<endl
 
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; ;
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
 
 
int main()
{
    spid;
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll a,b,c,d,x,y;
        cin>>a>>b>>c>>d;
        cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
        
        
    }
    return 0;
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
vector<vector<int>> w;
vector<int> r;
int main()
{
	int n, m, R;
	cin >> n >> m >> R;
	r.resize(R);
	rep(i, 0, R)cin >> r[i], r[i]--;
	sort(all(r));
	w.resize(n, vector<int>(n, 1 << 30));
	rep(i, 0, n)w[i][i] = 0;
	rep(i, 0, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		w[a][b] = w[b][a] = c;
	}
	rep(k, 0, n) {
		rep(s, 0, n) {
			if (w[s][k] == 1 << 30)continue;
			rep(e, 0, n) {
				if (w[k][e] == 1 << 30)continue;
				w[s][e] = min(w[s][e], w[s][k] + w[k][e]);
			}
		}
	}
	int ans = 1 << 30;
	while (next_permutation(all(r))) {
		int len = 0;
		rep(i, 0, R - 1) {
			len += w[r[i]][r[i + 1]];
		}
		ans = min(ans, len);
	}
	printf("%d\n", ans);
	return 0;
}

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

//#define USING_LONG_LONG
#ifdef USING_LONG_LONG
    #define int long long
    const int INF=1001001001001001001ll;
#else
    const int INF=1001001001;
#endif

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREP(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define clr(a) memset((a),0,sizeof(a))
#define CLR(a) memset((a),-1,sizeof(a))
#define each(i,v) for(__typeof((v).begin()) i=(v).begin();i!=(v).end();i++)
#define minv(a,b) (a)=min((a),(b))
#define maxv(a,b) (a)=max((a),(b))
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<string>vs;
typedef pair<int,int>pii;
#define fi first
#define se second


const int SQ=400;
int N,Q;

struct latte{
    vi v;
    int m;
    latte(){v.clear();m=INT_MAX;}
};
vector<latte>li;
signed main(){
    scanf("%d%d",&N,&Q);

    latte now;
    rep(i,N){
        now.v.pb(INT_MAX);
        if(i%SQ==SQ-1){li.pb(now);now=latte();}
    }
    if(now.v.size())li.pb(now);

    while(Q--){
        int type,x,y;scanf("%d%d%d",&type,&x,&y);
        if(type==0){
            int cur=0;
            rep(i,li.size()){
                if(cur<=x&&x<cur+li[i].v.size()){
                    li[i].v[x-cur]=y;
                    li[i].m=INT_MAX;
                    rep(j,li[i].v.size())minv(li[i].m,li[i].v[j]);
                    break;
                }
                cur+=li[i].v.size();
            }
        }
        else{
            int cur=0,ret=INT_MAX;
            rep(i,li.size()){
                if(x<=cur&&cur+li[i].v.size()<=y+1)minv(ret,li[i].m);
                else if(!(y<cur||cur+li[i].v.size()<=x)){
                    rep(j,li[i].v.size()){
                        if(x<=cur+j&&cur+j<=y)minv(ret,li[i].v[j]);
                    }
                }
                cur+=li[i].v.size();
            }
            printf("%d\n",ret);
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;
    vector<ll> b = a;

    for(ll i=1; i<n; i++)
        b[i] = (b[i-1] + a[i]) % MOD;

    ll res = 0;
    for(ll i=1; i<n; i++)
        (res += (b[i-1] * a[i]) % MOD) %= MOD;
    cout << res << endl;
}

Measured memory_bytes: 6364
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
div = []
rdiv = []
for i in range(1,int(s**.5+1)):
  if s % i == 0:
    div.append(i)
    rdiv.append(s//i)
if s == int(s**.5)**2:
  div = di[:-1]
rdiv.reverse()
div += rdiv
div.reverse()
#print(div)
for i in range(len(div)):
  now = div[i]
  tmp = []
  for x in a:
    tmp.append(x%now)
  tmp.sort()
  b = n - sum(tmp) // now
  #print(now,tmp,b)
  ans = 0
  for j in range(b):
    ans += tmp[j]
  if ans <= k:
    print(now)
    break

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    vi v;
    v. push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v);
    v.erase(unique(v.begin(), v.end()), v.end());
    P(v.size());

    return 0;
}



Measured memory_bytes: 256
<?php

    $N = intval(trim(fgets(STDIN)));
    
    $H = array_map('intval',explode(" ",trim(fgets(STDIN))));
    $max=0;
    for($i=0;$i<$N-1;$i++){
        if(($H[$i]-$H[$i+1])>2){
            echo "No";
            exit;
        }
        if($max<$H[$i]){
            $max = $H[$i];
        }
        // echo $max."\n";
        if($max-$H[$i+1]>=2){
            echo "No";
            exit;   
        }
    }
    echo "Yes";
?>

Measured memory_bytes: 27132
n = gets.chomp.to_i

class Fixnum
  def bijective_s(base=nil, offset=nil)
    offset ||= 'A'.ord #65
    base ||= 26
    value = self
    result = []
    while value > 0
      value -= 1
      result << (value%base+offset).chr
      value /= base
    end
    result.reverse.join
  end
end

puts n.bijective_s.downcase

Measured memory_bytes: 14368
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

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

Measured memory_bytes: 888
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
if N%2 == 0:
    for e in A:
        if e%2 == 0:
            print(0)
            exit()
else:
    for e in A:
        if e%2 == 1:
            print(0)
            exit()
L = Counter(A)
ans = 1
mod = 10**9+7
for key,value in L.items():
    if N%2 == 1 and key == 0 and value > 1:
        print(0)
        exit()
    if value > 2:
        print(0)
        exit()
    ans *= value%mod
print(ans%mod)

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

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_map<string, int> counts;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    counts[S]++;
  }

  vector<string> K = {"AC", "WA", "TLE", "RE"};
  for (string s : K) {
    cout << s << " x " << counts[s] << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1));
  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      if (s[i-1] == t[j-1])
        dp[i][j] = dp[i-1][j-1]+1;
      else
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  string ans;
  int x = s.size(), y = t.size();
  while (x && y) {
    if (s[x-1] == t[y-1]) {
      ans += s[x-1];
      x--, y--;
    } else if (dp[x-1][y] == dp[x][y])
      x--;
    else
      y--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35584
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //Map<String, Integer> map = new HashMap<String, Integer>();
    int x = sc.nextInt();
    int y = sc.nextInt();
    System.out.println(x + y/2);
  }
}


Measured memory_bytes: 23380
#include <iostream>

using namespace std;

int func(int n)
{
  if(n % 2 == 0){
    return n / 2;
  }else{
    return 3*n+1;
  }
}
int main(void)
{
  int s;
  cin >> s;

  int a1 = s;
  int ai = a1;
  for(int i = 2; ; i++){
    ai = func(ai);
    int aj = a1;
    for(int j = 1; j < i; j++){
      if(ai == aj){
        cout << i << endl;
        return 0;
      }
      aj = func(aj);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include<random> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back 
#define mod 1000000007 
using namespace std; 
void fastio() 
{ 
    #ifndef ONLINE_JUDGE 
    freopen("INPUT.txt","r",stdin); 
    freopen("OUTPUT.txt","w",stdout); 
    #endif 
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL) ; 
    cout.tie(NULL); 
}

signed main() 
{ 
    fastio(); 
    int t=1;
   // cin>>t;
    while(t--)
    {
       string s,ss;
       cin>>s>>ss;
       int c=0;
       for(int i=0;i<3;i++)
       {
           if(s[i]==ss[i])
           c++;
       }
       cout<<c;
    }
}


Measured memory_bytes: 3640
n, p = map(int, input().split())
s = input()

c = [0 for i in range(p)]
c[0] = 1
x = 0
ans = 0
for i,j in enumerate(s[::-1]):
  if p == 2 or p == 5:
    if int(j)%p == 0:
      ans += n-i
  x = (x + int(j)*pow(10,i,p))%p
  c[x] += 1
if ans:
  print (ans)
  exit()
for i in range(p):
  ans += (c[i]*(c[i]-1))//2
print (ans)



Measured memory_bytes: 9288
using System;
using System.Linq;

public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine().Trim());
    int[] A = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
    int[] B = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
    int[] C = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
    
    int sum = 0;
    int previous = -1;
    foreach(var i in A) {
      sum += B[i - 1];
      if(i == previous + 1) {
        sum += C[previous - 1];
      }
      previous = i;
    }
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        for (int i = 0; i <= x; i++) {
            for (int j = 0; j <= x; j++) {
                if(i + j == x) {
                    int tmp = (i * 2) + (j * 4);
                    if(tmp == y) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35736
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int m, temp;
  int ans[3];
  m = n;
  for(int i = 2; i >= 0; i--){
    ans[i] = m % 10;
    m /= 10;
  }
  for(int i = 0; i < 3; i++){
    if(ans[i] == 1) ans[i] = 9;
    else ans[i] = 1;
  }
  printf("%d\n", ans[0] * 100 + ans[1] * 10 + ans[2]);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;

struct fast_io {
        fast_io(){
                std::cin.tie(nullptr);
                std::ios::sync_with_stdio(false);
        };
} fio;

signed main(){
        cout<<fixed<<setprecision(10);

        int N, X;
        int a, b;
        int ans = 0;

        cin>>N>>X;

        a = X;
        b = N - X;

        ans += X;
        ans += N - X;

        while(true){
          if(a < b) swap(a, b);
          // cout<<"a = "<<a<<" b = "<<b<<" ans = "<<ans<<endl;
          ans += b;

            ans += 2 * (a/b - 1) * b;

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

          a = a % b;

        }

        return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  s += t;
  int a = 0;
  for(int i = 0; i < s.size(); i++) {
    int b = s[i] - '0';
    for(int j = 1; j < s.size()-i; j++) {
      b *= 10;
    }
    a += b;
  }
  for(int i = 0; i < a; i++) {
    if(i*i == a) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}

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

struct Edge {
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main(){
    ll n;
    cin >> n;
    Graph G(n);
    for(ll i=0;i<n-1;i++){
        ll from,to,weight;
        cin >> from >> to >> weight;
        from--;
        to--;
        G[from].push_back(Edge(to, weight));
        G[to].push_back(Edge(from, weight));
    }
    vector<ll> color(n,-1);
	queue<ll> que;
	color[0]=0;
	que.push(0);
	while(!que.empty()){
        auto v=que.front();
        que.pop();
        for(auto nv:G[v]){
            if(color[nv.to]!=-1) continue;
            else{
                que.push(nv.to);
                if(nv.weight%2==0) color[nv.to]=color[v];
                else color[nv.to]=1-color[v];
            }
        }
    }
    for(ll i=0;i<n;i++){
        cout << color[i] << endl;
    }
}


Measured memory_bytes: 10024
#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 LINF LONG_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);

    ll N;
    cin >> N;

    vector<ll> a(5);
    rep (i, 5) {
        cin >> a[i];
    }
    
    ll minimam = LINF;
    ll index = 0;
    rep (i, 5) {
        if (minimam > a[i]) {
            minimam = a[i];
            index = i;
        }
    }

    cout << 5 + (N + minimam - 1) / minimam - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

vector<vector<double>> dp(3005, vector<double>(3005, -1));
vector<double> p(3005);

//dp[h][t] = probability of getting h heads and t tails
double solve(int h, int t)
{
    if(dp[h][t] != -1)
        return(dp[h][t]);
    if(h == 0 && t == 0)
        return(dp[h][t] = 1);
    if(h == 0)
        return(dp[h][t] = (1-p[h+t]) * solve(h, t-1));
    if(t == 0)
        return(dp[h][t] = p[h+t] * solve(h-1, t));
    return(dp[h][t] = p[h+t] * solve(h-1, t) + (1-p[h+t]) * solve(h, t-1));
}

int main()
{
    int n;
    double ans = 0;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> p[i];
    for(int i=0;i<=n;i++)
        if(i > (n-i))
            ans += solve(i, n-i);
    cout << setprecision(10) << ans << endl;
    return(0);
}

Measured memory_bytes: 71040
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n;
ll s[200];

bool dp[200][20000];

int main(){
    cin >> n;
    REP(i,n) {
        cin >> s[i];
    }

    dp[0][0] = true;
    REP(i,n) {
        REP(j,10001) {
            dp[i + 1][j] |= dp[i][j];
            dp[i + 1][j + s[i]] |= dp[i][j];
        }
    }

    ll ans = 0;
    REP(i,10001) {
        if(dp[n][i] && i % 10) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char s[10],t[10];
  cin>>s>>t;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(s[i]==t[i])cnt++;
  }
  cout<<cnt<<endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

int dp[222222];
int ok[26];
string str;
vector<vector<int> > v(26);

int dfs(int n){
	DBG(
	cout << "DFS " << n << endl;
	);
	if(dp[n] != INF)return dp[n];
	int ans = INF;
	REP(i,26){
		auto it = lower_bound(ALL(v[i]),n);
		DBG(cout << "IN DFS " << n << " IT IS " << *it << endl;);
		ans = min(ans,dfs((*it)+1) + 1);
	}
	return dp[n] = ans;
}

void dfs2(int n){
	if(dp[n] == 1){
		REP(i,26)ok[i] = 0;
		for(int i = n;i < str.size();i++){
			ok[str[i]-'a']++;
		}
		REP(i,26){
			if(ok[i] == 0){
				char tmp = 'a' + i;
				cout << tmp << endl;
				return;
			}
		}
	}
	
	REP(i,26){
		auto it = lower_bound(ALL(v[i]),n);
		if(dp[*it+1] + 1 == dp[n]){
			char tmp = 'a' + i;
			cout << tmp;
			dfs2(*it+1);
			return;
		}		
	}
	return;
}

int main()
{
	int tmp = 0;
	cin >> str;
	REP(i,222222)dp[i] = INF;
	dp[str.size()] = 1;
	
	REP(i,str.size()){
		v[str[i]-'a'].PB(i);
	}
	
	REP(i,str.size()){
		ok[str[str.size()-1-i]-'a']++;
		if(ok[str[str.size()-1-i]-'a'] == 1){
			tmp++;
			if(tmp == 26)break;
		}
		dp[str.size() - 1 - i] = 1;
	}
	DBG(SHOW1d(dp,str.size()););	
	dfs(0);
	DBG(SHOW1d(dp,str.size()););
	dfs2(0);
	
	return 0;
}

Measured memory_bytes: 2688