akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct topological_sort{
    vector<vector<int>> graph;
    vector<bool> done;
    vector<int> res;
    topological_sort(vector<vector<int>> &graph):graph(graph),done(graph.size()){
        //rep(i,0,v) topo_dfs(i);
        for(int i=0; i<graph.size(); ++i) dfs(i);
        reverse(res.begin(),res.end());
    }
    void dfs(int v){
        if(done[v]) return;
        done[v]=true;
        for(auto &u:graph[v]) dfs(u);
        res.push_back(v);
    }
};


void solve(){
    int v,e;
    cin >> v >> e;
    vector<vector<int>> graph(v);
    rep(i,0,e){
        int s,t;
        cin >> s >> t;
        graph[s].push_back(t);
    }
    topological_sort ts(graph);
    rep(i,0,v) cout << ts.res[i] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n;

    cin >> n;


    ll ans = 0;

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            for(int k=1; k<=n; k++)
            {

                if(i==j && j==k)
                {
                    ans += k;
                    continue;
                }
                ans += __gcd(i,__gcd(j,k));
            }
        }
    }

    cout << ans << endl;




    return 0;
}



Measured memory_bytes: 3652
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

struct edge {
	int to, cap, rev;
	edge(int t, int c, int r):to(t), cap(c), rev(r){}
};

int n, m;
int s, t;

vector<vector<edge> > G;
vector<int> level;
vector<int> iter;
constexpr int INF = 0xfffffff;

void init(int V) {
	G.assign(V, vector<edge>());
	level.assign(V, 0);
	iter.assign(V, 0);
}

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

