akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
int n,m;
int a[300000],b[300000];
vector<int>vec[200000];
queue<int>que;
bool flag[200000];
vector<P>route;
void bfs(){
    que.push(1);
    while(!que.empty()){
    point:;
        int p=que.front(); que.pop();
        flag[p]=true;
        int l=vec[p].size();
        rep(i,l){
            if(flag[vec[p][i]]==false){
                que.push(vec[p][i]);
                route.push_back(make_pair(vec[p][i],p));
                flag[vec[p][i]]=true;
            }
        }
    }
    return;
}
signed main(){
    cin>>n>>m;
    rep(i,m){
        cin>>a[i]>>b[i];
        vec[a[i]].push_back(b[i]);
        vec[b[i]].push_back(a[i]);
    }
    bfs();
    bool afla=true;
    rep(i,n){
        if(flag[i+1]==false)afla=false;
    }
    if(!afla)puts("No");
    else{
        puts("Yes");
        sort(all(route));
        rep(i,n-1){
            cout<<route[i].second<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 19984
a,b,c,x,y = gets.split.map(&:to_i)
price = 0
min_price = 100000000000

if a + b < c * 2
  puts a * x + b * y
  exit 0
end
([x,y].min..[x,y].max).each do |i|
  if x > y
    price = i * c * 2 + (x - i) * a
  elsif x < y
    price = i * c * 2 + (y - i) * b
  else
    price = [i * c * 2 + (x - i) * a, i * c * 2 + (y - i) * b].min
  end
  min_price = price if price < min_price
end
puts min_price

Measured memory_bytes: 1788
def solve():
    N, X, M = map(int, input().split())

    _l = tuple([i**2 % M for i in range(M)])

    _a = X
    ans_l = [0] * M
    ans_l[0] = _a
    seq = [_a]
    s = g = 0
    for i in range(1, M):
        _a = _l[_a]
        ans_l[i] = _a + ans_l[i-1]
        if _a in seq:
            s = seq.index(_a)
            g = len(seq)-1
            break
        seq.append(_a)
    _tmp = N - s
    loop = _tmp // (g - s + 1)
    zan = _tmp % (g - s + 1)
    ans = ans_l[s-1] + (ans_l[g] - ans_l[s-1]) * loop + \
        (ans_l[s+zan-1] - ans_l[s-1])
    print(ans)


solve()


Measured memory_bytes: 75592
n,a,b=map(int, input().split())
s=input()
pass_all=0
pass_foreigner=0

for i in range(n):
    if s[i]=='a' and pass_all<a+b:
        pass_all+=1
        print("Yes")
    elif s[i]=='b' and pass_all<a+b and pass_foreigner<b:
        pass_all+=1
        pass_foreigner+=1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long H;
  	long sum = 0;
  	int i = 0;
  	
    scanf("%ld",&H);
	while(H >= 1){
	    sum += pow(2,i);
	    H = H/2;
	    i++;
	}
	printf("%ld\n",sum);
  	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <limits>
#include <iomanip>
#include <bitset>

#define INF 1000000000
#define Inf 1000000000000000000
#define mp make_pair
#define pb push_back
#define EPS 1e-9

using namespace std;

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

int h, w, ans;
char a[1010][1010];
set<ii> v;

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

  cin >> h >> w;
  for(int i = 1; i <= h; ++i)
    for(int j = 1; j <= w; ++j)
      cin >> a[i][j];

  for(int i = 1; i <= h; ++i)
    for(int j = 1; j <= w; ++j)
      if (a[i][j] == '.' && (a[i][j + 1] == '#' || a[i][j - 1] == '#' || a[i + 1][j] == '#' || a[i - 1][j] == '#')) v.insert(mp(i, j));

  while(v.size() > 0) {
    for(set<ii>::iterator it = v.begin(); it != v.end(); ++it) {
      int i = it->first;
      int j = it->second;
      a[i][j] = '#';
    }
    set<ii> new_v;
    for(set<ii>::iterator it = v.begin(); it != v.end(); ++it) {
      int i = it->first;
      int j = it->second;
      if (j < w && a[i][j + 1] == '.') new_v.insert(mp(i, j + 1));
      if (j > 1 && a[i][j - 1] == '.') new_v.insert(mp(i, j - 1));
      if (i < h && a[i + 1][j] == '.') new_v.insert(mp(i + 1, j));
      if (i > 1 && a[i - 1][j] == '.') new_v.insert(mp(i - 1, j));
    }
    v = new_v;
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 32256
import java.util.*;
public class Main {
	static char[] l = new char[] {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int counter = 0;
			boolean isd = true;
			boolean isld = true;
			boolean isrd = true;
			for(int i = 0; i < n; i++) {
				String a = stdIn.next();
				if(a.equals("lu")) {
					isld = false;
				}
				if(a.equals("ru")) {
					isrd = false;
				}
				if(a.equals("ld")) {
					isld = true;
				}
				if(a.equals("rd")) {
					isrd = true;
				}
				if(isd && !isld && !isrd) {
					isd = false;
					counter++;
				}
				if(!isd && isld && isrd) {
					isd = true;
					counter++;
				}
 			}
			System.out.println(counter);
		}
	}
}

Measured memory_bytes: 26920
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s,t;
cin>>t>>s;
cout<<s<<t;




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// https://boostjp.github.io/tips/multiprec-int.html
// https://boostjp.github.io/tips/multiprec-float.html
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using namespace std;

#define ll long long
#define ld long double
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll n,m,k = 1;
struct UnionFind {
    ll n;
    vector<ll> par,rank;

    UnionFind(ll N) : par(N) {
        n = N;
        REP(i,n) par[i] = i;
        rank.assign(n, 1);
    }

    ll root(ll x) {
        ll tmp = x;
        while(par[tmp] != tmp) {
            tmp = par[tmp];
        }
        return par[x] = tmp;
    }

    void unite(ll x, ll y) {
        ll rootX = root(x);
        ll rootY = root(y);
        if (rootX == rootY) return;
        rank[rootY] += rank[rootX];
        chmax(k, rank[rootY]);
        par[rootX] = rootY;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll count(ll x) {
        return rank[root(x)];
    }
};

int main() {
    INIT();

    cin >> n >> m;

    UnionFind unionFind(n);
    REP(i,m) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        unionFind.unite(a,b);
    }
    cout << k;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

bool checkYear(int n) {
    return true;
}
bool checkMonth(int n) {
    if(n >= 1 && n <= 12) { return true; }
    return false;
}

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

    int one = (S[0] - '0') * 10 + (S[1] - '0');
    int two = (S[2] - '0') * 10 + (S[3] - '0');

    bool y1 = checkYear(one);
    bool m1 = checkMonth(one);
    bool y2 = checkYear(two);
    bool m2 = checkMonth(two);

    if(!y1 || !y2) {
        printf("NA\n");
    }
    else if(y1 && m1 && y2 && m2) {
        printf("AMBIGUOUS\n");
    }
    else if(y1 && !m1 && y2 && !m2) {
        printf("NA\n");
    }
    else if(y1 && !m1 && y2 && m2) {
        printf("YYMM\n");
    }
    else if(y1 && m1 && y2 && !m2) {
        printf("MMYY\n");
    }
    else {
        assert(false);
    }

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#define N 200000
using namespace std;
int a[N],b[N],c[N],i,n;long long x;
inline bool cmp(int u,int v){return a[u]<a[v];}
int main()
{
    for(scanf("%d",&n),i=0;i<n;i++)scanf("%d%d",a+(b[i<<1]=i<<1),a+(b[i<<1|1]=i<<1|1));
    for(sort(b,b+(n<<1),cmp),i=0;i<n;i++)x+=a[b[i]],c[b[i]>>1]++;
    for(i=0;i<n;i++)if(c[i]==2)return 0&printf("%lld\n",x);
    for(i=1;i<n;i++)if((b[i-1]^b[i])&1)return 0&printf("%lld\n",x+(b[n-1]>>1==b[n]>>1?a[b[n]]-a[b[n-2]]<a[b[n+1]]-a[b[n-1]]?a[b[n]]-a[b[n-2]]:a[b[n+1]]-a[b[n-1]]:a[b[n]]-a[b[n-1]]));
    return 0&printf("%lld\n",x);
}

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

int main() {
    int q; cin >> q;
    list<int> L; list<int>::iterator l_itr = L.begin();
    
    for (int i = 0; i < q; ++i) {
        int ope; cin >> ope;
        
        // insert
        if (ope == 0) {
            int x; cin >> x;
            l_itr = L.insert(l_itr, x);
        }
        // move
        else if (ope == 1) {
            int d; cin >> d;
            if (d >= 0 ) for (int i = 0; i < d; ++i) ++l_itr;
            else for (int i = 0; i < -d; ++i) --l_itr;
        }
        // erase
        else if (ope == 2) {
            l_itr = L.erase(l_itr);
        }
    }
    // output
    for (auto itr: L) cout << itr << endl;
    return 0;
}


Measured memory_bytes: 18648
def uru(y):
    return y % 4 == 0 and y % 100 != 0 or y % 400 == 0

def y_to_d(y):
    ret = 0
    for i in range(y):
        if uru(i):
            ret += 366
        else:
            ret += 365
    return ret

month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


def m_to_d(y, m):
    m -= 1
    ret = 0
    for i in range(m):
        ret += month[i]
    if m >= 2 and uru(y):
        ret += 1
    return ret


while True:
    y1, m1, d1, y2, m2, d2 = map(int, input().split())
    if min(y1, m1, d1, y2, m2, d2) < 0:
        quit()
    ymd1 = y_to_d(y1) + m_to_d(y1, m1) + d1
    ymd2 = y_to_d(y2) + m_to_d(y2, m2) + d2
    print(ymd2 - ymd1)



Measured memory_bytes: 5596
use proconio::{input, fastout};
use std::cmp::min;

const INF: i64 = 9000000000000000000;
const INFS: i32 = 2000000000;

fn calc(a: &Vec<usize>, ss: usize, pc: &Vec<Vec<i32>>, p: &Vec<i32>) -> Vec<i64> {
    let n = a.len();
    let mut res = vec![INF; n+1];
    for s in 0..(1<<n) {
        let mut st = ss;
        let mut b = n;
        for i in 0..n {
            if s>>i&1 == 0 {
                st &= !(1<<a[i]);
                b -= 1;
            }
        }
        let mut now: i64 = 0;
        for i in 0..n {
            now += pc[st][a[i]] as i64 * p[a[i]] as i64;
        }
        res[b] = min(res[b], now);
    }
    res
}
#[fastout]
fn main() {
    input! {
        n: usize,
        xyp: [(i32, i32, i32); n],
    }
    let x: Vec<i32> = xyp.iter().map(|e| e.0).collect();
    let y: Vec<i32> = xyp.iter().map(|e| e.1).collect();
    let p: Vec<i32> = xyp.iter().map(|e| e.2).collect();

    // pre calc
    let mut pcx = vec![vec![INFS;n];1<<n];
    let mut pcy = vec![vec![INFS;n];1<<n];
    for s in 0..(1<<n) {
        let mut px = vec![0i32];
        let mut py = vec![0i32];
        for i in 0..n {
            if s>>i&1 != 0 {px.push(x[i])}
            else           {py.push(y[i])}
        }
        for i in 0..n {
            let mut m = INFS;
            for j in 0..(px.len()) {
                m = min(m, (px[j]-x[i]).abs())
            }
            pcx[s][i] = m;
            let mut m = INFS;
            for j in 0..(py.len()) {
                m = min(m, (py[j]-y[i]).abs())
            }
            pcy[((1<<n)-1)&!s][i] = m;
        }
    }
    //main
    let mut ans = vec![INF;n+1];
    for s in 0..(1<<n) {
        let mut ax: Vec<usize> = Vec::new();
        let mut ay: Vec<usize> = Vec::new();
        for i in 0..n {
            if s>>i&1 != 0 {ax.push(i);}
            else           {ay.push(i);}
        }
        let dx: Vec<i64> = calc(&ax, s,&pcx,&p);
        let dy: Vec<i64> = calc(&ay,((1<<n)-1)&!s,&pcy,&p);
        for i in 0..dx.len() {
            for j in 0..dy.len() {
                ans[i+j] = min(ans[i+j], dx[i]+dy[j]);
            }
        } 
    }
    for i in 0..(n+1) {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 8764
def solve():
    n, m = map(int, input().split())
    lrs = list(list(map(int, input().split())) for _ in range(m))
    max_l, min_r = max([l for l, r in lrs]), min([r for l, r in lrs])
    ans = min_r - max_l + 1
    return ans if ans > 0 else 0


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 28268
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int main()
{
    int n,v[100],c[100],maxi=0;
    cin>>n;
    pair<int,int>p[n];
    for(int i=0;i<n;i++)
        cin>>v[i];
    for(int i=0;i<n;i++)
        cin>>c[i];
    for(int i=0;i<n;i++){
        if(v[i]>=c[i])
            maxi+=v[i]-c[i];
    }
    cout<<maxi;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
#define G() Cr = getchar()
#define LL long long
int Xr; char Cr;
inline int rd() {
	Xr = 0, G();
	while(Cr < '0' || Cr > '9') G();
	while(Cr >= '0' && Cr <= '9') Xr = (Xr<<1) + (Xr<<3) + (Cr&15), G();
	return Xr;
}
#define MAX_N 200005
int n;
int va[MAX_N];
map<int,int>mp;
LL ans;
int main() { 
	n = rd();
	for(int i = 1; i <= n; i++) {
		va[i] = rd();
		ans += mp[i-va[i]];
		mp[va[i]+i]++;
	}
	cout<<ans;
}

Measured memory_bytes: 21392
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename flow_t>
struct FordFulkerson{
    struct edge{
        int to;
        flow_t cap;
        int rev;
        edge(int to, flow_t cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    vector<vector<edge>> graph;
    vector<int> used;
    const flow_t INF;
    int timestamp;
    
    FordFulkerson(int n) : INF(numeric_limits<flow_t>::max()), timestamp(0){
        graph.resize(n);
        used.assign(n, -1);
    }

    void add_edge(int from, int to, flow_t cap){
        graph[from].push_back(edge(to, cap, graph[to].size()));
        graph[to].push_back(edge(from, 0, graph[from].size() - 1));
    }

    flow_t dfs(int s, int t, flow_t flow){
        if(s == t)  return flow;
        used[s] = timestamp;
        for(auto &e : graph[s]){
            if(e.cap > 0 && used[e.to] != timestamp){
                flow_t d = dfs(e.to, t, min(flow, e.cap));
                if(d > 0){
                    e.cap -= d;
                    graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    flow_t max_flow(int s, int t){
        flow_t flow = 0;
        for(flow_t f; (f = (dfs(s, t, INF)) > 0); timestamp++){
            flow += f;
        }
        return flow;
    }
};

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n), d(n);
    FordFulkerson<int> flow(2 * n + 2);
    int s = 0, t = 2 * n + 1;
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        flow.add_edge(s, i + 1, 1);
    }
    for(int i = 0; i < n; ++i){
        cin >> c[i] >> d[i];
        flow.add_edge(n + i + 1, t, 1);
    }
    for(int i = 0; i < n; ++i){
        int u = i + 1;
        int rx = a[i], ry = b[i];
        for(int j = 0; j < n; ++j){
            int v = n + j + 1;
            int bx = c[j], by = d[j];
            if(rx < bx && ry < by)  flow.add_edge(u, v, 1);  
        }
    }
    cout << flow.max_flow(s, t) << "\n";
}

Measured memory_bytes: 384
import sys

x,n = map(int,input().split()) 
p = list( map(int,input().split()) )


for i in range(x+1):
    s = x-i
    t = x+i
    
    if s in p and t in p:
        continue
    
    elif s in p and t not in p :
        print(t)
        sys.exit()
    
    else :
        print(s)
        sys.exit()

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,t;
	cin>>n>>t;
	int a[n];
	ll ans = 0;
	for(int i = 0; i<n;i++) cin>>a[i];
	for(int i = 1; i<n; i++)
	{
		ans += min(t,a[i]-a[i-1]);
	}
	cout<<ans+t<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int break_count = 0;
        int next = 1;

        for (int i = 0; i < n ; i++) {
            if (sc.nextInt() == next) {
                next++;
            } else {
                break_count++;
            }
        }
        if (next == 1) {
            System.out.println(-1);
        } else {
            System.out.println(break_count);
        }
    }

}


Measured memory_bytes: 63344
#include<stdio.h>
int s[1000020];
int f(int a,int b){
  if(a==b||b==0)return 1;
  if(s[a]-s[b]-s[a-b]>0)return 0;
  return 1;
}
int main(){
  int n,i,h,d[1000010]={};
  scanf("%d",&n);
  for(i=2;i<1e6+10;i++){
    if(i%2==0)s[i]=s[i/2]+1;
  }
  for(i=1;i<1e6+10;i++)s[i]=s[i]+s[i-1];
  for(i=0;i<n;i++)scanf("%1d",&d[i]);
  for(i=h=0;i<n;i++){
    d[i]--;
    if(d[i]==1)h=1;
  }
  if(h){
    for(i=h=0;i<n;i++){
      if(d[i]==1)h=(h+f(n-1,i))%2;
    }
    printf("%d\n",h);
  }
  else{
    for(i=h=0;i<n;i++){
      if(d[i]==2)h=(h+f(n-1,i))%2;
    }
    printf("%d\n",h*2);
  }
  return 0;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int n;
    cin >> n;

    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];

    bool flag = true;
    for (int i = 0; i < s.size() - 1; ++i) {
        if (s[i].back() != s[i + 1].front()) {
            flag = false;
        }
    }
    sort(all(s));
    rep(i, 0, s.size() - 1) {
        if (s[i] == s[i + 1]) {
            flag = false;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> W(N);
    for(int i = 0; i < N; i++){
        cin >> W.at(i);
    }

    bool f = true;

    for(int i = 0; i < N-1; i++){
        if((W.at(i)).back() != (W.at(i+1)).front())
            f = false;
        for(int j = i+1; j < N; j++){
            if(W.at(i) == W.at(j))
                f = false;
        }
    }

    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a,b;
    cin >> a >>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0)
      cout <<"Possible"<<endl;
    else cout <<"Impossible"<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

using namespace std;
int dp[100001][101];
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n,capacity;
	
	
	cin>>n>>capacity;
	vector<int> wt(n);
	vector<int> val(n);
	
	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	
	for(int i=0;i<=capacity;i++){
		for(int j=0;j<=n;j++){
			if(i == 0 or j == 0) 
				dp[i][j] = 0;
			else if(i >= wt[j-1])
				dp[i][j] = max(val[j-1] + dp[i - wt[j-1]][j-1],dp[i][j-1]);
			else
				dp[i][j] = dp[i][j-1];
		}
	}
	
	cout<<dp[capacity][n];
	
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int , int>data;
    for(int i = 0; i < N; i++) {
        int j ;
        cin >> j;
        data[j] ++;
    }
    if(data.size() == 1) {
        cout << 1 << endl;
        return 0;
    }
    int x = 0;
    for(auto &i : data) {
        i.second--;
        i.second %= 2;
        if (i.second)x++;
    }
    cout << data.size() - x % 2 << endl;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        boolean ans = false;
        int max = 0;
        int sum = 0;
        
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
            if (max < l[i]) {
                sum += max;
                max = l[i];
            } else {
                sum += l[i];
            }
        }
        
        if (max < sum) {
            ans = true;
        }
        
        System.out.println(ans ? "Yes":"No");
    }

}

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

int main(){
    int H, W;
    std::cin >> H >> W;
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    std::vector< std::vector< int > > ans(H, std::vector< int >(W));
    int index = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(i % 2 == 0){
                ans[i][j] = index + 1;
            }else{
                ans[i][W - j - 1] = index + 1;
            }
            A[index]--;
            if(A[index] == 0){
                index++;
            }
        }
    }
    
    for(int i=0; i<H; i++){
        bool first = true;
        for(int j=0; j<W; j++){
            if(first){
                std::cout << ans[i][j];
                first = false;
            }else{
                std::cout << " " << ans[i][j];
            }
        }
        std::cout << std::endl;
    }
    
    
    
    return 0;
}



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

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

    int cnt = 0;
    for (int i=0; i<n; i++) {
        // same value
        while(i<n-1 && a[i] == a[i+1]) i++;

        // up
        if (i<n-1 && a[i] < a[i+1])
            while(i<n-1 && a[i] <= a[i+1]) i++;
        // down
        else if (i<n-1 && a[i] > a[i+1])
            while(i<n-1 && a[i] >= a[i+1]) i++;

        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
 
class Main {
 
    public static void main(String[] args) {
 
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        scan.close();
        int i = 1;
 
        do{
            int x = i;
            if(x % 3 == 0){
                System.out.print(" " + i);
            }else{
                do{
                    if(x % 10 == 3){
                        System.out.print(" " + i);
                        break;
                    }else{
                        x /= 10;
                    }
                }while(x != 0);
            }
        }while( ++i <= n);
        System.out.print("\n");
 
    }
 
}
 

Measured memory_bytes: 24272
program abc087c
  implicit none
  integer :: n, i
  integer,dimension(:),allocatable :: u, l
  read *, n
  allocate(u(n),l(n))
  read *, u, l
  do i = 2,n
     u(i) = u(i)+u(i-1)
  end do
  do i = n-1,1,-1
     l(i) = l(i)+l(i+1)
  end do
  print *, maxval(u+l)
end program abc087c


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

int main()
{
  int n, k;
  int a, g, m;
  
  cin >> n >> k;

  cin >> g;
  m = g;
  for(int i = 0; i < n - 1; i++) {
    cin >> a;
    g = __gcd(a, g);
    m = max(m, a);
  }
  
  if(k % g == 0 && k <= m) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return (0);
  
}


Measured memory_bytes: 256
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(s==u){
		cout<<a-1<<" "<<b<<endl;
	}
	else cout<<a<<" "<<b-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn=200010;
int n,m,a,b,tag[maxn<<2],tmp[maxn<<2],minv[maxn<<2];
void pushdown(int l,int r,int o)
{
    tmp[o]=tag[o]+r-l;
	minv[o]=tag[o];
    if(l!=r)
    {
        int mid=l+r>>1,lo=o<<1,ro=lo|1;
        tag[lo]=tag[o];
		tag[ro]=tag[o]+mid-l+1;
    }
    tag[o]=0;
}
int query(int l,int r,int o,int x)
{
    if(tag[o])pushdown(l,r,o);
    if(l>x)return m+1;
    if(r<=x)return tmp[o];
    int mid=l+r>>1,lo=o<<1,ro=lo|1;
    int a=query(l,mid,lo,x),b=query(mid+1,r,ro,x);
    if(x<=r)a+= x>=mid ? x-mid : 0;
    else a+=r-mid;
    minv[o]=min(minv[lo],minv[ro]);
    tmp[o]=min(tmp[lo]+r-mid,tmp[ro]);
    return min(a,b);
}
void update(int l,int r,int o,int ql,int qr,int v)
{
    if(tag[o])pushdown(l,r,o);
    if(r<ql || l>qr)return;
    if(l>=ql && r<=qr)
    {
        tag[o]=v+l-ql;
        pushdown(l,r,o);
        return;
    }
    int mid=l+r>>1,lo=o<<1,ro=lo|1;
    update(l,mid,lo,ql,qr,v);
	update(mid+1,r,ro,ql,qr,v);
    minv[o]=min(minv[lo],minv[ro]);
    tmp[o]=min(tmp[lo]+r-mid,tmp[ro]);
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
	{
		a=read();b=read();
		int val=min(m+1,query(1,m,1,a-1)+1);
		update(1,m,1,a,b,val);
		if(minv[1]>=m)puts("-1");
		else printf("%d\n",minv[1]+i);
	}
	return 0;
}
/*

*/


Measured memory_bytes: 9756
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

ll h, w, n, ans[10]{};
map<P, int> g;

int main() {
    cin >> h >> w >> n;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        for (int j = -1; j <= 1; j++) {
            for (int k = -1; k <= 1; k++) {
                int nx = a + j, ny = b + k;
                if (nx > 1 && nx < h && ny > 1 && ny < w) g[{nx, ny}]++;
            }
        }
    }
    ans[0] = (h - 2) * (w - 2);
    for (auto itr : g) {
        ans[itr.second]++;
        ans[0]--;
    }
    REP(i, 10) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 56448
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
  int a,b;
  cin >> a >> b;
  int n;
  if(b==100){
      n=a*1000+b;
  }
  else if(b/10>=1){
      n=a*100+b;
  }
  else if(b<10){
      n=a*10+b;
  }
  bool c=false;
  rep(i,sqrt(n)+2){
      if(i*i==n){
          c=true;
          break;
      }
  }
  if(c)cout <<"Yes" << endl;
  else cout << "No" << endl;
  
}

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



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>




#include <ostream>
#include <sstream>


using namespace std;
class B {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    string a, b;
    in >> a >> b;
    string res;
    if(a.size() < b.size()){
      res = "LESS";
    }else if(a.size() > b.size()){
      res = "GREATER";
    }else{
      res = "EQUAL";
      for(int i = 0; i < a.size(); ++i){
        if(a[i] < b[i]){
          res = "LESS";
          break;
        }
        if(a[i] > b[i]){
          res = "GREATER";
          break;
        }
      }
    }
    out << res << endl;
	}
};


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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define N 10100
#define inf
#define mod
#define rg register
using namespace std;
typedef long long ll;
typedef double db;
int n,m,fa[N],x[N],y[N];
db tot=0,ans=0;
struct data{
	int x,y;
	db z;
}q[N*10];
bool cmp(data a,data b){ return a.z>b.z; }
int find(int k){ return fa[k]==k?fa[k]:fa[k]=find(fa[k]); }
db get_dis(int a,int b){ return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])); }
int main(){
//	freopen ("2224.in","r",stdin);
//	freopen ("2224.out","w",stdout);
	scanf ("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf ("%d%d",&x[i],&y[i]),fa[i]=i;
	for (int i=1;i<=m;++i){
		scanf ("%d%d",&q[i].x,&q[i].y);
		q[i].z=get_dis(q[i].x,q[i].y);tot+=q[i].z;
	}
	sort(q+1,q+m+1,cmp);
	int cnt=0;
	for (int i=1;i<=m;++i){
		int f1=find(q[i].x),f2=find(q[i].y);
		if (f1==f2) continue;
		fa[f1]=f2;
		cnt++;ans+=q[i].z;
		if (cnt==n-1) break;
	}
	printf ("%.3lf\n",tot-ans);
	return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>

int main(void)
{
	int a, b, c;

	scanf("%d%d%d", &a, &b, &c);

	if (a == b) {
		if (a == c) //すべて同じ場合
		{
			printf("No\n");
		}
		else //Cのみ違う場合
		{
			printf("Yes\n");
		}
	}
	else if (b == c) //Aのみ違う場合
	{
		printf("Yes\n");
	}
	else if (a == c) //Bのみ違う場合
	{
		printf("Yes\n");
	}
	else //すべて違う場合
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	ll ans;
	rep(i, n){
		if(i == 0) ans = k;
		else ans *= (k-1);
	}
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (a < 3200)
            {
                s = "red";
            }
            Console.WriteLine(s);
        }
    }

}


