akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s)begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

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

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

//------------------HEAD---------------------

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true){
    int n;
    cin>>n;
    if(n==0)return 0;
    rep(i,9){
        int t;cin>>t;
        n-=t;
    }
    cout<<n<<endl;
    }
    return 0;
}


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

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

    int a = n%10;

    switch (a)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
    default:
        break;
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;
  if (n&1) {cout << "No\n"; return 0;}
  string s;
  cin >> s;
  cout << (s.substr(0,n/2)==s.substr(n/2,n/2)?"Yes\n":"No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
//#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef vector<string> vi;
typedef pair<int,int> pi;
const int N = 2e5+10;
bool pr[N];
vector<int>prime;

int main()
{
     int n;
      int a[1001];
      int m[4][4];
      memset(a,0,sizeof a);
      for(int i  =1; i<=3; i++){
        for(int j = 1; j<=3; j++){
             cin >> m[i][j];
        }
      }

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

    for(int j=1; j<=3; j++){
       int cnt = 0;
        for(int k = 1; k<=3; k++){
            if(a[m[j][k]]) cnt++;
        }
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
for(int j=1; j<=3; j++){
      int cnt = 0;
        for(int k = 1; k<=3; k++){
            if(a[m[k][j]]) cnt++;
        }
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }

   int cnt = 0;
    for(int i=1; i<=3; i++){

        if(a[m[i][i]]) cnt++;
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }

    for(int j=1,i=3; j<=3; j++,i--){

        if(a[m[i][j]]) cnt++;
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;



    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
b = list(map(int, input().split()))
ans = []
for i in range(N):
    for j in range(N-i, 0, -1):
        if b[j-1] == j:
            ans.append(b.pop(j-1))
            break
    if len(ans) != i+1:
        print(-1)
        sys.exit()

for i in reversed(ans):
    print(i)
    

Measured memory_bytes: 9192
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long m=9999999999;
  long long answer=0;
  int judge=0;
  for(int i=0;i<N;i++){
    long long A;
    cin>>A;
    answer+=abs(A);
    if(A<0) judge++;
    if(abs(A)<m) m=abs(A);
  }
  if(judge%2==0) cout<<answer<<endl;
  else cout<<answer-2*m<<endl;
  
  return 0;
}

Measured memory_bytes: 3164
while true 
  abc = STDIN.gets
  abc.chomp!
  if abc == "0 0 0" then break end
  a, b, c = abc.split(" ").map { |item| item.to_i }
  x = Math.sqrt(a*a+b*b)
  y = Math.sqrt(b*b+c*c)
  z = Math.sqrt(a*a+c*c)

  n = STDIN.gets
  n = n.to_i
  n.times do
    r = STDIN.gets
    r = r.to_i * 2
    if r>x or r>y or r>z then
      puts "OK"
    else
      puts "NA"
    end
  end
end

Measured memory_bytes: 8588
#[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; n],
    }
    let mut m = 0.0f64;
    for &ai in &a {
        m += 1.0 / ai as f64;
    }
    println!("{}", 1.0 / m);
}


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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=9;i++){
		if(n%i==0&&n/i<=9){
			printf("Yes");return 0;
		}
	}
	printf("No");
	return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: "List[int]"):
    tot = 0
    for a in A:
        tot += 1/a
    tot = 1/tot
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	int N = s.size();
	s = "0" + s;
	bool fl = true;

	/*
	for (int i = 0; i <= N; i++) {
		cout << "i=" << i << " s[i]=" << s[i] << endl;
	}
	*/
	for (int i = 0; i <= N / 2; i++) {
		if (s[i] != s[N - i]) {
			//cout << "i=" << i << endl;
			fl = false;
			break;
		}
	}

	if (s[1] == '0')fl = false;
	if (!fl)cout << -1 << endl;
	else {
		vector<pair<int, int>> ed;
		int left = 1;
		for (int i = 2; i <= N - 1; i++) {
			if (s[i] == '1') {
				for (int j = left; j < i; j++) {
					ed.push_back(make_pair(j, i));
				}
				left = i;
			}
		}
		ed.push_back(make_pair(N - 1, N));
		for (int i = 0; i < ed.size(); i++) {
			cout << ed[i].first << " " << ed[i].second << endl;
		}
	}
}


