akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = (1LL << 50);
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, Q; cin >> n >> m >> Q;
    vll a(n); for(auto& e : a) cin >> e;
    vll b(m); for(auto& e : b) cin >> e;
    vll X(Q); for(auto& e : X) cin >> e;

    a.emplace_back(-INF); a.emplace_back(+INF);
    b.emplace_back(-INF); b.emplace_back(+INF);
    sort(_all(a)); sort(_all(b));

    for(auto& x : X){
        auto itr_a = lower_bound(_all(a), x);
        auto itr_b = lower_bound(_all(b), x);

        int ra = itr_a - begin(a), la = ra - 1;
        int rb = itr_b - begin(b), lb = rb - 1;

        ll dra = a[ra] - x, dla = x - a[la];
        ll drb = b[rb] - x, dlb = x - b[lb];

        ll res = min({max(dra, drb), max(dla, dlb),
                      2 * dra + dlb, 2 * dlb + dra,
                      2 * drb + dla, 2 * dla + drb});

        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 3680
use std::collections::BinaryHeap;
use std::cmp;

fn main(){
    let mut sc = Scanner::new();
    let n = sc.next();
    let x : i64 = sc.next();
    let mut a = vec![0i64; n];
    for e in a.iter_mut() { *e = sc.next(); }
    let mut ans = a.iter().fold(0, |x, y| x + y);
    a.resize(n*2, 0);
    for i in 0..n { a[i+n] = a[i]; }

    for mg in 1..n {
        let mut s:BinaryHeap<(i64, usize)> = (n-mg..n).map(|i| (-a[i], i)).collect();
        let mut del = vec![false; n*2];
        let mut cand = x*mg as i64;
        for j in n..n+n {
            while del[s.peek().unwrap().1] {
                s.pop();
            }
            let min = *s.peek().unwrap();
            // println!("min: {} {}", min.0, min.1);
            cand += cmp::min(-min.0 as i64, a[j]);
            del[j-mg] = true;
            s.push((-a[j], j));
        }
        ans = cmp::min(ans, cand);
    }
    println!("{}", ans);
}

// Scanner

#[allow(dead_code)]
struct Scanner {
    token_buffer : Vec<String>,
    index : usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner{
        Scanner { token_buffer: vec![], index: 0 }
    }

    fn wrapped<T>(& mut self) -> Result<T,&str> where T: std::str::FromStr {
        let s = try!(self.fetch_token());
        let t = try!(s.parse::<T>().map_err(|_| "Parse error"));
        Ok(t)
    }
    fn next<T>(& mut self) -> T where T: std::str::FromStr {
        self.wrapped::<T>().unwrap()
    }

    fn fetch_token(&mut self) -> Result<&String,&str> {
        while self.index >= self.token_buffer.len() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    Ok(_)  => return Err("End of file"),
                    Err(_) => return Err("Failed to read line"),
                }
            }
            self.token_buffer = st.split_whitespace()
                .map(|x| x.to_string())
                .collect();
            self.index = 0;
        }

        self.index += 1;
        Ok(&self.token_buffer[self.index - 1])
    }
}


Measured memory_bytes: 1148
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<LL,LL>PL;
const LL INF=1e18;
vector<LL>V;
LL N,i,j;
LL A[123];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N;
    for(i=1;i<=N;i++)
        cin>>A[i];
    for(i=N;i>0;i--)
    {
        for(j=i;j>0;j--)
            if(A[j]==j)
                break;
        if(j<=0)
            break;
        V.push_back(j);
        for(;j<N;j++)
            A[j]=A[j+1];
        A[N]=0;
    }
    reverse(V.begin(),V.end());
    if(i>0)
        cout<<-1;
    else
        for(i=0;i<N;i++)
            cout<<V[i]<<'\n';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        var p = new int[n];

        for (int i = 0; i < q; i++)
        {
            p[sc.nextInt() - 1]++;
        }

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        for (int i = 0; i < n; i++)
        {
            if (q - k < p[i]) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
        Console.Out.Flush();
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

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

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

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

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 17596
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;
int main(){

	int a, b;
  double theta;
  cin >> a >> b >> theta;
  theta = M_PI*theta/180;
 
  double S = a * b * sin(theta)/2;
 
  double c = sqrt(a*a + b*b - 2*a*b*cos(theta));
  double L = a + b + c;
  double h = S*2/a;
  printf("%.8lf \n", S);
  printf("%.8lf \n", L);
  printf("%.8lf \n", h);
return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define lli long long

int main() 
{
    int n,m,x;
    cin >> n >> m >> x;
    
    int a[n+1][m+1];
    int c[n+1];
    
    int ans = INT_MAX;
    
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++) cin >> a[i][j];
    }
    
    int mask = (1<<n);
    
    for(int i=1;i<mask;i++) {
        int val[m];
        memset(val,0,sizeof val);
        
        for(int j=0;j<n;j++){
            if(i&(1<<j)) {
                for(int k=0;k<m;k++){
                    val[k]+=(a[j][k]);
                }
            }
        }
        
        int f = 0;
        for(int k=0;k<m;k++){
            if(val[k]<x) {
                f = 1;
                break;
            }
        }
        
        if(f==0) {
            int cost=0;
            for(int j=0;j<n;j++){
                if(i&(1<<j)) {
                    cost+=(c[j]);
                }
            }
            
            ans=min(ans,cost);
        }
    }
    
    if(ans==INT_MAX) cout<<-1<<endl;
    else cout<<ans<<endl;
	return 0;
}

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

