akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::vector<long long> A){
    ll cnt=1, cntBad=1;
    rep(i, N){
        if(A[i] & 1){//* A[i] odd
            cnt *= 3;
        }
        else{   //* A[i] even
            cnt *= 3;
            cntBad *=2;
        }
    }
    cout << cnt - cntBad << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> t(n + 2);
  int time = 0;
  for (int i = 1; i <= n; i++) {
    int in;
    cin >> in;
    t[i].first = time;
    time += in;
    t[i].second = time;
  }
  t[n + 1].first = time;
  t[n + 1].second = time;
  time *= 2;
  for (int i = 0; i <= n + 1; i++) {
    t[i].first *= 2;
    t[i].second *= 2;
  }
  vector<int> v(n + 2);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  vector<double> speed_limit(time + 1, 1 << 30);
  for (int j = 0; j <= n + 1; j++) {
    int start = t[j].first;
    int last = t[j].second;
    double cur = v[j];
    for (int i = start; i >= 0; i--) {
      speed_limit[i] = min(speed_limit[i], cur);
      cur += 0.5;
    }
    cur = v[j];
    for (int i = start; i <= last; i++) {
      speed_limit[i] = min(speed_limit[i], cur);
    }
    for (int i = last; i <= time; i++) {
      speed_limit[i] = min(speed_limit[i], cur);
      cur += 0.5;
    }
  }
  double ans = 0;
  for (int i = 0; i < time; i++) {
    ans += 1. * (speed_limit[i] + speed_limit[i + 1]) / 2 / 2;
  }
  cout << setprecision(20) << fixed << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	S := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		S[i] = v
	}
	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())
	T := make([]int, q)
	for i := 0; i < q; i++ {
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		T[i] = v
	}

	cnt := 0
	m := make(map[int]bool, n)
	for _, t := range T {
		for _, s := range S {
			if t == s {
				if _, ok := m[s]; !ok {
					cnt++
					m[s] = true
				}
				continue
			}
		}
	}
	fmt.Println(cnt)
}



Measured memory_bytes: 1340
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

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




const int INF = 1000000;
const int mod = 1e9 + 7;



int a, b, c, x;

int nextX() {
	return (a * x + b) % c;
}


int main(){
	int n;
	while (cin >> n >> a >> b >> c >> x && n || a || b || c || x) {
		vi v(n, 0);
		rep(i, n) cin >> v[i];
		int flame = 0, idx = 0;
		bool f = false;
		//cout << a << " " << x << " " << b << " " << c << endl;
		for (flame = 0; flame <= 10000; flame++) {
			//cout << x << endl;
			if (x == v[idx]) idx++;
			if (idx == n) {
				f = true;
				break;
			}
			x = nextX();
		}
		cout << (f ? flame : -1) << endl;
	}
}

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

using namespace std;

//0-1 Knapsack: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B
void printDP(const int n, const int c, vector<vector<int> >& dp){
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= c; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

int solve_a(const int n, const int c, const vector<int>& v, const vector<int>& w) {
    
    vector<vector<int>> dp(n + 1, vector<int>(c + 1, 0));
    
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= c; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    }
    //printDP(n, c, dp);
    return dp[n][c];
}

int solve_b(const int n, const int c, const vector<int>& v, const vector<int>& w) {
    
    vector<vector<int>> dp(n + 1, vector<int>(c + 1, 0));
    
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j <= c; j++) {
            dp[i][j] = dp[i + 1][j];
            if (j >= w[i]) {
                dp[i][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }
    //printDP(n, c, dp);
    return dp[0][c];
}

int solve_c_rec(int i, int j, vector<vector<int>>& dp,
        const vector<int>& v, const vector<int>& w) {
    if (i == 0 || j == 0) {
        return 0;
    }
    if (dp[i][j] != -1) {
        return dp[i][j];
    }
    int result = solve_c_rec(i - 1, j, dp, v, w);
    if (j >= w[i - 1]) {
        result = max(result, solve_c_rec(i - 1, j - w[i - 1], dp, v, w) + v[i - 1]);
    }
    dp[i][j] = result;
    return result;   
}

int solve_c(const int n, const int c, const vector<int>& v, const vector<int>& w) {
    vector<vector<int>> dp(n + 1, vector<int>(c + 1, -1));
    return solve_c_rec(n, c, dp, v, w);
}

int main() {
    int n, c;
    cin >> n >> c;
    vector<int> v(n, 0);
    vector<int> w(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i] >> w[i];
    }
    int ans = solve_c(n, c, v, w);
    cout << ans << endl;
}

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;