Measured memory_bytes: 11092
N = int(input())
ans = []
if N == 0:
    print(0)
    exit()
while not(N==0):
    a = -(N%(-2))
    b = (N-a)//(-2)
    N = b
    ans.append(str(a))
ans = [ans[-i-1] for i in range(len(ans))]
print("".join(ans)) 
   

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(LL, a, b, n);
	LL m = min(b - 1, n);
	OUT(a * m / b);
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

const int N=3e5+20,BIT=62,MOD=1e9+7;
int n;
long long a[N],ans;

long long mul(long long a,long long b,long long c)
{
	return ((a*b)%MOD*c)%MOD;
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);

	for(int j=0;j<BIT;j++)
	{
		int zero=0,one=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]%2==1) one++;
			else zero++;
			a[i]/=2;
		}
		ans+=mul(zero,one,(1ll<<j)%MOD);
		ans%=MOD;
	}

	printf("%lld",ans);
}

Measured memory_bytes: 2560
def bubble_sort(A, N):
	count = 0
	flag = 1
	while flag:
		flag = 0
		for i in range(N-1, 0, -1):
			if A[i] < A[i-1]:
				temp = A[i]
				A[i] = A[i-1]
				A[i-1] = temp
				count += 1
				flag = 1

	return A, count

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

A, count = bubble_sort(A, N)
print(' '.join(map(str, A)))
print(count)


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>