int main(void){
    int n,t;
    cin >> n >> t;
    vector<pair<int,int>> dish(n);
    int a,b;
    rep(i,n){
        cin >> a >> b;
        dish[i] = make_pair(a,b);
    }
    sort(all(dish));
    //　dp[i][j] = 1～i 番目の料理で j 分以内に完食できる美味しさの合計の最大値
    vector<vector<ll>> dp(n+1, vector<ll>(t,0));
    for(int i=1; i<=n; i++){
        for(int j=1; j<t; j++){
            if(j >= dish[i-1].fs){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-dish[i-1].fs] + dish[i-1].sc);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    ll ans=0;
    for(int i=1; i<=n; i++){
        ans = max(ans, dp[i-1][t-1]+dish[i-1].sc);
    }
    cout << ans << endl;
}

Measured memory_bytes: 70784
n = int(input())
d = {}
for _ in range(n):
    s = str(input())
    d[s] = 1 if s not in d else d[s] + 1
M = max(d.values())
L = []
for k, v in d.items():
    if v == M:
        L.append(k)
L.sort()
for x in L:
    print(x)



Measured memory_bytes: 35424
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MAX = 1e5 + 10;

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

	vector<vector<ll>> DP(2, vector<ll>(MAX,LINF));

	int N,S;
	cin >> N >> S;

	vector<int> W(N), R(N);

	for(int i = 0; i < N; i++) cin >> W[i] >> R[i];

	DP[1][0] = DP[0][0] = 0;

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

		for(int j = MAX; j >= 0; j--){
			if(R[i] + j < MAX)
				DP[1][R[i] + j] = min(DP[1][R[i] + j], DP[1][j] + W[i]);
		}

		DP[0] = DP[1];

	}

	int ans;

	for(int i = MAX - 1; i >= 0; i--){
		if(DP[1][i] <= S){
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5484
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

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

	cout << max(0, c - a + b) << endl;
	
	return 0;
}

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

ll dp[51][51][2510];
ll a[51];

int main() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n; ++i) cin >> a[i];

  dp[0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k <= 2500; ++k) {
        dp[i][j][k] = dp[i - 1][j][k];
        if (j > 0 && k >= a[i - 1])
          dp[i][j][k] += dp[i - 1][j - 1][k - a[i - 1]];
      }
    }
  }

  ll res = 0;
  for (int j = 1; j <= n; ++j)
    if (x * j < 2510) res += dp[n][j][x * j];
  cout << res << endl;
}


Measured memory_bytes: 49280
// Problem : D - String Formation
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <deque>

using namespace std;

int main()
{
	string s;
	cin>>s;
	deque<char> dq;
	for(auto e : s) dq.push_back(e);
	
	int q;
	cin>>q;
	bool invert = false;
	for(int t=0;t<q;t++)
	{
		int qt;
		cin>>qt;
		if(qt == 1)
		{
			invert = !invert;
		}
		else
		{
			int f; char c;
			cin>>f>>c;
			if(f == 1)
			{
				if(invert) dq.push_back(c);
				else dq.push_front(c);
				//add front;
			}
			else
			{
				if(invert) dq.push_front(c);
				else dq.push_back(c);
				// add end;
			}
		}
	}
	if(invert)
		while(!dq.empty())
		{
			cout << dq.back();
			dq.pop_back();
		}
	else 
		while(!dq.empty())
		{
			cout << dq.front();
			dq.pop_front();
		}
	
	return 0;
}

