akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cout << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cout << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

struct City;
vector<City> cities;

struct City {
	int index;
	int x, y;
	int par;
	int root() {
		if (par == index) return par;
		return par = cities[par].root();
	}
	void merge(int i) {
		if(index != i)
			cities[root()].par = cities[i].root();
	}
};

bool xcomp(const City &a, const City &b) {
	return a.x < b.x;
}

bool ycomp(const City &a, const City &b) {
	return a.y < b.y;
}

int main() {
	int N = in();
	cities.resize(N);
	rep(i, N) {
		cities[i].index = cities[i].par = i;
		cities[i].x = in();
		cities[i].y = in();
	}
	
	vector<City> cx = cities, cy = cities;
	sort(cx.begin(), cx.end(), xcomp);
	sort(cy.begin(), cy.end(), ycomp);
	
	typedef pair<int, pint> pip;
	priority_queue<pip> px, py;
	rep(i, N - 1) {
		px.push(mp(cx[i].x - cx[i + 1].x, mp(cx[i].index, cx[i + 1].index)));
		py.push(mp(cy[i].y - cy[i + 1].y, mp(cy[i].index, cy[i + 1].index)));
	}
	
	ll ans = 0;
	int t = 0;
	while (t < N - 1) {
		//pr(t);
		int xdiff = px.empty() ? INF : -px.top().first;
		int ydiff = py.empty() ? INF : -py.top().first;
		if (xdiff < ydiff) {
			pip top = px.top();
			px.pop();
			if (cities[top.second.first].root() != cities[top.second.second].root()) {
				cities[top.second.first].merge(top.second.second);
				ans += xdiff;
				t++;
			}
		}
		else {
			pip top = py.top();
			py.pop();
			if (cities[top.second.first].root() != cities[top.second.second].root()) {
				cities[top.second.first].merge(top.second.second);
				ans += ydiff;
				t++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7604
#include<bits/stdc++.h>
using namespace std;
int frog(int n , int h[])
{
    int dp[n+5];
    dp[1]=0;
    dp[2]=abs(h[1] - h[2]);
    for(int i=3;i<=n ;i ++)
    {
        dp[i]= min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]) );

    }
    return dp[n];
}
int main()
{
    int n;
    cin>>n;
    int h[n+5]={0};
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    cout<< frog(n, h);
}


Measured memory_bytes: 4356
#include <iostream>
using namespace std;
 
int main(){
    int h, w, cnt;
    while(true){
        cin >> h >> w;
        if(h==0) break;
        for(int j=0;j<h;j++){
            for(int i=0;i<w;i++){
                if((i+j)%2==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
    cout << endl;
    }
}


Measured memory_bytes: 3096
s = input()
n = int(s)

arrays = []

max_num = 0

v = input().split()
for i in range(n):
    arrays.append(int(v[i]))

for i in range(len(arrays)):
    max_num = max(max_num, arrays[i])

min_num = max_num

for i in range(len(arrays)):
    min_num = min(min_num,arrays[i])

answer = max_num - min_num

print(answer)

Measured memory_bytes: 9120
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;

int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a!=b&&b!=c&&c!=a)cout<<3<<endl;
  else if(a==b&&b==c)cout<<1<<endl;
  else cout<<2<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	long long a,b;

	cin >> a >> b;
	long long upper = sqrt(max(a, b)) + 10L;

	long long  count = 1;

	for (long long  i = 2; i < upper; i++) {
		bool first = false;

		while(a % i == 0) {
			a /= i;
			first = true;
		}
		bool second = false;
		while(b % i == 0) {
			b /= i;
			second = true;
		}
		if (first && second) {
			count++;
		}
		if (a == 1 && b == 1) {
			break;
		}
	}
	if (a > 1 && b > 1 && a == b) {
		count ++;
	}
	cout << count << endl;


	return 0;
}


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

char a[1000001];
long long ans = 0;

int main() {
	scanf("%s",a);
	for (int i = strlen(a) - 1; i >= 0; i--) {
			if (a[i] - '0' >= 6 || a[i] - '0' == 5 && a[i - 1] - '0' >= 5) a[i - 1]++;
			ans = ans + min(a[i] - '0', 10 - (a[i] - '0'));
	}
	if (a[0] - '0' >= 6) ans++;
	printf("%lld\n",ans);
	return 0;
} 


Measured memory_bytes: 1280
//Problem Link:  https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_A


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>

using   namespace std;

const long long int MOD = 1000000007;
const long long int INF = 100000000;
long long int N,M;
long long int C[30];
long long int dp[21][100000];
//
// int DP(int n,int v)
// {
// 	if(n<0||v<0) return INF;
//
// 	if(dp[n][v]!=-1) return dp[n][v];
// 	return min(DP(n-1,v),DP(n,v-C[n])+1);
// 	//return dp[n][v] = min(DP(n-1,v),DP(n,v-C[n])+1);
// }
//
// int main()
// {
//     cin >> N >> M;
//
// 		for(int i = 0; i < M; i++){
// 			cin >> C[i];
// 		}
//
//     memset(dp,-1,sizeof(dp));
//
// 		for(int i = 0; i < 21; i++){
// 			dp[i][0]=0;
// 		}
//     cout << DP(M - 1,N) << endl;
//
// 		return 0;
// }


int DP(int n,int v)
{
	if(v == 0) return 0;
	if(n<0||v<0) return INF;

	if(dp[n][v]!=-1) return dp[n][v];
	//return min(DP(n-1,v),DP(n,v-C[n])+1);
	return dp[n][v] = min(DP(n-1,v),DP(n,v-C[n])+1);
}

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

		for(int i = 0; i < M; i++){
			cin >> C[i];
		}

    memset(dp,-1,sizeof(dp));
    cout << DP(M-1, N) << endl;

		return 0;
}


// 55 4
// 1 5 10 50



Measured memory_bytes: 19580
import re

inp = re.split(" ",input())
max_i = int(inp[0])
max_j = int(inp[1])

field = []
calcfield = []

for i in range(max_i):
    inp = input()
    field.append([])
    calcfield.append([])
    for j in range(max_j):
        field[i].append(inp[j])
        calcfield[i].append('.')


for i in range(max_i):
    for j in range(max_j):
        if field[i][j] == '#':
            if i > 0 and field[i-1][j] == '#':
                calcfield[i][j] = '#'
                calcfield[i-1][j] = '#'
            elif i+1 < max_i and field[i+1][j] == '#':
                calcfield[i][j] = '#'
                calcfield[i+1][j] = '#'
            elif j > 0 and field[i][j-1] == '#':
                calcfield[i][j] = '#'
                calcfield[i][j-1] = '#'
            elif j+1 < max_j and field[i][j+1] == '#':
                calcfield[i][j] = '#'
                calcfield[i][j+1] = '#'

if field==calcfield:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n, a, b, ans = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++)
	{
		int copy_i = i;
		int sum = 0;
		while (copy_i > 0)
		{
			sum += copy_i % 10;
			copy_i /= 10;
		}
		if (sum >= a && sum <= b)ans += i;
	}
	cout << ans;
}

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