using namespace std;
int main() {
int N, n, j;
string s;
cin >> N;

vector<tuple<int, string, int>> p(N);
for (int i = 0; i < N; ++i) {
        cin >> s >> n;
        p[i] = make_tuple(n, s, i + 1); 
} 

sort(p.begin(), p.end(), greater<tuple<int, string, int>>());

vector<tuple<string, int, int, int>> q(N);
for (int i = 0; i < N; ++i) {
        tie(n, s, j) = p[i];
        q[i] = make_tuple(s, i, n, j); 
}

sort(q.begin(), q.end());

for (int i = 0; i < N; ++i) {
        tie(ignore, ignore, ignore, j) = q[i];
        cout << j << endl;
}
}

Measured memory_bytes: 888
#include<stdio.h>
#define max 10000
#define nil -1

struct Node{
  int parent,left,right;
};

struct Node T[max];
int n,D[max],H[max];

void setDepth(int u,int d){
  if(u==nil)return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left != nil){
    h1 = setHeight(T[u].left)+1;
  }
  if(T[u].right != nil){
    h2 = setHeight(T[u].right)+1;
  }
  return H[u] = (h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent == nil)return nil;
  if(T[T[u].parent].left != u && T[T[u].parent].left !=nil)
  return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right !=nil)
  return T[T[u].parent].right;

  return nil;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ",getSibling(u) );
  int deg = 0;
  if(T[u].left != nil )deg++;
    if(T[u].right != nil )deg++;
    printf("degree = %d, ",deg );
    printf("depth = %d, ",D[u] );
    printf("height = %d, ",H[u] );

    if(T[u].parent == nil){
      printf("root\n" );
    }
  else if(T[u].left == nil && T[u].right== nil){
    printf("leaf\n" );
  }else {
    printf("internal node\n" );
  }
}