int madd(int x,int y) {
	if (x+y<MD) return x+y; else return x+y-MD;
}
int mmul(int x,int y) {
	return int(ll(x)*y % MD);
}

int const MAXN=4400;
int C[MAXN][MAXN];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	C[0][0]=1;
	rep(i,1,MAXN) rep(j,0,i+1) {
		C[i][j]=C[i-1][j];
		if (j>0) C[i][j]=madd(C[i][j],C[i-1][j-1]);
	}
	
	int N,K;
	cin>>N>>K;
	rep(i,1,K+1) cout<<mmul(C[K-1][i-1],C[N-K+1][i])<<"\n";
}


Measured memory_bytes: 74368
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,f;
  string s;
  cin>>n>>s;
  f=n;
  for(int i=0;i<n-1;i++){
    //char w=s.at(i);
    if(s.at(i)==s.at(i+1))f--;
  }
  cout<<f<<endl;
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int cell[100000] = {0};
    int N, input;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> input;
        cell[i] = input;
    }

    int curr = 0, _max = 0;
    for (int i = 0; i < N - 1; i++) {
        // cout << "i, i+1 => " << cell[i] << " " << cell[i + 1] << endl;
        if (cell[i] >= cell[i + 1]) {
            curr++;
        } else {
            curr = 0;
        }

        // cout << "max, curr => " << _max << " " << curr << endl;

        if (curr > _max) {
            _max = curr;
        }
    }
    cout << _max << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
char str[maxn];
int main(){
    while (~scanf("%s",str)){
        int n=strlen(str);
        int ans=n;
        for (int i=1;i<n;i++)
            if (str[i]!=str[i-1]) ans=min(ans,max(i,n-i));
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();
	int result = B;
	if(C<= A+B) {
	    result = result+C;
	}else {
	    result = result + (A+B) + 1;
	}
	System.out.println(result);

    }
}

Measured memory_bytes: 24660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<string> w(n), used;
  bool tf = true;
  for (int i = 0; i < n; i++) cin >> w[i];
  used.push_back(w[0]);
  for (int i = 1; i < n and tf; i++) {
    if (w[i][0]!=w[i-1][w[i-1].size()-1]) tf = false;
    auto itr = find(used.begin(), used.end(), w[i]);
    if (itr != used.end()) tf = false;
    used.push_back(w[i]);
  }
  if (tf) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
N = 100
print(N, N)

v = [['.' for j in range(N)] for i in range(N)]

