akhauriyash/Code-Regression huggingface dataset:
/* author   : mpily :-()
title : Competing.cpp
time :Sat Oct 19 15:19:33 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<int>arr(N);
	vector<int>sums(N);
	for(int i = 0; i < N; i++){
		cin>>arr[i];
	}
	int sum = 0;
	for(int i = N-1; i >= 0; i--){
		sums[i] = sum;
		sum+=arr[i];
	}
	int ans = 0;
	for(int i = 0; i < N; i++){
		ans+=sums[i]*arr[i];
	}
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let s = it.next().unwrap();
    let t = it.next().unwrap();
    let mut ai = HashMap::new();
    for (i, c) in s.chars().enumerate() {
        ai.entry(c).or_insert(Vec::new()).push(i);
    }
    let mut n_fallback = 0;
    let mut cur = 0;
    if !t.chars().all(|c| ai.get(&c) != None) {
        println!("{}", -1);
        return;
    }
    let a: Result<usize, usize> = Err(11);
    for c in t.chars() {
        let l = &ai[&c];
        let n = l.len();
        let mut i = match l.binary_search(&cur) {
            Ok(x) => x,
            Err(x) => x,
        };
        if i >= n {
            n_fallback += 1;
            i = 0;
        }
        cur = l[i] + 1;
    }
    println!("{}", n_fallback * s.len() + cur);
}


Measured memory_bytes: 6396
n=input()

if n[-1]=='2' or n[-1]=='4' or n[-1]=='5' or n[-1]=='7' or n[-1]=='9':
  print('hon')
if n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
  print('pon')
if n[-1]=='3':
  print('bon')

Measured memory_bytes: 9144
K=int(input())
c_gu=0
c_ki=0
if (K%2==0):
    c_gu=int(K/2)
    c_ki=int(K/2)
else:
    c_gu=int(K/2)+1
    c_ki=int(K/2)
print(c_gu*c_ki)
        

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
static const int N=100;
int main()
{
    int M[N][N];
    int n,u,k,v;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        M[i][j]=0;
    }
    for(int i=0;i<n;i++)
    {
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++)
        {
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j) cout<<" ";
            cout<<M[i][j];
        }
        cout<<endl;
    }
    return 0;
}




Measured memory_bytes: 3140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;

int main()
{
	int a,b,c,d,suml = 0,sumr = 0;
	cin >> a >> b >> c >> d;
	suml = a + b;
	sumr = c + d;
	if(suml == sumr) cout << "Balanced" << endl;
	else if(suml > sumr )cout << "Left" << endl;
	else cout << "Right" << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  bool ans = true;
  rep(i, s.size()) {
    if (i % 2 == 0) {
      ans &= s[i] == 'R' || s[i] == 'U' || s[i] == 'D';
    } else {
      ans &= s[i] == 'L' || s[i] == 'U' || s[i] == 'D';
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}


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

#define int long long
#define test int t; cin >> t; while (t--)
#define deb(x) cerr << "[" << #x  << " : "<< x << "]\n";
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const int maxn = 2e6 + 10;
const long double Pie = acos(-1);

signed main() {

	string str;
	cin >> str;

	int ans = 0;

	for (int i = 0; i < (int)str.size(); i++) {
		ans += str[i] - '0';
	}

	if (ans % 9 == 0) cout << "Yes";
	else              cout << "No";

	return 0;
}



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

typedef long long ll;

int main(){
  ll M,N,ans = 0,rest;
  cin >> M >> N;
  
  if(M * 2 >= N){
    ans = N / 2;
  }
  else{
    rest = N - M * 2;
    ans = M + rest / 4;
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    ll N , Y ;
   cin>>N>>Y;
  N-=Y;
  int ans =N/(Y-1)+1;
  if(N%(Y-1)!=0)ans++;
  cout<<ans;
   return 0;
}

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

#define ll long long

int main()
{
    ll a,b,k;

    cin>>a>>b>>k;


    if(a%b ==0){
        cout<<(a/b) * k <<endl;
    }else{
     ll x = (a/b) + 1;

     cout<< x*k<<endl;


    }



    return 0;
}


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

struct UnionFind{
  vector<ll> d; //子なら親のID,根なら-サイズを保存
  UnionFind(ll n=0) : d(n,-1) {} //最初はみんな根でサイズ1 (コンストラクタ :と{}の間には初期化子が入る)
  ll find(ll x){
    //自分が根なら自分を、そうでなければ親のfind結果を返す(再帰)
    if( d.at(x) < 0 )  return x;
    return d.at(x) = find(d.at(x)); //親のfindの結果で上書き(メモ化で木のサイズを小さくする)
  }
  // グラフを併合する関数　併合に成功すればtrue, もともと同じ集合ならfalseを返す
  bool unite(ll x,ll y){
    x = find(x); y = find(y);
    if( x == y ) return false; //元々同じグループなら、やることはない (falseはminimun spaning treeで使えるので便利)
    if( -d.at(x) < -d.at(y) ) swap(x,y); //サイズが大きい方に小さい方をくっつけたい
    d.at(x) += d.at(y); //xにyをくっつける（＝サイズをyを根とするグラフの分増やす）
    d.at(y) = x; //yのグラフの根をxに書き換える
    return true;
  }

  //同じ集合に属しているか判定する関数
  bool same(ll x,ll y){ return find(x) == find(y); }
  //要素の属する集合のサイズを返す関数
  ll size(ll x){ return -d.at( find(x) ); }
};

int main(){
  ll n,m;cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    ll a,b;cin >> a >> b;
    --a;--b;
    uf.unite(a,b);
  }
  ll max_size = -1;
  rep(i,n){
    max_size = max(max_size,uf.size(i));
  }

  cout << max_size << endl;

  return 0;
}


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

typedef long long ll;

const ll N=1e5+5;
ll n, a[N][3], dp[N][3];

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

   cin>>n;
   for(ll i=1; i<=n; i++){
       for(ll w=0; w<3; w++){
           cin>>a[i][w];
           dp[i][w] = a[i][w];
       }
   }

   for(ll i=2; i<=n; i++){
       for(ll w=0; w<3; w++){
           dp[i][w] += max(dp[i-1][(w+1)%3], dp[i-1][(w+2)%3]);
       }
   }

   cout<<(ll)max(dp[n][0],max(dp[n][2],dp[n][1]));

}


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

int main() {
  int64_t N,K;
  cin >> N >> K;
  //cout << N << K << endl;
  //0~NのN+1種類和、ただし
  
  int64_t ans = 1; //i=N+1の場合
  
  for(int64_t i=K; i<N+1; i++){
    if(i==1){
      ans += N+1;
    }
    else if(i==2){
      int64_t kagen = 1;
      int64_t jogen = N+N-1;
      ans += jogen - kagen +1;
    }
    else{
      int64_t kagen = i*(i-1)/2;
      int64_t jogen = i*(2*N-i+1)/2;
      ans += jogen - kagen +1;
    }
    //cout << 'hogehoge' << endl;
  }
  int64_t pp= pow(10,9)+7;
  cout << ans%pp << endl;
}

//cout << fixed << setprecision(10) << (long double)2*sum/(long double)N << endl;


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
typedef struct {
    int num;
    int pref;
    int yer;
    int ID;
}unit;
int compare(const void *a,const void *b){
    unit s= *(unit*)a,t= *(unit*)b;
    int tmp1=s.yer,tmp2=t.yer;
    if(tmp1>tmp2)return 1;
    return -1;
}
int comp(const void *a,const void *b){
    unit s= *(unit*)a,t= *(unit*)b;
    int tmp1=s.num,tmp2=t.num;
    if(tmp1>tmp2)return 1;
    return -1;
}
int main()
{   int n,m;
    scanf("%d%d",&n,&m);
    unit K[m];
    int used[100001];
    for(int i=0;i<100001;i++)used[i]=1;
    
    for(int i=0;i<m;i++){
        scanf("%d%d",&K[i].pref,&K[i].yer);
        K[i].num=i;
    }
    qsort(K,m,sizeof(unit),compare);
    for(int i=0;i<m;i++){
        K[i].ID=used[K[i].pref];
        used[K[i].pref]++;
    }
    qsort(K,m,sizeof(unit),comp);
    for(int i=0;i<m;i++){
        if(K[i].pref<10){
            printf("00000%d",K[i].pref);
        }else if(K[i].pref<100){
            printf("0000%d",K[i].pref);
        }else if(K[i].pref<1000){
            printf("000%d",K[i].pref);
        }else if(K[i].pref<10000){
            printf("00%d",K[i].pref);
        }else if(K[i].pref<100000){
            printf("0%d",K[i].pref);
        }else{
            printf("%d",K[i].pref);
        }
        if(K[i].ID<10){
            printf("00000%d",K[i].ID);
        }else if(K[i].ID<100){
            printf("0000%d",K[i].ID);
        }else if(K[i].ID<1000){
            printf("000%d",K[i].ID);
        }else if(K[i].ID<10000){
            printf("00%d",K[i].ID);
        }else if(K[i].ID<100000){
            printf("0%d",K[i].ID);
        }else{
            printf("%d",K[i].ID);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 4972
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <ctime>
#include <cstdint>
#include <cmath>

#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define EACH(i,x)   for(auto & i : x)
#define ALL(x)      begin(x),end(x)

using namespace std;

typedef vector<int> vecint;

constexpr int MaxVal=16384;
int tree[MaxVal];
int read(int idx){
  int sum = 0;
  while (idx > 0){
    sum += tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}
void update(int idx ,int val){
  while (idx <= MaxVal){
    tree[idx] += val;
    idx += (idx & -idx);
  }
}
int bs(int i){
  int k=8192;
  int j=0;
  while(k){
    if(read(j+k)<i)
      j+=k;
    k/=2;
  }
  return j+1;
}

int main()
{
  while(true){
    int n,k,m;cin>>n>>k>>m;
    if(!(n||k||m))break;
    REP(i,16384)tree[i]=0;
    REP(i,n)update(i+1,1);
    int p=m;
    REP(i,n-1){
      update(p,-1);
      int l=read(p);
      int rk=k%(n-i-1);
      if(l+rk==n-i-1 || (l==0&&((k%(n-i-1)==0))))
        p=bs(n-i-1);
      else{
        int c=(l+rk)%(n-i-1);
        p = bs(c);
      }
    }
    cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
inline int read () {
	int num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
int n, m;
int main () {
	int ans = 0;
	n = read (); m = read ();
	for (int i = 1;i <= sqrt (m);i ++) { 
		int x = i;
		if (m % x == 0) {
			if (m / x >= n)
				ans = max (ans, x);
			x = m / x;
			if (m / x >= n)
				ans = max (ans, x);
		}
	} 
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

//dp[i][j]
//i番目までの魔法を使い、モンスターの体力をj減らす場合の、消費魔法の最小値
int dp[1010][10010];

int main() {

    int h, n; cin >> h >> n;

    vector<int> a(n);
    vector<int> b(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }

    //初期化
    for (int i = 0; i < 1010; ++i) {
        for (int j = 0; j < 10010; ++j) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= h; ++j) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][min(j+a[i], h)] = min(dp[i+1][min(j+a[i], h)], dp[i+1][j] + b[i]);
        }
    }

    cout << dp[n][h] << endl;
}

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

using namespace std;

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

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

ll N, M;
string s;


void solve() {
    cin >> N >> M;
    ll cnt = 0;
    REP(i,1,10000000) {
        ll k = i;
        ll c = 0;
        while (k % 100 == 0) {
            c++;
            k /= 100;
        }
        if (c == N) {
            cnt++;
            if (cnt == M) {
                cout << i << endl;
                break;
            }
        }
    }
}

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


Measured memory_bytes: 256
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
//----------------------------------------------------------------------------------------------------------------------------------------------------

typedef struct data
{
	ll a,b,c,d;
}DATA;
vector<string> nums;
ll n,m;
void get_num(ll idx, string num, ll prev_)
{
	if(prev_ > m)
		return;
	if(idx == n)
	{
        nums.pb(num);
		return;
	}
	num.pb(prev_+'0');
	get_num(idx+1,num,prev_);
    num.pop_back();
    get_num(idx,num,prev_+1);
}
int main()
{
	ll q,a,b,c,d;
	cin>>n>>m>>q;
	vector<DATA> v;
	for(ll i=0;i<q;i++)
	{
		cin>>a>>b>>c>>d;
		--a;
		--b;
		DATA x;
		x.a = a;
		x.b = b;
		x.c = c;
		x.d = d;	
		v.pb(x);
	}
	ll maxx = 0;
    string aux;
    get_num(0,aux,1);
    for(string it: nums)
	{
		ll ans = 0;
		for(auto it1: v)
		{
			if(it[it1.b] - it[it1.a] == it1.c)
				ans += it1.d;
		}
		maxx = max(maxx, ans);
	}
	cout<<maxx;
	return 0;
}


Measured memory_bytes: 7376
#include <bits/stdc++.h> 
    #define MOD 1000000007
    using namespace std;
    
    typedef unsigned int ll;
    typedef long long ull;

    int main() {
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin) ;
        freopen("output.txt", "w", stdout) ;
        #endif
        ios_base::sync_with_stdio(false);
        cin.tie(NULL) ; cout.tie(NULL) ;
        int n,l;
        cin >> n>>l;
        string str[n];

        for(int i = 0; i < n; i++){
            cin >> str[i];
        }
        sort(str,str + n);
        for(int i = 0; i < n ; i++){
            cout << str[i];
        }
        cout << endl;
    }

Measured memory_bytes: 3652
tmp = [int(i) for i in raw_input().split()]
list1 = []
list2 = []
for i in range(100):

    amari = tmp[0]%(i+1)

    if amari == 0:
        list1.append(i+1)

for i in range(100):
    amari = tmp[1] % (i+1)

    if amari == 0:
        list2.append(i+1)

match = []

for i in list1:
    for s in list2:
        if i == s:
            match.append(s)

print(match[len(match)-tmp[2]])

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	string s;
	cin >> s;
	FOR(i, 0, s.size()-1) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				ps(No);
				return(0);
			}
		}
		else {
			if (s[i] == 'R') {
				ps(No);
				return(0);
			}
		}
	}
	ps(Yes)
	return(0);
}

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

int main() {
	int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++)cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//行列計算
//二次元vectorを用いる
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll m=1e9+7; //mod
//A*B
mat mul(mat &a, mat &b){
    mat c(a.size(), vec(b[0].size()));
    for(ll i=0; i<a.size(); i++){
        for(ll k=0; k<b.size(); k++){
            for(ll j=0; j<b[0].size(); j++){
                c[i][j]=(c[i][j]+a[i][k]*b[k][j])%m;
            }
        }
    }
    return c;
}
//A^n
mat pow(mat a, ll n){
    mat b(a.size(),vec(a.size()));
    for(ll i=0; i<a.size(); i++){
        b[i][i]=1;
    }
    while(n>0){
        if(n&1)b=mul(b,a);
        a=mul(a,a);
        n>>=1;
    }
    return b;
}
//matは mat a(3, vec(3)); のように呼び出す

int main(){
    ll n,k; cin>>n>>k;
    mat a(n,vec(n));
    rep(i,n){
        rep(j,n) cin>>a[i][j];
    }
    a=pow(a,k);
    ll res=0;
    rep(i,n){
        rep(j,n) res+=a[i][j];
    }
    cout<<res%m<<endl;
    return 0;
}

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

int main ()
{
	int mind=0;
	
	string s;
	cin>>s;
	
	for (int i=0;i<s.length();i++)
	{
		if(s[i]=='+')
		mind++;
		
		else 
		mind--;
	}
	cout<<mind;
	
	
	
}

Measured memory_bytes: 256
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d" @@ fun n m ->
  let set_ary = Array.init n @@ fun _ ->
    Scanf.scanf " %d" @@ fun k -> 
      let ary = Array.init k @@ fun _ -> Scanf.scanf " %d" Fun.id in
      IntSet.of_list @@ Array.to_list ary in
  Printf.printf "%d\n" @@ IntSet.cardinal @@ Array.fold_left IntSet.inter set_ary.(0) set_ary

Measured memory_bytes: 4316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
int w,h;
int main(){
	while(1){
		cin >> h>> w;
		if(w==0&&h==0)break;
		int p=w*w+h*h;
		int ansh=0;
		int answ=0;
		int copy=1e9;
		for(int i=1;i<150;i++){
			for(int j=i+1;j<=150;j++){
				if(p<i*i+j*j&&i*i+j*j<copy){
					copy=i*i+j*j;
					ansh=i;
					answ=j;
				}
				if(i*i+j*j==copy){
					if(i<ansh){
						ansh=i;
						answ=j;
					}
				}
				if(p==i*i+j*j){
					if(i>h&&copy>p){
						copy=i*i+j*j;
						ansh=i;
						answ=j;
					}
					else if(copy==p&&i>h&&i<ansh){
						copy=i*i+j*j;
						ansh=i;
						answ=j;
					}
				}
			}
		}
		cout << ansh << " " << answ << endl;
	}
}


Measured memory_bytes: 3052
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int ans = 700;
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'o')
        {
            ans += 100;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 100;
int n;
ll a[N];
vector<pii> ans;
int main(){
	scanf("%d", &n);
	rep(i, 0, n) scanf("%lld", a + i);
	int mx = max_element(a, a + n) - a, mn = min_element(a, a + n) - a;
	if(abs(a[mx]) > abs(a[mn])) {
		rep(i, 1, n) {
			int cnt = 0;
			while(a[i] < a[i - 1]) {
				a[i] += a[mx];
				ans.pb({mx, i});
				if(abs(a[mx]) < abs(a[i]))
					mx = i;
			}
		}
	} else {
		for(int i = n - 1; i > 0; i--) {
			int cnt = 0;
			while(a[i] < a[i - 1]) {
				a[i - 1] += a[mn];
				ans.pb({mn, i - 1});
				if(abs(a[mn]) < abs(a[i - 1]))
					mn = i - 1;
			}
		}
	}
	printf("%d\n", sz(ans));
	for(auto it : ans) printf("%d %d\n", it.fi + 1, it.se + 1);
	return 0;
}


Measured memory_bytes: 3836
N = gets.to_i
aOrig = gets.split

a = Marshal.load(Marshal.dump(aOrig))
N.times do |i|
    (N - 1).downto(i + 1) do |j|
        if a[j][1] < a[j - 1][1] then
            tmp = a[j]
            a[j] = a[j - 1]
            a[j - 1] = tmp
        end
    end
end
puts a.join(' ')
puts "Stable"

a = Marshal.load(Marshal.dump(aOrig))
N.times do |i|
    minJ = i
    i.upto(N - 1) do |j|
        minJ = j if a[j][1] < a[minJ][1]
    end
    if minJ != i then
        tmp = a[i]
        a[i] = a[minJ]
        a[minJ] = tmp
    end
end
puts a.join(' ')

na = aOrig.map {|aa| aa[1]}
repeaters = []
N.times do |i|
    (i + 1).upto(N - 1) do |j|
        repeaters.push([i, j].sort) if na[i] == na[j]
    end
end
isStable = true
repeaters.each do |r|
    isStable = false if a.find_index(aOrig[r[0]]) > a.find_index(aOrig[r[1]])
end
puts isStable ? "Stable" : "Not stable"



Measured memory_bytes: 6916
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int dsum(int x) {
    int s = 0;
    for (int i = x; i > 0; i /= 10) {
        s += i % 10;
    }

    return s;
}

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

    int N; cin >> N;

    int prev = 10001;
    int streak = 0;
    int result = 0;

    for (int i = 0; i < N; ++i) {
        int color;
        cin >> color;

        if (color != prev && streak > 0) {
            result += streak / 2;
            streak = 0;
        }

        streak++;
        prev = color;
    }

    result += streak / 2;

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 1000000007;

int main() {
	double pi = 3.14159265;
	double n;
	cin >> n;
	cout << 2 * n * pi << endl;
}


Measured memory_bytes: 3784
package main

import (
	"fmt"
)

func main() {
	var a int

	fmt.Scan(&a)

	if a >= 400 && a < 600 {
		fmt.Println(8)
	} else if a >= 600 && a < 800 {
		fmt.Println(7)
	} else if a >= 800 && a < 1000 {
		fmt.Println(6)
	} else if a >= 1000 && a < 1200 {
		fmt.Println(5)
	} else if a >= 1200 && a < 1400 {
		fmt.Println(4)
	} else if a >= 1400 && a < 1600 {
		fmt.Println(3)
	} else if a >= 1600 && a < 1800 {
		fmt.Println(2)
	} else if a >= 1800 && a < 2000 {
		fmt.Println(1)
	}

}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n, a, b;
  cin>>n>>b>>a;
  if(b + a >= n){
    cout<<min(n, b)<<endl;
  }
  else{
    long long t = n / (b + a);
    t *= b;
    n %= (a + b);
    t += min(b, n);
    cout<<t<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]
A.sort()
lim = A[-1]
se = [True for i in range(lim + 1)]
ans = 0
for i, a in enumerate(A):
    if se[a]:
        if not((i != n - 1 and A[i + 1] == a) or (i != 0 and A[i - 1] == a)):
            ans += 1
        tmp = a
        while not tmp > lim:
            se[tmp] = False
            tmp += a
print(ans)


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

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String args[]){
		for(int i=s.nextInt(); i>0; i--){
			int[] in={s.nextInt(),s.nextInt(),s.nextInt()};
			Arrays.sort(in);
			System.out.println(
					in[2]*in[2]==(in[1]*in[1]+in[0]*in[0])
					?"YES":"NO");
		}
	}
}

Measured memory_bytes: 33772
#include <string>
#include <iostream>
using namespace std;
string a,b;
string transform(string a){
    string b = a.substr(1,a.length() - 1);
    b += a[0];
    return b;
}
int main(){
    cin>>a>>b;
    if(a == b){
        cout<<"Yes";
        return 0; 
    }
    int len = a.length();
    for (int i = 0; i < len; i++)
    {
        a = transform(a);
        if(a == b){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/numeric>
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))
#define     pii       pair<int,int>
#define     N         100005
using namespace std;

int main(){
    __;
/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
*/


    string s;
    int won=0;
    cin >> s;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]!='o') won++;
    }

    if(won < 8) cout << "YES";
    else cout << "NO";

   return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

