akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

	return NIL;

}

Node treeMaximum(Node x){

	return NIL;
}

Node treeSearch(Node u, int k){


	return NIL;
}

Node treeSuccessor(Node x){


	return NIL;
}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y



}

void insert(int k){
	Node y = NIL;
	Node x = root;
	Node z;

	z = (Node)malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	if (root == NIL)
	{
		root = z;
		return;
	}
	while (x != NIL) {
		y = x;
		if (k < x->key)
			x = x->left;
		else
			x = x->right;
	}

	if (k < y->key)
		y->left = z;
	else
		y->right = z;
}

void inorder(Node u){
	if (u == NULL) return;

	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node u){
	if (u == NULL) return;

	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}


int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", com);
		if (com[0] == 'f'){
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i'){
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}
	return 0;
}

Measured memory_bytes: 26116
#include<bits/stdc++.h>
using namespace std;
int n,v[55];
long double ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    ans=v[1];
    for(int i=2;i<=n;i++){
        ans=(ans+v[i])/2.0;
    }
    cout<<fixed<<setprecision(7)<<ans;
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e3;
vi adj[N + 1];
int level[N + 1];

void bfs (int n, bool vis[]) {
    vis[n] = true;
    level[n] = 0;
    queue <int> q;
    q.push(n);
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (auto i : adj[x]) {
            if (!vis[i]) {
                vis[i] = true;
                level[i] = level[x] + 1;
                q.push(i);
            }
        }
    }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, y;
	cin >> n >> x >> y;
	for (int i = 1; i < n; i++) {
	    adj[i].pb(i + 1);
	    adj[i + 1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);
	bool vis[n + 1];
	int cnt[n] = {0};
	for (int i = 1; i <= n; i++) {
	    for (int j = 1; j <= n; j++) {
	        vis[j] = false;
	        level[j] = 0;
	    }
	    bfs(i, vis);
	    for (int j = 1; j <= n; j++) {
	        cnt[level[j] - level[i]]++;
	    }
	}
	for (int i = 1; i < n; i++) {
	    cout << cnt[i] / 2 << "\n";
	}
 	return 0;
}

Measured memory_bytes: 384
import math

N, K = map(int, input().split())
ans = 0
for m in range(1, N+1):
    x = math.log2(K / m)
    if x - int(x) > 0:
        x += 1
    if x > 1:
        ans += (1/2) ** int(x) / N
    else:
        ans += 1 / N
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		int n, q; scanf("%d %d", &n, &q);
		if (n == 0)break;
		vector<tuple<ll, string, ll>> vp(n);
		for (int i = 0; i < n; i++) {
			string s;
			ll e, w;
			cin >> s >> e >> w;
			vp[i] = make_tuple(w, s, e);
		}
		sort(vp.begin(), vp.end());
		while (q--) {
			ll t; scanf("%lld", &t);
			auto itr = lower_bound(vp.begin(), vp.end(), make_tuple(t, "", -1));
			if (itr == vp.end()) puts("Unknown");
			else {
				ll e, w;
				string s;
				tie(w, s, e) = *itr;
				ll one = w - (e - 1);
				if (t < one) puts("Unknown");
				else {
					cout << s << " " << (1 + (t - one)) << "\n";
				}
			}
		}
	}
	return 0;

}


Measured memory_bytes: 3288
# coding: utf-8
N = int(input())
S = input()

w, e = 0, 0
for i in range(N):
    if S[i] == "E":
        e += 1
ans = e

for i in range(N):
    if S[i] == "E":
        e -= 1
    ans = min(ans, e+w)
    
    if S[i] == "W":
        w += 1
print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  
  for(int i = 0; i <= W + 1; i++){
    cout << "#";
  }
  
  cout << endl;
  
  for(int i = 0; i < H; i++){
    cin >> vec[i];
    cout << "#" << vec[i] << "#" << endl;
  }
  
  for(int i = 0; i <= W + 1; i++){
    cout << "#";
  }
  
  return 0;
}

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

using ld = long double;

constexpr ld eps = 1e-10;

struct event {
    ld t;
    vector<int> star;
    bool operator<(event const& e) const {
        return t < e.t;
    }
};

