akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <set>

#define ll long long
#define ld long double
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double>
#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define mod 1000000007


using namespace std;
int n;
int arr[22][22];
int dp[22][(1<<21)];
bool used[22];

/*

 ll solve(int index,int woman)
{
    if(index==n)
        return 1;


    if (~dp[index][woman])
        return dp[index][woman];
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(arr[index][i] && !used[i])
        {   used[i]=1;
            ans+=solve(index+1,i);
            ans%=mod;
            used[i]=0;
        }
    }
    return dp[index][woman]=ans;
}

 */

ll solve(int man,int woman)
{
    if(man==n)
        return 1;
    if (~dp[man][woman])
        return dp[man][woman];
    ll ans=0;
    for(int i=0;i<n;i++)
    {

        if(arr[man][i] && !((1<<i)& woman))
        {
            ans+=solve(man+1,(1<<i)| woman);
            ans%=mod;
        }
    }
    return dp[man][woman]=ans;
}
int main() {

    HS;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];
        memset(dp,-1,sizeof(dp));
        cout << solve(0,0);
    return 0;
}

Measured memory_bytes: 183744
N=int(input())
L=list(map(int,input().split()))
L.sort()
N=len(L)

ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]+L[j]>L[k] and L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k]:
                ans+=1

print(ans)


Measured memory_bytes: 67744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i)
        scanf("%d",&arr[i]);
    sort(arr.rbegin(),arr.rend());
    ll ans = 0;
    vector<int> sides;
    for(int i = 0; i < n-1; ++i)
        if(arr[i] == arr[i+1]){
            sides.push_back(arr[i]);
            ++i;
        }
    if(sides.size() >= 2)
        ans = (ll)sides[0]*sides[1];
    cout << ans << '\n';
}


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

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

	min = a;
	med = b;
	max = c;
	if (b < a){
		min = b;
		med = a;
	}
	if (c < med){
		max = med;
		med = c;
		if (med < min){
			med = min;
			min = c;
		}
	}
	
	cout << min << " " << med << " " << max << endl;

	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {
	ll a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a*b));
	system("PAUSE");
}

Measured memory_bytes: 504
import sys

a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
thr = e / (e + 100) * 100

water = set()
sugar = set()