int main() {
  string a;
  cin>>a;
  if(a.size()<4) cout<<"No"<<endl;
  else if(a.at(0)=='Y'&&a.at(1)=='A'&&a.at(2)=='K'&&a.at(3)=='I'){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main() {
	long long N;
	cin >> N;
	if (N == 2) cout << -1 << endl;
	else if (N % 2 == 1) {
		for (int i = 0; i < N; i++) {
			for (int j = 1; j < N; j++) {
				cout << (i + j) % N + 1;
				if (j == N - 1) cout << endl;
				else cout << " ";
			}
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			for (int j = 1; j < N; j++) {
				if (i * 2 >= N && j * 2 >= N) {
					if (j == N - 1) cout << i - N / 2 + 1;
					else cout << (i + j + 1) % N + 1;
				}
				else cout << (i + j) % N + 1;
				if (j == N - 1) cout << endl;
				else cout << " ";
			}
		}
	}
}

Measured memory_bytes: 256
H,N=map(int,input().split())
magic=[list(map(int,input().split())) for _ in range(N)]
maxA=max(a for a,b in magic)
DP=[0]*(H+maxA)
for i in range(1,H+maxA):
    DP[i]=min(DP[i-a]+b for a,b in magic)
print(DP[H])

Measured memory_bytes: 3664
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 12/7/2018, 10:04:54 PM
 * 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 <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#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;

set<int> S;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  S.insert(a);
  S.insert(b);
  S.insert(c);
  cout << S.size() << endl;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        return 2.0 * (double)n * Math.PI;
    }
}


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

long long dp[51], dp2[51];

long long solve(int N, long long X){
    if(X == 1){
        if(N == 0) return 1;
        else return 0;
    }
    if(1 < X && X <= 1+dp[N-1]) return solve(N-1, X-1);
    if(X == 2+dp[N-1]) return dp2[N-1] + 1;
    if(2+dp[N-1] < X && X <= 2+2*dp[N-1])
        return dp2[N-1]+1+solve(N-1, X-2-dp[N-1]);
    if(X == 3+2*dp[N-1]) return 2*dp2[N-1]+1;
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long long x;
    cin >> n >> x;
    dp[0] = 1;
    dp2[0] = 1;
    for(int i = 1; i <= n; i++){
        dp[i] = 2 * dp[i-1] + 3;
        dp2[i] = 2 * dp2[i-1] + 1;
    }
    cout << solve(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    string S; cin >> S;
    int SL = S.size();

    if (SL == 2) cout << S << endl;
    else {
        reverse(S.begin(), S.end());
        cout << S << endl;
    }
    
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    int ans = B / A;
    if (ans >= C) {
        cout << C << endl;
    } else {
        cout << ans << endl;
    }
}

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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec)                                                    \
  std::cout << "\033[31m" << #vec << ": [ ";                            \
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}    \
  cout << "]"<< "\033[m" << endl;