template<typename... Args>
event make_event(ld t, Args... i) {
    vector<int> v = {i...};
    event e = {t, v};
    return e;
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<ld> x(n), y(n), z(n), vx(n), vy(n), vz(n), r(n), vr(n);
        for(int i=0; i<n; ++i) {
            cin >> x[i] >> y[i] >> z[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
        }
        vector<event> events;
        for(int i=0; i<n; ++i) {
            for(int j=i+1; j<n; ++j) {
                ld a = pow(vx[i] - vx[j], 2) + pow(vy[i] - vy[j], 2)
                       + pow(vz[i] - vz[j], 2) - pow(vr[i] + vr[j], 2);
                ld b = 2 * ((x[i] - x[j]) * (vx[i] - vx[j]) + (y[i] - y[j]) * (vy[i] - vy[j])
                            + (z[i] - z[j]) * (vz[i] - vz[j]) + (r[i] + r[j]) * (vr[i] + vr[j]));
                ld c = pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)
                       + pow(z[i] - z[j], 2) - pow(r[i] + r[j], 2);
                ld D = b * b - 4 * a * c;
                if(abs(a) < eps && abs(b) > eps) {
                    ld t = - c / b;
                    if(t > 0) {
                        events.push_back(make_event(t, i, j));
                    }
                } else if(D >= 0) {
                    ld t1 = (-b - sqrt(D)) / (2 * a);
                    ld t2 = (-b + sqrt(D)) / (2 * a);
                    if(t1 > 0) {
                        events.push_back(make_event(t1, i, j));
                    } else if(t2 > 0) {
                        events.push_back(make_event(t2, i, j));
                    }
                }
            }
            events.push_back(make_event(r[i] / vr[i], i));
        }
        sort(events.begin(), events.end());
        vector<bool> vanish(n);
        vector<ld> res(n);
        for(auto& e : events) {
            bool ok = true;
            for(auto& s : e.star) {
                ok &= !vanish[s];
            }
            if(ok) {
                for(auto& s : e.star) {
                    res[s] = e.t;
                    vanish[s] = true;
                }
            }
        }
        for(auto x : res) {
            cout << fixed << setprecision(10) << x << endl;
        }
    }
}


Measured memory_bytes: 5440
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

int main () {
  int n, m;
  cin >> n >> m;
  vector<tiii> data(m);
  rep(i,m) {
    int p, y;
    cin >> p >> y;
    data[i] = tiii(p,y,i);
  }
  sort(data.begin(), data.end());
  int x = 0;
  int prev_p = -1;
  vector<tiii> id(m);
  rep(i,m) {
    int p, y, num;
    tie(p, y, num) = data[i];
    if (prev_p == p) x++;
    else x = 1;
    prev_p = p;
    id[i] = tiii(num, p, x);
  }
  sort(id.begin(), id.end());
  rep(i,m) printf("%06d%06d\n", get<1>(id[i]), get<2>(id[i]));
  return 0;
}

Measured memory_bytes: 3840
import java.util.*;

public class Main{
      
      public static void main(String[] args) {
          
           Scanner sc = new Scanner(System.in);
           
           int n = sc.nextInt();
		
           List<List<Edge>> edges = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			edges.add(new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			int c = sc.nextInt();

			edges.get(a).add(new Edge(a, b, c));
			edges.get(b).add(new Edge(b, a, c));
		}

		int q = sc.nextInt();
		int k = sc.nextInt() - 1;

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

		long[] d = new long[n];
		boolean[] used = new boolean[n];
		Deque<Integer> st = new ArrayDeque<>();
		st.push(k);
		while (!st.isEmpty()) {
			int e = st.pop();

			used[e] = true;
			for (Edge next : edges.get(e)) {
				if (used[next.v]) {
					continue;
				}
				d[next.v] = d[e] + next.w;

				st.push(next.v);
			}
		}

		for (int i = 0; i < q; i++) {
			System.out.println(d[x[i]] + d[y[i]]);
		}
      }
        
      private static class Edge {
		int u; // from
		int v; // to
		int w; // cost

		Edge(int u, int v, int w) {
			this.u = u;
			this.v = v;
			this.w = w;
		} 
      }
     
}       