Measured memory_bytes: 1024
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int  n, m, ans = 0 ; 
    cin >> n >> m ; 
    vector < pair<int, int> > ab ; 
    vector <int>  ocupy ; 
    for (int  i = 1 ; i <= m; i++) ocupy.pb(i); 
    for (int  i = 0 ; i < n ; i++) {
        int a,b ; cin>>a>>b;
        if (a>m) continue;
        ab.emplace_back(b,a) ; 
    }
    sort(all(ab)) ; 
    for (int  i = sz(ab)-1 ; i >= 0 ; i--) { 
        int k = ab[i].ss ; 
        auto  it = lower_bound(ocupy.begin(), ocupy.end(), k ) ; 
        if (it != ocupy.end()) {
            int in =  it - ocupy.begin() ; 
            ocupy.erase( ocupy.begin() + in ) ; 
            ans += ab[i].ff ; 
        }
    }
    co (ans) ; 
}
// https://atcoder.jp/contests/abc137/tasks/abc137_d 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 6140
import math
n=int(input())
s=int(input())

def f(b,n):
    m=math.floor(n/b)
    if n>=b:
        return f(b,m) + n%b
    else:
        return n

if n<s:
    print(-1)
elif n==s:
    print(n+1)
else:
    for i in range(2,int(math.sqrt(n))+1):
        if f(i,n)==s:
            print(i)
            break
    else:
        for p in range(int(math.sqrt(n)),0,-1):
            if (n-s)%p==0:
                b=(n-s)//p+1
                #print(b)
                #print(f(b,n))
                if f(b,n)==s:
                    print(b)
                    break
        else:
            print(-1)

Measured memory_bytes: 43612
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,m;
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

N = inp()
dd = inp_list()

dd_sorted = sorted(dd)