max_10000 = Y // 10000
for x in range(max_10000 + 1):
    rem = Y - 10000 * x

    if x > N:
        continue

    max_5000 = rem // 5000

    for y in range(max_5000 + 1):
        if x + y > N:
            continue

        rem_2 = rem - 5000 * y
        if x + y + rem_2 // 1000 == N:
            print('{} {} {}'.format(x, y, rem_2 // 1000))
            exit()


print('{} {} {}'.format(-1, -1, -1))



Measured memory_bytes: 9216
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
      String[] abc = line.split(" ", 0);
		int A = Integer.parseInt(abc[0]);
      int B = Integer.parseInt(abc[1]);
      int C = Integer.parseInt(abc[2]);
      
      if(B == C){
      	System.out.println(A);
      }else if(A == C){
        System.out.println(B);
      }else{
        System.out.println(C);
      }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

vector<v32> poss;
void go(int i, int j, int n, int m, v32 temp)
{
	if (i >= n)
	{
		poss.push_back(temp);
		return;
	}
	for (int k = j; k < m + 1; k++)
	{
		v32 temp1 = temp;
		temp1.push_back(k);
		go(i + 1, k, n, m, temp1);
	}
	return;
}

void solve()
{
	int n, m, q;
	cin >> n >> m >> q;
	vector<pair<p32, p32>> arr(q);
	for (int i = 0; i < q; i++)
	{
		cin >> arr[i].fi.fi >> arr[i].fi.se >> arr[i].se.fi >> arr[i].se.se;
		arr[i].fi.fi--;
		arr[i].fi.se--;
	}
	for (int i = 1; i < m + 1; i++)
	{
		v32 temp;
		go(0, i, n, m, temp);
	}
	db(sz(poss));
	ll ans = 0;
	for (auto vec : poss)
	{
		ll sum = 0;
		for (auto q : arr)
		{
			if (vec[q.fi.se] - vec[q.fi.fi] == q.se.fi)
				sum += q.se.se;
		}
		ans = max(ans, sum);
	}
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

#define fi first
#define se second
#define ll long long

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;

int cnt;
bool used[N];
vector < int > v[N];

void dfs( int x )
{
    if( used[x] ){
        return;
    }
    used[x] = true;
    cnt++;
    if( cnt == 4 ){
        cout << "YES";
        exit(0);
    }
    for( int y : v[x] ){
        dfs(y);
    }
    cnt--;
}

void solve1()
{
    for( int i = 1; i < 4; i++ ){
        int x,y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for( int i = 1; i <= 4; i++ ){
        cnt = 0;
        dfs(i);
        for( int j = 1; j <= 4; j++ ){
            used[j] = false;
        }
    }
    cout << "NO";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 7296
N = int(input())
A = list(map(int, input().split()))
A.sort()
mod = 10 ** 9 + 7
ans = 0
B = []
if N % 2 == 0:
    for i in range(1, N, 2):
        B.append(i)
        B.append(i)
else:
    B.append(0)
    for i in range(2, N, 2):
        B.append(i)
        B.append(i)

if A == B:
    print(2 ** ( N // 2) % mod)
else:
    print(0)


Measured memory_bytes: 13880
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 22:49:34 2020

@author: Aruto Hosaka
"""


N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)

count = A[0]
if N % 2 == 1:
    for n in range(1,(N-1)//2):
        count += 2*A[n]
    count += A[N//2]
else:
    for n in range(1,N//2):
        count += 2*A[n]
print(count)

Measured memory_bytes: 31604
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static boolean ok(String name, String src) {
		if (src.indexOf(name) >= 0) return true;
		for (int i = 2; i < src.length(); ++i) {
			for (int j = 0; j < i; ++j) {
				StringBuilder sb = new StringBuilder();
				int pos = j;
				while (pos < src.length()) {
					sb.append(src.charAt(pos));
					pos += i;
				}
				if (sb.indexOf(name) >= 0) return true;
			}
		}
		return false;
	}

	public static void main(String[] args) {
		int N = sc.nextInt();
		String name = sc.next();
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			if (ok(name, sc.next())) ++ans;
		}
		System.out.println(ans);
	}

}

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

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (d > t*s) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

Measured memory_bytes: 3632
n = int(input())
a = [int(i) for i in input().split()]
answer = 1
for i in range(len(a)):
    answer = answer * a[i]
    if answer > 10 ** 18:
        if 0 in a:
            print(0)
        else:
            print(-1)
        break
else:
    print(answer)


Measured memory_bytes: 21792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		StringBuilder str = new StringBuilder();

		int min = X - K + 1;
		int range = K * 2 - 1;
		for(int i=0; i<range; i++) {
			str.append(min + i);
			str.append(" ");
		}
		sc.close();
		System.out.println(str);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int a,b;
		cin >> a >> b;
		cout<<(a*b)/__gcd(a,b);
	}   
}     

Measured memory_bytes: 256
N = int(input())

pow6 = [6**i for i in range(1,7)]
pow9 = [9**i for i in range(1,6)]

dp = [1e10 for i in range(N+1)]
dp[0] = 0

for i in range(N):
    dp[i+1] = dp[i]+1

    for x in pow6:
        if i+1 - x < 0: break
        dp[i+1] = min(dp[i+1], dp[i+1 - x]+1)
    
    for x in pow9:
        if i+1 - x < 0: break
        dp[i+1] = min(dp[i+1], dp[i+1 - x]+1)
    
print(dp[N])


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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main() {
	vector<int> a;
	
	int n;
	cin >> n;
	int ans = 0;
	int now = 1;
	
	while(ans != n){
		if(ans < n){
			ans += now;
			a.push_back(now);
		}
		if(ans > n){
			remove(a, a.size() - 1);
			ans -= now;
			while(ans < n){
				bool flag = true;
				for(int i = 0; i < a.size() - 1; i++){
					if(a[i+1] - a[i] > 1){
						a[i]++;
						ans++;
						flag = false;
					}
					if(ans == n){
						break;
					}
				}
				if(flag){
					a[a.size() - 1]++;
					ans++;
				}
			}
		}
		now++;
	}
	
	for(int i = 0; i < a.size(); i++){
		cout << a[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	var str string
	fmt.Scan(&str)
 
	if len(str) == 2 {
		fmt.Println(str)
	} else if len(str) == 3 {
		for i := 2; i >= 0; i-- {
			fmt.Print(string(str[i]))
		}
		fmt.Println()
	}
	return
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=b-1;i>=a;i--)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9 +7;
const ll N = 1e12 + 5 ;
ll ans=0;

ll power(ll a,ll b)
{
    ll res=1;
    a%=mod;
    while(b>0)
    {
        if(b%2==1)
        {
            res = (res * a)%mod;
        }
        b/=2;
        a = (a*a)%mod;
    }
    return res;
}



int main()
{
    fast;
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            for(ll k=1;k<=n;k++)
            {
                ll x=__gcd(i,j);
                ans += __gcd(x,k);
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3652
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> A(n); for (auto& a: A) cin>>a;
  int q; cin>>q;
  vector<int> M(q); for (auto& m: M) cin>>m;

  vector<bool> dp(2001, false);
  dp[0]=true;
  for (auto a : A) {
    for (int i = 2000; i >= 0; i--) {
      if (!dp[i])
        continue;
      auto t = i + a;
      if (t <= 2000)
        dp[t] = true;
    }
  }
  for (auto m : M) {
    cout << (dp[m] ? "yes" : "no") << endl;
  }

  return 0;
}



Measured memory_bytes: 3144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back


class UF{
private:
    vector<int> par,rank,elmNum;
    vector<set<int>> elmList;
public:
    int groups;

    UF(int __size):par(__size) , rank(__size,0) , elmNum(__size,1), elmList(__size) , groups(__size){
        rep(i,__size)elmList[i].insert(i);
        for(int i=0;i<__size;i++)par[i]=i;
    }

    int getElementsNum(int n){ return elmNum[find(n)]; }
    set<int> getElementsList(int n){ return elmList[find(n)]; }

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

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;

        groups--;
        if(rank[x]<rank[y]){
            par[x]=y;
            elmNum[y]+=elmNum[x];
            for(auto &e:elmList[x])elmList[y].insert(e);

        }else{
            par[y]=x;
            elmNum[x]+=elmNum[y];
            for(auto &e:elmList[y])elmList[x].insert(e);
            if(rank[x]==rank[y])rank[x]++;
        }
    }

    bool isSame(int x,int y){
        return find(x)==find(y);
    }
};

signed main(){
    int v,e;
    cin>>v>>e;
    UF uf(v);

    vector<int> a(e), b(e);
    rep(i,e){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    reverse(all(a));
    reverse(all(b));

    int tmp = v*(v-1)/2;

    vector<int> ans;
    rep(i,e){
        ans.pb(tmp);
        if(uf.isSame(a[i],b[i])){
            ;
        }else{
            tmp -= uf.getElementsNum(a[i]) * uf.getElementsNum(b[i]);
            uf.unite(a[i], b[i]);
//            cout<<a[i]<<" "<<b[i]<<endl;
//            cout<<uf.getElementsNum(a[i]) <<" "<<uf.getElementsNum(b[i])<<endl;;
        }
    }

    reverse(all(ans));
    for(auto elm:ans)cout<<elm<<endl;

}


Measured memory_bytes: 46068
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> n(N + 2);
    rep(i, 0, N) {
        cin >> P[i];
        n[P[i]] = i + 1;
    }
    long long res = 0LL;
    multiset<int> se; //今見てるやつより大きい数字のindex
    se.insert(0);
    se.insert(0);
    se.insert(N + 1);
    se.insert(N + 1);
    rep(i, 0, N) {
        int t = N - i;
        int p = n[t];
        auto ite = se.lower_bound(p);
        int mae1, mae2, ato1, ato2;
        ++ite;
        ato2 = *ite;
        --ite;
        ato1 = *ite;
        --ite;
        mae2 = *ite;
        --ite;
        mae1 = *ite;
        se.insert(p);
        // cout << "t:" << t << ",p:" << p << ",mae1:" << mae1 << ",mae2:" <<
        // mae2
        //      << ",ato1:" << ato1 << ",ato2:" << ato2 << ",res+="
        //      << (((mae2 - mae1) * (ato1 - p)) + ((p - mae2) * (ato2 - ato1)))
        //      *
        //             t
        //      << endl;
        res += 1LL *
               (((mae2 - mae1) * (ato1 - p)) + ((p - mae2) * (ato2 - ato1))) *
               t;
    }
    cout << res << endl;
}

Measured memory_bytes: 5760
N = int(input())
A = list(map(int, input().split()))

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

leftGcd = [-1] * (N + 1)
leftGcd[0] = A[0]

for i, a in enumerate(A, start=1):
    leftGcd[i] = gcd(leftGcd[i - 1], a)

rightGcd = [-1] * (N + 1)
rightGcd[-1] = A[-1]

for i, a in enumerate(reversed(A), start=1):
    rightGcd[-(i + 1)] = gcd(rightGcd[-i], a)

ans = max(rightGcd[1], leftGcd[-2])
for mid in range(1, N):
    ans = max(ans, gcd(leftGcd[mid], rightGcd[mid + 1]))

print(ans)

Measured memory_bytes: 14428
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		String ans = "";
		
		for(int i=0;i<k;i++) {
			ans += "ACL";
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 38532
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IO

main = do
  n <- readLn :: IO Int
  a <- getIntListBC
  b <- getIntListBC
  let (x, y) = solve (zip a b) (0, 0)
      sa = sum a
      sb = sum b
      diff = sb - sa
  if (diff-x)*2 == (diff-y) && diff >= x && diff >= y
    then putStrLn "Yes"
    else putStrLn "No"

solve :: [(Int, Int)] -> (Int, Int) -> (Int, Int)
solve [] (x, y) = (x, y)
solve ((a,b):s) (x, y)
  | a < b =
  let c = if odd (b-a)
            then (+1) $ div (b-a) 2
            else div (b-a) 2
  in solve ((a+c*2, b):s) (x+c, y)
  | a > b =
  let c = a-b
  in solve ((a, b+c):s) (x, y+c)
  | otherwise = solve s (x, y)

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine


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

int main() {
	
	float n;
	int i,count = 0;
	
	cin>>n;
	
	for(i = 1 ; i <= n ; i++)
	{
	    if(i % 2 != 0)
	    count++;
	}
	//cout<<"count: "<<count<<endl;
	
	float sum = count / n;
	
	printf("%.10f\n",sum);
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

res = float("inf")
for x in range(min(A), max(A) + 1):
    cost = 0
    for j in range(n):
        y = A[j]
        cost += pow(x - y, 2)
    res = min(res, cost)
print(res)


Measured memory_bytes: 3060
#include<iostream>
#include<string>

using namespace std;

int main(){

	string inp;
	bool f=false,f2=false,f3=false,f4=false;

	cin>>inp;

	for(int i=0;i<inp.size();i++){
		if(inp[i]>='a'&&inp[i]<='z') f=true;
		else if(inp[i]>='A'&&inp[i]<='Z') f2=true;
		else if(inp[i]>='0'&&inp[i]<='9') f3=true;
	}

	if(inp.size()>=6) f4=true;

	if(f&&f2&&f3&&f4) cout<<"VALID"<<endl;
	else cout<<"INVALID"<<endl;
	return 0;
}

Measured memory_bytes: 1180
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a[5];

int main()
{
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a , a + 3);
	printf("%d\n",a[0] + a[1]);
	return 0;
}
	

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int main() {
   int n = 0;
   double N = 0;
   int M = 0;
   int L = 100;
   int c = 0;
  scanf("%d", &n);
  for (int i = 0;i < n; i++) {
   N = L;
   M = L;
   c = 0;
   N *= 1.05;
   N -= M;
  while (N > 1) {
   N -= 1;
   c += 1;
  }
  if ( N > 0) {
   L += 1;
   }
   L += c;

  }

 L *= 1000;
 printf("%d\n", L);
  return 0;
}

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

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

    string s; cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 != 0 && s[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 0 && s[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;

int main () {
  int N;
  while (cin >> N) {
    map<int, int> m;
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      m[a]++;
    }
    if (m.size() == 1) {
      int a = m.begin()->first;
      if (a == 0) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else if (m.size() == 2) {
      pair<int, int> a = *m.begin();
      pair<int, int> b = *(++m.begin());
      if (a.first != 0) swap(a, b);
      if (a.first == 0 && a.second * 2 == b.second) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else if (m.size() == 3) {
      vector<pair<int, int> > v;
      for (auto p: m) {
        v.push_back(p);
      } if (v[0].second == v[1].second && v[1].second == v[2].second &&
            (v[0].first ^ v[1].first) == v[2].first) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3840
N,M,Q=map(int,input().split())
R=[list(map(int,input().split())) for i in range(Q)]
S=[1]*N

def dfs(d):
  if d==N-1:
    t=0
    for a,b,c,d in R:
      if S[~-b]-S[~-a]==c:
        t+=d
    return t
  else:
    m=0
    for i in range(S[d],M+1):
      S[d+1]=i
      m=max(m,dfs(d+1))
    return m

print(dfs(0))


Measured memory_bytes: 9140