Measured memory_bytes: 179848
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		
		for (long i=1; i<=B; i++) {
			if (A*i%B == 0) {
				System.out.println(A * i);
                break;
			}
		}
	}
}

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

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    rep(r, N + 1) rep(g, N + 1) {
        int b = (N - R * r - G * g) / B;
        if (R * r + G * g + B * b == N && b >= 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll m,n,i,s=0,c=0;
  cin>>n>>m;
  ll a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    s+=a[i];
  }
  sort(a,a+n);
  for(i=n-1;i>=0;i--)
  {
    if((a[i]*4*m)>=s)
     c++;
  }
  //cout<<c<<endl;
  if(c>=m)
  cout<<"Yes";
  else
  cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,len;
int main()
{
    scanf("%d%d",&a,&b);
    c=b;
    while(c>0)
    {
        c/=10;
        len++;
    }
    a=a*pow(10,len)+b;
    if(sqrt(a)==floor(sqrt(a)))printf("Yes");
    else printf("No");
    return 0;
} 

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

//安定なソート
public class Main {

	public static void main(String[] args) {
		// 入力値の取得
		try (
				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {

			int n = Integer.parseInt(br.readLine());
			String[] s = br.readLine().split("\\s");
			ArrayList<Card> bubList = new ArrayList<>(); // バブルソート用
			for (int i = 0; i < n; i++) {
				char suit = s[i].charAt(0);
				int num = Integer.parseInt(s[i].substring(1, 2));
				Card card = new Card(suit, num);
				bubList.add(card);
			}
			ArrayList<Card> selList = new ArrayList<>(bubList); // 選択ソート用（複製）
			// ソートの実行
			Main.bubbleSort(bubList);
			Main.selectionSort(selList);
			// 結果の表示
			Main.displayCard(bubList);
			System.out.println("Stable");
			Main.displayCard(selList);
			String ans = Main.isStable(bubList, selList) ? "Stable" : "Not stable";
			System.out.println(ans);

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	// バブルソート
	static int bubbleSort(ArrayList<Card> cl) {
		int cnt = 0;
		for (int i = 0; i < cl.size(); i++) {
			for (int j = cl.size() - 1; i + 1 <= j; j--) {
				// 1つ前のカードの数字の方が大きい場合
				if (cl.get(j).num < cl.get(j - 1).num) {
					cnt++;
					Card tmp = cl.get(j);
					cl.set(j, cl.get(j - 1));
					cl.set(j - 1, tmp);
				}
			}

		}
		return cnt;

	}

	// 選択ソート
	static int selectionSort(ArrayList<Card> cl) {
		int cnt = 0;
		for (int i = 0; i < cl.size(); i++) {
			int mini = i;
			for (int j = i + 1; j < cl.size(); j++) {
				if (cl.get(mini).num > cl.get(j).num) {
					mini = j;
				}
			}
			if (i != mini) {
				cnt++;
				Card tmp = cl.get(mini);
				cl.set(mini, cl.get(i));
				cl.set(i, tmp);
			}
		}

		return cnt;

	}

	// 配列の要素表示
	static void displayCard(ArrayList<Card> cl) {
		cl.get(0).showCard();
		for (int i = 1; i <= cl.size() - 1; i++) {
			System.out.print(" ");
			cl.get(i).showCard();
			if (i == cl.size() - 1) { // 最後の一回
				System.out.println();
			}
		}
	}

	// バブルソートと選択ソートの結果を比較
	static boolean isStable(ArrayList<Card> in, ArrayList<Card> out) {
		for (int i = 0; i < in.size(); i++) {
			if (in.get(i) != out.get(i)) {
				return false;
			}
		}
		return true;
	}

}

class Card {
	char suit; // 絵柄（H:ハート、D:ダイヤ、S:スペード、C:クラブ）
	int num; // 番号

	// コンストラクター
	Card(char suit, int num) {
		this.suit = suit;
		this.num = num;
	}

	void showCard() {
		System.out.print("" + suit + num); // 文字列連結でString型に
	}

}



Measured memory_bytes: 24652
#include<stdio.h>

int
main(int argc, char *argv[])
{
        char buf;

        while((buf = getc(stdin)) != EOF) {
                if ('a' <= buf && buf <= 'z')
                        buf = buf - 'a' + 'A';
                putc(buf, stdout);
        }

return 0;
}

Measured memory_bytes: 524
#include<atcoder/all>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long Int;

int main(){
    int n, q, a, command, x, y;
    cin >> n >> q;
    atcoder::fenwick_tree<Int> ft(n);
    for(int i = 0;i < n;i++){
        cin >> a;
        ft.add(i, a);
    }
    
    while(q--){
        cin >> command >> x >> y;
        if(command == 0)ft.add(x, y);
        else cout << ft.sum(x, y) << endl;
    }
    return 0;
}

Measured memory_bytes: 8244
Q = int(input())
N = list(int(input()) for i in range(Q))
m = [0]*(max(N)+1)
N_max = max(N)
r = 320
for i in range(2,r):
    for j in range(2,r):
        for k in range(2,100000//(i*j)+1):
            if i*j*k < N_max+1 and (i!=j or j!=k or k!=i):
                m[i*j*k] = 1
for i in range(1,len(m)):
    m[i] = m[i]+m[i-1]
for i in N:
    print(m[i])



Measured memory_bytes: 13700
//  यस्य स्मरणमात्रेण जन्मसंसारबन्धनात् ।  विमुच्यते नमस्तस्मै विष्णवे प्रभविष्णवे ॥
 
 
 
/****
*     Author- Indrajeet Mishra
*             MNNIT Allahabad, Prayagraj
*             Chemical Engineering undergraduate
 
 
 
****/
 
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
 
#include <bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)
 
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=0;cin>>n;
    ll a[n]={0};
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    ll count=0,ans=0;
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            rep(k,j+1,n){
                if(a[i]+a[j]>a[k])
                ans++;
                else break;
            }
        }
    }
    cout<<ans;
    return 0;
}

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

int main(void)
{
    int N, *A;
    char c;
    int i, j;
    int max, max2;
    
    
    scanf("%d%c", &N, &c);
    
    
    A = (int*)malloc(sizeof(int)*(N+1));
    
    
    max = max2 = 0;
    
    
    for(i=0; i<N; i++)
    {
        scanf("%d%c", &A[i], &c);
        
        
        if(A[i] >= max)
        {
            max2 = max;
            max = A[i];
        }
        else if(A[i] > max2)
        {
            max2 = A[i];
        }
    }
    
    for(i=0; i<N; i++)
    {
        if(A[i] != max)
        {
            printf("%d\n", max);
        }
        else
        {
            printf("%d\n", max2);
        }
    }
    
    
    free(A);
    
    
    //system("pause");
    
    return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>

int main()
{
    
    int n, r;
    
    scanf("%d%d", &n,&r);
    
    if (n < 10) {
    
        printf("%d\n", r + (100 * (10-n)));
        
    } else{
        printf("%d\n", r);
    }


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, a, N) for(int i = a; i < N; i++)

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);

    rep(i, 0, N) {
        scanf("%d", &A[i]);
        A[i] -= i + 1;
    }

    sort(A.begin(), A.end());
    int median;
    if (N % 2 == 0) median = (A[N / 2] + A[N / 2 - 1]) / 2;
    else median = A[(N + 1) / 2 - 1];

    ll ans = 0;
    rep(i, 0, N) ans += abs(A[i] - median);

    cout << ans << endl;
}

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

int main() {
  int rate;
  cin >> rate;
  if(rate<1200){
    cout << "ABC" << endl;
  }else if(rate<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int INF = Integer.MAX_VALUE/2;
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		int[] dp = new int[20000];
		int ans = INF;
		Arrays.fill(dp, INF);
		dp[0] = 0;
		for(int i = 0; i < N; i++)
			for(int j = A[i]; j < 20000; j++)
				dp[j] = Math.min(dp[j], dp[j-A[i]] + B[i]);
		for(int i = H; i < 20000; i++)
			ans = Math.min(ans, dp[i]);
		System.out.println(ans);
	}

}

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

int main()
{
    string s,t;
    cin>>s>>t;
    
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1],i,j;

    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else
            {
                if(s[i-1]==t[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
    }
   i=n;
   j=m;
   vector<char>v;
   while(i>0 && j>0)
   {
       if(dp[i][j] != max(dp[i-1][j],dp[i][j-1]))
       {
           v.push_back(s[i-1]);
           i--;j--;
       }
       else if(dp[i][j]==dp[i-1][j])
       {
           i--;
       }
       else
       {
           j--;
       }
   }
   for(i=v.size()-1;i>=0;i--)
   {
       cout<<v[i];
   }
   cout<<endl;
}

Measured memory_bytes: 35456
fun main(args: Array<String>) {
    val N = nextLong()
    var ans = 0
    divisor(N).drop(1).forEach { x ->
        var w = N
        while (w % x == 0L) w /= x
        w %= x
        if (w == 1L) ans += 1
    }
    ans += divisor(N - 1).drop(1).size
    println(ans)
}

fun divisor(value: Long) = 
    (1 .. Math.sqrt(value.toDouble()).toLong())
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .distinct()
        .sorted()

fun next() = readLine()!!
fun nextLong() = next().toLong()



Measured memory_bytes: 50732
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll k, n;
  cin >> k >> n;
  vll as(2 * n);
  vll bs(2 * n);

  rep(i, n) {
    cin >> as[i];
    bs[n-1-i] = k - as[i];
  }
  rep(i, n) {
    as[i + n] = as[i] + k;
    bs[i + n] = bs[i] + k;
  }

  ll ans = LONG_LONG_MAX;
  rep(i, n) {
    ll cand = as[i + n - 1] - as[i];
    chmin(ans, cand);
    cand = bs[i + n - 1] - bs[i];
    chmin(ans, cand);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>

int main() {
	int x1, x2, x3, x4, x5;
	scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);
	if (x1 == 0) {
		printf("1");
	}
	else if (x2 == 0) {
		printf("2");
	}
	else if (x3 == 0) {
		printf("3");
	}
	else if (x4 == 0) {
		printf("4");
	}
	else if (x5 == 0) {
		printf("5");
	}
	return 0;
}

Measured memory_bytes: 1640
s = input()
l = ["AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHBARA", "KIHABARA", "AKIHABR", "AKIHBAR", "KIHABAR", "AKIHBRA", "KIHABRA", "KIHBARA", "AKIHBR", "KIHABR", "KIHBAR", "KIHBRA", "KIHBR"]
print("YES" if s in l else "NO")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);
		String input = in.nextLine();

		int[] abcArray = new int[26];
		byte[] asciiCodes = {65};
		try{
			asciiCodes = input.getBytes("US-ASCII");
		}catch(Exception e){
			System.out.println(e.toString());
		}
		for(int i = 0; i < asciiCodes.length; i++){
			int index = (int)asciiCodes[i] - 97;
			abcArray[index]++;
		}
		boolean isOk = true;
		for(int i = 0; i < abcArray.length; i++){
			if(abcArray[i] > 1){
				isOk = false;
			}
		}
		if(isOk){
			System.out.println("yes");
		}else{
			System.out.println("no");
		}
	}

}