int main(){
  int v,l,r,root = 0,n;
  scanf("%d",&n);

  for(int i = 0;i<n;i++){
    T[i].parent = nil;
  }

  for(int i = 0;i<n;i++){
    scanf("%d %d %d", &v,&l,&r );
    T[v].left = l;
    T[v].right = r;
    if(l!=nil)T[l].parent =v;
    if(r!=nil)T[r].parent = v;
  }

  for(int i = 0;i<n;i++)if(T[i].parent ==nil)root =i;

  setDepth(root,0);
  setHeight(root);

  for(int i ;i <n;i++)print(i);

  return 0;
}



Measured memory_bytes: 2044
// abc169_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  ll ans = 1;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) { cin >> a.at(i); }
  sort(a.begin(), a.end());
  if (a.front() == 0) {
    cout<<0<<endl;
    return 0;
  }
  ll limit = 1e18;

  rep(i, n) {
    if (limit / ans < a.at(i)) {
      cout << -1 << endl;
      return 0;
    }

    ans *= a.at(i);
  }

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


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long N){
    if (N % 2 == 0){
        cout << N << endl;
    } else{
        cout << N*2 << endl;
    }
}

int main(){

    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}



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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int Q;
    cin >> Q;
    rep(i, Q) {
        ll A, B, a, b, ans, C;
        cin >> a >> b;
        A = min(a, b);
        B = max(a, b);
        if (A == B) {
            //(1,2A-1)...(A-1,A+1),(A+1,A-1)...(2A-1,1)
            ans = 2 * A - 2;
        } else if (A + 1 == B) {
            //(1,2A)...(A-1,A+2),(A+2,A-1)...(2A,1)
            ans = 2 * A - 2;
        } else {
            C = sqrt(A * B);
            if (C * C == A * B) C--;
            if (C * (C + 1) >= A * B) {
                //(1,A+B+1)...(A-1,B+1),(A+1,2C-A-1)...(C,C)...(2C-1,1)
                ans = 2 * C - 2;
            } else {
                //(1,A+B+1)...(A-1,B+1),(A+1,2C-A)...(C,C+1)...(2C,1)
                ans = 2 * C - 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")

    };
}

fn main() {
    input!(n: usize, a: usize, b: usize,);
    if n * a <= b {
        println!("{}", n * a);
    } else {
        println!("{}", b)
    }
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int [] a = new int[n];
        Set<Integer> set = new HashSet<>();
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (set.contains(a[i])) {
                if (a[i] > 1) ok = false;
            }
            set.add(a[i]);
        }
        long gcd = 0;
        for (int i = 0; i < n; i++) gcd = gcd(gcd, a[i]);
        int [] prime = new int[1000003];
        prime[1] = 1;
        for (int i = 2; i <= 1000000; i++) {
            if (prime[i] > 0) continue;
            int ct = 0;
            if (set.contains(i)) ct++;
            for (int j = 2 * i; j < prime.length; j += i) {
                if (set.contains(j)) ct++;
                prime[j] = 1;
            }
            if (ct >= 2) ok = false;
        }
        if (ok && gcd == 1) {
            out.println("pairwise coprime");
        } else if (!ok && gcd == 1) {
            out.println("setwise coprime");
        } else {
            out.println("not coprime");
        }
        out.close();
    }

    static long gcd(long a, long b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 141280