int kaibun(string s){
  int n = s.length();
  rep(i, n/2){
    // cout << s[i] << s[n - i - 1] << endl;
    if(s[i] == s[n - i - 1]) {
      continue;
    }
    else {
      return -1;
    }
  }
  return 0;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  string s1;
  rep(i, (n-1)/2) {
    s1.push_back(s[i]);
  }
  string s2;
  for(int i=(n+3)/2-1; i<n; ++i){
    s2.push_back(s[i]);
  }
  // cout << "result: " << kaibun(s) << endl;
  // kaibun(s1);
  if(kaibun(s) == 0 && kaibun(s1) == 0 && kaibun(s2) == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  // check(s);
  // check(s1);
  // check(s2);

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int N,M,A,B;
    int ans = 0;
    cin >> N >> M;
    long long H[100100];
    int Ten[100100] = {0};
    rep(i,N){
        cin >> H[i];
    }
    rep(i,M){
        cin >> A >> B;
        if(H[A-1] > H[B-1]){
            Ten[B-1]=1;
        } else if(H[A-1] < H[B-1]){
            Ten[A-1]=1;
        } else {
            Ten[A-1]=1;
            Ten[B-1]=1;
        }
    }

    rep(i,N){
        if(Ten[i] == 0) ans++;
    }

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

Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(i=1; i<=a; i++){
		for(j=1; j<=a; j++){
			for(jj=1; jj<=a; jj++){
				b+=__gcd(i,__gcd(j,jj));
			}
		}
	}
	cout<<b;
	return 0;
}

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

int main(){
    int n, hm = -1, ans = 0;
    cin >> n;
    for(int i=0;i<n;++i){
        int h;
        cin >> h;
        if(h >= hm) ++ans;
        hm = max(h, hm);
    }
    cout << ans << endl;
    
    return 0;
}

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

int n;
vector<char> ada;
string s;
int main(){
	cin >> n;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(ada.size() == 0){
			ada.push_back(s[i]);
		} else if(ada.back() != s[i]) ada.push_back(s[i]);
	}
	cout << ada.size() << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3 + 10;
const ll mod = 924844033;
ll fac[maxn], inv[maxn], facinv[maxn], bin[maxn];
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
	inv[1] = 1; for(int i = 2; i < maxn; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	facinv[0] = 1; for(int i = 1; i < maxn; ++i) facinv[i] = facinv[i - 1] * inv[i] % mod;
	bin[0] = 1; for(int i = 1; i < maxn; ++i) bin[i] = bin[i - 1] * 2 % mod;
}
ll C(int n, int m) { return n < m ? 0 : fac[n] * facinv[m] % mod * facinv[n - m] % mod;}
int n, k, tot;
int pos[maxn];
ll f[3][maxn][maxn];
void add(ll & x, ll y) { x += y; while(x >= mod) x -= mod;}
int main()
{
	pre();
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= min(n, 2 * k); ++i)
		for(int j = i; j <= n; j += 2 * k)
			pos[++tot] = j;
	f[0][0][0] = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j <= i; ++j)
		{
			for(int p = 0; p < 3; ++p) add(f[0][i][j], f[p][i - 1][j]);
			if(j)
			{
				if(pos[i] + k <= n)
				{
					for(int p = 0; p < 3; ++p) 
						add(f[1][i][j], f[p][i - 1][j - 1]);
				}
				if(pos[i] - k >= 1)
				{
					for(int p = 0; p < 3; ++p)
						if(p != 1 || pos[i - 1] + k != pos[i] - k)
							add(f[2][i][j], f[p][i - 1][j - 1]);
				}
			}
			//for(int p = 0; p < 3; ++p) cout << p << ' ' << i << ' ' << j << ' ' << f[p][i][j] << endl;
		}
	ll ans = 0;
	for(int j = 0; j <= n; ++j)
		for(int p = 0; p < 3; ++p)
		{
			if(j & 1) add(ans, mod - f[p][n][j] * fac[n - j] % mod);
			else add(ans, f[p][n][j] * fac[n - j] % mod);
		}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 71740
#include <vector>
#include <iostream>
#include <stdio.h>

using namespace std;

int search(vector<int> A, const int n, const int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key) i++;
	return i != n;
}

int main(void) {
	int n, q, key; cin >> n;
	vector<int> S(n + 1);

	int res = 0;
	for (int i = 0; i < n; i++) scanf("%d", &S[i]);

	cin >> q;
	for (int i = 0; i < q; i++) {
		scanf("%d", &key);
		if (search(S, n, key)) res++;
	}

	cout << res << endl;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 10;
const ll mod = 1e9 + 7;
int cnt[26];
char s[maxn];
ll ans = 1;
int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; ++i)
		++cnt[s[i] - 'a']; 
	for(int i = 0; i < 26; ++i)
		ans = ans * (cnt[i] + 1) % mod;
	ans = (ans + mod - 1) % mod; 
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
n=int(input())
h=list(map(int,input().split()))

