akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using namespace std;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> lazyflag;
    const ll inf;
public:
    LazySegmentTree(vector<ll> v) : inf((1LL<<31)-1) {
        int sz = (int)v.size();
        n = 1;
        while (n < sz) n *= 2;

        node.resize(2*n-1);
        lazy.resize(2*n-1, inf);
        lazyflag.resize(2*n-1, false);

        for (int i=0; i<sz; ++i) node[i+n-1] = v[i];
        for (int i=n-2; i>=0; --i) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    // 伝搬させるため
    void eval(int k, int l, int r) {
        if (lazyflag[k]) {
            node[k] = lazy[k];

            // 範囲が半分になるから，値も半分になる
            if (r - l > 1) {
                lazy[2*k+1] = lazy[2*k+2] = lazy[k];
                lazyflag[2*k+1] = lazyflag[2*k+2] = true;
            }

            lazyflag[k] = false;
        }
    }

    // [a, b)
    void query(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;

        // k番目のノードで遅延評価
        eval(k, l, r);

        // 範囲外なら何もしない
        if (r <= a or b <= l) return;

        // 完全に被覆していたら評価
        if (a <= l and r <= b) {
            lazy[k] = x;
            lazyflag[k] = true;
            eval(k, l, r);
        }
        else {
            // そうじゃないなら，被覆するまで下がる
            query(a, b, x, 2*k+1, l, (l+r)/2);
            query(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }

    ll getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;
        if (r <= a or b <= l) return inf;

        eval(k, l, r);
        if (a <= l and r <= b) return node[k];
        ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> v(n, (1LL<<31)-1);

    LazySegmentTree lst(v);
    rep(i, q) {
        int c;
        cin >> c;
        if (c == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            lst.query(s, t+1, x);
        }
        else {
            ll s, t;
            cin >> s >> t;
            cout << lst.getmin(s, t+1) << endl;
        }
    }
}



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

int main()
{
    int N;
    cin >> N;
    double sum = 0;
    for(int i = 0; i < N; i++)
    {
        double x;
        string u;
        cin >> x >> u;

        if(u == "JPY")
        {
            sum += x;
        }
        else if(u == "BTC")
        {
            sum += x * 380000;
        }
    }
    cout << sum << endl;
    return 0;
}

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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    /*
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    */

    vi count(26);
    string s;
    while(getline(cin, s))
    {
        REP(i, s.length())
        {
            if('a' <= s[i] && s[i] <= 'z') count[s[i]-'a']++;
            else if('A' <= s[i] && s[i] <= 'Z') count[s[i]-'A']++;
        }
    }
    REP(i, 26)
    {
        cout << (char)('a'+i) << " : " << count[i] << endl;
    }
}


Measured memory_bytes: 3168
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val s = (1..m).map { readLine()!!.split(' ').drop(1).map(String::toInt) }
    val p = readLine()!!.split(' ').map(String::toInt)
    var cnt = 0
    (0 until Math.pow(2.0, n.toDouble()).toInt()).forEach {
        val onSw = Integer.toString(it, 2).padStart(n, '0').toCharArray()
            .mapIndexed { i, c -> (i + 1) to c }
            .filter { it.second == '1' }
            .map(Pair<Int, Char>::first)
        val t = (0 until m).all { s[it].filter { onSw.contains(it) }.count() % 2 == p[it] }
        if (t) cnt++
    }
    println(cnt)
}


Measured memory_bytes: 42772
#include <stdio.h>

