akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define mod 1000000007
#define pb push_back  
#define endl "\n"
#define fi first
#define se second 
#define ll long long
int power(int a,int b,int m=mod)
{
    if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
     
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}

int32_t main()
{
   IOS
   
   double d,t,s;
   cin>>d>>t>>s;
   
   if((d/s)<=t)
   {
   	cout<<"Yes"<<endl;
   }
   else
   {
   	cout<<"No"<<endl;
   }
   
}

Measured memory_bytes: 3732
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main () {
  int n;
  cin >> n;
  ll result = 0, temp;
  std::vector<ll> a(n+1),b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) {
    if(a[i] - b[i] > 0) result += b[i];
    else {
      result += a[i];
      temp = b[i] - a[i];
      if(a[i+1] - temp > 0) {
        result += temp;
        a[i+1] -= temp;
      } else {
        result += a[i+1];
        a[i+1] = 0;
      }
    }
  }
  cout << result << endl;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=-1,sum=0,cnt=0;
  while(ans==-1&&cnt++<10000000){ 
    if(sum%60+a<c||sum%60>c)sum+=a+b;
    else ans=sum+(c-sum%60);

  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1164
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

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

    if(h > w) swap(h,w);
    int sum = 0;
    for(int i = 1;i <= h;++i){
        sum += w;
        if(sum >= n) return cout << i << '\n',0;
    }



    return 0;
}


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

#define REP(i,n) for(int i=0;i<int(n);i++)
#define MP make_pair

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr LL INF = 1LL << 60;

int returnMinDistance(vector<pair<int,LL>> &d, vector<bool> &inq) {
    int index = -1;
    REP(i,d.size()) {
        if (!inq[i]) continue;
        if (index == -1) {
            index = i;
        } else {
            if (d[index] > d[i]) index = i;
        }
    }
    return index;
}

void Dijkstra(int s, VVLL &g, vector<pair<int,LL>> &d, LL &l) {
    REP(i,d.size()) d[i] = MP(d.size(),INF);
    d[s] = MP(0,0);
    vector<bool> inq(d.size(), true);
    REP(i,d.size()) {
        int index = returnMinDistance(d,inq);
        inq[index] = false;
        REP(j,d.size()) {
            if (g[index][j] == INF) continue;
            pair<int,LL> tmp;
            tmp.first = d[index].first;
            tmp.second = d[index].second + g[index][j];
            if (tmp.second > l) {
                tmp.first++;
                tmp.second = g[index][j];
            }
            d[j] = min(d[j], tmp);
        }
    }
}

int main() {
    LL n,m,l;
    cin >> n >> m >> l;
    int a,b,c;
    VVLL es(n,VLL(n,INF));
    REP(i,m) {
        cin >> a >> b >> c;
        --a; --b;
        if (c > l) continue;

        es[a][b] = min(es[a][b], (LL)c);
        es[b][a] = min(es[b][a], (LL)c);
    }

    vector<vector<pair<int,LL>>> d(n,vector<pair<int,LL>>(n));
    REP(i,n) Dijkstra(i,es,d[i],l);

    int q,s,t;
    cin >> q;
    REP(i,q) {
        cin >> s >> t;
        --s; --t;
        if (d[s][t].first == n) cout << -1 << endl;
        else cout << d[s][t].first << endl;        
    }
    return 0;
}

Measured memory_bytes: 2688
n,k=[int(j) for j in input().split()]
h=[]
for i in range(n):
    h.append(int(input()))
h.sort()

ans=1000000000000000

for i in range(n-k+1):
    small=h[i]
    big=h[i+k-1]
    ans=min(ans,big-small)
    
print(ans)

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

int main() {
    int N;
    cin >> N;
    
    int ans = 0;
    
    // 対象が奇数のみなのでステップ数は2
    for (int i = 1; i <= N; i += 2) {
        int cnt = 0;
        // 正の約数カウンタ
        
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) ++cnt;
        }
        
        if (cnt == 8) ++ans;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int N = 200000 + 5;