# nの足場までいく最小コストを a_n とする。
# a_1のコストは0,  a_2のコストは(h_1からの１通りなので)\h_1-h_2\
dp=[0]*n
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[-1]) 

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

int main() {

  int n;
  cin >> n;
  
  vector<int> a(n),b(100000);
  for ( int i = 0; i < n; i++){
    cin >> a[i];
    if ( a[i] == 0 ){
      b[0]++;
      b[1]++;
      continue;
    }else if ( a[i] == 99999 ){
      b[99999]++;
      b[99998]++;
    }else{
      b[a[i]]++;
      b[a[i]+1]++;
      b[a[i]-1]++;
    }   
  }
  
  int saidai;
  for ( int i = 0; i < 100000; i++){
    saidai = max(saidai,b[i]);
  }
  
  cout << saidai << endl; 
  
}

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


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

    sort(d.begin(), d.end());
    // for(int i = 0; i < n; i++) {
    //     cout << i << ":" << d[i] << endl;
    // }
    int middleL, middleR;
    middleL = n/2-1;
    middleR = middleL+1;

    int ans = d[middleR] - d[middleL];
    cout << ans << endl;
}


Measured memory_bytes: 640
using System;
class Program
{
	static void Main()
	{
        string[] a = Console.ReadLine().Split(' ');
		int b = int.Parse(a[0]);
		int c = int.Parse(a[1]);
        if(c == 0)
        {
            Console.WriteLine(b);
            return;
        }

        if(c == 1)
        {
            if(int.Parse(Console.ReadLine()) != b)
            {
                Console.WriteLine(b);
            }
            else
            {
                Console.WriteLine(b - 1);
            }
            return;
        }

        string[] d = Console.ReadLine().Split(' ');
        int[] e = Array.ConvertAll(d, int.Parse);

        if(!(Array.IndexOf(e, b) >= 0))
        {
            Console.WriteLine(b);
            return;
        }

        int f = b, g = b; 
        for(int i=0; i<c+1; i++)
        {
            f -= 1;
            if(!(Array.IndexOf(e, f) >= 0))
            {
                Console.WriteLine(f);
                return;
            }

            g += 1;
            if(!(Array.IndexOf(e, g) >= 0))
            {
                Console.WriteLine(g);
                return;                
            }

        }
	}
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll N, T; cin >> N >> T;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> t(N); rep(i, N) cin >> t[i];
  
  ll ans = T;

  rep(i, N - 1) {
    if(t[i] + T > t[i+1]) {
      ans += t[i+1]-t[i];
    } else {
      ans += T;
    }
  }
  
  cout << ans << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4668
#include <stdio.h>
#define MAX 100
#define INF 1000000
#define NIL -1
   
int n;
int d[MAX],w[MAX][MAX],pi[MAX];
   
void prime() {
  
  int u,v,i,j,color[MAX],min;
   
  for(u=0;u<n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=0;
  }
   
  d[0]=0;
   
  for(i=0;i<n;i++) {
     
    min = INF;
    for (j=0;j<n;j++){
      if(color[j]==1)
    continue;
       
      if(d[j]<=min){
    u=j;
    min=d[j];
      }
    }
     
    for(v=0;v<n;v++){
      if(w[u][v]==-1){
     continue;
      }
      if(color[v]==1){
    continue;
      }
       
      if(w[u][v] < d[v]){
    pi[v]=u;
    d[v]=w[u][v];
      }
    }
    color[u]=1;
  }
}
 
main() {
  int i,j,sum=0;
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&w[i][j]);
    }
  }
   
  prime();
  for(i=0;i<n;i++)
    sum+=d[i];
   
  printf("%d\n",sum);
   
  return 0;
}

Measured memory_bytes: 640
def abc175b_making_triangle():
    n = int(input())
    l = list(map(int, input().split()))
    cnt = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            if l[i] == l[j]:
                continue
            for k in range(j + 1, n):
                if l[i] == l[k] or l[j] == l[k]:
                    continue
                longest = max(l[i], l[j], l[k])
                total = l[i] + l[j] + l[k]
                if longest < total - longest:
                    cnt += 1
    print(cnt)

abc175b_making_triangle()