Measured memory_bytes: 21716
from collections import deque

n=int(input())
l=deque()
for i in range(n):
    com=input()
    if(com=="deleteFirst"):
        l.popleft()
    elif(com=="deleteLast"):
        l.pop()
    else:
        com,val=com.split()
        if(com=="insert"):
            l.appendleft(val)
        elif(com=="delete"):
            try:
                l.remove(val)
            except:
                pass

print(' '.join(l))



Measured memory_bytes: 69732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll a, v, b, w;
    cin >> a >> v >> b >> w;
    ll t;
    cin >> t;
    ll d = abs(a - b);
    if ((v - w) * t >= d) {
        cout << "YES" << endl;
    } else
        cout << "NO" << endl;
}

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

int main(void){
    int n;
    string s, result;
    
    cin >> n >> s;
    
    if(n >= 3200){
        result = s;
    } else {
        result = "red";
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-2-24 21:32:31
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef complex<double> P;

bool cmp_x(const P& p, const P& q)
{
  if (p.real() != q.real())
    return p.real() < q.real();
  return p.imag() < q.imag();
}

double det(P p, P q)
{
  return (conj(p) * q).imag();
}

double dot(P p, P q)
{
  return (conj(p) * q).real();
}

double theta(P p, P q)
{
  return arg(q / p);
}

vector<P> convex_hull(P* ps, int n)
{
  sort(ps, ps + n, cmp_x);
  int k = 0;
  vector<P> qs(n * 2);
  for (auto i = 0; i < n; i++)
  {
    while (k > 1 && det(qs[k-1] - qs[k-2], ps[i] - qs[k-1]) <= 0)
      k--;
    qs[k++] = ps[i];
  }
  for (auto i = n-2, t=k; i >= 0; i--)
  {
    while (k > t && det(qs[k-1] - qs[k-2], ps[i] - qs[k-1]) <= 0)
      k--;
    qs[k++] = ps[i];
  }
  qs.resize(k - 1);
  return qs;
}

double kaku(P x, P p, P y)
{
  return theta(y - p, x - p);
}

double PI = 3.1415926535897932384626433832795;

int main()
{
  int N;
  cin >> N;
  P ps[120];
  P ind[120];
  for (auto i = 0; i < N; i++)
  {
    double x, y;
    cin >> x >> y;
    ind[i] = ps[i] = P(x, y);
  }
  vector<P> V = convex_hull(ps, N);
  double ans[120];
  fill(ans, ans + N, 0);
  int M = V.size();
  for (auto i = 0; i < M; i++)
  {
    double prob = (PI - kaku(V[(i-1 + M)%M], V[i], V[i+1])) / (2 * PI);
    for (auto j = 0; j < N; j++)
    {
      if (V[i] == ind[j])
      {
        ans[j] = prob;
      }
    }
  }
  for (auto i = 0; i < N; i++)
  {
    cout << fixed << setprecision(12) << ans[i] << endl;
  }
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        xy: [(i32, i32); n],
    }

    let mut zz = vec![];
    let mut ww = vec![];

    for (x, y) in xy {
        zz.push(x + y);
        ww.push(x - y);
    }

    let z_max = zz.iter().copied().max().unwrap();
    let z_min = zz.iter().copied().min().unwrap();
    let w_max = ww.iter().copied().max().unwrap();
    let w_min = ww.iter().copied().min().unwrap();

    let ans = std::cmp::max(z_max-z_min, w_max-w_min);

    println!("{}", ans);
}


Measured memory_bytes: 9244
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007


using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
lg n,m,k,ans;
int main()
{
    cin>>n;
    string kk="";
    while(n>0)
    {
        lg i = n%26;
        i--;
        if(i<0) i=25;
        string h = "a";
        h[0]+=i;
        kk = h+kk;
        if(n%26==0) n--;
        n/=26;
        if(n==0) break;
    }
    cout<<kk<<endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e12+1;
const int mod=1000000007;
//const int mod=998244353;

int n,m,k;
const int N=3e5+10;



long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

vector<long long int> fact,fact_inverse;
template<typename type>
void tabulate(type n){
    fact.resize(n+1);
    fact_inverse.resize(n+1);
    fact[0]=1;
    fact_inverse[0]=binpow(1, mod-2, mod);
    for (int i=1; i<n+1; i++) {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inverse[i]=binpow(fact[i], mod-2, mod);
    }
}
template<typename type>
long long int nCk(type n,type k){
    return n<k?0:fact[n]*fact_inverse[n-k]%mod*fact_inverse[k]%mod;
}
template<typename type>
long long int nPk(type n,type k){
    return n<k?0:fact[n]*fact_inverse[n-k]%mod;
}



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n >> m;
    tabulate(n+50);
    ll ans=1;
    for(int i=2; i*i<=m; i++){
        if(m%i==0){
            int u=0;
            while(m%i==0){
                m/=i;
                u++;
            }
            (ans*=nCk(n+u-1,u))%=mod;
        }
    }
    if(m!=1)(ans*=n)%=mod;
    cout << ans << el;
    return 0;
}






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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    vector<set<int>> edge(N);
    vector<set<int>> edge_inv(N);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        edge[x].insert(y);
        edge_inv[y].insert(x);
    }
    // topological sort
    vector<int> numbers(N);
    queue<int> children;
    int num = 0;
    for (int i = 0; i < N; i++) {
        if (edge[i].size() == 0) {
            children.push(i);
        }
    }
    while (!children.empty()) {
        int child = children.front();
        children.pop();
        numbers[child] = N - num;
        num++;
        for (auto parent: edge_inv[child]) {
            edge[parent].erase(child);
            if (edge[parent].size() == 0) {
                children.push(parent);
            }
        }
    }
    vector<pair<int, int>> nodes;
    vector<int> length(N);
    for (int i = 0; i < N; i++) {
        nodes.emplace_back(make_pair(numbers[i], i));
    }
    sort(nodes.begin(), nodes.end());
    for (auto node: nodes) {
        // priority, No. of nodes
        // cout << node.first << node.second << endl;
        if (edge_inv[node.second].empty()) {
            length[node.second] = 0;
        } else {
            length[node.second] = -1;
            for (auto nd: edge_inv[node.second]) {
                length[node.second] = max(length[node.second], length[nd] + 1);
            }
        }
    }
    // for (int i = 0; i < N; i++) {
    //     cout << i + 1 << " number: " << numbers[i] << ", length: " << length[i] << endl;
    // }
    cout << *max_element(length.begin(), length.end()) << endl;
    return 0;
}