void bfs(int s) {
	fill(level.begin(), level.end(), -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		for(int i = 0; i < (int)G[v].size(); ++i) {
			const edge& e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f) {
	if(v == t)
		return f;

	for(int& i = iter[v]; i < (int)G[v].size(); ++i) {
		edge& e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]) {
			const int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}

	return 0;
}

int max_flow(int a, int b) {
	int flow = 0;
	vector<vector<edge>> tmp(G);
	add_edge(a + n, t, 1);
	add_edge(b + n, t, 1);

	for(;;) {
		bfs(s);
		if(level[t] < 0) {
			G = move(tmp);
			return flow;
		}

		fill(iter.begin(), iter.end(), 0);
		int f;
		while((f = dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}

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

	cin >> n >> m;

	init(n + n + 1);
	s = n;
	t = n + n;

	for(int i = 0; i < n; ++i) {
		add_edge(i, i + n, 1);
	}

	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;

		cout << (max_flow(a, b) == 2 ? "Yes" : "No") << endl;
		add_edge(a + n, b, 1);
		add_edge(b + n, a, 1);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1704
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u32,
        d: [u32; n],
    };
    let mut c = d.clone();
    c.sort();
    c.dedup();
    println!("{}", c.iter().len());
}


Measured memory_bytes: 4476
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int p, m;

	void run(){
		for(;;){
			p=sc.nextInt();
			m=sc.nextInt();
			if((p|m)==0){
				break;
			}
			solve();
		}
	}

	void solve(){
		long n1=0, d1=1;
		long n2=m, d2=1;
		for(long d=1; d<=m; d++){
			double left=1, right=m;
			for(int i=0; i<100; i++){
				double mid=(left+right)/2;
				if(mid*mid<p*d*d+EPS){
					left=mid;
				}else{
					right=mid;
				}
			}
			int n=(int)(left+EPS);
			if(n1*d<n*d1&&n*n<p*d*d){
				n1=n;
				d1=d;
			}
			// debug(n, left,d);
			n++;
			if(p*d*d<n*n&&n*d2<n2*d){}else{
				// debug("error!");
			}

			if(n<=m){
				if(p*d*d<n*n&&n*d2<n2*d){
					n2=n;
					d2=d;
				}
			}
		}
		long gcd=gcd(n2, d2);
		n2/=gcd;
		d2/=gcd;
		gcd=gcd(n1, d1);
		n1/=gcd;
		d1/=gcd;
		println(n2+"/"+d2+" "+n1+"/"+d1);
	}

	long gcd(long m, long n){
		for(; n!=0;){
			m=m%n;
			long t=m;
			m=n;
			n=t;
		}
		return m;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
A, B, C = map(int, input().split())
D = list(map(int, input().split()))
E = list(map(int, input().split()))

a, b = [0], [0]
for i in range(A):
    a.append(a[i] + D[i])
for i in range(B):
    b.append(b[i] + E[i])

ans, j = 0, B
for i in range(A + 1):
    if a[i] > C:
        break

    while b[j] > C - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47492
w,h = map(int,input().split())
pq = [[int(input()),0] for _ in range(w)] + [[int(input()),1] for _ in range(h)]
pq.sort()

a = w + 1
b = h + 1
ans = 0
for x,i in pq:
    if i == 0:
        ans += b*x
        a -= 1
    else:
        ans += a*x
        b -= 1

print(ans)

Measured memory_bytes: 81112
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[100005];
	vector<pair<int, int>> v;
	for(int i=0;i<n;i++){
		cin >> a[i];
		v.push_back(make_pair(a[i], i+1));
	}
	sort(v.begin(), v.end());
	for(int i=0;i<n-1;i++){
		cout << v[i].second << ' ';
	}
	cout << v[n-1].second << endl;
	return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
int n;cin>>n;
if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)cout<<"hon"<<endl;
else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon"<<endl;
else cout<<"bon"<<endl;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    rep(i, s.size()) {
        if (i + 1 < s.size() && s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2;
            return 0;
        }
        if (i + 2 < s.size() && s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;
pll coords[9];

double dist(pll a, pll b)
{
    return sqrt((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s));
}
int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for(int i=0; i<N; i++)
    {
        cin >> coords[i].f >> coords[i].s;
    }
    double sum = 0.000000000000;
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<N; j++)
        {
            sum += dist(coords[i], coords[j]);
        }
    }

    cout << setprecision(20) << sum/double(N);
    return 0;
}


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

typedef long long ll;
typedef pair<int,string> pis;
vector<pis> v;

template<class T>
T sqr(T a) { return a * a; }

int main() {
	string s;

	v.push_back(pis(0x000000, "black"));
	v.push_back(pis(0x0000ff, "blue"));
	v.push_back(pis(0x00ff00, "lime"));
	v.push_back(pis(0x00ffff, "aqua"));
	v.push_back(pis(0xff0000, "red"));
	v.push_back(pis(0xff00ff, "fuchsia"));
	v.push_back(pis(0xffff00, "yellow"));
	v.push_back(pis(0xffffff, "white"));

	while(cin >> s, s[0]-'0') {
		int a = 0;
		for(int i = 0; i < 6; i++) {
			a *= 16;
			if(0 <= s[i+1] && s[i+1] <= '9')
				a += s[i+1] - '0';
			else
				a += s[i+1] - 'a' + 10;
		}

		int res = -1;
		ll mn = 1e9;
		for(int i = 0; i < v.size(); i++) {
			ll tmp = 0;
			for(int j = 0; j < 3; j++) {
				tmp += sqr(((v[i].first >> (j * 8)) & 0xff) - ((a >> (j * 8)) & 0xff));
			}
			if(tmp < mn) {
				mn = tmp;
				res = i;
			}
		}
		cout << v[res].second << endl;
	}
}

Measured memory_bytes: 1184
def seiseki(a,b,c)
 if(a==-1||b==-1)
  return "F"
 elsif(a+b>=80)
  return "A"
 elsif(a+b>=65)
  return "B"
 elsif(a+b>=50)
  return "C"
 elsif(a+b>=30)
  if(c>=50)
   return "C"
  else
   return "D"
  end
 else
  return "F"
 end
end
while(1)
a,b,c=gets.chomp.split(" ").map(&:to_i);
if(a==-1&&b==-1&&c==-1)
 break
end
print("#{seiseki(a,b,c)}\n")
end



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

int main(){
  string s;
  cin >> s;
  int a, b;
  for (int i=0; i<s.length(); i++){
    if (s.at(i)=='A'){
      a=i;
      break;
    }
  }
  for (int i=s.length()-1; i>0; i--){
    if (s.at(i)=='Z'){
      b=i;
      break;
    }
  }
  cout << b-a+1 << endl;
}



Measured memory_bytes: 640
def f(W):
    if len(W) != len(set(W)):
        return False
    for i in range(len(W) - 1):
        if W[i][-1] != W[i + 1][0]:
            return False
    return True


N = int(input())
W = [input() for _ in range(N)]
print('Yes' if f(W) else 'No')


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

int main() {
  int n;
  cin >> n;
  int a, b, c, d;
  a = n / 1000;
  b = n / 100 - a * 10;
  c = n / 10 - a * 100 - b * 10;
  d = n - ( a * 1000 + b * 100 + c * 10 );
  if ( a == b && b == c && c == d) {
  	cout << "Yes" << endl;
  }
  else if (a == b && b ==c) {
    cout << "Yes" << endl;
  }
  else if (b == c && c == d) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include"stdio.h"
#include"stdlib.h"
#include"cstring"
struct Node{
    int key;
    Node *prev;
    Node *next;
};

Node *head;
void init(){
    head = (Node *)malloc(sizeof(Node));
    head->next = head;
    head->prev = head;
}
void insert(int x){
    Node *p = (Node *)malloc(sizeof(Node));
    p->key=x;
    p->next=head->next;
    p->prev=head;
    head->next->prev=p;
    head->next=p;
}
void deleteNode(int x){
    Node *p=head->next;
    while(p->key!=x && p!=head)
    {
        p=p->next;
    }
    if(p==head)
        return;
    else{
        p->prev->next=p->next;
        p->next->prev=p->prev;
        free(p);
    }
}
void deleteFirst(){
    Node *p=head->next;
    p->prev->next=p->next;
    p->next->prev=p->prev;
    free(p);
}
void deleteLast(){
    Node *p=head->prev;
    p->prev->next=p->next;
    p->next->prev=p->prev;
    free(p);
}
int main(){
    int n,key;
    char com[15];
    init();
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s%d",com,&key);
        if(com[0]=='i'){
            insert(key);
        }
        else
        {
            if(strlen(com)>6){
                if(com[6]=='F'){
                    deleteFirst();
                }
                else{
                    deleteLast();
                }
            }
            else{
                deleteNode(key);
            }
        }
    }
    Node *p=head->next;
    int isf=0;
    while(p!=head)
    {
        if(isf++>0)printf(" ");
        printf("%d",p->key);
        p=p->next;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 33860
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll H,W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < H; ++i) {
        cout << A[i] << endl;
        cout << A[i] << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

int top, S[1000];

void push(int x) {
    S[++top] = x;
}
int pop() { 
   return S[top--];
}
void init(){
    top = 0;
}
int main() {
    int a, b;
    init();
    char s[100];
    while(scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            push(pop()+pop());
        }else if(s[0]=='-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(s[0]=='*'){
            push(pop()*pop());
        }else{
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
    return 0;
}


Measured memory_bytes: 3204
#include<cstdio>
using namespace std;

int h, d[10][5];

int check() {
  int counter = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < 3; j++) {
      if (d[i][j] == -10) continue;
      if (d[i][j] == d[i][j + 1] && d[i][j] == d[i][j + 2]) {
        int num = d[i][j];
        for (int k = j; k < 5; k++) {
          if (d[i][k] == num) d[i][k] = -1, counter += num;
          else break;
        }
        break;
      }
    }
  }
  return counter;
}

void fall() {
  for (int j = 0; j < 5; j++) {
    int counter = 0, temp = -1;
    for (int i = h - 1; i >= 0; i--) {
      if (d[i][j] == -10) { temp = i; break; }
      if (d[i][j] == -1) counter++;
      else d[i + counter][j] = d[i][j];
    }
    for (int i = 0; i < counter; i++) d[temp + 1 + i][j] = -10;
  }
}

int main() {
  while (1) {
    scanf("%d", &h);
    if (h == 0) break;
    for (int i = 0; i < h; i++) for (int j = 0; j < 5; j++) scanf("%d", &d[i][j]);
    int sum = 0;
    while (1) {
      int counter = check();
      if (counter == 0) break;
      sum += counter;
      fall();
    }
    printf("%d\n", sum);
  }
}



Measured memory_bytes: 2708
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    bool ans=(a*b)%2==0;
    
    if(ans == true){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
        return 0;
    }


Measured memory_bytes: 256
X, K, D = map(int, input().split())
X = abs(X)

a, b = divmod(X, D)
# print(f'{a=}, {b=}')

if a >= K:
    ans = X - K * D
    ans = abs(ans)
    print(ans)
    exit()

_K = K - a
# print(f'{_K=}')
if _K % 2 == 0:
    ans = b
else:
    ans = abs(b - D)
print(ans)


Measured memory_bytes: 9184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int T=sc.nextInt();
		pl((T/A)*B);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 21204
using System;
using System.Linq;
using System.Collections.Generic;
public class Test
{
    public static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        Console.WriteLine(Div(Gcd(input[0], input[1]),input[2]));
        Console.ReadKey();
    }
    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    public static int Div(int a, int b)
    {
        for (int i = 105;true;i--)
        {
            if (a % i == 0)
            {
                b--;
            }
            if(b==0)
                return i;
        }
    }
}

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

const int INF = 100100101;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,1,0,-1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w){
    if(s[si][sj]=='#') continue;
    vector<vector<int>> dist(h, vector<int>(w,INF));
    queue<P> q;
    auto update = [&](int i, int j, int x){
      if(dist[i][j]!=INF) return;
      dist[i][j]=x;
      q.push(P(i,j));
    };
    update(si,sj,0);
    while(!q.empty()){
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir,4){
        int ni = i + di[dir], nj = j + dj[dir];
        if(ni>=h||ni<0||nj>=w||nj<0) continue;
        if(s[ni][nj]=='#') continue;
        update(ni,nj,dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w){
      if(dist[i][j]==INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef long long ll;
typedef long double ld;



int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    string s;
    cin>>s;
    int ans = s.size()-1;
    rep(i,0,s.size()){
        char cur = s[i];
        int last = -1;
        int res = 0;
        rep(j,0,s.size()){
            if(s[j]==s[i]){
                res = max(res,j-last-1);
                last = j;
            }
        }
        res = max(res,int(s.size())-last-1);
        ans = min(ans,res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
ans=0
que=deque([])
que.append(a[0])
for i in range(1,n):
    ans+=que.popleft()
    que.append(a[i])
    que.append(a[i])
print(ans)



Measured memory_bytes: 106320
l = input().split(' ')
l = list(map(int, l))
W = l[0]
H = l[1]
x = l[2]
y = l[3]
r = l[4]

if x+r <= W and x-r >= 0 and y+r <= H and y-r >= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    int a;
    cin >> a;
    int ans = a * a * a;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  for(;cin>>n,n;)
    {
      bool flag =false;
      int cnt=0;
      for(int i=0;i<n;i++)
	{
	  int tmp;
	  cin>>tmp;
	  if(tmp>0) 
	    cnt++;
	  if(tmp > 1)
	    flag = true;
	}
      if(flag)
	cout<<cnt+1<<endl;
      else
	cout<<"NA"<<endl;
     
    }  
}
  

Measured memory_bytes: 1160
#include<stdio.h>
 
int main(void)
{
  int x,y;
  int i = 0;
  int sum = 0;
  scanf("%d %d", &x, &y);
 while (i < 2){
    if(x > y){
      sum += x;
      x--;
    }
    else{
      sum += y;
      y--;
    }
    i++;
  }
  printf("%d\n", sum);
  return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};




int main(){
  int n,m;
  cin>>n>>m;
  ll a[n];
  rep(i,n){
    cin>>a[i];
    a[i]--;
    }
  ll b[2*m+1],c[2*m+1];
  rep(i,2*m+1)b[i]=c[i]=0;
  ll ans=0;
  rep(i,n-1){
    if(a[i]<a[i+1]){
      ans+=a[i+1]-a[i];
      b[a[i]+2]++;
      b[a[i+1]+1]--;
      c[a[i+1]+1]-=a[i+1]-a[i]-1;
      }
    else{
      int x=a[i+1]+m;
      ans+=x-a[i];
      b[a[i]+2]++;
      b[x+1]--;
      c[x+1]-=x-a[i]-1;
      }
    }
  rep(i,2*m)b[i+1]+=b[i];
  rep(i,2*m+1)c[i]+=b[i];
  rep(i,2*m)c[i+1]+=c[i];
  rep(i,m)c[i]+=c[i+m];
  ll ma=0;
  rep(i,m)ma=max(c[i],ma);
  cout<<ans-ma<<endl;     
  return 0;
  }

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

int main()
{
    int n;
    cin >> n;
    vector<int> ans(n);

    for (int x = 1; x < 100; ++x) {
        for (int y = 1; y < 100; ++y) {
            for (int z = 1; z < 100; ++z) {
                int out = x*x + y*y + z*z + x*y + y*z + z*x;
                if (out <= n) {
                    ++ans[out-1];
                }
            }
        }
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

const ll Mod = 1e9+7;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;
  rep(i, dy) cout << "U";
  rep(i, dx) cout << "R";
  rep(i, dy) cout << "D";
  rep(i, dx+1) cout << "L";
  rep(i, dy+1) cout << "U";
  rep(i, dx+1) cout << "R";
  cout << "D";
  cout << "R";
  rep(i, dy+1) cout << "D";
  rep(i, dx+1) cout << "L";
  cout << "U";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)998244353
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[100010], b[100010], sum;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum % (n * (n + 1) / 2)) {
		puts("NO");
		return 0;
	}
	sum /= n * (n + 1) / 2;
	rep(i, n - 1)b[i] = a[i + 1] - a[i] - sum;
	b[n - 1] = a[0] - a[n - 1] - sum;
	rep(i, n) {
		if (b[i] > 0 || b[i] % n) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int dp[100010];
int a[100],p;
void f()
{
    int ans=1;
    p=0;
    for(int i=1;i<=5;i++)
    {
        ans*=9;
        a[p++]=ans;
    }
    ans=1;
    for(int i=1;i<=6;i++)
    {
        ans*=6;
        a[p++]=ans;
    }
    a[p++]=1;
    sort(a,a+p);
}
int main()
{
    int t,A;
    int i,j;
    f();
    while(scanf("%d",&t)==1)
    {
        for(i=1;i<=t;i++)
            dp[i]=INF;
        for(i=0;i<p;i++)  //硬币面值
        {
            for(j=a[i];j<=t;j++)//dp[j]表示总数为j时所需的硬币数
                dp[j]=min(dp[j],dp[j-a[i]]+1);//dp[j-A]表示总和为j-A时，所需的硬币数，而且dp[j-A]+1也可使面值恰好为t
        }
        printf("%d\n",dp[t]);
    }
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    cout << (N + 1) / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# ABC139E - League
from collections import deque


def main():
    N, *A = map(int, open(0).read().split())
    B = {}
    for i in range(N):
        x = i * (N - 1)
        B[i + 1] = deque(A[x : x + N - 1])
    cnt, cur, days = 0, [0] * (N + 1), [0] * (N + 1)
    q = deque(list(range(1, N + 1)))
    while q:
        x = q.popleft()
        if not B[x]:  # player x has finished all games
            continue
        y = B[x].popleft()
        if cur[y] == x:  # player y's next game is against x and vice versa
            cnt += 1
            days[x] = days[y] = max(days[x], days[y]) + 1
            cur[x], cur[y] = 0, 0
            q.append(x), q.append(y)
        else:  # the opponent will do another game before playing against x
            cur[x] = y
    flg = cnt == N * (N - 1) // 2  # finished all scheduled games or not
    print(max(days) if flg else -1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 146352
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
	int N,K;
	cin >> N >> K ;
	int d[K+1];
	int A[K+1][N+1];
	int n[N] ;
	int i = 1;
	while (i <= N)
	{
		n[i] = i;
		i++;
	}
	int j;
	i = 1;
	while (i <= K)
	{
		cin >> d[i];
		j = 1;
		while (j <= d[i])
		{
			cin >> A[i][j];
			n[A[i][j]] = -1;
			j++;
		}
		i++;
	}
	i = 1;
	int cnt = 0;
	while (i <= N)
	{
		if (n[i] != -1)
			cnt++;
		i++;
	}
	cout << cnt << endl;
	return 0;
}


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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;

    vector<vector<int>> d(N+1,vector <int>(N+1,0));
    
    for(int i = 1; i < N; i++){
        for(int j = i+1; j < N+1; j++){
            int m = j - i;
            int temp = abs(X - i) + abs(Y - j) + 1;

            d.at(i).at(j) = min(m,temp);
        }
    }

    vector <int> K(N,0);
  
    for(int i = 1; i < N; i++){
        for(int j = i+1; j < N+1; j++){
            K.at(d.at(i).at(j))++;
        }
    }

    for(int i = 1; i < N; i++){
        cout << K.at(i) << endl;
    }
}


Measured memory_bytes: 16000
use std::collections::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, k) = i.read2::<usize, usize>();
    let h = i.read_vec::<isize>(n);
    writeln!(o, "{}", solve(k, &h)).unwrap();
}
fn solve(k: usize, h: &[isize]) -> isize {
    let mut c = VecDeque::new();
    c.push_back(0);

    for i in 1..h.len() {
        let c_next = c
            .iter()
            .enumerate()
            .map(|(j, &ci)| ci + (h[i] - h[i - c.len() + j]).abs())
            .min()
            .unwrap();
        c.push_back(c_next);
        if c.len() > k {
            c.pop_front();
        }
    }
    *c.back().unwrap()
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    Int res = 0;
    unordered_map<Int, Int> mp;
    for (Int i = 0; i < (Int)n; i++) {
        if (i > 0 and a[i - 1] == a[i]) {
            mp[a[i]]++;
            continue;
        }
        if (i < n - 1 and a[i] == a[i + 1]) {
            mp[a[i]]++;
            continue;
        }
        vector<Int> c = divisor(a[i]);
        bool check = true;
        for (Int j = 0; j < (Int)c.size(); j++) {
            if (mp[c[j]] > 0) {
                check = false;
                break;
            }
        }
        if (check) {
            res++;
        }
        mp[a[i]]++;
    }
    print(res);
    return 0;
}

Measured memory_bytes: 33328
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int n;
	scanf("%d", &n);
	printf("Christmas ");
	rep(i, 25 - n){
	  printf("Eve ");
	}
	
	Please AC;
}


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

struct	UnionFind {
	int		size;
	int		*par;
	int		*rank;
	int		num_group;
	UnionFind(int size): size(size), par(NULL), rank(NULL), num_group(size) {
		assert(size > 0);
		par = new int[size];
		rank = new int[size];
		assert(par != NULL && rank != NULL);
		for (int i = 0; i < size; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	~UnionFind() {
		delete [] par;
		delete [] rank;
		par = NULL;
		rank = NULL;
	}
	int		find(int idx) {
		if (par[idx] == idx)
			return idx;
		return (par[idx] = find(par[idx]));
	}
	bool	same(int lhs, int rhs) {
		if (find(lhs) == find(rhs))
			return true;
		return false;
	}
	void	unite(int lhs, int rhs) {
		int	par_l = find(lhs), par_r = find(rhs);
		if (par_l == par_r)
			return;
		if (rank[par_l] < rank[par_r]) {
			par[par_l] = par_r;
		} else {
			par[par_r] = par_l;
			if (rank[par_l] == rank[par_r])
				++rank[par_l];
		}
		--num_group;
	}
};

int	main()
{
	int	N;
	int64_t	x, y;
	cin >> N;
	vector<pair<int64_t, int>>			x_vec(N);
	vector<pair<int64_t, int>>			y_vec(N);
	vector<tuple<int64_t, int, int>>	edge;
	for (int i = 0; i < N; ++i) {
		cin >> x >> y;
		x_vec.at(i) = make_pair(x, i);
		y_vec.at(i) = make_pair(y, i);
	}
	sort(x_vec.begin(), x_vec.end());
	sort(y_vec.begin(), y_vec.end());
	int64_t	cost;
	int		src, dst;
	for (int i = 1; i < N; ++i) {
		cost = x_vec.at(i).first - x_vec.at(i - 1).first;
		src = x_vec.at(i - 1).second;
		dst = x_vec.at(i).second;
		edge.push_back(make_tuple(cost, src, dst));
	}
	for (int i = 1; i < N; ++i) {
		cost = y_vec.at(i).first - y_vec.at(i - 1).first;
		src = y_vec.at(i - 1).second;
		dst = y_vec.at(i).second;
		edge.push_back(make_tuple(cost, src, dst));
	}
	sort(edge.begin(), edge.end());
	UnionFind	uf(N);
	int64_t		total = 0;
	for (auto tpl: edge) {
		tie(cost, src, dst) = tpl;
		if (uf.same(src, dst))
			continue;
		total += cost;
		uf.unite(src, dst);
		if (uf.num_group == 1)
			break;
	}
	cout << total << endl;
}


Measured memory_bytes: 9584
N = int(input())


shop_dict = {}
for i in range(1,N+1):
    input_li = input().split()
    s = input_li[0]
    p = int(input_li[1])
    if s not in shop_dict.keys():
        shop_dict[s] = {}
    shop_dict[s][p] = i

all_city = list(shop_dict.keys())
all_city.sort()

for city in all_city:
    pt_list = list(shop_dict[city].keys())
    pt_list.sort(reverse=True)
    for pt in pt_list:
        print(shop_dict[city][pt])

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int count = 0;
  for (int i = 1; i <= N; i++) {
    string S = to_string(i);
    int K = S.size();
    int sum = 0;
    for (int j = 0; j < K; j++) {
      sum += (S[j]-48);
    }
    if (sum >= A && sum <= B) count += i;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define X first
#define Y second
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define D double
#define ll long long
#define REP(i,a) for(int i=0;i<a;i++)
#define REP1(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i<=b;i++)
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define RREP1(i,a,b) for(int i=a;i>b;i--)
#define RREP2(i,a,b) for(int i=a;i>=b;i--)
#define SREP(i,x) for(auto i:x)
#define MS0(x) memset((x),0,sizeof((x)))
#define MS1(x) memset((x),-1,sizeof((x)))
#define MSF(x) memset((x),127,sizeof(x))
#define pb push_back
#define LE(x) (int)((x).size())
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<D,D>
#define im guagua
#define RI(x) x=rit()
#define RII(a,b) a=rit(),b=rit()
#define RIII(a,b,c) a=rit(),b=rit(),c=rit()
#define debug 0
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10 ;
const ll mod7 = 1e9+7;
const ll mod9 = 1e9+9;
using namespace std;
inline ll rit(){
    ll f=0,key=1;
    char c;
    do{
        c=getchar();
        if(c=='-') key=-1;
    }while(c<'0' || c>'9');
    do{
        f=f*10+c-'0';
        c=getchar();
    }while(c>='0' && c<='9');
    return f*key;
}
inline void fprt(D f){
    printf("%.08lf",f);
}
void init(){
}
const int Z = 100005;
int n;
int a[Z],cnt[Z];
void read(){
    int sum,var;
    RI(n);
    REP(i,n){
        RI(a[i]);
        cnt[a[i]]++;
    }
    sum = 0;
    var = 0;
    REP(i,Z){
        if(cnt[i]>0){
            var++;
            sum+=(cnt[i]-1);
        }
    }
    printf("%d\n",var-(sum%2));
}
void solve(){
}
int main(){
    int nn=1;
    // nn=rit();
    while(nn--){
        // while(cin>>n) 
            init(),read(),solve();
    }
    return 0;
}

Measured memory_bytes: 1024
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int k, x;
    cin >> k >> x;
    for (int i = max(-1000000, x - k + 1); i < min(1000001, x + k); i++)
    {
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(){
	int N, K; cin >> N >> K;
	if(N<K){
		cout << 0 << endl;
	}else{
		cout << 10 << endl;
	}



	return 0;
}


Measured memory_bytes: 764
N,K,Q = map(int,input().split(" "))
a2={}
for i in range(Q):
  j = input()
  if j not in a2:
    a2[j] = 1
  else:
    a2[j] += 1
    
for i in range(N):
  if str(i+1) not in a2:
    a2[str(i+1)] = 0
  if a2[str(i+1)] >= Q-K+1:
    print("Yes")
  else:
    print("No")

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

int main() {
	int n;
	while ( cin >> n, n ) {
		vector<string> v;
		int l = 0;
		for ( int i = 0; i < n; i++ ) {
			string s;
			cin >> s;
			string t = "";
			t.push_back(s[0]);
			for ( int j = 1; j < s.size(); j++ ) {
				char c = s[j-1];
				if ( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ) t.push_back(s[j]); 
			}
			l = max(l, (int)t.size());
			v.push_back(t);
		}

		int k;
		vector<string> now(n, "");
		for ( k = 0; k < l; k++ ) {			
			for ( int i = 0; i < n; i++ ) {
				if ( (int)v[i].size() > k ) {
					now[i].push_back(v[i][k]);
				}
			}

			map<string, bool> m;
			bool flag = true;
			for ( int i = 0; i < n; i++ ) {
				if ( m[now[i]] ) {
					flag = false;
					break;
				}
				m[now[i]] = true;
			}

			if ( flag ) break;
		}

		if ( k < l ) cout << k+1 << endl;
		else cout << -1 << endl;
	}

	return 0;
}



Measured memory_bytes: 3192