Measured memory_bytes: 9224
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << (X - Z)/(Y+Z) << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll x; cin>>x;
    for (ll i=-130;i<=130;i++){
        for(ll j=-130;j<=130;j++){
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}








































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

using namespace std;

int main()
{
    long long int n, a, i, cnt;
    set<long long int> s;
    set<long long int>::iterator it;
    cin >> n;
    for(i=0; i<n; i++)
    {
        cin >> a;                    //coded BY Shoaib......
        it= s.find(a);
        if(it== s.end())
        {
            s.insert(a);
        }
        else
        {
            s.erase(a);
        }

    }

    cout << s.size();
    return 0;
}


Measured memory_bytes: 8228
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m,k;
char c[10][10]; 
int main()
{
	cin >>n>>m>>k;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
			cin >>c[i][j];
	int res=0;
	for (int i=0;i<(1<<n);i++)
	{
		for (int j=0;j<(1<<m);j++)
		{
			int r=0;
			for (int x=0;x<n;x++)
			{
				if (i & (1<<x)) continue;
				for (int y=0;y<m;y++)
				{
					if (j & (1<<y)) continue;
					r+=(c[x][y]=='#');
				}
			}
			//cout <<i<<" "<<j<<" "<<r<<" ##\n";
			if (r==k) res++;
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 3632
import sys

input = sys.stdin.readline

n, x, m = map(int, input().split())

arr = [-1] * m
cumsum = [x]
a = x
for i in range(1, n):
    a *= a
    a %= m
    if arr[a] == -1:
        arr[a] = i
        cumsum.append(cumsum[-1] + a)
    else:
        di, mo = divmod(n - i, i - arr[a])

        ans = cumsum[-1]
        ans += di * (cumsum[-1] - cumsum[arr[a] - 1])
        ans += cumsum[arr[a] - 1 + mo] - cumsum[arr[a] - 1]
        break
else:
    ans = cumsum[-1]

print(ans)


Measured memory_bytes: 68164
x = []
a = 0
while True:
    x.append(int(input()))
    if x[a] == 0 or a == 9999:
        break
    a += 1
i = 0
for b in x:
    if b == 0 or i == 10000:
        break
    print('Case ' + str(i + 1) + ': ' + str(b))
    i += 1


Measured memory_bytes: 5904
N =int(input())
a = list(map(int,input().split()))
ki = 0
ni = 0
yon = 0
for i in range(N):
    if a[i]%2 == 1:
        ki += 1
    elif a[i]%4 != 0:
        ni += 1
    else: yon += 1
if ki+int(ni>0) <= yon+1:
    print("Yes")
else: print("No")

Measured memory_bytes: 14252
ABCD = list(map(int, list(input())))

s = [(ABCD[0], str(ABCD[0]), ABCD[1:])]
while s:
	acc, exp, nums = s.pop()
	if acc == 7 and len(nums) == 0:
		print(exp + "=7")
		break
	elif len(nums) == 0:
		continue
		

	if len(nums) == 1:
		next_nums = []
	else:
		next_nums = nums[1:]
	s.append((acc + nums[0], exp+"+"+str(nums[0]), next_nums))
	s.append((acc - nums[0], exp+"-"+str(nums[0]), next_nums))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vi L(N);
    F0R(i, N) cin >> L[i];
    int a, b, c, total = 0;
    for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			for (int k = j + 1; k < N; ++k) {
				a = L[i], b = L[j], c = L[k];
				if (a<b+c && b<c+a && c<a+b) ++total;
			}
		}
	}
	cout << total << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int res = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1')res++;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		Set<Integer> s = new HashSet<Integer>();
		int N = sc.nextInt(), t = 0;
		while (N-->0) {
			int a = sc.nextInt();
			if (s.contains(a)) s.remove(a);
			else s.add(a);
		}
		System.out.println(s.size());
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 62284
#include <bits/stdc++.h>
using namespace std;
int n = 0, m = 0, like[350][350];
bool hav[350]; int tot = 0, peo[350], cho[350];
bool abl(int x)
{
	tot = m;
	for(int i = 1; i <= m; i++) hav[i] = true, peo[i] = 0;
	for(int i = 1; i <= n; i++) peo[like[i][1]]++, cho[i] = 1;
	while(tot > 0)
	{
		int w = 0;
		for(int i = 1; i <= m; i++)
			if(peo[i] > x) { w = i; break; }
		if(w == 0) return true;
		hav[w] = false, tot--, peo[w] = 0;
		if(tot == 0) break;
		for(int i = 1; i <= n; i++)
			if(like[i][cho[i]] == w)
			{
				while(not hav[like[i][cho[i]]]) cho[i]++;
				peo[like[i][cho[i]]]++;
			}
	}
	return false;
}
signed main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			scanf("%d", &like[i][j]);
	int l = 1, r = n, t = 0;
	while(l < r)
	{
		t = l + ((r - l) >> 1);
		if(abl(t)) r = t;
		else l = t + 1;
	}
	cout << l << endl;
	return 0;
}

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

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

    int n; cin >> n;
    string s; cin >> s;
    
    map<char, ll> m; rep(i,n) m[s[i]]++;
    ll ans = m['R']*m['G']*m['B'];

    rep(i,n){
        for(int j = i+1; j < n; ++j){
            int k = 2*j-i; if(j >= k || k >= n) continue;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), C = sc.nextInt(), sum = 0;
		int[] B = new int[M];
		for (int i = 0; i < M; i++) B[i] = sc.nextInt();
		for (int i = 0; i < N; i++) {
			int[] A = new int[M];
			for (int a = 0; a < M; a++) {
				A[a] = sc.nextInt();
			}
			int count = 0;
			for (int j = 0; j < M; j++) {
//				System.out.println(A[j] + " " + B[j]);
				count += A[j]*B[j];
			}
			if (count+C > 0) sum++;
		}
		System.out.println(sum);
	}

}

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