Measured memory_bytes: 20988
from collections import defaultdict
from collections import deque

d = defaultdict(set) #初期中身は空のset

N, M = map(int, input().split())
for i in range(M):
  A, B = map(int, input().split())
  d[A-1].add(B-1)
  d[B-1].add(A-1)
        
check = [0]*N
mans = 0

for i in range(N):
    ans = 0
    if check[i] == 0:
        check[i] = 1
        ans += 1
        sl = deque(list(d[i]))
        while sl:
            s = sl.pop()
            if check[s] == 0:
                check[s] = 1
                ans += 1
                sl.extend(list(d[s]))
    if mans < ans:
        mans = ans

print(mans)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.size()) {
    rep(j, i + 1) {
      bool flag = true;
      FOR(k, j, i + 1) {
        if(s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T') flag = false;
      }
      if(flag) ans = max(ans, i - j + 1);
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int a = 0, b = 0;
	int x;
	for (int i = 0; i < 4; i++) {
		cin >> x;
		a += x;
	}
	for (int i = 0; i < 4; i++) {
		cin >> x;
		b += x;
	}
	cout << max(a, b) << endl;
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  int n = 1000;
  cin >> a >> b;
  for(int i = 1; i <= n; i++) {
    if((int)(i*0.08) == a && (int)(i*0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
	int n;
	std::cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++) {
		double a;
		std::cin >> a;
		ans += 1.0 / a;
	}

	printf("%lf\n", 1.0/ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N+1],B[N+1];
    for(int i=0;i<N;i++) cin >> B[i];
    A[0]=B[0];
    for(int i=0;i<N-1;i++){
        A[i+1]=B[i];
        if(A[i]>B[i]) A[i]=B[i];
    }
    int total=0;
    for(int i=0;i<N;i++) total += A[i];

    cout << total << endl;
    return 0;
}


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

using namespace std;

#define mod 1000000007

long long int a[100001];

class UF
{
private:
	vector<int> parent;
	vector<vector<long long int> > v;

public:
	UF(int n)
	{
		parent = vector<int>(n + 1, -1);
		v = vector<vector<long long int> >(n + 1);
		for(int i = 0; i < n; i++){
			v[i].push_back(a[i]);
		}
	}

	int getparent(int n)
	{
		if(parent[n] < 0) return n;
		return parent[n] = getparent(parent[n]);
	}

	void add(int x, int y)
	{
		x = getparent(x);
		y = getparent(y);
		if(x == y) return;
		if(x > y) swap(x, y);
		parent[y] = x;
		copy(v[y].begin(), v[y].end(), back_inserter(v[x]));
	}

	vector<long long int> getv(int n)
	{
		return v[n];
	}
};

int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	UF uf(n);
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		uf.add(x, y);
	}
	priority_queue<int> qu;
	long long int ans = 0;
	int treenum = 0;
	for(int i = 0; i < n; i++){
		if(uf.getparent(i) == i){
			treenum++;
			vector<long long int> tmp = uf.getv(i);
			sort(tmp.begin(), tmp.end());
			ans += tmp[0];
			for(int j = 1; j < tmp.size(); j++){
				qu.push(-tmp[j]);
			}
		}
	}
	if(treenum == 1){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0; i < treenum - 2; i++){
		if(qu.empty()){
			cout << "Impossible" << endl;
			return 0;
		}
		ans += -qu.top();
		qu.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 12884
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

using P=pair<int,int>;


vector<int>G[2000*(2000-1)/2];

int dfs(int x,vector<int>&d){
  if(d[x]!=-1)return d[x];
  d[x]=1;
  for(auto&&v:G[x]){
    chmax(d[x],dfs(v,d)+1);
  }
  return d[x];
}

bool solve(){
  ll n;cin>>n;
  map<pair<int,int>,int>mp;
  map<int,pair<int,int>>mp2;
  int _k=0;
  for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
    mp[P(i,j)]=_k;
    mp[P(j,i)]=_k;
    mp2[_k]=P(i,j);
    _k++;
  }

  vector<int>h(n*(n-1)/2,0);

  rep(i,n){
    int last=-1;
    rep(j,n-1){
      ll a;cin>>a;a--;
      if(last!=-1){
        G[mp[P(i,last)]].push_back(mp[P(i,a)]);
        h[mp[P(i,a)]]++;
      }
      last=a;
    }
  }

  stack<int>st;

  rep(i,n*(n-1)/2)if(h[i] == 0)st.push(i);

  vector<int>ans;
  while(st.size()) {
    int i = st.top(); st.pop();
    ans.push_back(i);
    for(auto& j: G[i]) {
      h[j]--;
      if(h[j] == 0) st.push(j);
    }
  }
  if((int)ans.size()!=n*(n-1)/2){
    cout<<-1<<endl;
    return false;
  }

  int ansn=0;
  vector<int>d(n*(n-1)/2,-1);

  rep(i,n*(n-1)/2){
    chmax(ansn,dfs(i,d));
  }
  cout<<ansn<<endl;
  // for(auto&&i:ans)cout<<mp2[i]<<endl;

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


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

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

using namespace std;

// data
int P[3][3];

void solve();
int main(){
    rep(i, 3){
        rep(j, 3){
            cin >> P[i][j];
        }
    }

    solve();
}

int manhattan(int (*P)[3]){
    int dst = 0;
    rep(i, 3){
        rep(j, 3){
            if(P[i][j] == 0) continue;

            int ti = (P[i][j] - 1) / 3,
                tj = (P[i][j] - 1) % 3; // target location
            dst += abs(ti - i) + abs(tj - j);
        }
    }

    return dst;
}

typedef pair<int, int> Pi;

struct State{
    State(int (*P0)[3], int move0, Pi blankBef, Pi blankNow){
        rep(i, 3)
            rep(j, 3)
                P[i][j] = P0[i][j];
        move = move0;
        dst = manhattan(P) + move;
        blank = blankNow;
        _blank = blankBef;
    }
    friend bool operator>(State s0, State s1){
        return s0.dst > s1.dst;
    }
    int dst;
    int move;
    int P[3][3];
    pair<int, int> blank, _blank;
};

const int di[4] = {-1, 1, 0 ,0},
    dj[4] = {0,0,-1, 1};
void solve(){
    // find blank
    int bi, bj;
    rep(i, 3)
        rep(j, 3) if (P[i][j] == 0) bi = i,
                                    bj = j;

    State s0(P, 0, Pi(bi, bj), Pi(bi, bj));
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.push(s0);

    while(!pq.empty()){
        State s = pq.top(); pq.pop();

        // check final
        if(manhattan(s.P) == 0){
            cout << s.move << endl;
            break;
        }
        
        rep(i, 4){
            int ii, jj;
            ii = s.blank.first + di[i];
            jj = s.blank.second + dj[i];

            if(ii>=0&&ii<3 && jj>=0&&jj<3 && Pi(ii, jj)!= s._blank){
                swap(s.P[s.blank.first][s.blank.second], 
                    s.P[ii][jj]);

                pq.push(State(s.P, s.move+1, s.blank, Pi(ii, jj)));

                swap(s.P[s.blank.first][s.blank.second],
                     s.P[ii][jj]);
            }
        }
    }
}


Measured memory_bytes: 3860
from math import gcd

def lcm(a,b):
    return (a//gcd(a,b))*b

def f(x,p):
    return x//p

A,B,C,D=map(int,input().split())
E=lcm(C,D)

X=f(B,C)-f(A-1,C)
Y=f(B,D)-f(A-1,D)
Z=f(B,E)-f(A-1,E)
print(B-A+1-(X+Y-Z))


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

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string S=Console.ReadLine();
    int w=int.Parse(Console.ReadLine());
      for(int i=0;i<(S.Length);i++){
        if(i%w==0){
          Console.Write(S.Substring(i,1));
        }
      }
      Console.Write("\n");
    }
  }

}


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

#define ll long long
#define endl '\n'
#define N 1e5+1;
#define INF 1e9

const ll MOD = 10e9+7;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}

vector<int> ans;
ll a[200001];
ll b[200001];
vector<int> sorted;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    string str;
    cin >> n >> str >> k;
    for(int i=0; i<n; i++)
    {
        if(str[i]!=str[k-1]) str[i] = '*';
    }
    cout << str;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 100005;
vector<int> A[MAXN], B[MAXN], gra[MAXN];
int vis[MAXN], val[MAXN], n, ra, rb;

int dfs(int u, vector<int> *tr) {
	int lst = 0;
	for (int v : tr[u]) {
		int c = dfs(v, tr);
		if (lst) {
			gra[lst].push_back(c);
			gra[c].push_back(lst);
			lst = 0;
		} else lst = c;
	}
	return !lst ? u : lst;
}

void dfs2(int u, int c) {
	vis[u] = 1, val[u] = c;
	for (int v : gra[u]) {
		if (vis[v]) { assert(val[v] == -c); continue; }
		dfs2(v, -c);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int p; scanf("%d", &p);
		if (p < 0) { ra = i; continue; }
		A[p].push_back(i);
	}
	for (int i = 1; i <= n; i++) {
		int p; scanf("%d", &p);
		if (p < 0) { rb = i; continue; }
		B[p].push_back(i);
	}
	for (int i = 1; i <= n; i++)
		if ((A[i].size() & 1) ^ (B[i].size() & 1))
			return puts("IMPOSSIBLE"), 0;
	puts("POSSIBLE");
	dfs(ra, A);
	dfs(rb, B);
	for (int i = 1; i <= n; i++)
		if (!vis[i] && !(A[i].size() & 1)) dfs2(i, 1);
	for (int i = 1; i <= n; i++) printf("%d ", val[i]);
	return 0;
}

Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
int A[100100];
vector<int> v;
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<N;i++){
		if(A[i]==K){
			cout << "POSSIBLE" << endl;
			return 0;
		}
		if(A[i]>K)v.pb(A[i]-K);
	}
	if(v.size()==0){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	int g = A[0];
	for(int i=0;i<N;i++){
		g = __gcd(g,A[i]);
	}
	for(int i=0;i<v.size();i++){
		if(v[i]%g==0){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define ll_1e9 (ll)1e9
using namespace std;


int main(){
    ll n,m;
    cin >> n >> m;
    ll cnt[n+1] = {};
    ll a[m],b[m];
    rep(i,0,m){
        cin >> a[i] >> b[i];
        cnt[a[i]]++;
        cnt[b[i]]++;
    }


    rep(i,0,n){
        if(cnt[i] % 2){
            cout << "NO" << endl;
            break;
        }
        else if(i == n-1){
            cout << "YES" << endl;
        }
    }

    return 0;
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            var T = Console.ReadLine().ToCharArray();
            Console.WriteLine(S.Zip(T, (s, t) => s == t ? 1 : 0).Sum());
        }
    }
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-

k, x = map(int, input().split())

min_x = max(x - k + 1, -1000000)

max_x = min(x + k - 1, 1000000)

ans = []
for i in range(min_x, max_x + 1):
    ans.append(str(i))

print(' '.join(ans))

Measured memory_bytes: 3060