int main(){
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	if(k > a){
		sum += a;
		k -= a;
		if(k > b){
			k -= b;
			if(k > c){
				sum -= c;
			}
			else
				sum -= k;
		}
	}
	else
		sum += k;
	cout << sum << endl;
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int> >  c(10, vector<int>(10));
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> c[i][j];
        }
    }

    // この順番 k, i, j
    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    vector<int> a;
    for(int i=0; i<h*w; i++){
        int aaa;
        cin >> aaa;
        if(aaa>=0){
            a.push_back(aaa);
        }
    }
    int ans = 0;
    for(auto aa: a){
        ans += c[aa][1];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))

X, Y, Z, K = inpl()
A = [ sorted(inpl(), key=lambda x: -x) for _ in range(3) ]
N = [X, Y, Z]

mem = defaultdict(int)
ans = sum([A[i][0] for i in range(3)])
mem[(0,0,0)] = 1
cand = [(ans,0,0,0)]

for i in range(K):
    cand.sort()
    c = cand[-1]
    print(c[0])
    n = [c[1],c[2],c[3]]
    cand.pop(-1)
    
    for p in range(3):
        if n[p] < N[p]-1:
            n[p] += 1
            if mem[(n[0],n[1],n[2])] == 0:
                mem[(n[0],n[1],n[2])] = 1
                cand.append((sum([A[j][n[j]] for j in range(3)]),n[0],n[1],n[2]))
            n[p] -= 1

Measured memory_bytes: 5088
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $t1=0;
  $x1=0;
  $y1=0;
  for($i=0;$i<$n;$i++){
    list($t,$x,$y) = explode(" ", trim(fgets(STDIN)));
    $ido=($t-$t1)- abs($x-$x1) - abs($y-$y1);
    if($ido >= 0 && $ido % 2 == 0){
    }else{
      echo "No";
      exit;
    }

    $t1=$t;
    $x1=$x;
    $y1=$y;
  }
  echo "Yes";
  exit;

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