for i in range(f // a + 1):
    for j in range((f - i * a) // b + 1):
        if i + j >= 1:
            water.add(i * a + j * b)

for i in range(f // c + 1):
    for j in range((f - i * c) // d + 1):
        sugar.add(i * c + j * d)

water = list(water)
sugar = list(sugar)
water.sort()
sugar.sort()

result = []
for w in water:
    for s in sugar:
        dens = s / (w + s) * 100
        if w + s > f or dens > thr:
            continue
        else:
            result.append((dens, w + s, s))

if len(result) == 0:
    print(-1)
    sys.exit()
else:
    result.sort(reverse=True)
    print(result[0][1], result[0][2])

Measured memory_bytes: 9860
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){

	string s;
	cin >> s;
	char prev='a',cur;
	int  cnt = 0;
	FORI(0, s.length()) {
		cur = s[i];
		if (cur != prev) {
			cnt++;
			prev = cur;
		}
	}
	cout << cnt - 1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


typedef struct Node{
    int number;
    vector<int> connected_nodes;
    long long point = 0;
} node_s;


void dfs(vector<node_s> &n, int root, int parent){
    if (root != 1){
        n[root].point += n[parent].point;
    }
    for(auto c : n[root].connected_nodes){
        if (c != parent){
            dfs(n, n[c].number, root);
        }
    }
}


int main(){
    int n, q;
    cin >> n >> q;
    vector<node_s> nodes(n + 1);
    for (int i = 1; i <= n; i++){
        node_s n;
        n.number = i;
        nodes[i] = n;
    }
    int a, b;
    for (int i = 1; i <= n - 1; i++){
        cin >> a >> b;
        nodes[a].connected_nodes.push_back(b);
        nodes[b].connected_nodes.push_back(a);
    }
    int p, x;
    for (int i = 0; i < q; i++){
        cin >> p >> x;
        nodes[p].point += x;
    }
    dfs(nodes, 1, 0);
    for(int i = 1; i <= n; i++){
        cout << nodes[i].point << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 25856
#include <iostream>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::swap;

void output(int *data, int n) {
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			cout << " ";
		}
		cout << data[i];
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	int array[n];
	for (int i = 0; i < n; i++) {
		cin >> array[i];
	}
	output(array, n);
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j >= 1; j--) {
			if (array[j - 1] > array[j]) {
				swap(array[j - 1], array[j]);
			}
		}
		output(array, n);
	}
	return 0;
} 

Measured memory_bytes: 3104
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    ll sum=0, mn=LLINF;
    rep(i,N){
        int a,b; cin>>a>>b;
        sum+=a;
        if(a>b&&mn>b) mn=b;
    }
    if(mn==LLINF) sum=mn=0;
    cout1(sum-mn);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, tmp, c, step;
    
    scanf("%d %d", &a, &b);
    
    while(a!=0 || b!=0){
        step=0;
        
        if(a<b){
           tmp = a;
           a = b;
           b = tmp;
        } 
    
        do{
           c = a%b;
           a = b;
           b = c;
           step++;
        }while(c != 0);
   
        printf("%d %d\n", a, step);
        scanf("%d %d", &a, &b);
    }
        
    
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n; cin >> n ;
    vector<ll> a(n);
    map<ll, ll> mp;
    for(int i = 0; i < n-1; ++i){
        cin >> a[i];
        --a[i];
        ++mp[a[i]];
    }
    for(int i = 0; i < n; ++i){
        cout << mp[i] << endl;
    }
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 17200
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,cnt1=0,cnt2=0,cnt,a,b;
  string s;
  cin >> n >> s;
  for(int i=0; i<n; i++) {
    if((int)s[i]<=77) {
      cnt1++;
    }
    else if((int)s[i]<=90) {
      cnt1--;
    }
    else if((int)s[i]<=109) {
      cnt2++;
    }
    else {
      cnt2--;
    }
  }
  a=max(cnt1,-cnt1),b=max(cnt2,-cnt2);
  cnt=a+b;
  cout << cnt << endl;
  if(cnt1>0) {
    for(int i=0; i<cnt1; i++) {
      cout << 'A';
    }
    
  }
  else if(cnt1<0) {
    for(int i=0; i<-cnt1; i++) {
      cout << 'N';
    }
  }
  if(cnt2>0) {
    for(int i=0; i<cnt2; i++) {
      cout << 'a';
    }
  }
  else if(cnt2<0) {
    for(int i=0; i<-cnt2; i++) {
      cout << 'n';
    }
  }
}


Measured memory_bytes: 3336
#include <iostream>

using namespace std;

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

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

    if (a[4]-a[0]<=k)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 24 12:23:05 2020

@author: vivek
"""

n,d=[int(i) for i in input().strip().split(" ")]
ans=0
for _ in range(n):
  x,y=[int(i) for i in input().strip().split(" ")]
  if x*x+y*y<=d*d:
    ans+=1
print(ans)

Measured memory_bytes: 9180
import sys
import numpy as np
n = int(input())

dp = list(map(int, sys.stdin.readline().split()))

for i in range(n-1):
    a, b, c = list(map(int, sys.stdin.readline().split()))
    dp0, dp1, dp2 = dp
    dp[0] = max(dp1+a,dp2+a)
    dp[1] = max(dp0+b,dp2+b)
    dp[2] = max(dp0+c,dp1+c)
print(max(dp))

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <string>
#define ll long long int
#define ull unsigned long long int
#define db long double
#define rep(i,p,q) for(i=p;i<q;++i)
#define REP(i,p,q) for(i=p;i<=q;++i)
#define MOD 1000000007
#define stop return 0
#define pb push_back
#define nil -1
#define initial 0
#define waiting 1
#define visited 2
#define inf 10e+9
#define pb push_back
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 300005
#define MAX2 2000005
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;

int main()
{
    ll a,b;
    cin>>a>>b;
    ll result = a;
    ll count = 1;
    if(b==1)
     cout<<0<<endl;

    else
    {
    while(1)
    {
      if(result<b)
      {
      	 result += (a-1);
      	 count++;
      }
      else
      	break;
    }
      cout<<count<<endl;
    }
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)
 
signed main(){
 
	lli a,b,c;
	cin>>a>>b>>c;
	lli d = (c-a-b);
	if(d<0)cout<<"No"<<endl;
	else if(d*d > 4*a*b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int n,f[100005];
long long m;
long long calc(int k)
{
	int l,r;
	long long cnt=0;
	r=n+1;
	for (l=1;l<=n;l++)
	{
		while (f[l]+f[r-1]>=k&&r>1) --r;
		cnt=cnt+(n-r+1);
	}
	return cnt;
}
int bs(int l,int r)
{
	if (l==r) return l;
	int mid=(l+r+1)/2;
	if (calc(mid)>=m) return bs(mid,r);
	else return bs(l,mid-1);
}
long long solve(int k,long long p)
{
	int l,r;
	long long ans=0,cnt=0;
	r=n+1;
	for (l=1;l<=n;l++)
	{
		while (f[l]+f[r-1]>=k&&r>1) --r;
		ans=ans+1ll*(n-r+1)*f[l];
		cnt=cnt+(n-r+1);
	}
	ans=ans*2;
	if (cnt>p) ans=ans-k*(cnt-p);
	return ans;
}
int main()
{
	scanf("%d%lld",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&f[i]);
	std::sort(f+1,f+n+1);
	int k=bs(1,200000);
	printf("%lld\n",solve(k,m));
	return 0;
}

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

using namespace std;

int main(void)
{
	int s;
	int upper, lower;

	cin >> s;

	upper = s / 100;
	lower = s % 100;

	bool isYYMM = false;
	bool isMMYY = false;

	if (1 <= lower && lower <= 12)
	{
		isYYMM = true;
	}
	if (1 <= upper && upper <= 12)
	{
		isMMYY = true;
	}

	if (isMMYY && isYYMM)
	{
		cout << "AMBIGUOUS";
	}
	else if (isMMYY && !isYYMM) {
		cout << "MMYY";
	}else if(!isMMYY && isYYMM){

		cout << "YYMM";
	}
	else {
		cout << "NA";
	}


	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a==1) && b==1) cout << "Draw" << endl;
  else if (a==1)  cout << "Alice" << endl;
  else if (b==1) cout << "Bob" << endl;
  else if (a == b) cout << "Draw" << endl;
  else if (a > b) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}




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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h.at(i);

	int ans = 0;
	rep(i, n){
		if(k <= h.at(i)) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
 
//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
 
int main(){
 
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> xs(n), ys(m);
 
    REP(i,n){
        cin >> xs[i];
        if(xs[i]>=y){
            cout << "War" << endl;
            return 0;
        }
    }
    int x_border = max(x, *max_element(xs.begin(), xs.end()));
 
    REP(i,m){
        cin >> ys[i];
        if(ys[i]<=x_border){
            cout << "War" << endl;
            return 0;
        }
    }
 
    cout << "No War" << endl;
 
 
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	ArrayList<ArrayList<Link>> link;
	int[] colors;
		
	private void solve() {
		//input
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		link = new ArrayList<ArrayList<Link>>();
		for(int i=0; i<N; i++) {
			link.add(new ArrayList<Link>());
		}
		for(int i=0; i<N-1;i++) {
			int u = in.nextInt()-1;
			int v = in.nextInt()-1;
			int w = in.nextInt();
			link.get(u).add(new Link(v,w));
			link.get(v).add(new Link(u,w));
		}
		
		colors = new int[N];
		for(int i=0; i<N; i++) {
			colors[i] = -1;
		}
		draw(0,0);
		
		//output
		for (int b : colors) {
			System.out.println(b);
		}
	}

	private void draw(int node, int color) {
		if(colors[node] != -1) return;
		colors[node] = color;
		for(Link l : link.get(node)) {
			if(l.w == 0) continue;
			if((l.w & 1) == 0) {
				draw(l.next, color);
			}else {
				draw(l.next, (color==0)?1:0);
			}
		}
	}
	
	private class Link{
		int next;
		int w;
		
		public Link(int next, int w) {
			this.next = next;
			this.w = w;
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}

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

int palindrome(int x) {
    string s = to_string(x);
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

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

    int count = 0;
    for (int i = a; i <= b; i++) {
        if (palindrome(i)) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3688
until(s=gets.gsub(/\d+/){|k|?1*k.hex})[?#]
n=1+s.index(?/)
eval"s[n*c-n+e-1]=?1;s[n*g-n+i-1]=?bdfh".tr('c-i',gets)
$><<s.gsub(/1+/,&:size)
end

Measured memory_bytes: 8828
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

struct Edge{
    int s, t, w;
    Edge(){};
    Edge(int s0, int t0, int w0){
        s = s0;
        t = t0;
        w = w0;
    }
    bool operator < (const Edge &e){
        return w < e.w;
    }
};


struct DisjointSet{
    vector<int> rank, p;

    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size, 0);
        p.resize(size, 0);
        rep(i, size) makeSet(i);
    }

    void makeSet(int x){
        rank[x] = 0;
        p[x] = x;
    }

    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }

    int findSet(int x){
        if(p[x] == x) return x;
        p[x] = findSet(p[x]);        
        return p[x];
    }

    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }

    void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        } else {
            p[x] = y;
            if(rank[x] == rank[y]) rank[y]++;
        }
    }
};



int main(){
    int N, M;
    cin >> N >> M;
    vector<Edge> G;

    rep(i, M){
        Edge e;
        cin >> e.s >> e.t >> e.w;
        G.push_back(e);
    }

    sort(all(G));

    DisjointSet ds(N);
    int ans = 0;

    rep(i, M){
        Edge e = G[i];
        if(!ds.same(e.s, e.t)){
            ds.unite(e.s, e.t);
            ans += e.w;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4448
'use strict'

function _xor(a,b){
	let sa = a.toString(2);
	let sb = b.toString(2);
	if(sa.length < sb.length){
		sa = ('0000000000000000000000000000000000000000000000000000000000000000000000'+sa).slice(-sb.length);
	}else if(sa.length > sb.length){
		sb = ('0000000000000000000000000000000000000000000000000000000000000000000000'+sb).slice(-sa.length);
	}
 
 
	let answer = 0;
	let bi = 1;
	for(let i=sa.length-1;i>=0;i--){
		if((sa[i]==="0"&&sb[i]==="1")||(sa[i]==="1"&&sb[i]==="0")){
			answer += bi;
		}
		bi *= 2;
	}
	return answer;
}

function xor(a,b){
  const m = 10000000;
  var tmp_up = (parseInt(a/m)^parseInt(b/m))*m;
  var tmp_down = (a%m)^(b%m);

  if(a<m && b<m){return tmp_down;}
  if(a<m){tmp_up = parseInt(b/m)*m;}
  if(b<m){tmp_up = parseInt(a/m)*m;}

  return tmp_down+tmp_up;
}

function acc_xor(n){
  if(n<=0){return 0;}
  if(n%4==0){
    return xor(0,n);
  }
  if(n%4==1){
    return 1;
  }
  if(n%4==2){
    return xor(1,n);
  }
  if(n%4==3){
    return 0;
  }

}

function main(input) {
  const formatted_input = input.split('\n');
  const A =  parseInt(formatted_input[0].split(' ')[0]);
  const B =  parseInt(formatted_input[0].split(' ')[1]);

  const acc_a = acc_xor(A-1);
  const acc_b = acc_xor(B);
  const result = _xor(acc_a, acc_b)
//  console.log([A,B]);
//  console.log([acc_a,acc_b]);
//  console.log(_xor(B,0))
  console.log(result);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main() {
	int n, m, diff[100000],x[100000];
	cin >> n >> m;
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	sort(x, x + m);
	for (int i = 0; i < m - 1; i++) {
		diff[i] = x[i+1]-x[i];
	}
	sort(diff, diff + m - 1);
	int ans = x[m-1]-x[0];
	for (int i = 0; i < n-1; i++) {
		ans -= diff[m - 2 - i];
	}
	cout << ans << endl;

}

Measured memory_bytes: 1024
//
//  main.cpp
//  淇冲彞
//
//  Created by RMBP on 2019/10/20.
//  Copyright 漏 2019 RMBP. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a[3],i,b,c;
    b=0;
    c=0;
    for (i=0;i<3;i++){
        cin>>a[i];
        if (a[i]==5){
            b=b+1;
        }
        else if (a[i]==7){
            c=c+1;
        }
    }
    if (b==2&c==1){
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    int n,a,cnt[100002],Max = 0;
    rep0(i, 100002)cnt[i] = 0;
    cin >> n;
    rep0(i, n){
        cin >> a;
        ++cnt[a];
        ++cnt[a + 1];
        ++cnt[a + 2];
    }
    rep1(i, 100002)Max = max(cnt[i], Max);
    cout << Max << endl;
    return 0;
}


Measured memory_bytes: 640
# coding: utf-8

str = input()
q = int(input())

for _ in range(q):
    line = input().split()
    c = line[0]
    a = int(line[1])
    b = int(line[2]) + 1

    if c == 'replace':
        str = str[:a] + line[3] + str[b:]
    elif c == 'reverse':
        str = str[:a] + str[a:b][::-1] + str[b:]
    else:
        print(str[a:b])


Measured memory_bytes: 5620
#!/usr/bin/python3

import os
import sys


def main():
    H, W = read_ints()
    A = [read_ints() for _ in range(H)]
    print(solve(H, W, A))


def solve(H, W, A):
    best = 2 ** 63
    for ay in range(H):
        for ax in range(W):
            s = 0
            for y in range(H):
                for x in range(W):
                    s += A[y][x] * min(abs(y - ay), abs(x - ax))
            best = min(best, s)

    return best


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5612
#include <stdio.h>
#include <math.h>
int main()
{
    long long int a,b;
    int count = 0;
    scanf("%lld%lld",&a,&b);

 //   printf("%lld %lld\n", a, b);
    while( a <= b)
    {
        a *= 2;
        count++;
    }
    printf("%d\n",count);
    return 0;
}


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

int main(void){
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n);

  for(int i = 0; i < n; i++){
    x[i].resize(d);
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      double distance = 0;
      for(int k = 0; k < d; k++){
        distance += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      if(ceil(sqrt(distance)) == floor(sqrt(distance))) ans++;
    }
  }

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,a[10],n;
  string str;
  char ans;
  cin >> n;
  for(int t=0;t<n;t++){  
    cin >> str;
    for(i=0;i<10;i++) a[i] = 0;
    for(i=0;i<str.size();i++){
      if(i != 0 && str[i] == '0'){
	if(str[i-1] == '1' && (a[1]) % 5 == 1) ans = '.';
	else if(str[i-1] == '1' && (a[1]) % 5 == 2) ans = ',';
	else if(str[i-1] == '1' && (a[1]) % 5 == 3) ans = '!';
	else if(str[i-1] == '1' && (a[1]) % 5 == 4) ans = '?';
	else if(str[i-1] == '1' && (a[1]) % 5 == 0) ans = ' ';
	else if(str[i-1] == '2' && (a[2]) % 3 == 1) ans = 'a';
	else if(str[i-1] == '2' && (a[2]) % 3 == 2) ans = 'b';
	else if(str[i-1] == '2' && (a[2]) % 3 == 0) ans = 'c';
	else if(str[i-1] == '3' && (a[3]) % 3 == 1) ans = 'd';
	else if(str[i-1] == '3' && (a[3]) % 3 == 2) ans = 'e';
	else if(str[i-1] == '3' && (a[3]) % 3 == 0) ans = 'f';
	else if(str[i-1] == '4' && (a[4]) % 3 == 1) ans = 'g';
	else if(str[i-1] == '4' && (a[4]) % 3 == 2) ans = 'h';
	else if(str[i-1] == '4' && (a[4]) % 3 == 0) ans = 'i';
	else if(str[i-1] == '5' && (a[5]) % 3 == 1) ans = 'j';
	else if(str[i-1] == '5' && (a[5]) % 3 == 2) ans = 'k';
	else if(str[i-1] == '5' && (a[5]) % 3 == 0) ans = 'l';
	else if(str[i-1] == '6' && (a[6]) % 3 == 1) ans = 'm';
	else if(str[i-1] == '6' && (a[6]) % 3 == 2) ans = 'n';
	else if(str[i-1] == '6' && (a[6]) % 3 == 0) ans = 'o';
	else if(str[i-1] == '7' && (a[7]) % 4 == 1) ans = 'p';
	else if(str[i-1] == '7' && (a[7]) % 4 == 2) ans = 'q';
	else if(str[i-1] == '7' && (a[7]) % 4 == 3) ans = 'r';
	else if(str[i-1] == '7' && (a[7]) % 4 == 0) ans = 's';
	else if(str[i-1] == '8' && (a[8]) % 3 == 1) ans = 't';
	else if(str[i-1] == '8' && (a[8]) % 3 == 2) ans = 'u';
	else if(str[i-1] == '8' && (a[8]) % 3 == 0) ans = 'v';
	else if(str[i-1] == '9' && (a[9]) % 4 == 1) ans = 'w';
	else if(str[i-1] == '9' && (a[9]) % 4 == 2) ans = 'x';
	else if(str[i-1] == '9' && (a[9]) % 4 == 3) ans = 'y';
	else if(str[i-1] == '9' && (a[9]) % 4 == 0) ans = 'z';
	if(str[i-1] != '0') cout << ans;
	for(j=0;j<10;j++) a[j] = 0;
      }
      else a[str[i]-'0']++;      
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a+b, max(a-b, a * b)) << endl;
}


Measured memory_bytes: 256
import collections

n, k, q = [int(elem) for elem in input().split()]

a_lst = []
for i in range(q):
  a = int(input())
  a_lst.append(a)

res = [k - q] * n
c = collections.Counter(a_lst)
for k in c.keys():
  res[k - 1] += c[k]

for elem in res:
  if elem > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 13944
N = int(input())
A = [int(input()) for _ in range(N)]


ans = 0
cnt = 0
for i in range(N):
    if A[i] != 0:
        ans += (A[i]+cnt)//2
        cnt = (A[i]+cnt)%2
    else:
        cnt = 0
print(ans)

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

int main() {
    int n,cnt;
    cin>>n;
    cnt=0;
    for(int i=1;i*i<=n-1;i++) {
        for(int j=i;j*i<n;j++) cnt+=2;
    }
    cnt-=int(sqrt(n-1));
    cout<<cnt<<endl;
    return 0;
}

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

int main() {
  int mod = 1e9 + 7;
  long long N;
  cin >> N;
  long long ans = 1;
  for (int i = 1; i <= N; ++i)
    ans = ans * i % mod;
  cout << ans << endl;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

typedef pair<string, ll> psl;

struct T
{
    string s;
    int p;
    int i;
};
T S[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> S[i].s >> S[i].p;
        S[i].i = i;
    }
    sort(S, S + N, [](T a, T b) { return a.s == b.s ? a.p > b.p : a.s < b.s; });
    REP(i, N)
    {
        cout << S[i].i + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>

std::vector<int> v;

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int x; scanf("%d", &x);
		if(x > i) return 0 * puts("-1");
		v.insert(v.begin() + x - 1, x);
	}
	for(int i = 0; i < n; i++) printf("%d\n", v[i]);
}

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

using namespace std;

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

typedef long long ll;

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

 long n;
  cin >> n;
  bool flag=false;
  rep(i,0,n){
  long a;
    cin >> a;
    if(a%2) flag=true;
  }
  
 
   if(flag) cout << "first" << endl;
   else cout << "second" << endl;
  
  
  
}


Measured memory_bytes: 256
int joseph(int n,int diff,int initial){
	int r=0,i=1;
	for(;i<n;i++)r=(r+diff)%i;
	return (r+1+initial)%n+1;
}
int main(){
	int n,k,m;
	for(;scanf("%d%d%d",&n,&k,&m),n;)printf("%d\n",joseph(n,k,m-1));
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
    int n;
    cin >> n;
    vector<int>d(n);
    for(int i=0; i<n; i++){
        cin >> d.at(i);
    }
    if (n%2 == 1){
        cout << 0 << endl;
    }

    else {
        sort(d.begin(), d.end());
        cout << d.at((n-1)/2+1) - d.at((n-1)/2) <<  endl;
    }
}

Measured memory_bytes: 640
<?php


fscanf(STDIN, "%d%d", $a, $b);
$min = min($a, $b);
if($min != $a){
    list($a, $b) = [$b, $a];
}
$max = (int)(sqrt($b)) + 1;
$ans = 1;
if($a % 2 == 0 && $b % 2 == 0){
    while($a % 2 == 0){
        $a = $a / 2;
    }
    $ans++;
}
for($i = 3; $i<=$max; $i=$i+2){
    if($a < $i){
        break;
    }
    if($a % $i == 0 && $b % $i ==0){
        while($a % $i == 0){
            $a = $a / $i;
        }
        $ans++;
    }
}

if(gcd($a, $b) > $max){
    $ans++;
}
echo $ans;
exit;


function gcd($m, $n){

    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}

Measured memory_bytes: 4604
n = int(input())
a = [int(_) for _ in input().split()]

new_a = [0] * n
for i in range(n):
    new_a[i] = a[i] - (i+1)
sorted_a = sorted(new_a)
b = sorted_a[n//2]
ans = 0
for i in range(n):
    ans += abs(new_a[i] - b)
print(ans)

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

int main() {
	string S;
  	cin >> S;
  
  string ans = "Yes";
  for(int i = 0; i < S.size(); i++){
    if( i % 2 == 0 && S.at(i) == 'L' ){
      ans = "No";
      break;
    }
    if( i % 2 == 1 && S.at(i) == 'R' ){
      ans = "No";
      break;
    }
  }
    
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int dp[105][4][2];


int nck(int n, int k){
  int ret = 1;
  REP(i, k){
    ret *= n;
    n--;
  }
  FORr(i, k, 1){
    ret /= i;
  }
  return ret;
}

int main(void){
  string s;
  int K;
  cin >> s >> K;

  int n = s.size();
  
  dp[0][0][0] = 1;
  REP(i, n){
    REP(j, 4){
      REP(k, 2){
        //nd:i桁目の数字
        int nd = s[i] - '0';
        
        //0~9まで数字を試す
        REP(d, 10){
          //ni:次の桁
          //nj:使った非0の数
          //nk:i桁目の数字と一致してるか=0,それ以下か=1
          int ni = i+1, nj = j, nk = k;
          //非0ならjを増やす
          if(d != 0) nj++;
          //njがkより大きい->k個非0を使ってたら飛ばす
          if(nj > K) continue;
          //dがndと一致してるか確かめる
          if(k == 0){
            if(d > nd) continue;
            if(d < nd) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def GCD(a, b):
    if a > b:
        A = a
        B = b
    elif b > a:
        A = b
        B = a
    else:
        return a

    r = A % B
    while r != 0:
        A = B
        B = r
        r = A % B

    return B


def LCM(a, b):
    g = GCD(a, b)
    return a*b // g


def solve(): # ABC070C- Multiple Clocks
    while 1:
        try:
            n = int(input())
            T = []
            for _ in range(n):
                T.append(int(input()))

            l = T[0]
            for i in range(1, n):
                l = LCM(l, T[i])

            print(l)
        except:
            break
            
            
solve()

Measured memory_bytes: 3064
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

/*

右と下について再帰的に求めに行く

重複して数えるということはないか

どこから始めるか、で場合分け

スタートと終わりがかぶらないから重複はないな。

...
.#.
.#. 
 
 周りのつながっている数を数える
 
 数えるのはルートじゃないからそれで重複しちゃいそう。
 
 union findでグループに入れちゃうっていうのもありか
 
 右と下みて、違うやつなら同じグループ、


*/

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


// http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
// 素集合データ構造
struct UnionFind
{
 // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
 vector<int> par;
 // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
 vector<int> sizes;

 UnionFind(int n) : par(n), sizes(n, 1) {
   // 最初は全てのデータiがグループiに存在するものとして初期化
   rep(i,n) par[i] = i;
 }

 // データxが属する木の根を得る
 int find(int x) {
   if (x == par[x]) return x;
   return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
 }

 // 2つのデータx, yが属する木をマージする
 void unite(int x, int y) {
   // データの根ノードを得る
   x = find(x);
   y = find(y);

   // 既に同じ木に属しているならマージしない
   if (x == y) return;

   // xの木がyの木より大きくなるようにする
   if (sizes[x] < sizes[y]) swap(x, y);

   // xがyの親になるように連結する
   par[y] = x;
   sizes[x] += sizes[y];
   // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
 }

 // 2つのデータx, yが属する木が同じならtrueを返す
 bool same(int x, int y) {
   return find(x) == find(y);
 }

 // データxが含まれる木の大きさを返す
 int size(int x) {
   return sizes[find(x)];
 }
};



ll h,w;
std::vector<string> s(500);

int main() {
    std::cin >> h>>w;
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }
    
    UnionFind uf(h*w);
    // kuro ,shiro
    unordered_map<ll,pair<ll,ll>> cou;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(i<h-1){
                if(s[i][j] != s[i+1][j]){
                    uf.unite(i*w+j,(i+1)*w+j);
                }
            }
            if(j<w-1){
                if(s[i][j] != s[i][j+1]){
                    uf.unite(i*w+j,i*w+j+1);
                }
            }
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(s[i][j] == '#'){
                cou[uf.find(i*w+j)].first++;
            }else{
                cou[uf.find(i*w+j)].second++;
            }
        }
    }
    ll sum = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(s[i][j]=='#'){
                sum += cou[uf.find(i*w+j)].second;
            }
        }
    }
    
    std::cout << sum << std::endl;
}
 

Measured memory_bytes: 10404
#include<cstdio>
#include<cmath>
int main(){
  double x1,y1,x2,y2;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  printf("%.7f\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, K;
  string S;

  cin >> N >> S >> K;
  for (int i = 0; S[i]; ++i) {
    if (S[i] != S[K-1]) {
      S[i] = '*';
    }
  }

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "sort"
)

func main() {
  var n int
  fmt.Scan(&n)
  L := make([]int, n)
  for i := range(L) {
    fmt.Scan(&L[i])
  }
  sort.Ints(L)
  ans := 0
  for i := 0; i < n; i++ {
    for j := i + 1; j < n; j++ {
      a, t := L[j+1:], L[j]+L[i]
      l, r := -1, len(a)
      for r-l > 1 {
        if m := (l+r)/2; a[m] < t {
          l = m
        } else {
          r = m
        }
      }
      ans += l + 1
    }
  }
  fmt.Println(ans)
}
	

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

bool build(vector<int> &vec, vector<queue<int> > & l, vector<queue<int> > & r){
  int li=0, ri=0;
  while(li<l.size() && l[li].size()==0) li++;
  while(ri<r.size() && r[ri].size()==0) ri++;

  int blk=0;
  rep(i,vec.size()){
    if(vec[i]!=-INF){
      if(l[blk].size()>0) return false;
      blk++;
    } else {
      if(li == l.size()){
        // rからとる
        if(ri > blk) return false;
        vec[i] = r[ri].front(); r[ri].pop();
        while(ri<r.size() && r[ri].size()==0) ri++;
      } else {
        // lからとる
        vec[i] = l[li].front(); l[li].pop();
        while(li<l.size() && l[li].size()==0) li++;
      }
    }
  }
  return true;
}

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  vector<int> res(n*n, -INF);
  rep(i,n) scanf("%d", &vec[i]);
  rep(i,n){ vec[i]--; res[vec[i]]=i+1;}

  vector<int> sorted(vec);
  sort(all(sorted));

  vector<queue<int> > l(n+1, queue<int>()); // これよりも左にならいける集合
  vector<queue<int> > r(n+1, queue<int>()); // 右にならいける集合

  rep(i,n){
    int idx = lower_bound(all(sorted), vec[i]) - sorted.begin();
    rep(j,i) l[idx].push(i+1);
    repl(j,i+1,n) r[idx+1].push(i+1);
  }

  if(build(res, l, r)){
    cout << "Yes" << endl;
    rep(i,n*n) printf("%d%c", res[i], " \n"[i==n*n-1]);
  } else {
    cout << "No" << endl;
  }


  return 0;
}


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


int main() {
    int n, k;
    int count = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int height;
        cin >> height;
        if (height >= k) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
S=input()

def Diff(S,S2):
    r=0
    for i in range(len(S)):
        if S[i]!=S2[i]:
            r+=1
            
    return r


if len(S)%2==0:
    print(min(Diff(S,"01"*int(len(S)/2)),Diff(S,"10"*int(len(S)/2))))
else:
    print(min(Diff(S,"01"*int(len(S)/2)+"0"),Diff(S,"10"*int(len(S)/2)+"1")))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	ios_base::sync_with_stdio( false );
     
    	int N, M;
    	cin >> N >> M;
     
    	int L = 0;
    	int R = N;
    	for( int i = 0; i < M; ++i ) {
    		int a, b;
    		cin >> a >> b;
     
    		L = max( L, a );
    		R = min( R, b );
    	}
     
    	cout << max( R-L + 1, 0 ) << endl;
     
    	return 0;
    }

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

int main(){
    int a,b;
    char op =' ';
    int f = 1;
    while(f){
        scanf("%d %c %d",&a,&op,&b);
        switch(op){
            case '+':printf("%d\n",a+b);break;
            case '-':printf("%d\n",a-b);break;
            case '*':printf("%d\n",a*b);break;
            case '/':printf("%d\n",a/b);break;
            default :f=0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3196
require "rational"
while line = gets
	test = line.split(/\s+/)
	tmp=[]
	tmp[0]=test[0].to_i
	tmp[1]=test[1].to_i
	test[0]=tmp[0].gcd(tmp[1]) 
	test[1]=tmp[0].lcm(tmp[1])
	print test[0]
	print(" ")
	puts test[1]
end

Measured memory_bytes: 6120
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (998244353)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

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


//std::ios::sync_with_stdio(false);
int vis[3005][30065],dp[3005][3005],a[3005],n,s;
int compute(int rem,int pos){
	if(rem<0){
		return 0;
	}
	if(pos==n){
		if(rem==0){
			return 1;
		}
		return 0;
	}
	if(vis[rem][pos]){
		return dp[rem][pos];
	}
	int val,val1;
	vis[rem][pos]=1;
	dp[rem][pos]=0;
	val=compute(rem-a[pos],pos+1);
	val1=compute(rem,pos+1)*2LL;
	val+=val1;
	val%=mod;
	dp[rem][pos]=val;
	return val;
}
main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int t,t1;
	t=1;
//	cin>>t;
	t1=t;
	while(t--){
//		cout<<"Case #"<<t1-t<<": ";
		int val,ans,i;
		cin>>n>>s;
		rep(i,n){
			cin>>a[i];
		}
		val=compute(s,0);
		cout<<val<<endl;
	}
	return 0;
} 


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

int n, m;
vector<int> a, b;
vector<int> o;

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x; cin >> x;
        if (x%2 == 1)
            o.push_back(x);
        else
            a.push_back(x);
    }

    if (n%2 == 1 && o.size() > 1) {
        cout << "Impossible\n";
        return 0;
    } if (n%2 == 0 && o.size() > 2) {
        cout << "Impossible\n";
        return 0;
    }

    if (o.size() == 1) {
        a.push_back(o[0]);
    } if (o.size() == 2) {
        a.insert(a.begin(), o[0]);
        a.push_back(o[1]);
    }

    if (m == 1) {
        b.push_back(1);
        if (n != 1)
            b.push_back(n - 1);
    } else {
        for (int i = 0; i < m; ++i) {
            if (i == 0) {
                if (a[i]%2 == 1)
                    b.push_back(a[i]+1);
                else {
                    b.push_back(1);
                    b.push_back(a[i]);
                }
                continue;
            }

            if (i == m-1) {
                if (a[i] != 1)
                    b.push_back(a[i]-1);
                continue;
            }

            b.push_back(a[i]);
        }
    }

    for (int i = 0; i < m; ++i)
        cout << a[i] << ' ';
    cout << "\n";
    cout << b.size() << "\n";

    for (int i = 0; i < b.size(); ++i)
        cout << b[i] << ' ';
    cout << endl;
}

Measured memory_bytes: 256
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
 
c = 0
for t in T:
    left = 0
    right = n
    while left < right:
        mid = int((left + right)/2)
        if(S[mid] == t):
            c+=1
            break
        elif(t<S[mid]):
            right = mid
        else:
            left = mid+1
 
print c

Measured memory_bytes: 14776
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] dices = new int[n];
        double[] expected = new double[n];
        double max = 0;
        for(int i = 0 ; i < n ; i++){
            dices[i] = scanner.nextInt();
            expected[i] = i == 0 ? calc(dices[i]) : expected[i - 1] + calc(dices[i]);

            if((i + 1) < k){
                continue;
            }

            double dice = (i + 1) == k ? expected[i] : expected[i] - expected[i - k];
            if(max < dice){
                max = dice;
            }
        }
        System.out.println(max);
    }

    static double calc (int n){
        double result = (1.0+n)/2;
        return result;
    }

}

Measured memory_bytes: 86604
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

const int max_n = 100005;

int cnt[max_n + 1];

int main(void)
{
	int n;
	int i;
	scanf("%d\n", &n);
	for(i = 0; i < n; ++i) {
		int x;
		scanf("%d ", &x);
		++cnt[(x + 1)]; // 0
		++cnt[(x + 2)]; // +1
		++cnt[x]; // -1
	}
	int best = 0;
	for(i = 0; i < max_n; ++i)
		best = max(best, cnt[i]);
	printf("%d\n", best);

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int cnt = 0;
	for(int i=0;i<s.length();++i){
		if(s[i]!=t[i]){
			cnt++;
		}
	}
	if(!cnt && s.length()==t.length()-1){
		cout<<"Yes"<<'\n';
	}
	else{
		cout<<"No"<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

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

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


int main() {
    int N; cin>>N;
    int A[N+1];
    rep(i,N+1)cin>>A[i];
    int B[N];
    rep(i,N)cin>>B[i];
    ll cnt =0;
    for(int i=0;i<N;i++){
        if(A[i]>=B[i])cnt+=B[i];
        else{
            cnt +=A[i];
            B[i]-=A[i];
            if(A[i+1]>B[i]){
                cnt+=B[i];
                A[i+1]-=B[i];
            }
            else{
                cnt+=A[i+1];
                A[i+1]=0;
            }

        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int f[50];

int fib(int x){
  if(x==0 || x==1)return f[x]=1;
  if(f[x]!=-1)return f[x];
  return f[x]=fib(x-1)+fib(x-2);
}

int main(){
  int i,n;
  for(i=0;i<50;i++){
    f[i]=-1;
  }
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}



Measured memory_bytes: 2048