Measured memory_bytes: 4264
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long a, b, x;
	cin >> a >> b >> x;
	if(a==0) cout << b/x+1;
	else cout << b/x - (a-1)/x;
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3

#!/usr/bin/env python3

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0

def dist(X,i,j):
    dist = 0
    for k in range(D):
        dist += (X[i][k] - X[j][k]) **2
    dist = dist ** 0.5
    return dist.is_integer()

for i in range(N):
    for j in range(N):
        if i >= j :
            continue
        else:
            if dist(X,i,j):
                cnt += 1

print(cnt)

Measured memory_bytes: 38256
def main():
    A,B=map(str, input().split(" "))
    A = int(A)
    B = int(B.split(".")[0] + B.split(".")[1])
    mul_AB = A * B
    if mul_AB < 100:
        print(0)
    else:
        print(str(mul_AB)[:-2])

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
e1 , e2 , e3 , e4 = map(int , input() . split())
if (e1 == e2) & ((e2 == e3 == e4) or (e3 == e4)) :
     print('yes')
elif (e2 == e3) & ((e3 == e1 == e4) or (e1 == e4)) :
     print('yes')
elif (e3 == e4) & ((e4 == e1 == e2) or (e1 == e2)) :
     print('yes')
elif (e4 == e1) & ((e1 == e2 == e3) or (e2 == e3)) :
     print('yes')
else :
     print('no')


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF (1ll<<60)
typedef long long ll;
using namespace std;

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

int main(){
    cin >> n;

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

    a.resize(n);
    b.resize(n);

    if (suma > sumb) {
        cout << "No" << endl;
        return 0;
    }

    ll cnt = 0;
    for (int i = 0; i < n; i++){
        if (b[i] > a[i]){
            cnt += (b[i] - a[i] + 1LL) / 2 ;
        }
    }   

    //cout << sumb -suma << "," << cnt << endl;
    
    if (sumb - suma >= cnt){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int N, M;
	vector<int> A(N);
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}
	vector<int> cnt(N, 0);
	vector<int> dia(N, 0);
	int mi = 0;
	for (int i = 0; i < N; i++) {
		if ((A[i] - cnt[A[i]]) < 0) {
			mi++;
		}
		else {
			dia[A[i] - cnt[A[i]]]++;
		}
		cnt[A[i]]++;

	}
	vector<int> rr;
	rr.clear();
	int res = 0;
	for (int i = 0; i < N; i++) {
		if (dia[i] == 0) {
			res++;
		}
	}
	//cerr << res << endl;
	int X, Y;
	for (int i = 0; i < M; i++) {
		cin >> X >> Y;
		Y--;
		X--;
		cnt[A[X]]--;
		if ((A[X] - cnt[A[X]]) >= 0) {
			dia[A[X] - cnt[A[X]]]--;
			if (dia[A[X] - cnt[A[X]]] == 0)res++;
		}
		if ((Y - cnt[Y]) >= 0) {
			if (dia[Y - cnt[Y]] == 0) res--;
			dia[Y - cnt[Y]]++;
		}
		cnt[Y]++;
		A[X] = Y;
		rr.push_back(res);
	}
	for (int i = 0; i < M; i++) {
		cout << rr[i] << endl;
	}

	
	return 0;
}

Measured memory_bytes: 57200
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=1e5+10;
int n,m,u,v,cnt,num[3];
int first[N],color[N];
bool flag;
struct edge{int to,next;}e[N*2];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void ins(int u,int v){e[++cnt]=(edge){v,first[u]};first[u]=cnt;}
void dfs(int x,int now,int fa)
{
	if(flag)return;
	color[x]=now;num[now]++;
	for(int i=first[x];i;i=e[i].next)
	{
		int to=e[i].to;
		if(to==fa)continue;
		if(color[to])
		{
			if(color[to]==now)flag=true;
			else continue;
		}
		else dfs(to,3-now,x);
	}
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		u=read();v=read();
		ins(u,v);ins(v,u);
	}
	dfs(1,1,0);