int main(){
	int a[100];
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=n-1; i>=1; i--) cout << a[i] << " ";
	cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());

		Map<String,Integer> lst = new TreeMap<String,Integer>();

		for (int i = 0; i < N; i++) {
			String s = sc.next();
			int pts = 100 - sc.nextInt();
			String s_pts = String.valueOf(pts);
			while (s_pts.length() < 3) {
				s_pts = "0" + s_pts;
			}
			s = s + " " + s_pts;
			lst.put(s,i+1);
		}

		for (String s : lst.keySet()) {
			System.out.println(lst.get(s));
		}

	}
}


Measured memory_bytes: 39752
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {


  private static void solve() {
    int n = ni();
    int m = ni();
    int[] x = na(m);
    Arrays.sort(x);
    List<Integer> list = new ArrayList<>();
    for (int i = 1; i <m; i ++) {
      list.add(x[i] - x[i - 1]);
    }
    long ret = 0;
    Collections.sort(list);
    for (int i = 0; i < m - n; i ++) {
      ret += list.get(i);
    }
    
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 35616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
    static void Main()
    {
        string line = Console.ReadLine().Trim();

        string[] lineRecord = Console.ReadLine().Trim().Split(' ');
        var list = new List<int>();
        foreach (var item in lineRecord)
        {
            list.Add(int.Parse(item));
        }

        var answer = CalcBreak(int.Parse(line), list);
        Console.WriteLine(answer);
    }

    private static int CalcBreak(int N, List<int> rengaNO)
    {
        int count = 0;
        if(!rengaNO.Contains(1)) return -1;

        foreach (var item in rengaNO)
        {
            if (item == count + 1) count++;
        }

        return rengaNO.Count() - count;
    }
}

Measured memory_bytes: 35420
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0)
# define CF
ll dp[55][2555];
int main(void)
{
    #ifdef CF
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    dp[0][0] = 1;
    int n,A;
    fi>>n>>A;
    for (int t = 1;t <= n;++t)
    {
        int v;
        fi>>v;
        for (int k = t;k;--k)
            for (int i = n * 50;i >= v;--i)
                dp[k][i] += dp[k - 1][i - v];
    }
    ll ans = 0;
    for (int i = 1;i <= n;++i)
        ans += dp[i][i * A];
    fo << ans << '\n';
    return 0;
}




Measured memory_bytes: 1280
import sys
from collections import defaultdict
from itertools import product, permutations, combinations
from time import time

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

q = list(range(N))
c = defaultdict(int)
t = [0]*N
r = 0
a = time()

while q:
    b = time()
    if b - a > 1.7:
        print(N*(N-1)//2)
        exit()
    r += 1
    nq = []
    for i in q:
        j = A[i][t[i]] - 1
        k = i
        if k < j:
            j, k = k, j
        c[(j, k)] += 1
        if c[(j, k)] == 2:
            t[j] += 1
            t[k] += 1
            if t[j] < N-1:
                nq.append(j)
            if t[k] < N-1:
                nq.append(k) 
    q = nq

for tt in t:
    if tt != N-1:
        print(-1)
        exit()

print(r)

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

int main() {
	ll x,ma=-1,w;
	cin>>x;
	for(ll i=1;i<50;i++){
		for(ll j=2;j<50;j++){
			w=pow(i,j);
			if(w<=x){
				ma=max(ma,w);
			}
		}
	}
	cout<<ma<<endl;
	return 0;
}



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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int h,w,i;
	cin>>h>>w;
	string a;
	for (i=0;i<w+2;i++){
		cout<<"#";
	}
	cout<<"\n";
	for (i=0;i<h;i++){
		cin>>a;
		cout<<"#"<<a<<"#"<<"\n";
	}
	for (i=0;i<w+2;i++){
		cout<<"#";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //REMEMBER TO REMOVE '/'
#include <iostream>
using namespace std;
#define ll long long
#define double long double
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define pb push_back
#define mp make_pair
#define REP(i,n) for(int i=0;i<n;i++)
#define RE(i,n) for(int i=1;i<=n;i++)
#define s second
#define f first
#define vi vector<int>
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define debug(x) cout<<x<<endl
#define debug2(x,y) cout<<x<<" "<<y<<endl
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define mii map<int,int>

#define int ll

//#define cin fin
//#define cout fout

#define MOD 100000000
#define rev 0
#define nrev 1
#define INF 100005
vector<int> adj[INF];
int dp[INF];
bool vis[INF];
void dfs(int i){
    vis[i]=true;
    for(auto v: adj[i]){
        if(!vis[v]) dfs(v);
        dp[i]=max(dp[i],dp[v]+1);
    }
}

signed main() {
    int n,m;
    cin>>n>>m;
    int a,b;
    map<int,int> ct;
    REP(i,m){
        cin>>a>>b;
        a--;b--;
        adj[b].pb(a);
        ct[a]++;
    }
    
    //find the vertex with in degree zero.
    //dp(i) =1+dp(i-one edge);
    REP(i,n) dp[i]=0;
    REP(i,n){
        if(ct[i]==0){
            dfs(i);
        }
    }
    int maxi=0;
    REP(i,n) maxi=max(maxi,dp[i]);
    cout<<maxi<<endl;
    return 0;
}



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

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

using namespace std;

using int64 = int64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << 'a';
  }
  queue<string> q;
  q.push("a");
  while (true) {
    string s = q.front();
    q.pop();
    if ((int)s.length() == n + 1) break;
    char mxS = *max_element(s.begin(), s.end());
    for (char c = 'a'; c <= mxS + 1; c++) {
      string ss = s;
      ss += c;
      if ((int)ss.length() == n) {
        cout << ss << '\n';
      }
      q.push(ss);
    }
  }
  return 0;
}