border_l = dd_sorted[N // 2 - 1]
border_r = dd_sorted[N // 2]
if border_l == border_r:
    print(0)
else:
    print(border_r - border_l)


Measured memory_bytes: 15444
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int k; cin >> k;
    string s; cin >> s;
    int n = sz(s);
    if (n<=k) cout << s << endl;
    else {
        rep(i,k) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3588
n, k = map(int, input().split())
apple = []
orange = []
for _ in range(n):
    apple.append(int(input()))
a = sorted(apple)
for i in range(n - k):
    b = - a[i] + a[i + k -1]
    c = a[-i-1] - a[-(i + k)]
    if b != 0 or c != 0:
        orange.append(min(b, c))
    else:
        orange.append(0)
        break
print(min(orange))

Measured memory_bytes: 56920
var
  n,i:longint;
  a:array[1..100] of qword;
 function gys(x,y:qword):qword;
  begin
    if y=0 then exit(x);exit(gys(y,x mod y));
  end;
begin
  readln(n);
  for i:=1 to n do readln(a[i]);
  for i:=2 to n do a[i]:=a[i] div gys(a[i],a[i-1])*a[i-1];
  writeln(a[n]);
end.

Measured memory_bytes: 128
import sys
from collections import defaultdict
dic1 = defaultdict(int)
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())

for i in range(n):
    s = readline().rstrip().decode('utf-8')
    dic1[s] += 1

ans = ["AC","WA","TLE","RE"]

for i in ans:
    print(i,"x",dic1[i])

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

int main(){
  int n,m;
  cin >> n>> m;
  int q=m/n;
  int ans=1;
  for(int k=1;k*k<=m;k++){
    if(m%k == 0){int b=m/k;
                 if(q>=b)ans=max(b,ans);
                 if(q>=k)ans=max(k,ans);
                }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()]+[i])
"""d = []
for i in range(n):#h:高さ
    d.append([c[i][1], c[i][0], i])"""
tans = 0
aans = 0
sumc = []

for i in range(n):
    sumc.append([c[i][0] + c[i][1], i])

sumc.sort(reverse=True)

for i in range(n):
    if i % 2 == 0:
        tans += c[sumc[i][1]][0]
    else:
        aans += c[sumc[i][1]][1]

print(tans -aans)

Measured memory_bytes: 39860
#include<cstdio>
#include<algorithm>
#define N 200005
#define LL long long
using namespace std;

struct node
{
	int s,nxt;
}p[N<<1];
int h[N],t[N];
LL f[N];
int n,tot;
void adeg(int x,int y)
{
	p[++tot].s=y; p[tot].nxt=h[x]; h[x]=tot;
}
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		adeg(u,v); adeg(v,u);
	}
	f[n]=1;
	for(i=n-1;i>=1;i--)
	{
		int num=0;
		for(j=h[i];j;j=p[j].nxt)
			if(p[j].s>i) t[++num]=p[j].s;
		//sort(t+1,t+num+1);
		f[i]=f[i+1]+n-i+1;
		for(j=1;j<=num;j++)
			f[i]-=(n-t[j]+1);
	}
	LL ans=0;
	for(i=1;i<=n;i++)
		ans+=f[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7880
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
insu = prime_factorize(N)

insu_num = []
ans = 0

while len(insu) != 0:
    num = insu.count(insu[0])
    insu_num.append(num)
    insu = insu[num:]

for num in insu_num:
    p = 1
    while True:
        num -= p
        if num>=0:
            ans += 1
        else:
            break 
        p += 1   

print(ans)

Measured memory_bytes: 9228
#include<cstdio>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	if(n<3){printf("No\n");return 0;}
	if(n&1)
	{
		printf("Yes\n");
		printf("%d %d\n",1,2);printf("%d %d\n",2,3);printf("%d %d\n",3,n+1);printf("%d %d\n",n+1,n+2);printf("%d %d\n",n+2,n+3);
		for(int i=4;i<=n;i+=2)printf("%d %d\n",i,i+1),printf("%d %d\n",i+n,i+n+1),printf("%d %d\n",i,1),printf("%d %d\n",i+n+1,1);
	}
	else
	{
		for(int i=1;i<n;i++)
		if((n^i^1)<n)
		{
			int st=n^i^1;
			printf("Yes\n");
			printf("%d %d\n",1,2);printf("%d %d\n",2,3);printf("%d %d\n",3,n+1);printf("%d %d\n",n+1,n+2);printf("%d %d\n",n+2,n+3);
			for(int j=4;j<n;j+=2)printf("%d %d\n",j,j+1),printf("%d %d\n",j+n,j+n+1),printf("%d %d\n",j,1),printf("%d %d\n",j+n+1,1);
			printf("%d %d\n",n,(i&1)?i+n:i);printf("%d %d\n",n*2,(st&1)?st+n:st);
			return 0;
		}
		printf("No\n");
	}
}


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

int main()
{
	string a, b;
	cin >> a >> b;
	int c = stoi(a + b);
	int d = (int)sqrt(c);
	cout << (d * d == c ? "Yes" : "No") << endl;
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/


int main()
{
    int n;
    cin >> n;
    vector <string> vec;
    while(n--){
        string s;
        cin >> s;
        sort(s.begin() , s.end());
        vec.pb(s);
    }

    sort(vec.begin() , vec.end());
    string s = vec[0];
    ll x = 1 , ans = 0;

    for(int i = 1; i < (int) vec.size(); ++i){
        string m = vec[i];
        if(s == m){
            x++;
        }else{
            ans += x * (x - 1) / 2;
            x = 1;
            s = m;
        }
    }

    ans += x * (x - 1) / 2;

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 5748
eval'H,W,A,B='+`tr ' ' ,`
*f=1
(H+W).times{f<<f[-1]*-~_1%M=10**9+7}
p (B...W).sum{|i|f[H-A-1+i]*f[A+W-i-2]*(f[H-A-1]*f[i]*f[A-1]*f[W-1-i]).pow(M-2,M)}%M

Measured memory_bytes: 33452
until(n,m=gets.split.map(&:to_i))==[0,0]do
r,p,a=[],[],[]
n.times{r<<gets.gsub("?",".").split}
m.times{p<<gets.split}
p.each{|p|r.reverse.each{|r|if/#{r[1]}/=~p[0]&&p[1]=~/#{r[2]}/
a<<p*" "if/p/=~r[0]
break
end}}
puts a.size,a
end

Measured memory_bytes: 9464
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<tuple<string, int, int>> x(n);
	for (int i = 0; i < n; i++)
	{
		string s;
		int p;
		cin >> s >> p;

		x.at(i) = make_tuple(s, p, i + 1);
	}

	sort(all(x), [](const tuple<string, int, int>& a, const tuple<string, int, int>& b)
		{
				return get<1>(a) > get<1>(b);
		});

	stable_sort(all(x), [](const tuple<string, int, int>& a, const tuple<string, int, int>& b)
		{
			return get<0>(a) < get<0>(b);
		});

	/*
	sort(all(x), [](const tuple<string, int, int>& a, const tuple<string, int, int>& b)
		{
			if (get<0>(a) != get<0>(b))
			{
				return get<0>(a) < get<0>(b);
			}
			else
			{
				return get<1>(a) > get<1>(b);
			}
		});
		*/

	for (int i = 0; i < n; i++)
	{
		println(get<2>(x.at(i)));
	}
}


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

int main(void) {
  int n;
  cin >> n;
  
  int a[n];
  rep(i, n) {
    cin >> a[i];
  }
  
  int pre = -999;
  rep(i, n) {
    if(pre <= a[i] - 1) {
      pre = a[i] - 1;
    } else if(pre <= a[i]) {
      pre = a[i];
    } else {
      puts("No");
      return 0;
    }
  }
  
  puts("Yes");
  return 0;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long N = sc.nextLong();//N人
		int M = sc.nextInt();
		int answer = 0;
		List<Integer> list = new ArrayList<Integer>();
		int K = 0;
		for(int i =0; i < N; i++) {
			K = sc.nextInt();
			for(int j=0; j < K; j++) {
				list.add(sc.nextInt());
			}
		}

		Map<Integer, Long> map = list.stream().collect(
                Collectors.groupingBy(x -> x, Collectors.counting())
        );

		for(Map.Entry<Integer, Long> entry : map.entrySet()) {
			if(entry.getValue() == N) {
				answer++;
			}
		}
		System.out.println(answer);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 26708
#include <iostream>

using namespace std;

int main()
{
    string S;
    cin>>S;

    if (S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba")
        cout<<"Yes\n";
    else
        cout<<"No\n";



    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define pf push_front
#define indexof order_of_key
#define valueat find_by_order

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

int INF=1000000000000;
int t;
int n,m,l;
int graph[301][301];
int q;

void input(){
    cin>>n>>m>>l;
    rep(i,0,n)
        rep(j,0,n){
            graph[i][j]=INF;
            if(i==j)
                graph[i][j]=0;
        }   
    rep(i,0,m){
        int x,y,z;
        cin>>x>>y>>z;
        graph[x-1][y-1]=z;
        graph[y-1][x-1]=z;
    }
}

void floyd_warshall(){
    rep(k,0,n)
        rep(i,0,n)
            rep(j,0,n)
                graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
    rep(i,0,n)
        rep(j,0,n){
            if(i==j)
                graph[i][j]=0;
            else if(graph[i][j]<=l)
                graph[i][j]=1;
            else
                graph[i][j]=INF;
        }
    rep(k,0,n)
        rep(i,0,n)
            rep(j,0,n)
                graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}

void solve(){
    floyd_warshall();
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        if(graph[s-1][t-1]>=INF)
            cout<<-1<<endl;
        else
            cout<<graph[s-1][t-1]-1<<endl;  
    }
}

main(){
    fastio;
    t=1;
    while(t--){
        input();
        solve();
    }
}

Measured memory_bytes: 1280
x = int(input())

if x == 2: print(x); quit()
if x % 2 == 0: x += 1

def is_prime(x):
    for i in range(3, x):
        if x % i == 0:
            return False
    return True

for i in range(x, 10**5 + 4, 2):
    if is_prime(i):
        print(i)
        break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int N; cin >> N;
  vector<int> a(N+1, 0); 
  cin >> a[0]; int b = a[0];
  int count = 1;
  int ans = 0;
  for(int i = 1; i<N; i++) {
    cin >> a[i];
    if(b==a[i]) {count++;}
    else {ans += count/2; b = a[i]; count = 1;} 

  }
  ans += count/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

n, t = map(int, input().split())
tmp = list(map(int, input().split()))
a = np.array(tmp)

ret = t
for i in range(1, n):
    if a[i] - a[i-1] <= t:
        ret += a[i] - a[i-1]
    else:
        ret += t

print(ret)


Measured memory_bytes: 34224
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct Node{
    int key;
    Node *left;
    Node *right;
    Node *parent;
};
Node *NIL;
Node *root = NIL;
Node *treeMinimum(Node *x){
    while( x->left != NIL ){
        x = x->left; 
    }
    return x;
}
Node *treeSuccessor(Node *x){
    if ( x->right != NIL ) return treeMinimum(x->right);
    Node *y = x -> parent;
    while( y != NIL && x == y -> right ) {
        x = y;
        y = y -> parent; 
    }
    return y; 
}
void dele(Node *t){
    Node *y;
    Node *x;
    if(t ->left == NIL || t ->right == NIL){
        y = t;
    }else{
        y = treeSuccessor(t);
    }
    if(y -> left !=NIL){
        x = y -> left;
    }else{
        x = y -> right;
    }
    if(x != NIL){
        x -> parent = y -> parent;
    }
    if(y -> parent == NIL){
        root = t;
    }else{
        if(y == y -> parent -> left){
            y -> parent -> left = x;
        }else{
            y -> parent -> right = x;
        }
    }
    if(y != t){
        t -> key = y -> key; 
    }
    free(y);
}
Node *find(int key){
    Node *x = root;
    Node *flag =NIL;
    while(x!=NIL){
        if(x ->key < key){
            x = x->right;
        }else if(x -> key > key){
            x = x->left;
        }else{
            flag = x;
            break;
        }
    }
    return flag;
}
void insert(int key){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = new Node;
    z -> key = key;
    z -> left = NIL;
    z ->right = NIL;
    while(x!=NIL){
        y = x;
        if(z -> key < x ->key){
            x = x->left;
        }else{
            x = x->right;
        }
        z -> parent = y;
    }
    if(y==NIL){
        root = z ;
    }else if(z -> key <= y -> key){
        y -> left = z;
    }else{
        y->right = z;
    }
}
void inorder(Node *p){
    if(p==NIL){
        return;
    }
    inorder(p->left);
    cout << ' ' << p->key;
    inorder(p->right);
}
void preorder(Node *p){
    if(p==NIL){
        return;
    }
    cout << ' ' << p -> key;
    preorder(p->left);
    preorder(p->right);
}
void print(void){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}
int main(void){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string command;
        cin >> command;
        if(command[0]=='i'){
            int key;
            cin >> key;
            //cout << key << endl;; 
            insert(key);

        }else if(command[0]=='f'){
            int key;
            Node *flag;
            cin >> key;
            flag = find(key);
            if(flag!=NIL){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }else if(command[0]=='d'){
            int key;
            Node *t;
            cin >> key;
            t = find(key);
            dele(t);
        }else{
            print();
        }
    }
    return 0;
}


Measured memory_bytes: 21760
#include <stdio.h>

int main()
{
	int i, N, L, a[100001];
	scanf("%d %d", &N, &L);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int max = 0, argmax = 0;
	for (i = 1; i < N; i++) {
		if (a[i] + a[i+1] > max) {
			max = a[i] + a[i+1];
			argmax = i;
		}
	}
	
	if (max < L) printf("Impossible\n");
	else {
		printf("Possible\n");
		for (i = 1; i < argmax; i++) printf("%d\n", i);
		for (i = N - 1; i >= argmax; i--) printf("%d\n", i);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    double v,c;
    cin>>n;
    std::deque<double> value;
    std::deque<double> cost;
    for (int i=0;i<n;i++) {
        cin>>v;
        value.emplace_back(v);
    }
    for (int j=0;j<n;j++) {
        cin>>c;
        cost.emplace_back(c);
    }
    int x=0,y=0;
    for (int k=0;k<n;k++) {
        if (value[k]/cost[k]>1.0) {
            x+=value[k];
            y+=cost[k];
        }
    }
    cout<<x-y<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

class SegmentTree{
public:
	vector<ll> dat;
	ll n;

	SegmentTree(ll n_){
		n=1;
		while(n<n_) n*=2;
		rep(i,2*n-1) dat.push_back(0);
	}

	void update(int k,ll a){
		k+=n-1;
		dat[k]=a;
		while(k>0){
			k=(k-1)/2;
			dat[k]=max(dat[2*k+1],dat[2*k+2]);
		}
	}

	ll query(int a,int b,int k,int l,int r){
		if(r<=a || b<=l) return 0;
		if(a<=l && r<=b) return dat[k];
		else{
			ll vl=query(a,b,2*k+1,l,(l+r)/2);
			ll vr=query(a,b,2*k+2,(l+r)/2,r);
			return max(vl,vr);
		}
	}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> h(n),a(n);
  rep(i,n) cin>>h[i];
  rep(i,n) cin>>a[i];
  vector<ll> dp(n+1,0);
  SegmentTree st(n+1);
  rep(i,n){
    dp[h[i]]=a[i]+st.query(0,h[i],0,0,st.n+1);
    st.update(h[i],dp[h[i]]);
  }
  ll ans=0;
  rep(i,n+1) ans=max(ans,dp[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 9712
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vi = vector<int>;
using vs = vector<string>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repp(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define repd(i, n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll k, l, m, n;
const ll M = 1e9 + 7;



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

	cin >> n;

	if(n == 1) return cout << 0 << endl, 0;

	ll m = M;

	ll prd1 = 1, prd2 = 1, prd3 = 1;
	rep(i, n) {
		prd1 *= 10;
		prd1 %= m;
		prd2 *= 9;
		prd2 %= m;
		prd3 *= 8;
		prd3 %= m;
	}

	ll result = (prd1 - 2 * prd2 + prd3) % m;
	if(result < 0) cout << result + m << endl;
	else cout << result << endl;
}

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

int main() {

  int N;
  cin >> N;

  // 2で割り切れない数の個数
  int count1 = 0;

  // 4で割り切れる数の個数
  int count2 = 0;

  // 4で割り切れないが2で割り切れる数の個数
  int count3 = 0;

  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    if (a % 2 != 0) {
      count1++;
    } else if (a % 4 == 0) {
      count2++;
    } else {
      count3++;
    }
  }
  
  string answer = "No";

  if (count3 == 0) {
    if (count1 <= count2 + 1) {
      answer = "Yes";
    }
  } else {
    if (count1 <= count2) {
      answer = "Yes";
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,s1,s2,g1,g2;
  cin >> n >> s1 >> s2 >> g1 >> g2;
  s1--;
  s2--;
  g1--;
  g2--;
  string m;
  cin >> m;
  
  rep(i,s1,g1-1){
    if(m[i]=='#'&&m[i+1]=='#') {
      cout << "No" << endl;
      return 0;
    }
  }
  rep(i,s2,g2-1){
    if(m[i]=='#'&&m[i+1]=='#') {
      cout << "No" << endl;
      return 0;
    }
  }
  
  if(g1<g2) {
    cout << "Yes" << endl;
    return 0;
  }
  
  rep(i,s2,g2+1){
    if(m[i-1]=='.'&&m[i]=='.'&&m[i+1]=='.'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	static int gcd(int x, int y) {
		 	int r;
		 	if(x>=y) {
		 		while (y > 0) {
		            r = x % y;
		            x = y;
		            y = r;
	        	}
		 		return x;
	        }else {
	        	 while (x > 0) {
	 	            r = y % x;
	 	            y = x;
	 	            x = r;
	 	        	}
	        	}

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

	}

}



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

#define ll long long
#define pb push_back
#define mkp make_pair

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	int a;
	cin>>a;
	int res=a+a*a+a*a*a;
	cout<<res<<'\n';
}


Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
typedef long long int LL;
typedef pair<int,int> P;

int main() {
	string s;
	cin >> s;
	char c = s[6];
	if(s[5]=='1') cout << "TBD" << endl;
	else if(c<='4') cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return f*k;
}
const int N=100055;
int n,a[N];
int gcd(int a,int b)
{	
	if(!b) return a;
	return gcd(b,a%b);
}
int sol()
{
	int cnt=0,sum=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			int S=0;
			for(int j=1;j<=n;j++)
				S=(S+a[j]-1)&1;
			return S;
		}
		if(a[i]&1) cnt++;
		else sum++;
	}
	if(sum&1) return 1;
	if(cnt>1) return 0;
	int now=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]&1) a[i]--;
		if(!now) now=a[i];
		else now=gcd(now,a[i]);
	}
	for(int i=1;i<=n;i++)
		a[i]/=now;
	return sol()^1;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	if(sol()) puts("First");
	else puts("Second");
	return 0;
}


Measured memory_bytes: 640
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
#include<set>
#include<iostream>

using namespace std;

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

const int MX = 1<<19;
const int MM = 1000000007;

int A[MX];

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	for(int i = 1; i <= N; i++) scanf("%d", A+i);
	for(int i = 1; i < N; i++){
		if( A[i] + A[i+1] >= K ){
			printf("Possible\n");
			for(int j = 1; j < i; j++) printf("%d\n", j);
			for(int j = N-1; j >= i; j--) printf("%d\n", j);
			return 0;
		}
	}
	printf("Impossible\n");
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define vp vector <pair<int,int>>
#define vpp vector <pair<pair<int,int>,int>>
#define si set<int>
#define f(x,y,z) for(x=y;x<z;x++)
#define fb(x,y,z) for(x=y;x>z;x--)
#define pb push_back
#define mp make_pair
#define ld long double
#define pqf priority_queue <int,vector <int>> 
#define pqb priority_queue <int,vector <int>,greater<int>> 
#define ps(x,y) fixed << setprecision(y) << x
#define setbits(x) __builtin_popcountll(x)
#define PI 3.1415926535897932
#define mod 1000000007

// AUTHOR AMAN DWIVEDI
int gcd(int a, int b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
int power(int a,int b)
{
    int c=1;
    while(b)
    {
        if(b&1)
        c*=a;
        a*=a;
        b/=2;
    }
    return c;
}
int32_t main()
{
    IOS
    int  a,b,c,d;
    cin >>a>>b>>c>>d;
    int p1 = a*c, p2 = a*d, p3 = b*c, p4 = b*d;
    int m1 = max(p1,p2);
    int m2 = max(p3,p4);
    cout<<max(m1,m2)<<"\n";
    
    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class362
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            if (A.Contains(0)) { Console.WriteLine(0); return; }

            long sum = 1;
            for (int i = 0; i < N; i++)
            {
                if (sum.ToString().Length-1 + A[i].ToString().Length-1 > 18)
                {
                    Console.WriteLine(-1);
                    return;
                }
                else if(sum.ToString().Length - 1 + A[i].ToString().Length - 1 == 18&&((sum%10)>1||(A[i]%10)>1))
                {
                    Console.WriteLine(-1);
                    return;
                }
                else if(sum*A[i]> 1000000000000000000)
                {
                    Console.WriteLine(-1);
                    return;
                }
                    sum *= A[i];
            }
            Console.WriteLine(sum);
        }
    }
}


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

int w,h;
int t[20][20];
int sx, sy;

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

bool goalFlg;

class Info{
public:
	int map[20][20];
	int cost,x,y;
};

bool move(int d, Info *info){
	int nx = info->x + dx[d];
	int ny = info->y + dy[d];
	if(nx>=0 && nx<w && ny>=0 && ny<h && info->map[ny][nx]==1) return false;

	while(true){
		nx = info->x + dx[d];
		ny = info->y + dy[d];

		if(nx<0 || nx>=w || ny<0 || ny>=h) return false;
		else if(info->map[ny][nx] == 1){
			info->map[ny][nx] = 0;
			return true;
		}
		else if(info->map[ny][nx] == 3){
			goalFlg = true;
			info->x = nx;
			info->y = ny;
			return true;
		}
		info->x = nx;
		info->y = ny;
	}
}

int bfs(void){
	stack<Info> s;
	Info info, ninfo;
	int ans = 999999999;

	goalFlg=false;

	for(int i=0;i<h;i++) for(int j=0;j<w;j++) info.map[i][j] = t[i][j];
	info.cost=0, info.x=sx, info.y=sy;
	s.push(info);

	while(!s.empty()){
		info = s.top(); s.pop();
		int ncost = info.cost + 1;
		if(ncost > 10) continue;

		for(int i=0;i<4;i++){
			ninfo = info;
			if(move(i,&ninfo) && !goalFlg){
				ninfo.cost = ncost;
				s.push(ninfo);
			}
			if(goalFlg){
				goalFlg = false;
				if(ans > ncost) ans = ncost;
				continue;
			}
		}
	}
	if(ans == 999999999) return -1;
	else return ans;
}

int main(void){
	while(cin>>w>>h && (w||h)){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>t[i][j];
				if(t[i][j] == 2) sx=j, sy=i;
			}
		}
		cout<<bfs()<<endl;
	}

	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<long long> dp(21);
    int a; cin >> a;
    dp[a] = 1;
    for (int i = 1; i < n - 1; i++) {
        cin >> a;
        vector<long long> dp2(21);
        for (int i = 0; i <= 20; i++) {
            if (i - a >= 0) dp2[i] += dp[i - a];
            if (i + a <= 20) dp2[i] += dp[i + a];
        }
        swap(dp, dp2);
    }
    cin >> a;
    cout << dp[a] << endl;
    return 0;
}


Measured memory_bytes: 3084