//	printf("%d %d\n",num[1],num[2]);
	if(flag)printf("%lld",1ll*n*(n-1)/2-m);
	else printf("%lld",1ll*num[1]*num[2]-m);
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    string s,t;
    cin>>s>>t;
    vector<vector<ll>> v(26);
    rep(i,s.size()){
        v[s[i]-'a'].push_back(i);
    }
    ll ind=0,numOf_s=0;
    for(auto c:t){
        if(v[c-'a'].size()==0){
            cout<<-1<<endl;return 0;
        }
        auto ite=lower_bound(ALL(v[c-'a']),ind);
        if(ite==v[c-'a'].end()){
            numOf_s++;
            ind=v[c-'a'][0]+1;
        }
        else{
            ind=*ite+1;
        }
    }
    cout<<numOf_s*s.size()+ind<<endl;
    return 0;
}


Measured memory_bytes: 1724
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<char> cs;

void solve(string &s, const int pos, const int kinds, const int N) {
    // printf("pos: %d, kinds: %d\n", pos, kinds);
    if (pos == N) {
        cout << s << endl;
        return;
    }

    for (int i = 0; i < kinds; i++) {
        char c = cs[i];
        s.push_back(c);
        solve(s, pos + 1, kinds, N);
        s.pop_back();
    }

    s.push_back(cs[kinds]);
    solve(s, pos + 1, kinds + 1, N);
    s.pop_back();
}

int main(void) {
    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cs.push_back('a' + i);
    }

    string str = "";
    solve(str, 0, 0, N);

    return 0;
}


Measured memory_bytes: 1536
a, b, k = map(int, input().split())
if b-a < k:
  for i in range(a, b+1):
    print(i)
else:
  min_a = [i for i in range(a, a+k)]
  max_b = [i for i in range(b, b-k,-1)]
  r = min_a + max_b
  for i in list(sorted(set(r))):
    print(i)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>


//---------------------------------------------
 


int main (void)
{
    string s;
    cin>>s;
    int ans =0;
    char bef = 'a';

    rep(i,s.size())
    {
        if(bef!=s[i])
        {
            ans ++;
            bef = s[i];
        }

    }

    cout<<ans-1<<endl;
}


Measured memory_bytes: 1144
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<string> W(N);
  map<string, int> mp;
  for (int i = 0; i < N; i++) {
    cin >> W[i];
    mp[W[i]]++;
  }

  int length = W[0].length();
  char tail = W[0][length - 1];

  for (int i = 1; i < N; i++) {
    if (mp[W[i]] != 1 || W[i][0] != tail) {
      cout << "No\n";
      return 0;
    }
    length = W[i].length();
    tail = W[i][length - 1];
  }

  cout << "Yes\n";

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b && a < c && b < c )
	{
		printf("Yes\n");
	}
	else 
	{
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 2568
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != t[i])
			ans ++;
	}
	cout << ans;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const bool debug = false;

int main(){
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n+1);
    rep(i,n){
        cin >> a.at(i+1);
    }

    vector<int> hist(n+1);
    vector<int> visit(n+1);
    visit[1] = 1;
    hist[1] = 1;
    int t = 1;
    int s = 1;
    for(int i=1;i<=n;i++)
    {
        s++;
        t = a.at(t);
        hist[s] = t;
        if(visit[t] > 0) break;
        visit[t] = s;
    }
    if(debug){
        cout << "visit:";
        rep(i,n){
            cout << visit[i+1] << " ";
        }
        cout << endl;
        cout << " hist:";
        rep(i,n){
            cout << hist[i+1] << " ";
        }
        cout << endl;

        cout << visit[t] << "-" << s << endl;
    }

    int idx;
    if(k < s){
        idx = k+1;
    }
    else {
        if(debug) cout << visit[t] << "+ (" << k-visit[t]  << " %" << s-visit[t] << ")" << endl;
        idx = visit[t] + ((k-visit[t]) % (s-visit[t])) + 1;
    }
    if(debug) cout << "idx:" << idx << endl;
    cout << hist[idx] << endl;
    
    return 0;
}

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