Measured memory_bytes: 25268
#include<bits/stdc++.h>
using namespace std;
int n,k;

int main()
{
	cin>>n>>k;
	int Max=(n-1)*(n-2)/2;
	if (k>Max) return puts("-1"),0;
	int res=Max-k;
	
	printf("%d\n",n-1+res);
	for (int i=2;i<=n;i++) printf("%d %d\n",1,i);
	
	for (int i=2;i<=n;i++)
		for (int j=i+1;j<=n;j++) {
			if (res==0) break;
			printf("%d %d\n",i,j);
			res--;
		}
	return 0;
}

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

using namespace std;

int main() {
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200){
        cout<<s<<endl;
        return 0;
    }else{
        cout<<"red"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define mp make_pair
#define pii pair<int, int>
#define PB push_back
#define F first
#define S second
#define Task ""
using namespace std;
const int mod=1000000007;
const int N=31625;
int f[105][N], g[105][N], n, k, sum[105][N], sumlen[105][N], sqr;
vector <int > v;
bool flag=0;

void Unique() {
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end())-v.begin());
}

int Find(int num) {
    return lower_bound(v.begin(), v.end(), num)-v.begin();
}

int number(int j) {
    return j-sqr+(int)flag;
}

void add(int &a, int b) {
    a=(a+b)%mod;
}

int Search(int val) {
    int l=1, r=sqr+1;
    while(r-l>1) {
        int mid=(r+l)>>1;
        if((int)(n/mid)>=val) l=mid;
        else r=mid;
    }
    return l;
}

bool square(int val) {
    int x=sqrt(val);
    return (x*x==val);
}

void hen() {
    flag=square(n);
    sqr=sqrt(n);
    rep(i, 1, sqr) v.push_back(n/i);

    Unique();
    rep(i, 1, sqr) {
        f[1][i]=1;
        sum[1][i]=i;
        sumlen[1][i]=sumlen[1][i-1];
        add(sumlen[1][i], number(n/i));
    }
    rep(i, 0, (int)v.size()-1) g[1][i]=v[i];

    rep(i, 2, k) {
        rep(j, 1, sqr) {
            add(f[i][j], g[i-1][Find(n/j)]);

            sum[i][j]=sum[i][j-1];
            add(sum[i][j], f[i][j]);
            sumlen[i][j]=sumlen[i][j-1];
            add(sumlen[i][j], (1ll*f[i][j]*number(n/j))%mod);
        }

        if(i<k) {
            rep(j, 0, (int)v.size()-1) {
                int val=v[j];
                add(g[i][j], sum[i][sqr]);
                int id=Search(val);
                add(g[i][j], (1ll*sum[i-1][id]*number(val))%mod);
                add(g[i][j], (0ll+sumlen[i-1][sqr]-sumlen[i-1][id]+mod)%mod);
                if(flag) g[i][j]=(g[i][j]-f[i][sqr]+mod)%mod;
            }
        } else {
            int ans=0;
            add(ans, sum[k][sqr]);
            add(ans, sumlen[k-1][sqr]);
            if(flag) ans=(ans-f[k][sqr]+mod)%mod;
            cout << ans;
        }
    }
}

int res;
void duyet(int val, int id) {
    if(id==k) { ++res; return; }
    rep(i, 1, n/val)
        duyet(i, id+1);
}

void buffalo() {
    duyet(1, 0);
    cout << res << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n >> k;
    if(n==1) return cout << 1, 0;
    //buffalo();
    hen();

    return 0;
}