int main(void)
{
	int a, x1, x2;
	
	scanf("%d" "%d", &x1, &x2);
	
	if(x1 > x2){
		a = x1 - x2;
	}
	else{
		a = x2 -x1;
	}
	
	printf("%d\n", a);
	
	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

bool is_even(int n)
{
  return n % 2 == 0;
}

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int count = 0;
  while (is_even(A) and is_even(B) and is_even(C)) {
    int A2 = B/2 + C/2;
    int B2 = A/2 + C/2;
    int C2 = A/2 + B/2;
    if (A == A2 and B == B2 and C == C2) {
      count = -1;
      break;
    }
    swap(A, A2);
    swap(B, B2);
    swap(C, C2);
    ++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){

	int N;
	string s,ans;
	string hoshino="Hoshino";
	string hoshina="Hoshina";

	cin>>N;getline(cin,s);
	for(int i=0;i<N;i++)
	{
		getline(cin,s);
	//	cout<<s;
		ans=s;
		while(1){
		int x=s.find("Hoshino",0);
		if(x==string::npos )break;
		for(int i=x;i<x+7;i++)
		{
			ans[i]=hoshina[i-x];
			s[i]='-';
		}
		
		}
cout<<ans<<endl;
	}
	return 0;
}
			

Measured memory_bytes: 1220
#include <iostream>

using namespace std;

int main() {
	int cnt = 0;

	int A,B,C;
	cin >> A;
	cin >> B;
	cin >> C;

	if (A == B) cnt++;
	if (A == C) cnt++;
	if (B == C) cnt++;

	if (cnt == 1) cout << "Yes";
	else cout << "No";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  vector <long long> A(N);
  vector <long long> B(N);
  vector <long long> C(N);
  for (int i=0;i<N;i++) cin>>A[i];
  for (int i=0;i<N;i++) cin>>B[i];
  for (int i=0;i<N;i++) cin>>C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  
  long long ans=0;
  long long an,cn;
  for (int i=0;i<N;i++){
    an=lower_bound(ALL(A),B[i])-A.begin();
    cn=C.end()-upper_bound(ALL(C),B[i]);
    //cout<<i<<" "<<B[i]<<" "<<" an "<<an<<" cn "<<cn<<endl;
    ans=ans+an*cn;
  }
  cout<<setprecision(20)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
const int N=1e6;
ll v[N+10];

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


    cin>>a>>b>>c>>d;

    ll ara[5];

    ara[0]=a*c;
    ara[1]=a*d;
    ara[2]=b*c;
    ara[3]=b*d;

    sort(ara,ara+4);

    cout<<ara[3]<<endl;





}


Measured memory_bytes: 3640
from bisect import bisect_left
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
SA = [0] * (N + 1)
SB = [0] * (M + 1)
for i in range(N):
    SA[i+1] = SA[i] + A[i]
for i in range(M):
    SB[i+1] = SB[i] + B[i]
result = 0
for x in range(N+1):
    if SA[x] > K:
        break
    y = bisect_left(SB, K - SA[x] + 1) - 1
    result = max(result, x + y)
print(result)

Measured memory_bytes: 47460
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    if(a < 10 && b < 10) {
	  System.out.println(a*b);
    } else {
      System.out.println(-1);
    }
  }
}

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

using namespace std;

#define mp make_pair
#define PI acos(-1)
#define TASK "hz"                     
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> pii; 
typedef vector <pii> vpii;
typedef vector <ll> vll;
typedef vector <string> vs;

string s;
vi p;

void solve() {
	int ans = sz(s);
	int cnt = 0;
	for(int i = 0; i < sz(s); i++) {    
		if(s[i] == 'T' && cnt != 0) {
			ans -= 2;
			cnt--;
		}
		if(s[i] == 'S') cnt++;
		//cout << i << ' ' << cnt << endl;
	}
	cout << ans << endl;
}

void read() {
	cin >> s;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
#endif
	read();
	solve();
	return 0;	
}

Measured memory_bytes: 720
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

int a[MAXN];
int n;

ll sum(int b){
    ll ret = 0;
    FOR(i,0,n) ret += abs(a[i] - b);
    return ret;
}

bool check(int b){
    return sum(b+1) < sum(b);
}



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

    ri(n);
    FOR(i,0,n) ri(a[i]), a[i] -= i+1;
    int l = -INF, r = INF;
    while(l < r){
        int mid = (l + r)>>1;
        if(check(mid)) l = mid + 1;
        else r = mid;
    }
    printf("%lld\n", sum(r));

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+100;
int a[maxn],b[maxn],s[maxn],sum[maxn],rr[maxn],ll[maxn];
int main()
{
    //freopen("i.txt","r",stdin);
    int n,t,last,ans2=0,ans1=0;
    scanf("%d",&n);
    priority_queue<int,vector<int>,greater<int> >r;
    priority_queue<int,vector<int>,less<int> >l;
    for(int i=0; i<n; i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        s[a[i]]++,s[b[i]]--;
        l.push(a[i]),r.push(b[i]);
    }
    t=r.top(),r.pop();
    rr[last=t]=1;
    while(!r.empty())
    {
        t=r.top(),r.pop();
        rr[t]=rr[last]+1;
        last=t;
    }
    t=l.top(),l.pop();
    ll[last=t]=1;
    while(!l.empty())
    {
        t=l.top(),l.pop();
        ll[t]=ll[last]+1;
        last=t;
    }
    for(int i=1; i<=100000; i++)
        if(!rr[i])rr[i]=rr[i-1];
    for(int i=100000; i>=0; i--)
        if(!ll[i])ll[i]=ll[i+1];
    for(int i=0; i<n; i++)
        ans1=max(n-ll[b[i]]-rr[a[i]],ans1);
    for(int i=1; i<=100000; i++)
        ans2=max(s[i]=s[i-1]+s[i],ans2);
    printf("%d %d\n",ans1,ans2);
}



Measured memory_bytes: 7504
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 10;
ll pos[MAXN];

void solve(){
    ll n; cin>>n;

    FOR(i,1,n){
        ll x; cin>>x;
        pos[x] = i;
    }

    ll ans = 0;
    multiset<ll> used;
    used.insert(0),used.insert(0),used.insert(n+1),used.insert(n+1);

    RFOR(i,1,n){
        used.insert(pos[i]);
        auto it = used.find(pos[i]);
        it--; ll s1 = *it;
        it--; ll s2 = *it;
        it++;it++;
        it++; ll e1 = *it;
        it++; ll e2 = *it;

        ans += (e2-e1)*(pos[i]-s1)*i;
        ans += (s1-s2)*(e1-pos[i])*i;
    }

    cout<<ans<<endl;
}