for i in range(N // 2, N):
    for j in range(N):
        v[i][j] = '#'

for a in range(A - 1):
    i = (a // (N // 2)) * 2 + (N // 2) + 1
    j = (a % (N // 2)) * 2
    v[i][j] = '.'

for b in range(B - 1):
    i = (b // (N // 2)) * 2
    j = (b % (N // 2)) * 2
    v[i][j] = '#'

for i in range(N):
    line = ""
    for j in range(N):
        line += v[i][j]
    print(line)


Measured memory_bytes: 3188
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std;

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

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


class AStudyScheduling {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        int64_t a,b,c,d,e;cin >> a >>b>>c>>d>>e;
        if(c < a) c += 24;
        if(d >= b){
            cout << 60 * (c - a) + (d - b) - e << '\n';
        }else{
            d += 60;
            c--;
            cout << 60 * (c - a) + (d -b) - e << '\n';
        }
	}
	void main2(istream& cin,ostream& cout){

	}
};


int main() {
	AStudyScheduling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll mod=1000000007;

class mll {
public:
	ll val;
    mll(int v){val=(v + mod) % mod;}
    mll operator + (mll m) { return mll((val + m.val + mod) % mod); } 
    mll operator - (mll m) { return mll((val - m.val + mod) % mod); }
    mll operator * (mll m) { return mll((val * m.val + mod) % mod); }
    mll operator / (mll m) { return mll((val * modinv(m.val, mod)) % mod); }
    void operator = (mll m) { val = m.val; }
    explicit operator ll() { return val; }

private:
    ll modinv(ll a, ll m){
        ll b=m,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b; swap(a,b);
            u-=t*v; swap(u,v);
        }
        u%=m;
        if(u<0){ u+=m; }
        return u;
    }
};

int main(){
    ll L=ii();
    ll R=ii();
    ll d=ii();
    ll ret=0;
    REP(i,L,R+1){
       if(i%d==0){
           ret++;
       } 
    }
    oie(ret);

    return 0;
}

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define      TEST    int t ; cin >> t ; while( t -- )

const ll big = 10e7 + 11 ;

int  main (  ) {

    FASTIO ;

    ll ans = 0 ;

    int n ;
    cin >> n ;

    for( int i = 1 ; i <= n ; i++ ){
        for( int j = 1 ; j <= n ; j++ ){
            for( int k = 1 ; k <= n ; k++ ){
                ans += __gcd(  i , __gcd( j , k ) ) ;
            }
        }
    }

    cout << ans ;


    return  0 ;
}


Measured memory_bytes: 3628
N=int(input())
L=[]
for i in range(N):
    n=int(input())
    L.append(n)

dp=[0 for i in range(N)]
dp[0]=1
mod=10**9+7
D=dict()
D[L[0]]=1
for i in range(1,N):
    if L[i]==L[i-1]:
        dp[i]=dp[i-1]
    elif L[i] not in D:
        D[L[i]]=dp[i-1]
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+D[L[i]]
        dp[i]%=mod
        D[L[i]]=dp[i]
    #print(dp)
print(dp[-1]%mod)
#print(D)

Measured memory_bytes: 85668
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll d[110];
    cin >> N;
    rep(i,0,N) cin >> d[i];
    sort(d,d+N);
    ll ans = 1;
    rep(i,0,N-1){
        if(d[i] != d[i+1]) ans++;
    }
    print(ans);

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> vec(26,0);

    for(int i=0; i<N; i++){
        vec[S[i]-'a']++;
    }
    long long ans = 1;
    for(int i=0; i<26; i++){
        ans*=(1+vec[i]);
        ans%=1000000007;
    }
    ans--;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <math.h>
#include <map>
using namespace std;

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

    long long sum=0;
    for(int i=1; i<=N; i++) {
        if(i%3!=0 && i%5!=0) {
            sum+=i;
        }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans;
string s;
map<string,ll> mp1,mp2;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        mp1[s]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>s;
        mp2[s]++;
    }
    for(auto x:mp1){
        ans=max(ans,x.second-mp2[x.first]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#pragma warning(disable : 4996)
using namespace std;
typedef long long ll;
ll N, M;
ll GCD(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	else {
		return GCD(b, a%b);
	}
}
int main() {
	while (scanf("%d%d",&N,&M)!=EOF)
	{
		int ans =GCD(N, M);
		cout << ans << " " << N * M / ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=200005;
const ll inf=1e9+7;
map<string,int> m;
int main()
{
    string s;
    m["SUN"]=7;
    m["SAT"]=1;
    m["FRI"]=2;
    m["THU"]=3;
    m["WED"]=4;
    m["TUE"]=5;
    m["MON"]=6;
    while(cin>>s)
    {
        cout<<m[s]<<"\n";
    }
}


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

int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    int mx = -1;
    rep(i,n){
        cin >>a[i];
        mx = max(a[i],mx);
    }
    int mn = 9999999;
    for(int i = 0;i <= mx;i++){
        int sum = 0;
        for(int j = 0; j<n;j++){
           int tmp = pow(a[j]-i, 2); 
           sum += tmp;
        }
        //cout<<sum<<endl;
        mn = min(sum,mn);
    }
    cout <<mn<<endl;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func pa() int {
	var s,t string
	_,_=fmt.Scanf("%s\n%s\n", &s,&t)
	ans:=0
	for i,_:=range s{
		if s[i]!=t[i]{
			ans++
		}
	}
	return ans

}

func main() {
	fmt.Printf("%d\n",pa())

}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

vector<i64> A;

vector<i64> cnt;

void dfs(int v, i64 k, bool loop) {
  if(!loop) {
    int t = A[v];
    if(cnt[t] == -1) {
      cnt[t] = cnt[v] + 1;
    }
    else {
      i64 step = cnt[v] - cnt[t] + 1;
      k %= step;
      loop = true;
    }
  }
  if(k == 0) {
    cout << v + 1 << endl;
    return;
  }
  dfs(A[v], k - 1, loop);
}
int main() {
  i64 N, K;
  cin >> N >> K;
  A.resize(N);
  cnt.resize(N, -1);
  rep(i,0,N) {
    cin >> A[i];
    A[i]--;
  }
  cnt[0] = 0;
  dfs(0, K, false);
}


Measured memory_bytes: 6400
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans;
    if (n == 1) ans = abs(a[0] - w);
    else ans = max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1]));
    cout << ans << endl;

}


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

// 線形探索をする関数
bool search(int A[], int n, int key) {
    A[n] = key;
    int i = 0;
    while (A[i] != key) {
        ++i;
    }
    if (i == n) {
        return false;
    }
    return true;
}

int main() {
    int n, S[10100], q, T[600];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }

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

    int sum = 0;
    for (int i = 0; i < q; ++i) {
        int key = T[i];

        if (search(S, n, key)) {
            ++sum;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, A, B; cin >> N >> A >> B;
  cout << (N / (A+B))*A + min(N % (A+B), A) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  
  int k[4]={0,0,0,0};
  rep(i, 6){
    int p;
    cin>>p;
    if(p==1){
      k[0]++;}
    if(p==2){
      k[1]++;}
    if(p==3){
      k[2]++;}
    if(p==4){
      k[3]++;}
  }
  
  int p2=0;
  rep(i, 4){
  if(k[i]>=3||k[i]<=0){
    cout<<"NO"<<endl;
    return 0;}
    if(k[i]==2){
      p2++;}
  }
  
  if(p2==2){
    cout<<"YES"<<endl;}
  else{
    cout<<"NO"<<endl;}
  
  
 return 0;
}


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

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<vector<int>> mt(n,vector<int>(n));
        priority_queue<int> ans;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                cin>>mt[i][j];
            }
        }
        for (int i = 0; i < n; ++i) {
            pair<int,int> vi(INT16_MAX,-1);
            for (int j = 0; j < n; ++j) {
                if(mt[i][j]<=vi.first){
                    vi=make_pair(mt[i][j],j);
                }
            }
            for (int j = 0; j < n; ++j) {
                if(mt[j][vi.second]>vi.first)break;
                if(j==n-1)ans.push(vi.first);
            }
        }
        if(ans.empty())cout<<0<<endl;
        else cout<<ans.top()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3024
int main(){
    int H,W,a,b;
    while (1==1){
        scanf("%d%d", &H, &W);
        if (H ==0 && W == 0){
            break;
        }
        for (b=0;b<W;b++){
            printf("#");
        }
        printf("\n");
        for(a=1;a<H-1;a++){
            for (b=0;b<W;b++){
                if ((b==0)|| (b==W-1)){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        for (b=0;b<W;b++){
            printf("#");
        }
        printf("\n\n");
    }
    return 0;
}

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

vector<int> g[1010];
int h[1010];

int main() {
	int v, e;
	cin >> v >> e;
	for(int i = 0; i < e; i++){
		int s, t;
		cin >> s >> t;
		g[s].push_back(t);
		h[t]++;
	}
	
	stack<int> st;
	for(int i = 0; i < v; i++){
		if(h[i] == 0){
			st.push(i);
		}
	}
	
	vector<int> ans;
	while(st.size()){
		int i = st.top();
		st.pop();
		ans.push_back(i);
		
	    for(vector<int>::iterator it = g[i].begin(); it != g[i].end(); ++it){
			h[*it]--;
			if(h[*it] == 0){
				st.push(*it);
		    }
	    }
	}
	
	if(ans.size() == v){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
#include <queue>
#include <iostream>
const int maxn=1e5+10;
const int mod=1e9+7;
using namespace std;
int a[100]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int n;
    cin>>n;
    printf("%d\n",a[n-1]);
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))
def fde(): print("-flag-")

def divisors(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n//i)

    return res


def main():
    N=ii()
    A=list(mi())
    R = divisors(A[0]) + divisors(A[1])

    ans = 0
    for r in R:
        miss_count = 0
        for a in A:
            if a % r != 0:
                miss_count += 1
                if miss_count == 2:
                    break
        
        if miss_count <= 1:
            ans = max(ans,r)
            

    print(ans)








if __name__ == "__main__":
    main()

Measured memory_bytes: 20580
import java.util.Scanner;

public class Main {
    public static int gcd(int p,int q){
        if(q == 0)
            return p;
        int r = p % q;
        return gcd(q,r);
    }

    public static void main(String[] args) {
        int a,b;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        int c = gcd(a,b);
        System.out.println(c);
    }
}


Measured memory_bytes: 26284
a, b, k = gets.chomp.split(' ').map(&:to_i)

(0...k).each{|i|
  if i%2==0 then
    if a%2==1 then
      a-=1
    end
    b += a/2
    a = a/2
  else
    if b%2==1 then
      b-=1
    end
    a += b/2
    b = b/2
  end
}

puts "#{a} #{b}"

Measured memory_bytes: 1788
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    n,k=map(int,input().split())
    mod=10**9+7
    for i in range(1,k+1):
        print(mod_comb4(n-k+1,i)*mod_comb4(k-1,i-1)%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 3940
#include<cstdio>
#include<algorithm>
#include<string>
#include<iostream>


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

using namespace std;




int main(){
	
	string s;
	
	int q[111];
	int qn;
	int i;
	bool f;
	
	fill(q,q+110,0);qn=0;
	f=true;
	
	
	while(true){
		//scanf("%s",s);
		
		getline(cin,s);
		
		if(s[0]=='.'&&s[1]==0)break;
		
		

		
		for(i=0;s[i]!=0;i++){
			if(f && s[i]=='('){
				q[qn++]=1;
			}
			if(f && s[i]=='['){
				q[qn++]=2;
			}
			if(f && s[i]==')'){
				if(qn==0){f=false;}
				if(q[--qn]!=1){f=false;}
			}
			if(f && s[i]==']'){
				if(qn==0){f=false;}
				if(q[--qn]!=2){f=false;}
			}
			if(s[i]=='.'){
				if(f && qn==0)puts("yes");
				else puts("no");
				
				fill(q,q+110,0);qn=0;
				f=true;
				
				break;
			}
		}
		
	
	}
	
	
}

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

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int diff = 0;
  
  for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i]) diff++;
  }
  
  cout << diff;
  return 0;
}

Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <bits/stdc++.h>


using namespace std;
using ll = long long ;

const int INF = 1001001001;
using Graph = vector<vector<int>>;

int main() {

    int n,m ; 
    cin >> n  >> m  ;

    Graph G(n) ;
    for(int i=0;i<m;i++){
        int a,b ;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
/*
input
a b
0 1
1 2
2 3
3 1

G[0] = {1}
G[1] = {0,2,3}
G[2] = {1,3}
G[3] = {2,1}

*/

vector<int> dist(n,-1);
vector<int> pre(n,-1);
//dist[v] はスタート頂点から頂点 v まで何ステップで到達できるかを表す
//pre[v] 前の部屋
queue<int> que;

dist[0] = 0 ;
pre[0] = 0 ;
que.push(0) ;

while (!que.empty())
{
    int v = que.front();
    que.pop();

    for(int u : G[v]){
        if(dist[u]!=-1) continue;
        dist[u] = dist[v] + 1 ;
        pre[u] = v ;
        que.push(u);
    }
}

  cout << "Yes" << endl ;
  for(int i=0;i<n;i++){
     //cout << dist[i] << endl ;
     if(i==0) continue;
     cout << ++pre[i] << endl ;
  }

    return 0 ;
}

Measured memory_bytes: 10712
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        long a = stdIn.nextLong();
        long b = stdIn.nextLong();
        long c = stdIn.nextInt();
        long d = stdIn.nextInt();
        
        long x = b / c - (a-1) / c;
        long y = b / d - (a-1) / d;

        long n = lcm(c,d);
        
        long w = b / n - (a-1) / n;

        System.out.println(b-a+1-(x+y-w));
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

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

int main(){
    int k,x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = il()
    X = sum(D) // N
    ret = MAX
    for x in range(X - 3, X + 3):
        tmp = 0
        for d in D:
            tmp += (d - x) ** 2
        ret = min(ret, tmp)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10228
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int max = 0;
    int maxn = 0;
    for(int i = 0; i < n; i++){
        if(max < a[i]) {
            max = a[i];
            maxn = i;
        }
    }
    double s = max/2.0;
    double d = s;
    int j;
    for(int i = 0; i < n; i++){
        if(i == maxn) continue;
        double f = fabs(s - a[i]);
        if(f <= d) {
             d = f;
             j = i;
        }
    }
    cout << max << " " << a[j] << endl;

    return 0;
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    lli h, w, x, y, z, mini, maxm, ans=INF ;
    cin>> h >> w ;
    for(lli i=1 ; i<=h/2 ; i++)
      {
        x=h-i ;
        y=w/2 ;
        z=w-(w/2) ;
        mini=INF ;
        maxm=-INF ;
        mini=min(mini, z*x) ; maxm=max(maxm, z*x) ;
        mini=min(mini, y*x) ; maxm=max(maxm, y*x) ;
        mini=min(mini, i*w) ; maxm=max(maxm, i*w) ;
        ans=min(ans, abs(mini-maxm)) ;
        mini=INF ;
        maxm=-INF ;
        x=h-i ;
        y=x/2 ;
        z=x-(x/2) ;
        mini=min(mini, z*w) ; maxm=max(maxm, z*w) ;
        mini=min(mini, i*w) ; maxm=max(maxm, i*w) ;
        mini=min(mini, y*w) ; maxm=max(maxm, y*w) ;
        ans=min(ans, abs(mini-maxm)) ;
      }
    for(lli i=1 ; i<=w/2 ; i++)
      {
        x=w-i ;
        y=h/2 ;
        z=h-(h/2) ;
        mini=INF ;
        maxm=-INF ;
        mini=min(mini, z*x) ; maxm=max(maxm, z*x) ;
        mini=min(mini, y*x) ; maxm=max(maxm, y*x) ;
        mini=min(mini, i*h) ; maxm=max(maxm, i*h) ;
        ans=min(ans, abs(mini-maxm)) ;
        mini=INF ;
        maxm=-INF ;
        x=w-i ;
        y=x/2 ;
        z=x-(x/2) ;
        mini=min(mini, z*h) ; maxm=max(maxm, z*h) ;
        mini=min(mini, i*h) ; maxm=max(maxm, i*h) ;
        mini=min(mini, y*h) ; maxm=max(maxm, y*h) ;
        ans=min(ans, abs(mini-maxm)) ;
      }
    cout<< ans ;
  }


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

int main() {
    int N, K, d, A;
    cin >> N >> K;
    vector<bool> hasSnack(N);
    rep(i, K) {
        cin >> d;
        rep(j, d) {
            cin >> A;
            hasSnack[A-1] = true;
        }
    }
    int ans = 0;
    rep(i, N) {
        if (!hasSnack[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
## ダイクストラ法
#O(ElogV)
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

################################
# n,w = map(int,input().split()) #n:頂点数　w:辺の数
#
# edge = [[] for i in range(n)]
# #edge[i] : iから出る道の[重み,行先]の配列
# for i in range(w):
#     x,y,z = map(int,input().split())
#     edge[x].append([z,y])
#     edge[y].append([z,x])
# print(dijkstra_heap(0))
##

n = int(input())

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(n-1):
    x,y,z = map(int,input().split())
    x-=1
    y-=1
    edge[x].append([z,y])
    edge[y].append([z,x])

Q,K = map(int,input().split())

d = dijkstra_heap(K-1)
for q in range(Q):
    x,y = map(int,input().split())
    x-=1
    y-=1
    print(d[x]+d[y])


# input
# 7 10
# 0 1 2
# 0 2 5
# 1 2 4
# 2 3 2
# 1 3 6
# 1 4 10
# 3 5 1
# 4 5 3
# 4 6 5
# 5 6 9
# output
# [0, 2, 5, 7, 11, 8, 16]

######################################################################

Measured memory_bytes: 55932
Scanf.scanf "%d %d %d %d" (fun a b c d ->
  let rec f a c =
    let c = c - b in
    if c <= 0 then "Yes"
    else g a c
  and g a c =
    let a = a - d in
    if a <= 0 then "No"
    else f a c
  in print_endline (f a c)
)


Measured memory_bytes: 3720
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto nq = readints();
    int n = nq[0], q = nq[1];

    auto segTree = new SegmentTree(n);
    for (int i = 0; i < q; i++) {
        auto xs = readints();
        int x = xs[1], y = xs[2];
        switch (xs[0]) {
        case 0: // change a[i] to x
            segTree.update(x, y);
            break;
        case 1: // find minimum
            int val = segTree.query(x, y + 1);
            writeln(val);
            break;
        default:
            break;
        }
    }
}

class SegmentTree {
    private int[] _data;

    this(int n) {
        int len = 1;
        while (len < n)
            len *= 2;

        _data = new int[len * 2];
        _data[] = int.max;
    }

    /// k ?????????????´????(0-indexed)??? a ????????´
    void update(int k, int a) {
        // ????????\???
        k += (_data.length / 2) - 1;
        _data[k] = a;
        // ?????????????????´??°
        while (k > 0) {
            k = (k - 1) / 2;
            _data[k] = min(_data[k * 2 + 1], _data[k * 2 + 2]);
        }
    }

    /// [a, b) ???????°????????±???????
    int query(int a, int b, int k, int l, int r) {
        // [a, b) ??¨ [l, r) ??????????????????
        if (r <= a || b <= l)
            return int.max;

        // [a, b) ??? [l, r) ????????¨???????????§????????°???????????\?????????
        if (a <= l && r <= b) {
            return _data[k];
        }
        else {
            // ????????§???????????°???2 ????????????????°????
            int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }

    int query(int a, int b) {
        return query(a, b, 0, 0, cast(int)(_data.length / 2));
    }
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,M;
int a[100005];

int dp[100005];

signed main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int f;
        cin>>f;
        a[f]=1;
    }
    dp[0]=1;
    if(a[1]==1)dp[1]=0;
    else dp[1]=1;
    for(int i=2;i<=N;++i){
        if(a[i]==1)dp[i]=0;
        else dp[i]=dp[i-1]+dp[i-2];
        dp[i]%=mod;
    }
    cout<<dp[N]<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
vector<ll>to[200005];
ll c[15];
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<ll>>a(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		a[i].resize(m);
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	ll ans = inf;
	ll sum;
	for (int bit = 0; bit < (1 << n); bit++) {
		vector<ll>t(m, 0);
		sum = 0;
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				for (int k = 0; k < m; k++) {
					t[k] += a[i][k];
				}
				sum += c[i];
			}
		}
		for (int j = 0; j < m; j++) {
			if (t[j] < x) {
				ok = false;
			}
		}
		if (ok) {
			ans = min(ans, sum);
		}
	}
	if (ans != inf) {
		cout << ans << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 8328
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] g = new int[n][];
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt()-1;
            int k = sc.nextInt();
            g[v] = new int[k];
            for (int j = 0; j < k; j++) {
                g[v][j] = sc.nextInt()-1;
            }
        }
        int[] a = new int[n];
        Arrays.fill(a, -1);
        a[0] = 0;
        ArrayDeque<Integer> q = new ArrayDeque<>();
        for(int b : g[0]) q.add(b);
        for (int i = 1; i < n; i++) {
            ArrayDeque<Integer> nexq = new ArrayDeque<>();
            while(!q.isEmpty()){
                int nex = q.poll();
                if(0 <= a[nex])continue;
                a[nex] = i;
                for(int c : g[nex]) nexq.add(c);
            }
            q.addAll(nexq);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int v = i+1;
            sb.append(v + " " + a[i] + "\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

}



Measured memory_bytes: 27704
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    double x1, y1, x2, y2, ans;
    cin >> x1 >> y1 >> x2 >> y2;
    ans = sqrt((x1 - x2) * (x1 -x2) + (y1 - y2) *(y1 - y2));
    printf("%0.8f", ans);
    return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<cstring>
#include<fstream>
#include<algorithm>

using namespace std;
typedef long long ll;
const ll mx=100+10;

int main(){

    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll res=a*c;
    res=max(res, a*d);
    res=max(res, b*c);
    res=max(res, b*d);
    cout<<res<<endl;

    return 0;
}


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

#define int long long

const int N = 1e5 + 10;
int n, ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	sort(ar, ar + n);
	
	if (ar[n / 2] == ar[n / 2 - 1])
		return cout << 0 << endl, 0;
	cout << ar[n / 2] - ar[n / 2 - 1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;


ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 ll n;cin>>n;
 int f=0;
 for(int i=0;i<=n;i++){
     double x=1.08;
     x*=i;
     ll d=floor(x);
     if(d==n){
         f=1;
         cout<<i;
         break;
     }
 }
 if(!f) cout<<" :( ";
      
}



  

Measured memory_bytes: 3736
S = input()

front = S[:2]
back =  S[2:]


# 諸々の判定
if front == '00':
  out_front = 'NA'
elif int(front) >= 13:
  out_front = 'YY'
else:
  out_front = 'AMBIGUOUS'
  
if back == '00':
  out_back = 'NA'
elif int(back) >= 13:
  out_back = 'YY'
else:
  out_back = 'AMBIGUOUS'
  

## 出力結果
if out_front == 'NA' and out_back == 'AMBIGUOUS':
  out = 'YYMM'
elif out_front == 'NA' and out_back == 'YY':
  out = 'NA'  
elif out_front == 'AMBIGUOUS' and out_back == 'NA':
  out = 'MMYY'
elif out_front == 'YY' and out_back == 'NA':
  out = 'NA'
elif out_front == 'NA' and out_back == 'NA':
  out = 'NA'
elif out_front == 'YY' and out_back == 'YY':
  out = 'NA'
elif out_front == 'YY' and out_back == 'AMBIGUOUS':
  out =  'YYMM'
elif out_front == 'AMBIGUOUS' and out_back == 'YY':
  out =  'MMYY'
elif out_front == 'AMBIGUOUS' and out_back == 'AMBIGUOUS':
  out =  'AMBIGUOUS'
else:
  out = 'hoge'
  
print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;



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

  int r, d;
  ll x;
  cin >> r >> d >> x;

  forn(i, 0, 10){
	  x = 1ll*x*r - d;
	  cout << x << endl;
  }


}




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

using namespace std;

class disjoint_set {
public:
    int n;
    vector<int> p;
    vector<int> size;
    int n_comp;
    explicit disjoint_set(int n) :
        n(n),
        p(n),
        size(n, 1),
        n_comp(n) {
        iota(p.begin(), p.end(), 0);
    }
    int parent(int x) {
        if (p[x] != x) {
            p[x] = parent(p[x]);
        }
        return p[x];
    }
    void merge(int a, int b) {
        const int pa = parent(a);
        const int pb = parent(b);
        if (pa == pb)
            return;
        if (size[pa] > size[pb]) {
            merge(b, a);
            return;
        }
        size[pb] += size[pa];
        p[pa] = pb;
        --n_comp;
    }
};
int main() {
    long long n, m, q;
    cin >> n >> m >> q;
    disjoint_set dj(n);
    vector<pair<int, int>> g;
    while (q--) {
        int a, b, c;
        cin >> a >> b >> c;
        if (c == 0) {
            dj.merge(a, b);
        } else {
            g.emplace_back(a, b);
        }
    }
    bool fail = false;
    for (auto p: g) {
        if (dj.parent(p.first) == dj.parent(p.second)) {
            fail = true;
            break;
        }
    }
    if (fail) {
        cout << "No\n";
        return 0;
    }
    if (!g.empty() && m == n - 1) {
        cout << "No\n";
        return 0;
    }
    long long n_comp = dj.n_comp;
    long long max_edges = n_comp * (n_comp - 1) / 2;
    for (int i = 0; i < n; ++i) {
        if (dj.p[i] == i)
            max_edges += dj.size[i] - 1;
    }
    if (max_edges >= m)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 2168
n, m = map(int, input().split())
sc = [input().split() for _ in range(m)]

for x in range(10 ** n):
    if len(str(x)) != n:
        continue
    for s, c in sc:
        if str(x)[int(s) - 1] != c:
            break
    else:
        print(x)
        exit()
print(-1)

Measured memory_bytes: 9184
#include <cstdio>
#include <cstring>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

typedef long long ll;
const int MOD = 1000000000 + 7;

int main(void) {
  int n;
  cin >> n;
  ll res = 1;
  REP(i, n) {
    res = (res * (i+1))%MOD;
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
/***/





#include<bits/stdc++.h>

using namespace std;

#define fstinpt     ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll          long long
#define bn          1000090
#define sn          1010
#define mod         100000007
#define iii(i)      cin>>i
#define ooo(i)      cout<<i
#define sss         cout<<" "
#define nnn         cout<<"\n"/**
#define iii(i)      iii>>i
#define ooo(i)      ooo<<i
#define sss         ooo<<" "
#define nnn         ooo<<"\n"*/
#define ff          first
#define ss          second
#define psb         push_back

/**
        ifstream iii;iii.open("D:\\prgrms\\codechef cntst 1\\input.txt");
        ofstream ooo;ooo.open("D:\\prgrms\\codechef cntst 1\\my output.txt");
         nnn; ooo("sp = "<<sp); nnn;
*/

int main()
{
	char c;
	iii(c);
	if(c <= 'Z') ooo('A');
	else ooo('a');
        return 0;
}




/**




*/















/***/


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,m;
pair<int,int>p[maxn];
int fa[maxn];
ll siz[maxn];
ll ans[maxn],cnt;
int fi(int x){
    if(x==fa[x])return x;
    return fa[x]=fi(fa[x]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)fa[i]=i,siz[i]=1;
    for(int i=1;i<=m;i++)scanf("%d%d",&p[i].first,&p[i].second);
    ans[++cnt]=1ll*n*(n-1)/2;
    for(int i=m;i>1;i--){
        int f1=fi(p[i].first),f2=fi(p[i].second);
        if(f1==f2)cnt++,ans[cnt]=ans[cnt-1];
        else{
            cnt++;
            ans[cnt]=ans[cnt-1]-(siz[f1]*siz[f2]);
            fa[f1]=f2;siz[f2]+=siz[f1];
        }
    }
    for(int i=cnt;i>=1;i--)printf("%lld\n",ans[i]);
}


Measured memory_bytes: 4096