Measured memory_bytes: 51840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin >> n;
    int arr[n];
    int c=0;
    for(i=0;i<n;i++)
        cin >> arr[i];
    for(i=1;i<n-1;i++)
    {
        if(((arr[i]>arr[i-1])&&(arr[i]<arr[i+1]))||((arr[i]<arr[i-1])&&(arr[i]>arr[i+1])))
            c++;

    }
    cout << c << endl;
}


Measured memory_bytes: 256
;; #!/usr/bin/env sbcl --script

(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defun main ()
  (let* ((n (read))
         (k (read))
         (a (make-array n :element-type 'fixnum))
         (dp (make-array n :element-type 'fixnum :initial-element (floor most-positive-fixnum 2))))
    (let ((stream (make-string-input-stream (read-line))))
      (loop for i from 0
         for j = (read stream nil) until (null j)
         do (setf (aref a i) j)))
    (flet ((relax (from to)
             (let* ((from-val (aref dp from))
                    (to-val (aref dp to))
                    (diff (abs (- (aref a to) (aref a from)))))
               (setf (aref dp to) (min to-val (+ from-val diff))))))
      (setf (aref dp 0) 0)
      (dotimes (i n)
        (dotimes (j k)
          (when (>= (+ i (1+ j)) n) (return))
          (when (< (+ i (1+ j)) n) (relax i (+ i (1+ j)))))))
    (format t "~a~%" (aref dp (- n 1)))))

(main)


Measured memory_bytes: 57704
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long div_c = b/c - (a-1)/c;
	long long div_d = b/d - (a-1)/d;
	long long lc = (c*d)/__gcd(c,d);
	long long both = b/lc - (a-1)/lc;
	cout << (b-a+1) - div_c - div_d + both;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int a[3];
void swap(int i, int j);

int main() {
  scanf("%i %i %i", &a[0], &a[1], &a[2]);

  if (a[0] > a[1]) { swap(0, 1); }
  if (a[0] > a[2]) { swap(0, 2); }
  if (a[1] > a[2]) { swap(1, 2); }
  printf("%d %d %d\n", a[0], a[1], a[2]);
}

void swap(int i, int j) {
  int tmp;
  tmp  = a[i];
  a[i] = a[j];
  a[j] = tmp;
}



Measured memory_bytes: 2100
a1, b1 = gets.split.map(&:to_i)
a2, b2 = gets.split.map(&:to_i)
a3, b3 = gets.split.map(&:to_i)

v = [a1, b1, a2, b2, a3, b3]
vv = [1, 2, 3, 4].map { |n| v.count { |i| i == n } }.count { |i| i % 2 == 1 }
puts(vv == 0 || vv === 2 ? 'YES' : 'NO')

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

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

n_nodes, m_edges = map(int, input().split())
edges = [[] for _ in range(n_nodes)]
for _ in range(m_edges):
    u, v = map(int, input().split())
    edges[u - 1].append([v - 1, 1])
    edges[v - 1].append([u - 1, 1])
# pprint(edges)

parents = [-1] * n_nodes


def dijkstra(n_nodes, edges, start):
    que = deque()
    dist = [INF] * n_nodes
    dist[start] = 0
    que.append([start, 0])
    while len(que) > 0:
        v, v_cost = que.popleft()
        if dist[v] < v_cost:
            continue
        for u, u_cost in edges[v]:
            if v_cost + u_cost < dist[u]:
                dist[u] = v_cost + u_cost
                parents[u] = v
                que.append([u, dist[u]])
    return dist


start = 0
dist = dijkstra(n_nodes, edges, start)
# print(dist)
# print(parents)

print('Yes')
for i in range(1, n_nodes):
    print(parents[i] + 1)


Measured memory_bytes: 131816
loop do
  n = gets.to_i
  break if n.zero?
  rs = n.times.map {
    id, *ts = gets.split.map(&:to_i)
    [ts.each_slice(2).map {|m, s| 60 * m + s }.inject(0, :+), id]
  }.sort
  puts [0, 1, -2].map {|i| rs[i][1] }
end

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

int main() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n){cin>>v[i];}
  sort(v.begin(),v.end());
  int i=0,c=1,ans=0;
  while(i<n){
    if(v[i]!=v[i+1]){
      if(c<v[i]){ans+=c;}
      if(c>v[i]){ans+=c-v[i];}
      c=1;i++;
    }
    while(v[i]==v[i+1]){i++;c++;}
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	int n,dx,dy;
	cin>>n;
	
	for(int i=0;i<n;i++){
		int x=0,y=0,px=0,py=0;
		while(cin>>dx>>dy){
			if(dx==0&&dy==0){cout<<px<<" "<<py<<endl;break;}
			else {
				x+=dx;y+=dy;
				if(x*x+y*y>px*px+py*py||x*x+y*y==px*px+py*py&&x>px){px=x;py=y;}
			}
		}
	}
}

Measured memory_bytes: 0