signed main(){
 
   FastRead;    
 
    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner sc = new Scanner(System.in);
int S = sc.nextInt();
int W = sc.nextInt();
//コンソールに入力した数字を受け取る
if(S>W) {
	System.out.println("safe");
}else {
	System.out.println("unsafe");
}
}
}


Measured memory_bytes: 35644
#include "bits/stdc++.h"
using namespace std;
struct Card{char suit,value;};

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

void sectionsort(struct Card aa[], int n) {
	for (int i = 0; i<n; ++i) {
		int minj=i;
		for (int j = i; j<n; j++) {
			if(aa[j].value<aa[minj].value){minj=j;}
		}
			swap(aa[i], aa[minj]);
		}
}
void print(struct Card aa[],int N){
	for (int i = 0; i < N; ++i) {
			if(i>0)cout<<" ";
			cout<<aa[i].suit<<aa[i].value;
	}
	cout<<endl;
}
bool isStable(struct Card c1[],struct Card c2[],int n){
	for (int i = 0; i < n; ++i) {
		if (c1[i].suit!=c2[i].suit) {
			return false;
		}
	}return true;
}

int main() {
	Card c1[100],c2[100];
	int n;
	cin>>n;
	for (int i = 0; i < n; ++i) {
		cin>>c1[i].suit>>c1[i].value;
	}
	for (int i = 0; i < n; i++) {c2[i]=c1[i];}
	bubble(c1, n);
	sectionsort(c2, n);
	print(c1,n);
	cout<<"Stable"<<endl;
	print(c2,n);
	if (isStable(c1,c2,n)) {
		cout<<"Stable"<<endl;
	} else{
		cout<<"Not stable"<<endl;
	}
}

Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<iterator>
#include<string>
#include<sstream>
#include<vector>
#include<map>

using namespace std;

struct pard {
	bool operator()(const pair<string, int>& _Left, const pair<string, int>& _Right) {
		return _Left.second != _Right.second ? _Left.second > _Right.second : _Left.first < _Right.first;
	}
};