typedef long long LL;
typedef long double LD;

LL getGCD(int a, int b){
    if(a % b == 0){
       return(b);
    }else{
       return(getGCD(b, a%b));
    }
} // a > b

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin >> k;
    LL ans = 0;
    int x[3];
    for(int i = 1;i <= k; i++){
        for(int j = 1;j <= k; j++){
            for(int m = 1;m <= k; m++){
                x[0] = i;
                x[1] = j;
                x[2] = m;
                sort(x, x + 3);
                ans += getGCD(x[2], getGCD(x[1], x[0]));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
set<ll>s;
int main()
{
    ft
    ll t,i,j,n,m,l,r,k,c,ans=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        s.insert(m);
    }
    m=s.size();
    if(n==m)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}

Measured memory_bytes: 9600
// for(auto it:m)
//     {
//         cout<<it.second;
//     }
// }
 
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
 
 
int main()
{
      int a,b;
      cin>>a>>b;
      int c=a-2*b;
      if(a>=2*b)
      {
          cout<<c;
      }
      else
      {
          cout<<0;
      }
      

}
 

Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a = i()
b = i()

if a > b:
	print("GREATER")
elif a == b:
	print("EQUAL")
else:
	print("LESS")

Measured memory_bytes: 9088
s = input()

n = len(s)
i = 0
ans = 1
pre = None
while i < n-1:
    if pre is None:
        pre = s[i]
    if pre == s[i+1]:
        pre = s[i+1:i+3]
        i += 2
    else:
        pre = s[i+1:i+2]
        i += 1
    if i < n:
        ans += 1


print(ans)


Measured memory_bytes: 9264
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {

    char ans[3][3];
    cin>>ans[0];
    cin>>ans[1];
    cin>>ans[2];

    printf("%c%c%c\n",ans[0][0],ans[1][1],ans[2][2]);
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine();
        for (var i = 0; i < int.Parse(line); ++i)
        {
            var sides = Console.ReadLine().Split().Select(int.Parse).ToList();
            sides.Sort();
            Console.WriteLine(sides[2] * sides[2] == sides[0] * sides[0] + sides[1] * sides[1] ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 9496
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a = s.nextInt();
		
		if (n % 500 <= a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  arrll(p,a);
  arrll(q,b);
  arrll(r,c);

  sort(all(p),greater<ll>());
  sort(all(q),greater<ll>());
  //sort(all(r),greater<ll>());

  while(p.size()>x) p.pop_back();
  while(q.size()>y) q.pop_back();

  vecll apple;
  rep(i,p.size()) apple.push_back(p[i]);
  rep(i,q.size()) apple.push_back(q[i]);
  rep(i,r.size()) apple.push_back(r[i]);
  sort(all(apple), greater<ll>());

  ll ans=0;
  rep(i,x+y){
    ans+=apple[i];
  }

  prt(ans);
}


Measured memory_bytes: 8560
using System;

class solution
{
    static void Main()
    {
        int sum = 0;
        while (true)
        {
            string str = Console.ReadLine();
            if (str == "0")
                break;
            else
            {
                char[] ca = str.ToCharArray();
                for (int i = 0; i < ca.Length; i++)
                {
                    sum += int.Parse(ca[i].ToString());
                }
                Console.WriteLine(sum);
                sum = 0;
            }
        }
    }
}

Measured memory_bytes: 9232
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
const ll INF = 1LL << 50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  ll N, T;
  cin >> N >> T;
  ll minv = INF, maxg = 0, ans = 0;

  REP(i, N) {
    ll A;
    cin >> A;
    minv = min(minv, A);

    if (A - minv > maxg) {
      maxg = A - minv;
      ans = 1;
    } else if (A - minv == maxg) {
      ans++;
    }
  }

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

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

int main() {
  int A,B;
  cin>>A>>B;
  int ans=0;
  for (int i=A; i<=B; i++) {
    int x=i;
    int reverse=0;
    while (x>0) {
      reverse=reverse*10+x%10;
      x/=10;
    }
    if (i==reverse) {
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import jdk.nashorn.internal.ir.LabelNode;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();

		double rate = 0.0;
		int[] ws = new int[]{1, 0};

		for (int i = 0; i <= 3000; i++) {
			for (int j = 0; j <= 3000; j++) {
				int water = ((a * i) + (b * j)) * 100;
				if (water == 0 || water >= f) break;
				int cap = Math.min(f - water, (water / 100) * e);
				for (int k = 0; k <= 3000; k++) {
					for (int l = 0; l <= 3000; l++) {
						int sugar = k * c + l * d;
						if (sugar > cap || water + sugar > f) break;
						if (rate <= 100.0 * sugar / (water + sugar)) {
							rate = 100.0 * sugar / (water + sugar);
							ws[0] = water;
							ws[1] = sugar;
						}
					}
				}
			}
		}

		System.out.println(ws[0] + ws[1] + " " + ws[1]);
	}
}


Measured memory_bytes: 21844
a,b=map(int,input().split())
s=["."*(b+2)]+["0"+input()+"0"for i in range(a)]+["."*(b+2)]
for i in range(1,a+1):
    for j in range(1,b+1):
        c=0
        if s[i][j]==".":
            if s[i-1][j]=="#":
                c+=1
            if s[i][j-1]=="#":
                c+=1
            if s[i+1][j]=="#":
                c+=1
            if s[i][j+1]=="#":
                c+=1
            if s[i-1][j-1]=="#":
                c+=1
            if s[i-1][j+1]=="#":
                c+=1
            if s[i+1][j-1]=="#":
                c+=1
            if s[i+1][j+1]=="#":
                c+=1
            t=s[i]
            s[i]=t[:j]+str(c)+t[j+1:]
for i in range(1,a+1):
    t=s[i]
    print(t[1:b+1])

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

string str = "AKIHABARA";
string ss = "KIHBR#";

main() {
    string s; cin >> s;
    if (s.size() > str.size() || s.size() < 5) {
        puts("NO");
    } else if (s.size() == str.size()) {
        if (s == str) {
            puts("YES");
        } else {
            puts("NO");
        }
    } else {
        int in = 0;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == 'K') {
                if (i != 0 && s[i - 1] == 'A') continue;
                s.insert(s.begin() + i, 'A');
                i++;
            } else if (s[i] == 'B') {
                if (i != 0 && s[i - 1] == 'A') continue;
                s.insert(s.begin() + i, 'A');
                i++;
            } else if (s[i] == 'R') {
                if (i != 0 && s[i - 1] == 'A') continue;
                s.insert(s.begin() + i, 'A');
                i++;
            }
        }
        if (s.back() != 'A') s = s + 'A';
//        cout << s;
        if (s != str) {
            puts("NO");
        } else
            puts("YES");
    }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s,t;
    i32 n,m;
    cin >> s >> t;
    bool can = 1;
    for(i32 i = 0; i < s.size(); ++i) {
        if(s[i] != t[i]) can = 0;
    }

if(can) cout << "Yes" << '\n';
 else cout <<"No"    << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3676
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<int ,int >man[200];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			int b,c,d;
			scanf("%d%d%d",&b,&c,&d);
			man[2*i]=make_pair(c,b);
			man[2*i+1]=make_pair(d,-b);
		}
		std::sort(man,man+a*2);
		bool ok=true;
		int now=0;
		for(int i=0;i<a*2;i++){
			now+=man[i].second;
			if(now>150)ok=false;
		}
		printf(ok?"OK\n":"NG\n");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

const bool operator<(pair<ll,ll> pa1 , pair<ll,ll> pa2) {
  return pa1.second > pa2.second;
}

int main(){
  ll t;
  cin >> t;
  ll k,l,r;
  rep(_,t){
    ll n;
    cin >> n;
    ll sum = 0;
    vector<pair<ll,ll>> vec1;
    vector<pair<ll,ll>> vec2;
    rep(i,n){
      cin >> k >> l >> r;
      k--;
      if(l >= r){
        //vec1.emplace_back(make_pair(k,l-r));
        vec1.emplace_back(make_pair(l-r,k));
        sum += r;
      }else{
        //vec2.emplace_back(make_pair(k,r-l));
        vec2.emplace_back(make_pair(r-l,k));
        sum += l;
      }
    }
    ll len1 = vec1.size();
    ll len2 = vec2.size();
    sort(all(vec1));
    sort(all(vec2));
    vector<ll> arr(n,0);
    set<ll> st;
    st.insert(-1);
    st.insert(n);
    rep(i,n){
      st.insert(i);
    }
    ll mini,maxi;
    rep_rev(i,len1){
      ll mini = min(len1-1,vec1[i].second);
      auto itr = st.upper_bound(mini);
      itr--;
      if(*itr != -1){
        t1 = *itr;
        st.erase(t1);
        sum += vec1[i].first;
      }
    }
    rep_rev(i,len2){
      ll maxi = max(len1,vec2[i].second+1);
      auto itr = st.lower_bound(maxi);
      if(*itr != n){
        t1 = *itr;
        st.erase(t1);
        sum += vec2[i].first;
      }
    }
//    for(auto itr:st){
//      cout << itr << endl;
//    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 17312
L, R  = map(int, input().split())

if (2019-(L%2019))+L <= R:
  print(0)

else:
  ans = 2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans = min(ans,(i*j)%2019)
  print(ans)

Measured memory_bytes: 40812
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	int count = 0;
	cin >> input;

	for (int i = 0; i < input.size() - 1; i++)
	{
		if (input[i] != input[i + 1])
			count++;
	}

	cout << count << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

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

int main(){
long long n,ab=0,a=0,b=0,ans=0;
vector<string>v;
string s;
cin>>n;

for(int i=0;i<n;++i){
    cin>>s;
    v.push_back(s);
}

for(int i=0;i<n;++i){
    int x=v[i].size();
    
    if(v[i][0]=='B'&&v[i][x-1]=='A')
    ab++;
    else if(v[i][0]!='B'&&v[i][x-1]=='A')
    a++;
    else if(v[i][0]=='B'&&v[i][x-1]!='A')
    b++;
    
    for(int j=0;j<v[i].size()-1;++j){
        if(v[i][j]=='A'&&v[i][j+1]=='B')
        ans++;
    }
    
}

if(ab>0){
ans+=ab-1;
if(a){ans++;a--;}
if(b){ans++;b--;}
}


ans+=min(a,b);
cout<<ans;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,i;
    long long b,k;
    vector<long long> table(100001,0);
    
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>a>>b;
        table[a]+=b;
    }
    for(i=0;i<100001;i++){
        k-=table[i];
        if(k<=0){
            cout<<i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    char a;
    cin >> a;
    cout << ++a << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto a = readln.chomp.to!int;
  auto b = readln.chomp.to!int;
  auto c = readln.chomp.to!int;
  auto d = readln.chomp.to!int;
  writeln(min(a,b) + min(c,d));
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;
int a[maxn];
bool cmp(int a,int b){
	return a > b;
}
int main(void){
	int n,k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n,cmp);
	if(k>=n){
		cout<<0<<endl;
	}else{
		ll sum = 0;
		for(int i = k; i < n; i++){
			sum += a[i];
		}
		cout<<sum<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 4e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,k,c,f[N],g[N];
char a[N];
map<pair<int,int>,int>vis;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k>>c>>a+1;
  for(int i=n;i>=1;i--){
    if(a[i]=='x')f[i]=f[i+1];
    else f[i]=max(f[i+1],1+f[i+c+1]);
  }
  for(int i=1;i<=n;i++){
    if(a[i]=='x')g[i]=g[i-1];
    else g[i]=max(g[i-1],1+g[max(i-c-1,0)]);
  }
  for(int i=1;i<=n;i++){
    if(a[i]=='o' && g[i]+f[i]==k+1){
      vis[{g[i],f[i]}]+=1;
    }
  }
  for(int i=1;i<=n;i++){
    if(a[i]=='o' && g[i]+f[i]==k+1){
      if(vis[{g[i],f[i]}]==1){
        cout<<i<<'\n';
      }
    }
  }
  return 0;
}

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

struct Rest{
    int number;
    string name;
    int rate;
};

int main(){
    int n;
    cin >> n;
    Rest a[n];
    Rest tmp;
    for(int i=0;i<n;i++){
        a[i].number = i + 1;
        cin >> a[i].name >> a[i].rate;
    }
    stable_sort(a, a+n, [](const Rest& x, const Rest& y){return x.name < y.name;});
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(a[j].name == a[j-1].name){
                if(a[j].rate > a[j-1].rate){
                    tmp = a[j-1];
                    a[j-1] = a[j];
                    a[j] = tmp;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << a[i].number << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

struct Point{
    int num;
    int sub;
};
int main(){
    int n; cin >> n;
    bool flag = true;
    vector<struct Point> p(n);
    vector<int> ans(n);
    rep(i,n){
        cin >> p[i].num;
        p[i].sub = i + 1 - p[i].num;
        if(p[i].sub < 0){
            flag = false;
            break;
        }
    }
    if(!flag) cout << -1 << endl;
    else{
        rep(i,n){
            if(p[i].sub==0) ans[i] = p[i].num;
            else ans.insert(ans.begin()+i-p[i].sub , p[i].num);
        }
        rep(i,n) cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1000000007;
const ll LLINF = 1000000000000000007LL;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b, k;
    cin >> a >> b >> k;
    if(k<=a){
        cout << a-k << " " << b << endl;
        return 0;
    }
    else if(k<=a+b){
        cout << 0 << " " << b-k+a << endl;
        return 0;
    }
    else cout << 0 << " " << 0 << endl;
    
    
    return 0;
}

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

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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  ll n,k;
  cin>> n>>k;
  vector<ll> h(n);
  rep(i,n){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  ll ans =100000000000;
  rep(i,n+1-k){
    ans =min(ans,h[i+k-1]-h[i]);
    if(ans==0){
      break;
    }
  }
  cout<<ans<<endl;
}



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

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

	int num_1 = k;
	int num_2 = k-1;
	for (int i = 1; i < n/2; i++) {
		num_1 *= (k - 1);
		num_2 *= (k - 1);
	}
	if (n % 2 != 0 && 1 < n) {
		num_1 *= (k -1);
	}
	int ans;
	if (1 < n) {
		ans = num_1 * num_2;
	} else {
		ans = num_1;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

struct Point {
    ll x;
    ll y;
};

struct Comp {
    bool operator() (const Point &i, const Point &j) {
        return (i.x < j.x);
    }
};

int main() {
    int N;
    cin >> N;
    vector<Point> P(N);
    for (int i=0; i<N; ++i) {
        ll x, y;
        cin >> x >> y;
        P[i].x = x;
        P[i].y = y;
        // debug
        // cout << P[i].x << "," << P[i].y << endl;
    }
    // 1次元なら... 隣接とは限らない2点間について、ある変異ベクトルで移動できる場合にコスト0ということになる.
    // その移り変われる2点のペアの最大数分だけコストが0になる.
    // 2次元なら... 各次元で同時に..
    // 数え上げればいい
    // sort by x
    //sort(P.begin(), P.end(), Comp());
    // 変異ベクトルの数をカウントする
    //
    map<pair<ll,ll>, int> Map;

    for (int i=0; i<N; ++i) {
        for (int j=0; j<N; ++j) {
            if (i==j) continue;
            ll dx = P[i].x - P[j].x;
            ll dy = P[i].y - P[j].y;
            pair<ll,ll> this_pair = make_pair(dx,dy);
            if (Map.find(this_pair) == Map.end()) {
                Map.insert(make_pair(this_pair, 1));
            } else {
                Map[this_pair]++;
            }
        }
    }
    int max_count = 0;
    for (auto it = Map.begin(); it != Map.end(); ++it) {
        max_count = max(max_count, it->second);
    }
    cout << N - max_count << endl;
    return 0;
}

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

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

vector<int> make_lst_g(int n) {
  vector<int> lst;
  int v = 1;
  while (v <= n) {
    lst.push_back(v);
    v = 3 * v + 1;
  }

  vector<int> lst_g(lst.size(), 0);
  rep(i, lst.size()) lst_g[i] = lst[lst.size() - i - 1];
  return lst_g;
}

int insertionSort(vector<int> &lst, int g) {
  int cnt = 0;
  for (int i = g; i < lst.size(); i++) {
    int v = lst[i];
    int j = i - g;
    while (j >= 0 && lst[j] > v) {
      lst[j + g] = lst[j];
      j -= g;
      cnt++;
    }
    lst[j + g] = v;
  }
  return cnt;
}

int shellSort(vector<int> &lst, vector<int> lst_g) {
  int cnt = 0;
  rep(i, lst_g.size()) cnt += insertionSort(lst, lst_g[i]);
  return cnt;
}

void print_lst(vector<int> lst) {}

int main() {
  int n;
  cin >> n;
  vector<int> lst_a(n, 0);
  rep(i, n) cin >> lst_a[i];

  vector<int> lst_g = make_lst_g(n);
  int m = lst_g.size();

  int cnt = shellSort(lst_a, lst_g);

  cout << m << endl;
  rep(i, lst_g.size()) {
    if (i > 0) cout << " ";
    cout << lst_g[i];
  }
  cout << endl;
  cout << cnt << endl;
  rep(i, n) cout << lst_a[i] << endl;

  return 0;
}



Measured memory_bytes: 6704
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n, k;
  cin >> n >> k;
  ll x[n], y[n];
  ll xcpy[n], ycpy[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    xcpy[i] = x[i];
    ycpy[i] = y[i];
  }
  sort(x, x + n);
  sort(y, y + n);
  ll ans = LLONG_MAX;
  for (int xl = 0; xl < n; xl++) {
    for (int xr = xl + 1; xr < n; xr++) {
      for (int yl = 0; yl < n; yl++) {
        for (int yr = yl + 1; yr < n; yr++) {
          int count = 0;
          for (int i = 0; i < n; i++) {
            if (x[xl] <= xcpy[i] && xcpy[i] <= x[xr] && y[yl] <= ycpy[i] &&
                ycpy[i] <= y[yr]) {
              count++;
            }
          }
          if (count >= k) {
            ll res = (x[xr] - x[xl]) * (y[yr] - y[yl]);
            ans = min(ans, res);
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

namespace nyg
{
	const int N=101000;

	int begin[N],next[N*2],to[N*2],w[N*2];

	int n,e;

	void add(int x,int y,int z,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		w[e]=z;
		if(k)add(y,x,z,0);
	}

	bool c[N];
	void dfs(int p=1,int h=0)
	{
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
				c[q]=c[p]^(w[i]&1),dfs(q,p);
	}

	void solve()
	{
		scanf("%d",&n);
		for(int i=1,u,v,h;i<n;i++)
			scanf("%d%d%d",&u,&v,&h),add(u,v,h);
		dfs();
		for(int i=1;i<=n;i++)
			printf("%d\n",c[i]);
	}
}

int main()
{
	nyg::solve();
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>

using namespace std;

using ll = long long;
int main() {
    ll n, m;
    cin >> n >> m;
    if (n > m / 2) {
        cout << m / 2;
    } else {
        cout << n + (m - 2 * n) / 4;
    }
    return 0;
}


Measured memory_bytes: 256