int main() {
    int N, x;
    cin >> N >> x;
    vector<long long> A(N + 1);
    for (int i = 1; i <= N; i++)
        cin >> A[i];
    A[0] = 0;

    long long res = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] + A[i + 1] > x) {
            res += A[i + 1] + A[i] - x;
            A[i + 1] -= A[i + 1] + A[i] - x;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int main(){

  vector<int>a;
  int tmp;
  char b,c;
  char d;
  a.push_back(1);
  a.push_back(0);
  a.push_back(0);
  
  while(cin >> b >> d >> c!='\0'){

    if(a[b-'A']!=0||a[c-'A']!=0)
      swap(a[b-'A'],a[c-'A']);


  }
  for(int i=0;i<3;i++){
    if(a[i]==1)
      cout << (char)(i+'A') << endl;
  }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n;
    cin >> n;
    int maxi = -123456;
    int freq[100000 + 3] = {0};
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        maxi = max(maxi, a);
        freq[a]++;
    }
    vector<int> sizes(maxi + 3);
    sizes[0] = 0;
    for(int i = 1; i <= maxi; i++)
    {
        if(freq[i] == 0)
            sizes[i] = sizes[i - 1];
        else
        {
            sizes[i] = sizes[i - 1] + freq[i];
        }
    }
    long long ans = 0;
    for(int i = 1; i <= maxi; i++)
    {
        if(sizes[i] == n - sizes[i])
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
S_dash = input()
T = input()

len_S = len(S_dash)
len_T = len(T)

candidate = []

# まず T と一致させられる位置があるかを調べる
for i in range(len_S - len_T + 1):
  # print(S_dash[i:i+len_T])
  tmp = S_dash[i:i+len_T]
  
  count = 0
  for s, t in zip(tmp, T):
    if s == t or s == '?':
      count += 1
  if count == len_T:
    candidate.append(S_dash[:i] + T + S_dash[i+len_T:])
    
if candidate != []:       
  replaced_candidate = [item.replace("?", "a") for item in candidate]
  replaced_candidate.sort()
  print(replaced_candidate[0])
else:
  print("UNRESTORABLE")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        long[] A = cin.arrayLong();

        int count = 0;
        long min = 1000000001;
        long sum = 0;

        for (int i = 0; i < N; i++)
        {
            if (A[i] < 0)
            {
                count++;
            }

            min = Math.Min(min, Math.Abs(A[i]));
            sum += Math.Abs(A[i]);
        }

        if (count % 2 == 0)
        {
            Console.WriteLine(sum);
        }
        else
        {
            Console.WriteLine(sum - 2 * min);
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 29020
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n;

int main() {
    while (cin >> n) {
        if (n == 0) break;
        int rem = 1000-n;
        
        int res = 0;
        res += rem/500; rem %= 500;
        res += rem/100; rem %= 100;
        res += rem/50; rem %= 50;
        res += rem/10; rem %= 10;
        res += rem/5; rem %= 5;
        res += rem;
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1160
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
ab.sort(key=lambda x: x[1])


s = ab[0][0]
e = ab[0][1]
ans = 1

for i in range(m):
    if (ab[i][0] <= s and e <= ab[i][1]) or s < ab[i][0] < e or s < ab[i][1] < e:
        continue

    ans += 1
    s = ab[i][0]
    e = ab[i][1]

print(ans)


Measured memory_bytes: 64728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	string s,t;
	ll i,j,f=0,n,k,m=0,l=0;
	cin>>s;
	cin>>t;
	n=s.length();
	k=t.length();
	for(i=0;i<=n-k;i++)
	{
		for(j=i;j<i+k;j++)
		{
			if(s[j]==t[l])
			{
				f++;
			}
			l++;
		}
		m=max(m,f);
		l=0;
		f=0;
	}
	cout<<k-m<<endl;return;
}





int main()
{
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}


	return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;

	void doIt() {
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int cnt = 0;
		for(int i = 0; i < N - 2; i++) {
			if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
				cnt++;
		}
		System.out.println(cnt);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define ll long long
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define deb(x) cout << #x << "=" << x << endl;
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

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

ll inv(const ll& a)
{
    return bin(a, mod-2)%mod;
}

ll fact[2000005];
ll inverse[2000005];

ll ncr(ll n, ll r)
{
    if(r==0 || n==r)
        return 1;

    return ((fact[n]%mod) * (((inverse[r] % mod) * (inverse[n-r]%mod)%mod))%mod)%mod;
}

int main() {
    fact[0] = 1;
for(ll i = 1; i<=2000000; ++i) 
    fact[i] = fact[i-1]*i, fact[i] %= mod;
for(ll i = 0; i<=2000000; ++i)
    inverse[i] = inv(fact[i])%mod;
    fastio
    ll n;
    cin>>n;

    if(n==1) {
        cout<<0<<endl;
        return 0;
    }
    ll ans = 0;
    for(int i = 0; i<=n; ++i) {
        ans += (i!=0?2:1)*ncr(n, i)*(bin(8, n-i));
        ans %= mod;
    }
    //cout<<ans<<endl;
    cout<<(bin(10, n) - ans + mod)%mod<<endl;
}

Measured memory_bytes: 34896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int n, a, b, c, d, e, ma, mi = INF;
int main() {
	while (1) {
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; ++i) {
			cin >> a >> b >> c >> d >> e;
			int mon = a + b + c + d + e;
			ma = max(ma, mon);
			mi = min(mi, mon);
		}
		cout << ma << " " << mi << endl;
		mi = INF;
		ma = 0;
	}
}


Measured memory_bytes: 3084
x,k,d = map(int,input().split())
ans = 0

x = abs(x)

if x-k*d > 0:
  ans = x-k*d
else:
  if (k-(x//d))%2 == 0: #右
    ans = x-(x//d)*d    
  else:
    ans = abs(x-(x//d+1)*d)  

print(ans)    


Measured memory_bytes: 9204
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int n, l;
    cin >> n >> l;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    stack<int> ans;
    rep(i, n-1){
        if(a[i] + a[i+1] >= l){
            ans.push(i+1);
            break;
        }
    }

    if(ans.empty()){
        cout << "Impossible" << endl;
        return 0;
    }

    int x = ans.top();
    for(int i = x - 1; i > 0; i--){
        ans.push(i);
    }
    for(int i = x + 1; i < n; i++){
        ans.push(i);
    }

    cout << "Possible" << endl;
    while(!ans.empty()){
        cout << ans.top() << endl;
        ans.pop();
    }

    return 0;
}


Measured memory_bytes: 2296
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,y;
	cin>>n>>y;
	for(int i=0;i<(n+1)*(n+1);i++){
		int a,b,c;
		a=i%(n+1);
		b=i/(n+1);
		c=n-a-b;
		if(c<0)
			continue;
		if(a*10000+b*5000+c*1000==y){
			cout<<a<<' '<<b<<' '<<c<<endl;
			return 0;
		}
	}
	cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256
// {{{ include
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
// }}}

//{{{ uf.hpp
#ifndef INCLUDE_UF_HPP
#define INCLUDE_UF_HPP
#include <vector>
#include <algorithm>
namespace orliv {
//{{{ UF merge, same, root, size, count
struct UF {
  std::vector<int> data;
  int cnt;
  UF(int n) : data(n, -1), cnt(n) {}
  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if (a != b){
      cnt--;
      data[a] += data[b];
      data[b] = a;
    }
    return a != b;
  }
  bool same(int a, int b){ return root(a) == root(b); }
  int root(int a){ return data[a] >= 0 ? data[a] = root(data[a]) : a; }
  int size(int a){ return -data[root(a)]; }
  int count(){ return cnt; }
};
//}}}
}
#endif
//}}}

using namespace std;
using namespace orliv;

typedef long long ll;
typedef pair<char, int> QT;

inline int in(){int x;scanf("%d",&x);return x;}

int par[100100];
int B[100100];

int main()
{
  int N, Q;
  while (N = in(), Q = in()){
    memset(B, 0, sizeof(B));
    for (int i = 2; i <= N; i++) par[i] = in();
    UF uf(N + 1);
    vector<QT> Qs;
    Qs.reserve(Q);
    for (int i = 0; i < Q; i++){
      char S[4];
      int v;
      scanf("%s %d", S, &v);
      Qs.push_back(QT(*S, v));
      if (*S == 'M' && !B[v]++) par[v] = -par[v];
    }
    par[1] = 1;
    for (int i = 2; i <= N; i++){
      if (par[i] < 0) par[i] = -par[i];
      else uf.merge(par[i], i);
    }
    reverse(Qs.begin(), Qs.end());
    ll ans = 0;
    for (const auto& q : Qs){
      int v = q.second;
      if (q.first == 'Q') ans += uf.root(v);
      else if (!--B[v]) uf.merge(par[v], v);
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3140
#include <stdio.h>
#include <cctype>
using namespace std;

int main(void){
	char ch = ' ';

	while(true){
		scanf("%c", &ch);

		if (islower(ch)) printf("%c",(char)toupper(ch));
		else if (isupper(ch))  printf("%c", (char)tolower(ch));
		else  printf("%c", ch);

		if (ch == '\n')	break;
	}

	return 0;
}

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define endl            "\n"

#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define mii             map <int, int>
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))


#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

const int inf = INT_MAX;
const long long INF = LLONG_MAX;

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e5 + 7;
vector <vi > adj(N);

bool vis[N];

int dp[100005][2];
int n;


void solve()
{
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s) {
		a--;
	}
	else if (u == t) b--;
	cout << a << " " << b << endl;

	return;
}

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

	cout << setprecision(9) << fixed;

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


	return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

ll gcd(ll x,ll y){
  if(y == 0)return x;
  return gcd(y,x % y);
}

ll lcm( ll m, ll n ){
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main(){
  ll ans = 1;
  cin >> n;
  vll vec;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
  }
  sort(all(vec));
  rep(i,0,vec.sz){
    ans = lcm(ans,vec[i]);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
bool dp[36],d2[4364];
int main()
{
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	memset(dp,false,sizeof(dp));
	dp[0]=true;
	rep(i,32){
		if(!dp[i]) continue;
		if(i+a<32) dp[i+a]=true;
		if(i+b<32) dp[i+b]=true;
	}
	memset(d2,false,sizeof(d2));
	d2[0]=true;
	rep(i,3640){
		if(!d2[i]) continue;
		if(i+c<3640) d2[i+c]=true;
		if(i+d<3640) d2[i+d]=true;
	}
	int o1=1,o2=0;
	rep(i,32) rep(j,3640){
		if(!dp[i] || !d2[j] || i<1) continue;
		if(i*100+j>f) continue;
		if(j>i*e) continue;
		int x=j*o1-(i*100+j)*o2;
		if(x>0 || (x==0 && o1<i*100+j)){
			o1=i*100+j;o2=j;
		}
	}
	cout<<o1<<' '<<o2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    bool flag = true;
    int moji[26];
    for (int i = 0; i < 26; ++i) moji[i] = 0;
    for (int i = 0; i < s.length(); ++i) moji[s[i]-'a']++;
    for (int i = 0; i < 26; ++i) if (moji[i]%2 != 0) flag = false;
    if (flag) cout << "Yes" << std::endl;
    else cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
p,M,f=pow,1000003,[1]
for i in range(1,M):f.append(f[i-1]*i%M)
for _ in'_'*int(input()):x,d,n=map(int,input().split());t=x*p(d,M-2,M)%M;print([p(x,n,M),(M-n>=t>0)*1and f[t+n-1]*p(f[t-1],M-2,M)*p(d,n,M)%M][d>0])

Measured memory_bytes: 94188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s,ss;

	cin >> a >> b >> x;

	ans = b / x - a / x;
	if(a % x == 0) {
		ans++;
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int a,b;
int main(){
  cin>>a>>b;
  if(b%a==0){
    cout<<a+b<<endl;
  } else {
    cout<<b-a<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e3+10;
vector<ll>vec[mx];

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n, q;
cin>>n>>q;
for(ll i=1;i<=q;i++){
    int ques, sub, value, size_q;
    cin>>ques;
    switch(ques){
        case 0: cin>>sub>>value;
                vec[sub].push_back(value);
                break;
        case 1: cin>>sub;
                size_q=vec[sub].size();
                if(0==size_q) printf("\n");
                else{
                    for(int j=0;j<size_q;j++){
                        if(0==j) printf("%lld", vec[sub][j]);
                        else printf(" %lld", vec[sub][j]);
                    }
                    printf("\n");
                }
                break;
        case 2: cin>>sub;
                vec[sub].clear();
                break;
    }
}


#ifdef LOCAL
fin.close();
#endif // LOCAL
}




Measured memory_bytes: 8784
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ara[202];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s,t;

  int a,b;
  cin>>a>>b;
  int x=b;
  for(int i=0;i<a;i++)
  {
    ara[i]=x--;
  }
  for(int i=a;i<2*a-1;i++)
  {
    ara[i]=++b;
  }
  sort(ara,ara+2*a-1);
  for(int i=0;i<2*a-1;i++)cout<<ara[i]<<" ";

  return 0;

}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;
typedef long long ll;
int main(){
    ll l,r,ans=2019;
    scanf("%lld %lld",&l,&r);
    for(ll i=l;i<=min(l+2019,r);i++){
        for(ll j=i+1LL;j<=min(l+2019,r);j++){
            ans=min(ans,i*j%2019);
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
 	string s, t;
 	cin >> s;

 	for (int i = 0; i < s.length()/2; i ++){
 		t += "hi";
 	}
 	if (s == t){
 		cout << "Yes" << endl;
 	}else{
 		cout << "No" << endl;
 	}
 	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans=0
for i in range(1,n+1):
    a=str(i)[0]
    b=str(i)[-1]
    for digit in range(1,7):
        if digit == 1:
            if a==b:
                ans+=1
        elif b!='0':
            mn = int(b+'0'*(digit-2)+a)
            mx = int(b+'9'*(digit-2)+a)
            if mn>n:
                break
            if mx<=n:
                ans+=10**(digit-2)
            else:
                ns=str(n)
                for j in range(1,len(ns)-1):
                    ans+=int(ns[j])*10**(max(digit-2-j,0))
                if ns[-1]>=a:
                    ans+=1
                break


print(ans)





Measured memory_bytes: 44908
<?php  
//fscanf(STDIN,"%d",$n);
$x = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<5;$i++){
  if($x[$i]==0){
    echo ($i+1);
    exit;
  }
}

//$juge ? echo 'YES' : echo 'NO';
//echo $n;

Measured memory_bytes: 16080
#include<cstdio>
#include<algorithm>
#include<vector>
#include<tuple>

using namespace std;

int main(){
	int n, m; scanf("%d %d", &n, &m);
	vector<vector<tuple<int, int>>> v(n + 1);
	for(int i = 0; i < m; i++){
		int p, y; scanf("%d %d", &p, &y);
		v[p].push_back(make_tuple(y, i));
	}
	for(int i = 0; i <= n; i++) sort(v[i].begin(), v[i].end());
	char res[100000][20];
	for(int i = 0; i <= n; i++) for(int j = 0; j < v[i].size(); j++){
		sprintf(res[get<1>(v[i][j])], "%06d%06d", i, j + 1);
	}
	for(int i = 0; i < m; i++) puts(res[i]);
	return 0;
}

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

int dp[100005][3];
int a[100005], b[100005], c[100005];
int main()
{
  	int n; cin >> n;
  	for (int i=1; i<=n; i++) cin >> a[i] >> b[i] >> c[i];
  	dp[0][0] = dp[0][1] = dp[0][2] = 0;
  
  	for (int i=1; i<=n; i++)
    {
      dp[i][0] = max (dp[i-1][1], dp[i-1][2]) + a[i];
      dp[i][1] = max (dp[i-1][2], dp[i-1][0]) + b[i];
      dp[i][2] = max (dp[i-1][1], dp[i-1][0]) + c[i];
    }
  	cout << max( max(dp[n][0], dp[n][1]), dp[n][2]);
  
	return 0;  
}


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

using ll=long long;

int main() {
  int N; cin >>N;
  vector<int> L(N*2);
  rep(i,0,N*2) {cin >>L[i];}
  sort(L.begin(),L.end());
  int ans=0;
  for (int i=1;i<N*2;i+=2) {
    ans+=min(L[i],L[i-1]);
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3608
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        //var A = long.Parse(Console.ReadLine());
        //var N = long.Parse(Console.ReadLine());
        //var NXT = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        long sum = 0;
        for (int i = 0; i < S.Length; i++)
        {
            var num = S[i] - '0';
            sum += num;
        }

        Console.WriteLine(sum%9 == 0 ? "Yes" : "No");
        
    }



}


public class PriorityQueue<T> : IEnumerable<T>
{
    private readonly List<T> _data = new List<T>();
    private readonly IComparer<T> _comparer;
    private readonly bool _isDescending;

    public PriorityQueue(IComparer<T> comparer, bool isDescending = true)
    {
        _comparer = comparer;
        _isDescending = isDescending;
    }

    public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
        : this(Comparer<T>.Create(comparison), isDescending)
    {
    }

    public PriorityQueue(bool isDescending = true)
        : this(Comparer<T>.Default, isDescending)
    {
    }

    public void Enqueue(T item)
    {
        _data.Add(item);
        var childIndex = _data.Count - 1;
        while (childIndex > 0)
        {
            var parentIndex = (childIndex - 1) / 2;
            if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
                break;
            Swap(childIndex, parentIndex);
            childIndex = parentIndex;
        }
    }

    public T Dequeue()
    {
        var lastIndex = _data.Count - 1;
        var firstItem = _data[0];
        _data[0] = _data[lastIndex];
        _data.RemoveAt(lastIndex--);
        var parentIndex = 0;
        while (true)
        {
            var childIndex = parentIndex * 2 + 1;
            if (childIndex > lastIndex)
                break;
            var rightChild = childIndex + 1;
            if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0)
                childIndex = rightChild;
            if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
                break;
            Swap(parentIndex, childIndex);
            parentIndex = childIndex;
        }
        return firstItem;
    }

    public T Peek()
    {
        return _data[0];
    }

    private void Swap(int a, int b)
    {
        var tmp = _data[a];
        _data[a] = _data[b];
        _data[b] = tmp;
    }

    private int Compare(T a, T b)
    {
        return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
    }

    public int Count => _data.Count;

    public IEnumerator<T> GetEnumerator()
    {
        return _data.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

Measured memory_bytes: 26672
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n;
ll k;
ll a[200005], f[200005];

bool check(ll lw){
	ll k1 = k;
	rep(i, n){
		if((a[i] * f[i]) <= lw) continue;
		ll l = ((a[i] * f[i]) - lw + f[i] - 1) / f[i];
		if(l > k1) return 0;
		k1 -= l;
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> f[i];
	sort(a, a + n);
	sort(f, f + n);
	reverse(f, f + n);
	ll l = 0, r = 1e13;
	while(l < r){
		ll mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3328
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}
	
	long inv(long a,long M) {
		return a==1?a:(M+(-M*inv(M%a,a)+1)/a);
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		if (N==1) {
			System.out.println(1);
			return;
		}
		N*=2;
		long ans=Long.MAX_VALUE;
		for (long d=2;d*d<=N;++d) if (N%d==0) {
			for (long P:new long[] {d,N/d}) {
				long Q=N/P;
				if (gcd(P,Q)!=1) continue;
				long u=inv(P,Q);
				long v=(u*P-1)/Q;
				ans=Math.min(ans, v*Q);
			}
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 36752
#include<stdio.h>

int solve(int,int);
int n,A[2000];

int main(){
  int q,M[2000],i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
    if(solve(0,M[i])) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res =solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

  
  



Measured memory_bytes: 2104
#include <stdio.h>

void euqlid(int,int);

int main(){
	int x, y, n;
	scanf("%d%d",&x,&y);
	if(x<y){
		n=x;
		x=y;
		y=n;
	}
	euqlid(x,y);
	return 0;
}

void euqlid(int x,int y){
	int n;
	n=x%y;
	while(n!=0){
		x=y;
		y=n;
		n=x%y;
	}
	printf("%d\n",y);
}


Measured memory_bytes: 2128
##templete
n = gets.chomp.to_i
a = gets.chomp.split(" ").map { |e| e.to_i }.sort

def div_array(x, res)
  index = 0
  num = 100000
  num.times do |i|
    if x % (i+1) == 0
      res[index] = i+1
      res[index+1] = x/(i+1)
      index += 2
    end
  end
  res.sort.uniq
end

lst0 = div_array(a[0], [])
lst1 = div_array(a[1], [])
lst = (lst0 + lst1).uniq

hash = {}

for x in lst do
  hash[x] = 0
end

for num in a do
  for x in lst do
    if num % x == 0
      hash[x] += 1
    end
  end
end

ans = 0

for i in lst.reverse do
  if hash[i] == n-1 || hash[i] == n
    puts i
    exit 0
  end
end


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,i,j,ans = 0,c = 0;scanf("%lld\n",&n);
  string s[n];char t[10];
  for(i=0;i<n;i++){
    scanf("%s\n",t);
    sort(t,t+10);
    string k(t,10);
    s[i] = k;
  }
  sort(s,s+n);
  for(i=1;i<n;i++){
    if(s[i]==s[i-1]) c++;
    else c = 0;
    ans += c;
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    double avg = (a[0]+a[1])/2.0;
    for(int i=2;i<n;i++)
    {
        avg = (avg+a[i])/2.0;
    }
    cout << fixed << avg << setprecision(5) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define left(x) x * 2
#define right(x) x * 2 + 1

#define eb emplace_back

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define ml " "
#define nl endl

#define lb lower_bound
#define ub upper_bound

#define fo(i, a, b) for (int i = a; i <= b; ++ i)
#define foo(i, a, b) for (int i = a; i >= b; -- i)

#define srt(a, n) sort(a, a + n)

const int N = 4e6 + 10;
const int sz = 1 << 17;
const int MOD = 1e9 - 7;
const int INF = 4e5 + 7;

int d[N];

vector <int> g[N];

bool u[N], u2[N];

queue <int> q;

int n, d2[N];

int bfs(int x) {
	q.push(x);
    d[x] = 0;
    u[x] = 1;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int i = 0; i < (int)g[v].size(); ++ i)
        {
            int to = g[v][i];
            if (!u[to])
            {
                u[to] = 1;
                q.push(to);
                d[to] = d[v] + 1;
            }
        }
    }
    int mx = 0;
    int pos = 0;
    for (int i = 1; i <= n; ++ i) {
   		if (mx < d[i]) {
   			mx = d[i];
   			pos = i;
   		}
    }
   	return pos;
}

int bfs1(int x) {
	q.push(x);
    d2[x] = 0;
    u2[x] = 1;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int i = 0; i < (int)g[v].size(); ++ i)
        {
            int to = g[v][i];
            if (!u2[to])
            {
                u2[to] = 1;
                q.push(to);
                d2[to] = d2[v] + 1;
            }
        }
    }
    int mx = 0;
    for (int i = 1; i <= n; ++ i)
    	mx = max(d2[i], mx);
    return mx;
}

main (){
	clog << "Ready\n";
	
	cin >> n;
	
	for (int i = 1; i < n; ++ i) {
		int x, y;
		cin >> x >> y;
		g[x].eb(y);
		g[y].eb(x);
	}
	
	int f = bfs(1); 
	
	int d = bfs1(f);
	
	cout << (d % 3 == 1 ? "Second" : "First");
	
	cerr << '\n';
}

Measured memory_bytes: 109300
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{

    class Program
    {
        public static int[] preOrder, inOrder;
        public static List<int> postOrder= new List<int>();
        public static int pos = 0;
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            preOrder = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            inOrder = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Reconstruct(0, n);
            for (int i = 0; i < n - 1; i++) Console.Write(postOrder[i] + " ");
            Console.WriteLine(postOrder[n - 1]);
        }
        private static void Reconstruct(int left, int right) 
        {
            if (left >= right) return;
            int root = preOrder[pos++];
            int m = Array.IndexOf(inOrder, root);
            Reconstruct(left, m);
            Reconstruct(m + 1, right);
            postOrder.Add(root);
        }
    }
}



Measured memory_bytes: 17912
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n,m = iim()
A = iil()

print(max(-1,n-sum(A)))

Measured memory_bytes: 9880
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, K);
  GS(S);
  S[K - 1] += 'a' - 'A';
  print(S);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
int N,D,X;
cin >> N >> D >> X;
vector<int> cho(N);
int cnt = 0;
for (int i = 0;i < N;i++) {
    cin >> cho.at(i);
    for (int j = 0;j * cho.at(i)+1 <= D;j++) {
        cnt++;
    }
}
cout << cnt + X << endl;





return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	x, _ := strconv.Atoi(stringLineScan())
	y := 1
	p := make(map[int]int, 0)
	p[1] = 1
	for i := 1; i <= n; i++ {
		p[y*2+3] = p[y]*2 + 1
		y = y*2 + 3
	}
	fmt.Println(eat(y, x, p))
}
func eat(l int, x int, p map[int]int) int {
	if x == 0 {
		return 0
	} else if l == 1 {
		return 1
	} else if l == x {
		return p[l]
	} else {
		d := (l - 3) / 2
		if x < d+2 {
			return eat(d, x-1, p)
		} else {
			return eat(d, x-d-2, p) + p[d] + 1
		}
	}
}


Measured memory_bytes: 640