int main() {
	int n;
	string line;
	char initial;

	while(cin >> n && n) {
//		cin.ignore(numeric_limits<streamsize>::max(), '\n');
		getline(cin, line);
		map<string, int> date_m;
		while(n--) {	
			getline(cin, line);
			istringstream iss(line);
			for(istream_iterator<string> ite = istream_iterator<string>(iss); ite != istream_iterator<string>(); ++ite) {
				++date_m.insert(make_pair(*ite, 0)).first->second;
			}
		}
		
		cin >> initial;
		vector< pair<string, int> > date_v(5);
		vector< pair<string, int> >::iterator first = date_v.begin(), last = partial_sort_copy(
			date_m.lower_bound(string(1, initial)), date_m.lower_bound(string(1, initial + 1)),
			date_v.begin(), date_v.end(), pard()
			);

		cout << (first != last ? first++->first : "NA");
		while(first != last) cout << ' ' << first++->first;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

const int INF = 1 << 29;

struct Balloon {
    int pos;
    int time;

    Balloon() {}
    ~Balloon() {}

    Balloon(int a, int b):
        pos(a), time(b) {}

};

struct State {
    int index;
    int dist;
    int weight;

    State() {}
    ~State() {}

    State(int a, int b, int c):
        index(a), dist(b), weight(c) {}

    bool operator < (const State& o) const {
        return dist == o.dist ? index < o.index : dist < o.dist;
    }

    bool operator > (const State& o) const {
        return dist == o.dist ? index > o.index : dist > o.dist;
    }
};

bool solve() {
    int n;
    int pos[45];
    int time[45];

    cin >> n;
    if (n == 0) {
        return false;
    }

    pos[0] = time[0] = 0;
    for (int j = 1; j <= n; ++j) {
        cin >> pos[j] >> time[j]; 
    }

    int dp[45][8];
    for (int j = 0; j <= n; ++j) {
        fill(dp[j], dp[j] + 8, INF);
    }

    dp[0][1] = 0;

    for (int j = 0; j < n; ++j) {
        int limitTime = time[j+1] - time[j];
        for (int k = 1; k <= 4; ++k) {
            if (abs(pos[j] - pos[j+1]) * k <= limitTime) {
                dp[j+1][k+1] = min(dp[j+1][k+1], dp[j][k] + abs(pos[j] - pos[j+1]));
            }
            if (pos[j] * k + pos[j+1] <= limitTime) {
                dp[j+1][2] = min(dp[j+1][2], dp[j][k] + pos[j] + pos[j+1]);
            }
        }
    }

    int ret = INF;
    for (int j = 1; j <= 4; ++j) {
        ret = min(ret, dp[n][j] + pos[n]);
    }
    if (ret < INF) {
        cout << "OK" << ' ' << ret << endl;
        return true;
    }

    for (int j = n-1; j >= 0; --j) {
        for (int k = 1; k <= 4; ++k) {
            if (dp[j][k] < INF) {
                cout << "NG" << ' ' << (j+1) << endl;
                return true;
            }
        }
    }
    return true;
}

int main() {
    while(solve());
    return 0;
}

Measured memory_bytes: 3020
x,n=list(map(int,input().split()))
import sys
if n==0:
  print(x)
  sys.exit()

p=list(map(int,input().split()))
for i in range(x,110):
  if 2*x-i not in p:
    print(2*x-i)
    sys.exit()
  if i not in p:
    print(i)
    sys.exit()
  


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;
int fr[M], bk[M], ar[M];

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

int main()
{ 
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> ar[i];
	fr[0] = ar[0]; 
	for(int i = 1; i < n; i++) {
		fr[i] = gcd(fr[i-1], ar[i] ); 
	}	
	bk[n-1] = ar[n-1];
	for(int i = n-2; i >= 0; i--) {
		bk[i] = gcd(bk[i+1], ar[i] );
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(i == 0) ans = max(ans, bk[i+1]);
		else if(i == n-1) ans = max(ans, fr[i-1]);
		else ans = max(ans, gcd(bk[i+1], fr[i-1]) );
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>


int main() {
#ifdef DEBUG

#endif
	int N, M;
	int X;
	scanf("%d %d", &N, &M);

	int n=1;
	int i;
	for (i = 0; i < M; i++) {
		n *= 2;
	}
	
	int ans = (100 * (N - M) + 1900 * M)*n;
	printf("%d\n", ans);


}

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

int main(){
	string s;
	cin >> s;
	deque<char> dq;
	deque<char> :: iterator it;
	int q;
	cin >> q;
	int l = s.size();
	for(int i = 0; i < l; i++)
		dq.push_back(s[i]);
	bool f = false;
	int t, c;
	char ch;
	for(int i = 0; i < q; i++){
		scanf("%d",&t);
		if(t == 1) f = !f;
		else if(t == 2){
			scanf("%d %c", &c, &ch);
			if(!f){
				if(c == 1) dq.push_front(ch);
				else if(c == 2) dq.push_back(ch);
			}
			else {
				if(c == 2) dq.push_front(ch);
				else if(c == 1) dq.push_back(ch);				
			}
		}
	}
	if(!f){
		for(it = dq.begin(); it != dq.end(); it++)
			printf("%c", *it);		
	}
	else{
		for(it = dq.end() - 1; it != dq.begin() - 1; it--)
			printf("%c", *it);			
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int n;
    string s;
    cin >> n >> s;
    int x;
    vector<int> a(n);
    rep(i,n) {
        if(s[i] == 'I') {
            x++;
        } else {
            x--;
        }
        a[i] = x;
    }

    sort(a.begin(), a.end());
    if (a[n-1] < 0)
        cout << 0 << endl;
        else
    cout << a[n-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

const int MAX=510000;

vll fac(MAX);
vll finv(MAX);
vll inv(MAX);

void combinit(ll m){
    fac[0]=1;fac[1]=1;
    finv[0]=1;finv[1]=1;
    inv[1]=1;
    rep2(i,2,MAX){
        fac[i]=fac[i-1]*i%m;
        inv[i]=m-inv[m%i]*(m/i)%m;
        finv[i]=finv[i-1]*inv[i]%m;
    }
}

ll combi(ll n,ll k,ll m=inf){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%m)%m;
}

int main(){
    ll h,w,a,b;cin>>h>>w>>a>>b;
    if(h-a>w-b){
        swap(h,w);
        swap(a,b);
    }
    combinit(inf);
    ll ans=(ll)0;ll tmp;
    for(ll i=(ll)0;i<h-a;i++){
        tmp=combi(h-a+b-1,i)*combi(w+a-b-1,h-1-i);
        tmp%=inf;
        ans+=tmp;
        ans%=inf;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 14948
#include<bits/stdc++.h>
using namespace std;
 
int calc_digit(int a){
  int i = 0;
  
  while(true){
    a = a / 10;
    i++;
    if(a == 0){
      break;
    }
  }
  return i;
}
 
 
int main() {
  long long n; cin >> n;
  int ans = 10;
  
  for(int a = 1; a <= sqrt(n); a++){
    if(n % a == 0){
      long long b = n / a;
    
      ans = min(ans, max(calc_digit(a), calc_digit(b)));
    }
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
int main() {
    int a, b; cin >> a >> b;
    cout << (a * b % 2 != 0 ? "Odd" : "Even") << endl;
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
vector<int> tree[maxN];
int subtree[maxN];

int dfs(int u = 0, int prv = -1)
{
  for (int v: tree[u])
    if (v != prv)
    {
      subtree[u] += 1;
      dfs(v, u);
    }
  return subtree[u];
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    memset(subtree, 0, sizeof(subtree));
    for (int i = 0; i < n; i++)
      tree[i].clear();

    for (int i = 1; i < n; i++)
    {
      int p; scanf("%d", &p); p--;
      tree[i].push_back(p), tree[p].push_back(i);
    }

    dfs();

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

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

using namespace std;

#define int long long



main(){

	int A, B, m; cin >> A >> B >> m;

	int a[A], b[B];

	int minim_a = 1e9, minim_b = 1e9;

	for(int i = 0; i < A; i++){
		cin >> a[i];
		minim_a = min(minim_a, a[i]);
	}

	for(int i = 0; i < B; i++){
		cin >> b[i];
		minim_b = min(minim_b, b[i]);
	}

	int record = minim_a + minim_b, x, y, c;

	for(int i = 0; i < m; i++){
		cin >> x >> y >> c;
		record = min(record, a[x - 1] + b[y - 1] - c);
	}


	cout << record << endl;


	




	return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	xs := make([]int, 5)

	sum := 0
	max := 0
	for i := range xs {
		fmt.Scan(&xs[i])
		if xs[i]%10 == 0 {
			sum += xs[i]
		} else {
			sum += (xs[i]/10 + 1) * 10
			if v := 10 - xs[i]%10; v > max {
				max = v
			}
		}
	}
	fmt.Println(sum - max)
}


Measured memory_bytes: 512
#include <iostream>  
#include <vector>  
#include <string>  
#include <algorithm>  
#include <cstdio>  
#include <cstring>  
#include <ctime>  
#include <cstdlib>  
#include <set>  
#include <map>  
#include <cctype>  
#include <list>  
#include <cmath>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <sstream>  
#include <functional>  
#include <cassert>  
using namespace std;  
  
#define tmax(a, b) if (b > a) a = b  
#define tmin(a, b) if (b < a) a = b  
char inc() { char _[10]; scanf("%s", _); return _[0]; }  
int ini() { int _; scanf("%d", &_); return _; }  
long long inll() { long long _; scanf("%I64d", &_); return _; }  
double ind() { double _; scanf("%lf", &_); return _; }  
string ins() { string _; cin >> _; return _; }  
int inl(char _[]) { if (!fgets(_, (int)1e8, stdin)) return -1; int i = strlen(_); if (_[i - 1] == '\n') _[--i] = 0; return i; }  
  
typedef pair<int, int> pii;  
typedef pair<char, char> pcc;  
typedef long long LL;  
const int inf = 0x3f3f3f3f;  
const LL lnf = 0x3f3f3f3f3f3f3f3f;  
const double pi = 3.14159265358979323846;  
const double eps = 1e-8;  
const int mod = 100007;  
const int maxn = 1e5 + 10;  
  
int n, a[maxn];
bool vis[maxn];
  
int main() {  
    int CAS = 0;  
    //std::ios::sync_with_stdio(0);  
    //std::cin.tie(0);  
#ifdef NIGHT_13  
    freopen("in.txt", "r", stdin);  
   // freopen("out.txt", "w", stdout);  
    int time_night_13 = clock();  
#endif // NIGHT_13  
  
	while (scanf("%d", &n) != EOF) {
		for (int i = 1; i <= n; ++i) {
			scanf("%d", &a[i]);
		}
		memset(vis, false, sizeof vis);
		vis[1] = true;
		int idx = 1;
		bool yes = true;
		int ans = 0;
		for (;;) {
			int ne = a[idx];
			if (vis[ne]) { yes = false; break; }
			else {
				idx = ne;
				++ans;
				vis[ne] = true;
			}
			if (idx == 2) break;
		}
		if (yes) {
			printf("%d\n", ans);
		} else {
			puts("-1");
		}
	}
  
#ifdef NIGHT_13  
    fprintf(stderr, "\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");  
    fprintf(stderr, "\t   Time: %d ms", (int)clock() - time_night_13);  
    fprintf(stderr, "\n...........................................\n\n");  
#endif // NIGHT_13  
    return 0;  
}  

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long r){
	cout << r*r << endl;
}

int main(){	
	long long r;
	scanf("%lld",&r);
	solve(r);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
cout << (n * (n - 1)) / 2 - n / 2 << endl;
for(int i = 1 ; i <= n ; ++i){
	for(int j = 1 ; j < i ; ++j){
		if(i + j == n + ((n & 1) ^ 1))
			continue;
		cout << j << ' ' << i << endl;
	}
}

return 0;
}



Measured memory_bytes: 256
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
ans.pop(0)
print('\n'.join(map(str,ans)))


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
 
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);

int main() {
	int n;
	cin >> n;
	set<string> st;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 19088
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

// 配列の総和
// greater


int main(){
    ll N, K;
    cin >> N >> K;
    ll H[N];
    rep(i, N)cin>>H[i];
    sort(H, H+N);
    ll ans = INT_MAX;
    rep(i, N-K+1){
        chmin(ans, H[i+K-1]-H[i]);
    }
    cout << ans << endl;
}




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

int main(){
    int N, M;
    cin >> N >> M;
    int left_max  = 1;
    int right_min = N;
    for (int i = 0; i < M; ++i){
        int l,r;
        cin >> l >> r;
        left_max  = max(l, left_max);
        right_min = min(r,right_min);
    }
    cout << max(0, right_min - left_max + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()

def main():
    Left = [10**10] # queri_num == 1の時はこっちが１多いことにする
    Right = [10**10]
    queri_num = 0 # mod 2
    const = 0
    min_val = 0

    """
    [a1, a2, ..., ai]の中央値を高速に求めないといけない所で分からず諦めた。。。

    発想は単純で、左側パートと右側パートを分けて管理しておいて、新しいクエリが来るごとに
    aを左に入れるか右に入れるか決めれば良い。
    ただし左右のパートをリストで管理するとaの挿入にO(N)かかってしまうので、ここでは
    ヒープによって管理する。なので挿入はO(logN)で可能。

    あと中央値における関数の最小値も求めないといけないが、これは基本的には単に|a - median|
    増えるだけなので、これもaの挿入時に逐次O(1)で決定可能。
    """

    Q = int(input())
    for _ in range(Q):
        queri = list(map(int, input().split()))
        if queri[0] == 2:
            x = -heappop(Left)
            print("{} {}".format(x, min_val + const))
            heappush(Left, -x)
        elif queri_num == 1:
            queri_num = 0
            const += queri[2]
            a = queri[1]
            mid = -heappop(Left)
            if a < mid:
                min_val += mid - a
                heappush(Left, -a)
                heappush(Right, mid)
            else:
                min_val += a - mid
                heappush(Left, -mid)
                heappush(Right, a)
        elif queri_num == 0:
            queri_num = 1
            const += queri[2]
            a = queri[1]
            left = -heappop(Left)
            right = heappop(Right)
            if a < left:
                min_val += left - a
                heappush(Left, -a)
                heappush(Left, -left)
                heappush(Right, right)
            elif a < right:
                # min_val is constant
                heappush(Left, -left)
                heappush(Left, -a)
                heappush(Right, right)
            else:
                min_val += a - right
                heappush(Left, -left)
                heappush(Left, -right)
                heappush(Right, a)


if __name__ == "__main__":
    main()


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

const ll N = 3*MAX5;
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, l;
string s, t, d, c;

// <------------- Implement Functions Here ----------> //




// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	if(n < 30) cout<<"No";
	else cout<<"Yes";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

enum RESULT{
	IDENTICAL,
	CLOSE,
	DIFFERENT,
};

struct Info{
	char name[201];
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

RESULT compare(char left[201],char right[201]){

	if(strCmp(left,right))return IDENTICAL;

	char content[201],work[201];
	int content_index,work_index = 0;

	queue<Info> N_L_Q,N_R_Q;
	queue<Info> L_Q,R_Q;

	//left
	for(int i = 0; left[i] != '\0'; ){
		if(left[i] != '"'){
			work[work_index++] = left[i];
			i++;

			if(left[i] == '\0'){
				work[work_index] = '\0';
				Info info;
				strcpy(info.name,work);
				N_L_Q.push(info);
				work_index = 0;
			}

		}else{

			if(work_index > 0){
				work[work_index] = '\0';
				Info info;
				strcpy(info.name,work);
				N_L_Q.push(info);
				work_index = 0;
			}

			content_index = 0;
			for(++i;left[i] != '"';i++){
				content[content_index++] = left[i];
			}
			if(content_index > 0){
				content[content_index] = '\0';
			}else{
				content[0] = '.';
				content[1] = '\0';
			}
			Info info;
			strcpy(info.name,content);
			L_Q.push(info);
			i++;
		}
	}

	//right
	for(int i = 0; right[i] != '\0'; ){
		if(right[i] != '"'){
			work[work_index++] = right[i];
			i++;

			if(right[i] == '\0'){
				work[work_index] = '\0';
				Info info;
				strcpy(info.name,work);
				N_R_Q.push(info);
				work_index = 0;
			}
		}else{

			if(work_index > 0){
				work[work_index] = '\0';
				Info info;
				strcpy(info.name,work);
				N_R_Q.push(info);
				work_index = 0;
			}

			content_index = 0;
			for(++i;right[i] != '"';i++){
				content[content_index++] = right[i];
			}
			if(content_index > 0){
				content[content_index] = '\0';
			}else{
				content[0] = '.';
				content[1] = '\0';
			}
			Info info;
			strcpy(info.name,content);
			R_Q.push(info);
			i++;
		}
	}

	int num = 0;

	if(N_R_Q.size() != N_L_Q.size()){
		return DIFFERENT;
	}

	while(!N_R_Q.empty()){
		if(!strCmp(N_R_Q.front().name,N_L_Q.front().name)){
			num++;
			break;
		}
		N_R_Q.pop();
		N_L_Q.pop();
	}

	if(num != 0){
		return DIFFERENT;
	}


	if(R_Q.size() != L_Q.size())return DIFFERENT;
	num = 0;

	while(!L_Q.empty()){
		if(!strCmp(L_Q.front().name,R_Q.front().name))num++;
		L_Q.pop();
		R_Q.pop();
	}

	if(num == 1){
		return CLOSE;
	}else{
		return DIFFERENT;
	}
}


int main(){

	char left[201],right[201];
	while(true){
		scanf("%s",left);
		if(left[0] == '.')break;

		scanf("%s",right);

		switch(compare(left,right)){
		case IDENTICAL:
			printf("IDENTICAL\n");
			break;
		case CLOSE:
			printf("CLOSE\n");
			break;
		case DIFFERENT:
			printf("DIFFERENT\n");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 2648
#include<cstdio>

int main(void) {
    int n;
    scanf("%d",&n);
    switch(n) {
        case 0:
            printf("1\n");
            break;
        case 1:
            printf("2\n");
            break;
        case 2:
            printf("1\n");
            break;
        default:
            printf("0\n");
            break;
    }
    return 0;
}

Measured memory_bytes: 2644
#include<iostream>
using namespace std;
int main()
{
    string a,b,c,d;
    cin>>a>>b>>c;
    d[0]=a[0];
    d[1]=b[1];
    d[2]=c[2];
    d[3]='\0';
    cout<<d[0]<<d[1]<<d[2]<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int e[105][105];
int ans;
int main(void){
	int n,k; cin>>n>>k;
	if(k>(n-1)*(n-2)/2){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=2;i<=n;i++){
		e[1][i]=1;
		ans++;
	}
	int a=(n-1)*(n-2)/2-k;
	int s=2,t=3;
	//cout<<a<<endl;
	for(int i=0;i<a;i++){
		e[s][t]=1;
		ans++;
		if(t<n){
			t++;
		}else{
			s++; t=s+1;
		}
	}
	cout<<ans<<endl;
	for(int i=0;i<105;i++){
		for(int j=0;j<105;j++){
			if(e[i][j]==1){
				cout<<i<<" "<<j<<endl;
			}
		}
	}
	
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(System.out);

        char[] n = in.next().toCharArray();
        for (int i = 1; i < n.length; i++) {
            if (n[i] == n[i - 1]) {
                out.println ("Bad");
                out.close();
                System.exit(0);
            }
        }
        out.println("Good");
        out.close();
    }
}

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

class Main {

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();

		UnionFind uf = new UnionFind(N);
		Set<Integer>[] direct = new HashSet[N];
		for (int i = 0; i < N; i++) {
			direct[i] = new HashSet<>();
		}

		for (int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			uf.union(a, b);
			direct[a].add(b);
			direct[b].add(a);
		}

		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = uf.scale(i) - 1 - direct[i].size();
		}


		Set<Integer>[] checked = new HashSet[N];
		for (int i = 0; i < N; i++) {
			checked[i] = new HashSet<>();
		}

		for (int i = 0; i < K; i++) {
			int c = sc.nextInt() - 1;
			int d = sc.nextInt() - 1;
			if (c == d) continue;
			if (checked[c].contains(d)) continue;
			if (checked[d].contains(c)) continue;
			if (direct[c].contains(d)) continue;
			if (uf.connected(c, d)) {
				a[c]--;
				a[d]--;
			}
			checked[c].add(d);
			checked[d].add(c);
		}


		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			sb.append(a[i]).append(" ");
		}
		System.out.println(sb.toString());
	}

	private static class UnionFind {

		private int n;
		private int[] a;
		private int[] scale;

		public UnionFind(int n) {
			this.n = n;
			a = new int[n];
			scale = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = i;
				scale[i] = 1;
			}
		}

		public void union(int v, int w) {
			int rv = root(v);
			int rw = root(w);
			if (rv != rw) {
				a[rv] = a[rw];
				scale[rw] += scale[rv];
			}
		}

		private int root(int v) {
			while (a[v] != a[a[v]]) a[v] = a[a[v]];
			return a[v];
		}

		public int scale(int v) {
			return scale[root(v)];
		}

		public boolean connected(int v, int w) {
			return root(v) == root(w);
		}
	}


}



Measured memory_bytes: 193448
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b){
        for(int i=0;i < b; i++){
            cout<<a;}
    }
     else{
        for(int i=0;i < a; i++){
            cout<<b;}  
            
        }
        
    
     
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
main(){
   long long i,j,k,l,m,n;
   while(cin>>m>>n){
    i=m%n;
    j=n-i;
    if(i>j)cout<<j<<endl;
    else cout<<i<<endl;
   }
     return 0;
}


Measured memory_bytes: 256
try:
    while True:
        #標準入力
        a_line = list(map(int,input().split()))
        b_line = list(map(int,input().split()))
        num1 = 0
        num2 = 0
        #場所も番号も同じならnum1数字が同じならnum2にいれる
        for num in range(0,4):
            if a_line[num] == b_line[num]:
                num1 += 1
                continue
            else:pass
            if a_line[num] in b_line:num2 += 1
            else:pass
        print(str(num1) + " " + str(num2))
#EOFErrorをひろう
except EOFError:
    pass


Measured memory_bytes: 5596
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
using namespace std;

double StandardDeviation(vector<int> s){
	int n = s.size();
	double S = 0;
	double D = 0;
	for(int i = 0; i < n; i++) S += s[i];
	double m = S / n;
	for(int i = 0; i < n; i++) D += (s[i] - m) * (s[i] - m);
	double d = sqrt( D / n );
	return d;
}

vector<int> Enter(int n){
	vector<int> s;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		s.push_back(a);
	}
	return s;
}

int main(){
	vector<double> alpha;
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		vector<int> s;
		s = Enter(n);
		double d = StandardDeviation(s);
		alpha.push_back(d);
	}
	for(int i = 0; i < alpha.size(); i++) cout << fixed << setprecision(8) << alpha[i] << endl;
	return 0;
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

string str[3];
int memo[3][3][20000];

bool ok(int a,int b,int diff) {
  if(memo[a][b][diff]!=0) return memo[a][b][diff]-1;
  if(str[a].size()<=diff) {
    memo[a][b][diff]=2;
    return memo[a][b][diff]-1;
  }
  for(ll i=0;i<min(str[a].size()-diff,str[b].size());i++) {
    if(str[a][i+diff]=='?'||str[b][i]=='?') continue;
    if(str[a][i+diff]!=str[b][i]) {
      memo[a][b][diff]=1;
      return memo[a][b][diff]-1;
    }
  }
  memo[a][b][diff]=2;
  return memo[a][b][diff]-1;
}

ll solve(int a,int b,int c) {
  int ans=1e6;
  for(int bs=0;bs<=str[a].size();bs++) {
    for(int cs=bs;cs<=max(bs+str[b].size(),str[a].size());cs++) {
      if(ok(a,b,bs)&&ok(a,c,cs)&&ok(b,c,cs-bs)) {
        int len=str[a].size();
        len=max(len,bs+(int)str[b].size());
        len=max(len,cs+(int)str[c].size());
        ans=min(ans,len);
      }
    }
  }
  return ans;
}

int main() {
  cin >> str[0] >> str[1] >> str[2];
  ll ans=solve(0,1,2);
  ans=min(ans,solve(0,2,1));
  ans=min(ans,solve(1,0,2));
  ans=min(ans,solve(1,2,0));
  ans=min(ans,solve(2,1,0));
  ans=min(ans,solve(2,0,1));
  cout << ans << endl;
}

Measured memory_bytes: 384
from collections import Counter

n = input()
N = int(n)
A = [int(a) for a in input().split()]
q = input()
Q = int(q)
B, C = [], []
for i in range(Q):
    b, c = input().split()
    B.append(int(b))
    C.append(int(c))


my_dict = Counter(A)

def cals_sum(my_dict):
    values = [ my_dict[key]*key for key in my_dict.keys() if my_dict[key] != 0]
    #for key in my_dict.keys():
    #    value = my_dict[key]
    #    sum += int(key) * int(value)
    return sum(values)
  
my_sum = cals_sum(my_dict)

for i in range(len(B)):
    b = B[i]
    c = C[i]
    tmpb = my_dict[b] 
    my_dict[b] = 0
    tmpc = my_dict[c]
    my_dict[c] = tmpb + tmpc
    
    my_sum += ((tmpb)*c - tmpb*b)

    print(my_sum)




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

int main() {
  int h, w;
  cin >> h >> w;
  cout << string(w + 2, '#') << "\n";
  for (int i = 0; i < h; ++i) {
    string a;
    cin >> a;
    cout << "#" << a << "#\n";
  }
  cout << string(w + 2, '#') << "\n";
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;

int N, U, V;
vi edge[MAX], children[MAX];
int parent[MAX];

void make_tree(int n, int p) {
    parent[n] = p;
    children[n] = vi();
    FORE (c, edge[n]) if (c != p) {
        children[n].push_back(c);
        make_tree(c, n);
    }
}

vi shortest_path(int s) {
    vi shortest;
    int path = s;
    while (path != V) {
        shortest.push_back(path);
        path = parent[path];
    }
    shortest.push_back(V);
    return shortest;
}

ll dnf(int n, int len, int ng) {
    if (children[n].size() == 0) return len;
    ll mx = 0;
    FORE (c, children[n]) if (c != ng) {
        mx = max(mx, dnf(c, len+1, ng));
    }
    return mx;
}

int solve() {
    if (edge[U].size() == 1 && edge[U][0] == V) return 0; // 一手目で終わる

    make_tree(V, -1);
    ll ans = 0;

    vi shortest = shortest_path(U);
    int idx = shortest.size()/2 - 1;
    ans = idx;
    if (shortest.size()&1) ans++;
    int u = shortest[idx], ng = shortest[idx+1];

    make_tree(u, -1);
    ans += dnf(u, 0, ng);
    return ans;
}

int main() {
    cin >> N >> U >> V;
    U--; V--;
    REP (i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    cout << solve() << endl;
}

Measured memory_bytes: 16896