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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string str;cin>>str;if(str.size() == 2)cout<<str;else REV(i,str.size())cout<<str[i];cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a,b;
	cin >> a >> b;
	cout << (6-a-b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int MOD = 1000000007;
const int maxn = 300000 + 10;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }
 
inline void updata(int &x, int y) { x = inc(x,y); }
 
inline int power(int x, int k) {
  int tmp = 1;
  while(k) {
    if(k & 1) tmp = mul(tmp,x);
    x = mul(x,x);
    k >>= 1;
  }
  return tmp;
}

char s[maxn];
int n, dp[maxn][7];

inline int encode(string s) {
	int Sz = s.size();
	if(!Sz) return 0;
	if(Sz == 3) return 6;
	if(Sz == 1) {
		if(s[0] == '0') return 3;
		else return 1;
	}
	if(s[0] == '0') return 4;
	if(s[1] == '1') return 2;
	else return 5;
}

inline string decode(int x) {
	if(x == 0) return "";
	if(x == 1) return "1";
	if(x == 2) return "11";
	if(x == 3) return "0";
	if(x == 4) return "00";
	if(x == 5) return "10";
	if(x == 6) return "100";
}

int trans[7][2];
int main() {
//	freopen("data1.in","r",stdin);
	scanf("%s", s + 1); n = strlen(s + 1);
	trans[0][0] = 3; trans[0][1] = 1;
	trans[1][0] = 5; trans[1][1] = 2;
	trans[2][0] = 2; trans[2][1] = 2;
	trans[3][0] = 4; trans[3][1] = 0;
	trans[4][0] = 3; trans[4][1] = 3;
	trans[5][0] = 6; trans[5][1] = 1;
	trans[6][0] = 5; trans[6][1] = 5;
	dp[0][0] = 1;
	for(int i = 1;i <= n;i ++) {
		for(int j = 0;j <= 6;j ++) {
			if(s[i] != '0') updata(dp[i][trans[j][1]],dp[i - 1][j]);
			if(s[i] != '1') updata(dp[i][trans[j][0]],dp[i - 1][j]);
		}
	}
	int Ans = inc(dp[n][1],dp[n][2]);
	printf("%d\n", Ans);
	return 0;
}


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

int main() {
   int a,b;
  cin>>a>>b;
  for(long long i=1;i<100000;i++){
    if(i*8/100==a&&i/10==b){
      cout<<i<< endl;
      return 0;
    }
  }
  cout<<"-1"<< endl;
}


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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;


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

    int n,m;
    string s;
    int b,c=0,sum=0;
    cin >> n;
    b = n / 500;
    n %= 500;
    c += b*1000;
    b = n / 5;
    c += b*5;
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC089D();

#if 1
int main()
{
	ABC089D();
	fflush(stdout);
	return 0;
}
#endif

static void ABC089D()
{
	int H, W, D;
	getint(H, W, D);

	std::vector<std::pair<int, int>> valPos(H * W + 1, std::pair<int, int>(0, 0));

	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			int val;
			getint(val);
			valPos[val].first = h + 1;
			valPos[val].second = w + 1;
		}
	}

	int gridCount = H * W;
	std::vector<int> costs(H * W + 1, 0);

	for (int i = D + 1; i <= gridCount; i++) {
		costs[i] = abs(valPos[i].first - valPos[i - D].first)
			+ abs(valPos[i].second - valPos[i - D].second)
			+ costs[i - D];
	}
	int Q;
	getint(Q);
	std::vector<int> ans(Q, 0);
	for (int i = 0; i < Q; i++) {
		int li, ri;
		getint(li, ri);

		ans[i] = costs[ri] - costs[li];
	}

	for (int i = 0; i < Q; i++) {
		printf("%d\n", ans[i]);
	}
}


Measured memory_bytes: 2560
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int isUnder(int T,int A){ // AがT以下で1,それ以外0
    if(A<=T) return 1;
    else return 0;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(A,B,C);
    if((A-C)*(B-C)<0) cout << "Yes" << nn;
    else cout << "No" << nn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  vector<int> cnt(1000009),A(n);
  for(int i=0;i<n;++i){
    cin>>A[i];
    cnt[A[i]]++;
  }
  int ans=0;
  for(int i=0;i<n;++i){
    if(A[i]==1){
      if(cnt[1]==1)ans++;
      continue;
    }
    if(cnt[A[i]]>=2||cnt[1]){
      continue;
    }
    bool ok=1;
    for(int j=2;1ll*j*j<=A[i]&&ok;++j){
      if(A[i]%j==0){
        if(cnt[A[i]/j]||cnt[j])ok=0;
      }
    }
    if(ok)ans++;
  }
  cout<<ans<<'\n';
  
  return 0;
}
//2020.06.14 20:35:40


Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 200010;
ll n;
ll a[N], b[N], c[N];
char s[20];
map<ll, ll> mp1, mp2;
map<ll, ll> dazhao[2][64];
ll ans, cnt, ans2, ans3;
ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}
int main() {
	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		c[i] = 1;
		scanf("%s", s + 1);
		ll len = strlen(s + 1), flag = 0;
		for (ll j = 1; j <= len; j++) {
			if (s[j] == '.') {
				flag = 1;
			} else {
				if (flag) {
					b[i] = b[i] * 10 + s[j] - '0';
					c[i] *= 10;
				} else {
					a[i] = a[i] * 10 + s[j] - '0';
				}
			}
		}
		ll g = gcd(b[i], c[i]);
		b[i] /= g;
		c[i] /= g;
	}
	for (ll i = 1; i <= n; i++) {
		if (b[i] == 0) {
			ans += cnt;
			cnt++;
			for (ll j = 1; j * j <= a[i]; j++) {
				if (a[i] % j == 0) {
					ans += mp1[j];
					if (a[i] / j != j) ans += mp1[a[i] / j];
				}
			}
		} else {
			ll num = a[i] * c[i] + b[i];
			if (c[i] % 2 == 0 && c[i] % 5 != 0) {
				ll tmp = c[i], cr = 0;
				while (tmp % 2 == 0) {
					cr++;
					tmp /= 2;
				}
				for (ll j = 5, t = 1; j <= num; j *= 5, t++) {
					if (num % j == 0) {
						ans += dazhao[1][t][cr];//以5^t为分母的分子是2^cr的倍数的有多少个 
						dazhao[0][cr][t]++;//以2^cr为分母的分子是5^t的倍数的加一个 
					} else {
						break;
					}
				}
			} else if (c[i] % 2 != 0 && c[i] % 5 == 0) {
				ll tmp = c[i], cr = 0;
				while (tmp % 5 == 0) {
					cr++;
					tmp /= 5;
				}
				for (ll j = 2, t = 1; j <= num; j *= 2, t++) {
					if (num % j == 0) {
						ans += dazhao[0][t][cr];//以2^t为分母的分子是5^cr的倍数的有多少个 
						dazhao[1][cr][t]++;//以5^cr为分母的分子是2^t的倍数的加一个 
					} else {
						break;
					}
				}
			}
			mp1[c[i]]++;
		}
	}
	for (ll i = n; i >= 1; i--) {
		if (b[i] == 0) {
			for (ll j = 1; j * j <= a[i]; j++) {
				if (a[i] % j == 0) {
					ans += mp2[j];
					if (a[i] / j != j) ans += mp2[a[i] / j];
				}
			}
		} else {
			mp2[c[i]]++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}
/*
5
1.124
2.6
3.5
4.000
5.000000
*/

Measured memory_bytes: 8996
import java.util.Scanner;

public class Main {
	static int nVertex = 0;
	static int nSta = 0;
	static int[] fa = null;
	static int[] rank = null;
	public static void init() {
		fa = new int[nVertex + 1];
		rank = new int[nVertex + 1];
		for(int i = 0; i <= nVertex; i++) {
			fa[i] = i;
			rank[i] = 0;
		}
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		nVertex = in.nextInt();
		nSta = in.nextInt();
		init();
		for(int i = 0; i < nSta; i++) {
			int u = in.nextInt();
			int v = in.nextInt();
			int rela = in.nextInt();
			if(!merge(u, v, rela)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	public static int getFa(int a) {
		if(a == fa[a])
			return a;
		int temp = fa[a];
		fa[a] = getFa(fa[a]);
		rank[a] = rank[temp] + rank[a];
		return fa[a];
	}
	public static boolean merge(int u, int v, int rela) {
		int fu = getFa(u);
		int fv = getFa(v);
		if(fu == fv)
			return rela + rank[u] == rank[v];
		fa[fv] = fu;
		rank[fv] = -rank[v] + rela + rank[u];
		return true;
	}
}


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

int main() {
	long long n;
	cin >> n;
	vector<long long>d(n);
	rep(i, n) {
		cin >> d[i];
	}
	sort(d.begin(),d.end());
	long long ans = d[(n / 2)] - d[(n / 2)-1];
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = 11234567890123;
LL N, W;
std::vector<LL>w, v;
std::vector<std::vector<LL>>memo;

LL dp(LL i, LL j)
{
	if (j > W) return -inf;
	if (i == N) return 0;
	if (memo[i][j] != -1) return memo[i][j];
	LL res1 = dp(i + 1, j + w[i]) + v[i];
	LL res2 = dp(i + 1, j);
	return memo[i][j] = std::max(res1, res2);
}

int main()
{
	in >> N >> W;
	w.resize(N); v.resize(N);
	rep(i, N) in >> w[i] >> v[i];

	memo.resize(N);
	rep(i, memo.size()) memo[i].resize(W + 1, -1);
	out << dp(0, 0) << std::endl;
}


Measured memory_bytes: 78592
#include<bits/stdc++.h>
#define N 1000010
using namespace std;
struct S{
	long long w,dep;
	long long u,v,ne;
}a[N],e[N];
	long long n,sz[N],dy[N],fir[N],root,vis[N],sum,pan;
	bool bo=false;
void add(long long u,long long v){
	e[++sum].ne=fir[u];
	fir[u]=sum;
	e[sum].v=v;
	e[sum].u=u;
//	e[sum].w=1;
}
bool cmp(S x,S y){
	return x.w>y.w;
}
void check(long long x,long long dis){
//	if(bo)return;
	pan+=dis;
	vis[x]=1;
	for(long long i=fir[x];i;i=e[i].ne){
		long long to=e[i].v;
		if(!vis[to]){
			//if(vis[to])bo=true;
			check(to,dis+1);
		}
	}
}
void dfs(long long x,long long father){
	vis[x]=1;
	for(long long i=fir[x];i;i=e[i].ne){
		long long to=e[i].v;
		if(to!=father&&!vis[to]){
			printf("%lld %lld\n",x,to);
			dfs(to,x);
		}
	}
}
long long query(long long sum){
	long long l=1,r=n;
	while(l<r){
		long long mid=(l+r+1)>>1;
		if(a[mid].w>sum)l=mid;
		else if(a[mid].w<sum)r=mid-1;
		else {
			l=mid;
			return a[l].dep;
		}
	}
	return 0;
}
int main(){
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)scanf("%lld",&a[i].w),sz[i]=1,a[i].dep=i;
	sort(a+1,a+n+1,cmp);
	for(long long i=1;i<=n;i++){
		long long tmp=n-2*sz[a[i].dep];
		long long father=query(a[i].w-tmp);
		sz[father]+=sz[a[i].dep];
/*		if(!father){
			if(root){
				printf("-1\n");
				return 0;
			}
			root=a[i].dep;
		}
*/		if(i!=n){
			add(a[i].dep,father);
			add(father,a[i].dep);
		}
	}
	root=a[n].dep;
	check(root,0);
	if(bo){
		printf("-1\n");
		return 0;
	}
	for(long long i=1;i<=n;i++)if(!vis[i]){
		printf("-1\n");
		return 0;
	}
	if(pan!=a[n].w){
		printf("-1\n");
		return 0;
	}
	memset(vis,0,sizeof(vis));
	dfs(root,0);
}

Measured memory_bytes: 32384
function main(){
  var localInput = input;
  var f = [
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ];
  
  var len = localInput.length - 1;
  for(;len--;){
    var l = localInput[len];
    var ix = parseInt(l[0]) + 2;
    var iy = parseInt(l[2]) + 2;
    switch(l[4]){
    case '3': // no-break case;
      f[iy+2][ix]++;
      f[iy-2][ix]++;
      f[iy][ix-2]++;
      f[iy][ix+2]++;
    case '2':
      f[iy+1][ix-1]++;
      f[iy+1][ix+1]++;
      f[iy-1][ix-1]++;
      f[iy-1][ix+1]++;
    case '1':
      f[iy+1][ix]++;
      f[iy][ix-1]++;
      f[iy][ix]++;
      f[iy][ix+1]++;
      f[iy-1][ix]++;
      break;
    }
  }
  
  var nd=0;//not dropped
  var md=0;//most dropped
  var y = 10;
  for(;y--;){
    var x = 10;
    for(;x--;){
      nd += !(f[y+2][x+2]);
      md = mx(f[y+2][x+2], md);
    }
  }
  
  console.log(nd);
  console.log(md);
}
   
function mx(a, b){
 var t = (a-b);
 return a - (t & (t >> 31));
}

var
input = '';
  
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

vector<vector<int>> G;

int main(){
  int n,m;
  cin >> n >> m;
  G=vector<vector<int>>(n);
  for(int i=0;i<m;++i){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> dist(n,-1);
  queue<int> que;
  vector<int> pre(n,-1);

  dist[0]=0;
  que.push(0);
  pre[0]=0;
  while(!que.empty()){
    int v=que.front();
    que.pop();


    for(int nv : G[v]){
      if(dist[nv]!=-1) continue;

      dist[nv]=dist[v]+1;
      pre[nv]=v;
      que.push(nv);
    }
  }

  cout << "Yes" << endl;


  for(int i=1;i<n;++i){
    cout << pre[i]+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 10680
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int h,n,i,j,a[1005],b[1005],dp[10005];
  const int INF=1e9;
  
  cin >> h >> n;
  for (i=0;i<n;i++) cin >> a[i] >> b[i];
  
  dp[0]=0;
  for (i=1;i<=h;i++){
    dp[i]=INF;
    for (j=0;j<n;j++){
      dp[i]=min(dp[i],dp[max(0,i-a[j])]+b[j]);
    }
  }
  
  cout << dp[h] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

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

int main(){
    ll n;cin>>n;
    ll a[n];
    ll ans=0;
    ll c[n+1];
    for(ll i=0;i<=n;i++){
        c[i]=0;
    }
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>n){
            ans++;
        }else{
            c[a[i]]++;
        }
    }
    for(ll i=1;i<=n;i++){
        if(c[i]>=i){
            ans+=c[i]-i;
        }else{
            ans+=c[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792
N=int(input())
a = list(map(int,input().split()))
c=0
i=0
while(c==0 and i<N):
    if(a[i]%2==0):
        if(a[i]%3==0 or a[i]%5==0):
            i+=1
        else:
            c+=1
    else:
        i+=1
if(c==0):
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    counter = cl.Counter()
    for i in range(N):
        s = input()
        counter.update({s: 1})
    item, value = zip(*counter.most_common())
    ans = []
    max_num = value[0]
    for i in range(len(value)):
        if value[i] == max_num:
            ans.append(item[i])

    ans.sort()
    print(*ans, sep="\n")


main()


Measured memory_bytes: 196828
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 105
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	vector <int> a(N + 1);
	for (int i = 1; i <= N; i++) scanf("%d", &a[i]);
	vector <int> put(N + 1, 0);
	vector <int> res;
	for (int i = N; i >= 1; i--) {
		int count = 0;
		for (int j = i + i; j <= N; j += i) count += put[j];
		if ((count & 1) != a[i]) put[i] = 1;
		if(put[i] == 1)	res.push_back(i);
	}
	sort(ALL(res));
	printf("%d\n", (int)res.size());
	for (int k = 0; k < res.size(); k++) printf("%d%c", res[k], " \n"[k == res.size() - 1]);
	return 0;
}

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
using namespace std;
int p[30],left[30],right[30];
void preParse (int cur) {
	printf (" %d",cur);
	if (left[cur]!=-1) preParse (left[cur]);
	if (right[cur]!=-1) preParse (right[cur]);
}
void inParse (int cur) {
	if (left[cur]!=-1) inParse (left[cur]);
	printf (" %d",cur);
	if (right[cur]!=-1) inParse (right[cur]);
}
void postParse (int cur) {
	if (left[cur]!=-1) postParse (left[cur]);
	if (right[cur]!=-1) postParse (right[cur]);
	printf (" %d",cur);
}
int main () {
	int n;
	scanf ("%d",&n);
	memset (p,-1,sizeof(p));
	memset (left,-1,sizeof(left));
	memset (right,-1,sizeof(right));
	for (int i=0;i<n;i++) {
		int id,l,r;
		scanf ("%d%d%d",&id,&l,&r);
		left[id]=l;
		right[id]=r;
		if (l!=-1) p[l]=id;
		if (r!=-1) p[r]=id;
	}
	for (int i=0;i<n;i++) {
		if (p[i]==-1) {
			printf ("Preorder\n");
			preParse (i);
			printf ("\nInorder\n");
			inParse (i);
			printf ("\nPostorder\n");
			postParse (i);
			printf ("\n");
			break;
		}
	}
    return 0;
}


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

int main(){
    int n, m;
    map<string, ll> mp;
    cin >> n;
    rep(i, n){
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    rep(i, m){
        string s;
        cin >> s;
        mp[s]--;
    }
    ll max = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        if(itr->second > max) max = itr->second;
    }
    cout << max << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll D; cin >> D;
  ll result = 0;
  rep(dig,19) {
    rep(pm,1<<((dig+1)/2-1)) {
      ll td = D, l = pow(10,dig-1), r = 1;
      bool plus[(dig+1)/2]; rep(i,(dig+1)/2) plus[i] = pm&(1<<i); plus[(dig+1)/2-1] = true;
      ll diff[(dig+1)/2];
      per(i,(dig+1)/2) {
        ll left = (td/r%10+10)%10;
        if (plus[i]) { diff[i] = (10-left)%10; td -= (l-r)*diff[i]; }
        else { diff[i] = left; td += (l-r)*diff[i]; }
        l /= 10; r *= 10;
      }
      bool ok = td==0;
      rep(i,(dig+1)/2-1) { if (diff[i]==0&&plus[i]) ok = false; }
      if (!ok) continue;
      // cout << dig << "," << pm << "->" << td << "..."; debug(diff,diff+(dig+1)/2);
      ll tmpr = 1; rep(i,(dig+1)/2) {
        if (i==0&&dig%2==1) tmpr *= 10;
        else if (i==(dig+1)/2-1) tmpr *= 9-diff[i];
        else tmpr *= 10-diff[i];
      }
      result += tmpr;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import math

def is_prime(n):
  if n & 0: return False
  for i in range(2, int(math.sqrt(n))+1):
    if n % i == 0:
      return False
  return True
  
def prime(n):
  if n < 2: return []
  P = [2]
  for i in range(3, n+1):
    if is_prime(i):
      P.append(i)
  return P

n = int(input())
P = prime(n)
cnt = [0]*len(P)

for i in range(2, n+1):
  x = i
  pi = 0
  while x > 1 and pi < len(P):
    if x % P[pi] == 0:
      cnt[pi] += 1
      x //= P[pi]
    else:
      pi += 1

ans = 1
for c in cnt:
  ans *= c+1
  ans %= 10**9 + 7
print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

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

        int count = 0;
        while (true) {
            for (int i = 0; i < xs.size(); i++) {
                if (xs.get(i) % 2 == 0) {
                    xs.set(i, xs.get(i) / 2);
                }
                else {
                    System.out.println(count);
                    return;
                }
            }

            count++;
        }
    }
}



Measured memory_bytes: 23636
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s = read!(String);
    let k = read!(usize);
    let k0 = k - 1; // 0-based

    // 文字列sを左から見ていって、1以外の数字がはじめて登場するインデックスをi、その1以外の数字をdとする
    // ex: "2345" なら i = 0, d = 2
    // ex: "12345" なら i = 1, d = 2
    // ex: "11111342" なら i = 5, d = 3
    // 5000兆日後のsは、インデックス0からi-1までは「1」、それ以降はdがずっと並ぶ形になる（少なくともk <= 10^18 の範囲においては）
    // このようなiとdを求めて、k0 <= i - 1 ならば1, そうでないならdを出力すればよい

    let c: Vec<char> = s.chars().collect();
    if c.iter().all(|&x| x == '1') {
        println!("1");
        return;
    }
    let i = c.iter().position(|&x| x != '1').unwrap();
    let d = c.get(i).unwrap();
    if k0 >= i {
        println!("{}", d);
    } else {
        println!("1");
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
const int maxn=300005;
typedef long long ll;
ll f1[maxn],f2[maxn];int a[maxn];
priority_queue<int,vector<int>,greater<int> > q1;
priority_queue<int,vector<int>,less<int> > q2;
int main(){
  int n;scanf("%d",&n);
  int n3=n*3,n2=n*2;
  for(int i=1;i<=n3;++i)scanf("%d",&a[i]);
  for(int i=1;i<=n;++i){
    f1[n]+=a[i];q1.push(a[i]);
  }
  for(int i=n+1;i<=n2;++i){
    f1[i]=f1[i-1];
    if(q1.top()<a[i]){
      f1[i]-=q1.top();f1[i]+=a[i];q1.pop();q1.push(a[i]);
    }
  }
  for(int i=n2+1;i<=n3;++i){
    f2[n2+1]+=a[i];q2.push(a[i]);
  }
  for(int i=n2;i>=n+1;--i){
    f2[i]=f2[i+1];
    if(q2.top()>a[i]){
      f2[i]-=q2.top();f2[i]+=a[i];q2.pop();q2.push(a[i]);
    }
  }
  ll ans=-(1ll<<60);
  for(int i=n;i<=n2;++i){
    ans=max(ans,f1[i]-f2[i+1]);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 5368
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself
        
*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"

/*
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int lcm(int a, int b)  
{  
    return (a*b)/gcd(a, b);  
}  
*/

/*
int powermod(int A, int p, int MOD = mod){
    A%=MOD;
    int res  = 1;
    while(p){
        if(p&1)
            res = ((__int128)res*A)%MOD;
        
        A = ((__int128)A*A)%MOD;
        p>>=1;
    }

    return res;
}
*/

/*
const int MAX = 100000; 
int prefix[MAX + 1]; 

void buildPrefix() 
{ 
	bool prime[MAX + 1]; 
	memset(prime, true, sizeof(prime)); 

	for (int p = 2; p * p <= MAX; p++) { 
		if (prime[p] == true) { 
			for (int i = p * 2; i <= MAX; i += p) 
				prime[i] = false; 
		} 
	} 
	prefix[0] = prefix[1] = 0; 
	for (int p = 2; p <= MAX; p++) { 
		prefix[p] = prefix[p - 1]; 
		if (prime[p]) 
			prefix[p]++; 
	} 
} 

int query(int L, int R) 
{ 
	return prefix[R] - prefix[L - 1]; 
}
*/

/*

//Find all paths from a to b in an undirected graph
vector<int> g[100000];
int visited[100000];
 //count of all the paths from 1 to n;
vector<string> ans;

void dfs(int visited[10000],int u,int v,vector<int> path)
{
    visited[u]=1;
    if(u==v)
    {
        string temp="";
        for(int i=0;i<path.size();i++)
        {
            temp+=to_string(path[i]);
        }
        ans.pb(temp);
    }
    else
    {
        for(int i=0;i<g[u].size();i++)
        {
            int y=g[u][i];

            if(visited[y]==0)
            {
                visited[y]=1;
                path.pb(y);
                dfs(visited,y,v,path);
                path.pop_back();
            }

        }
    }

    visited[u]=0;

}
*/

vector<pair<int,string>> vp;

void solve()
{
    string n;
    cin>>n;
    
    int sum=0;
    for(int i=0;i<n.size();i++)
    {
        sum+=n[i]-'0';
    }
    
    if(sum%9==0)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
    
}

int32_t main(void)
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<stdio.h>
#include <math.h>
using namespace std;

int main() {
	char x[1000];
	while (true) {
		cin >> x;
		if (x[0] == '0') break;
		int sum = 0;
		for (int i = 0; x[i] != '\0'; ++i) {
			sum += x[i] - '0';
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 3196
#include<stdio.h>

int main(void)
{
	int i,j,a;
	int array[3];
	
	scanf("%d %d %d",&array[0],&array[1],&array[2]);
	for(i=0;i<2;i++){
		for(j=2;j>i;j--){
			if(array[j-1]>array[j]){
				a=array[j];
				array[j]=array[j-1];
				array[j-1]=a;
			}
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
	
	return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    intmax_t N, A, B;
    cin >> N >> A >> B;

    if (A % 2 == B % 2) {
        cout << (B - A) / 2 << "\n";
    } else {
        cout << min(A - 1, N - B) + 1 + (B - A - 1) / 2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,a,amax = -9999999,amin = 99999999999;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> a;
        if(amax < a){amax = a;}
        if(amin > a){amin = a;}
    }
    cout << amax - amin << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,K = list(map(int,input().split()))
data = [list(map(str, input().split())) for _ in range(N)]
base = 10**6

BW_data = [[0 for i in range(2*K)] for i in range(2*K)]

for x,y,c in data:
  x,y = int(x)%(2*K),int(y)%(2*K)
  if c == "B":
    BW_data[y][x] += 1
  else:
    BW_data[y][x] += base

def ACC2(l):
  H = len(l)
  W = len(l[0])
  ret = [[0]*(W+1) for i in range(H+1)]
  for i in range(H):
    for j in range(W):
      ret[i+1][j+1] = ret[i+1][j] + ret[i][j+1] - ret[i][j] + l[i][j]
  return ret

def RANGE_SUM_in_ACC(l,h1,h2,w1,w2):
  return l[h2][w2]-l[h2][w1]-l[h1][w2]+l[h1][w1]

BW_ACC = ACC2(BW_data)

BW_res = [[0 for i in range(2*K)] for i in range(K)]

for j in range(K):
  for i in range(2*K):
    if i<K:
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,j,j+K,i,i+K)
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,0,max(0,j),0,max(0,i))
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,0,max(0,j),min(2*K,i+K),2*K)
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,min(2*K,j+K),2*K,0,max(0,i))
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,min(2*K,j+K),2*K,min(2*K,i+K),2*K)
    else:
      BW_res[j][i] = BW_ACC[-1][-1]-BW_res[j][i-K]
      
ans = 0
for j in range(K):
  for i in range(2*K):
    ans = max(ans,BW_res[j][i]%base+BW_res[j][(i+K)%(2*K)]//base)
print(ans)

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

int sb(int nm,vector<int> c,vector<int> d,vector<bool> x) {
	bool av = true;
	x.at(nm) = true;
	for(int i=0;i<x.size();i++)
	{
		if(x.at(i) == false)
		{
			av = false;
		}
	}
	if(av)
	{
		return 1;
	}
	int rt =0;
	for(int i =0;i<c.size();i++)
	{
		if(c.at(i) == nm + 1)
		{
			if(x.at(d.at(i) - 1))
			{
				continue;
			}
			else
			{
				//nm = d.at(i) - 1;
				//x.at(nm) = true;
				rt += sb(d.at(i)-1,c,d,x);
			}
		}
		else if(d.at(i) == nm + 1)
		{
			if(x.at(c.at(i) - 1))
			{
				continue;
			}
			else
			{
				//nm = c.at(i) - 1;
				//x.at(nm) = true;
				rt += sb(c.at(i)-1,c,d,x);
			}
		}
	}
	return rt;
}

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> a(m,0),b(m,0);
	vector<bool> v(n,false);
	for(int i = 0;i < m;i++)
	{
		cin >> a.at(i) >> b.at(i);
	}
	v.at(0) = true;
    cout << sb(0,a,b,v) << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a >= 13 {
		fmt.Println(b)
		return
	}
	if a >= 6 && a <= 12 {
		fmt.Println(b / 2)
		return
	}
	fmt.Println(0)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  string s,t;
  cin>>s>>t;
  t.erase(len(t)-1);
  if(s==t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
class Editor
    def initialize(s)
        @instruction = s
        @output = ""
    end

    def type
        (0..@instruction.length - 1).each do |i|
            char = @instruction[i]
            if char == "B" 
                @output.slice!(-1) if @output.length > 0
            else
                @output += char
            end
        end
    end

    def display
        puts @output
    end
end

e = Editor.new(gets.chomp)
e.type
e.display


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

int main() {
  int K, N;
  cin >> K >> N;
  
  int a[N];
  cin >> a[0];

  int max_dis = a[0];
  
  for (int i=1; i < N; i++){
    cin >> a[i];
    if ((a[i]-a[i-1]) > max_dis){
      max_dis = a[i]-a[i-1];
    }
  }
  
  if (((K-a[N-1])+a[0]) > max_dis)
    max_dis = (K-a[N-1])+a[0];

  cout << K - max_dis << endl;
  
  return 0;
}


Measured memory_bytes: 1152
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
const int M = ((int)1e9 + 7);
int power(int x, int y){
    x %= M;
    int ans = 1;
    while(y){
        if(y & 1)
            ans = (ans * x) % M;
        y >>= 1LL;
        x = (x * x) % M;
    }
    return ans;
}
int add(int a, int b){
    return((a % M + b % M) % M);
}
int sub(int a, int b){
    return((a % M - b % M + M) % M);
}
int mul(int a, int b){
    return(((a % M) * (b % M)) % M);
}
int divi(int a, int b){
    return(mul(a, power(b, M - 2)) % M);
}
const int Xn = 2e6 + 10;
int factorial[Xn],ifactorial[Xn];
void pre(){
	factorial[0] = 1;
	ifactorial[0] = 1;
	for(int i=1;i<Xn;i++){
		factorial[i] = mul(factorial[i-1],i);
		ifactorial[i] = divi(1,factorial[i]);
	}
}
int nCr(int n,int r){
	return divi(factorial[n],mul(factorial[r],factorial[n-r]));
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	pre();
	cin >> k;
	string s;
	cin >> s;
	n = s.length();
	int sum = 0;
	for(int i = n;i <= n + k;i++){
		int cur = mul(power(25,i - n),power(26,(n + k - i)));
		cur = mul(cur , nCr(i - 1,n - 1));
		sum = add(sum,cur);
	}
	cout << sum;
}
//.........

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

using ll = long long;

int main() {
    int N; cin >> N;
    vector<ll> a(3*N);
    for (int i = 0; i < 3*N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = 0LL;
    for (int i = 0; i < 2*N; i++) {
        if (i%2 == 1) {
            ans += a.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var alp = new List<string>() { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        var text = "";
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            text += line.Trim().ToLower();
        }
        var textlength = text.Length;
        foreach(var x in alp)
        {
            var buf = textlength - text.Replace(x, "").Length;
            Console.WriteLine("{0} : {1}",x, buf);
        }
    }
}

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	vi pre(n), suf(n);
	pre[0] = a[0];
	for(int i = 1; i < n; i++) {
		pre[i] = __gcd(pre[i - 1], a[i]);
	}
	
	suf[n - 1] = a[n - 1]; 
	for(int i = n - 2; i >= 0; i--) {
		suf[i] = __gcd(suf[i + 1], a[i]);
	}
	
	int ans = pre[n - 1];
	ans = max(ans, pre[n - 2]);
	ans = max(ans, suf[1]);
	for(int i = 1; i < n - 1; i++) {
		ans = max(ans, __gcd(pre[i - 1], suf[i + 1]));
	}
	
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 4584
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in<ll>();
	vector<vector<int>> C(N,vector<int>(26,0));
	REP(i,N){
		string S=in<string>();
		REP(j,S.size()){
			C[i][S[j]-'a']++;
		}
	}
	string T;
	REP(j,26){
		int minC=1<<30;
		REP(i,N){
			minC = min(minC,C[i][j]);
		}
		REP(i,minC) T.push_back((char)(j+'a'));
	}

	out(T);
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	h := nextInt()
	w := nextInt()
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			s := nextStr()
			if s == "snuke" {
				str := []byte{byte('A' + j)}
				fmt.Println(string(str) + strconv.Itoa(i+1))
				return
			}
		}
	}
}


Measured memory_bytes: 640
'''
参考
https://drken1215.hatenablog.com/entry/2020/06/21/224900
'''
N = int(input())
A = list(map(int, input().split()))

INF = 10 ** 5
cnt = [0] * (INF+1)

Q = int(input())
BC = []

for _ in range(Q):
    BC.append(list(map(int, input().split())))

for a in A:
    cnt[a] += 1

total = sum(A)

for b, c in BC:
    total += (c-b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(total)


Measured memory_bytes: 32808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k%2==0) {
    cout << (a-b) << endl;
  } else {
    cout << (b-a) << 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;
  cin>>N;
  vector<int> R(N);
  rep(i,N) cin>>R[i];
  int mx = -1000000000;
  int mn = R[0];
  for(int i=1;i<N;i++){
    mx = max(mx,R[i]-mn);
    mn = min(mn,R[i]);
  }
    cout<<mx<<endl;
  return 0;
}


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

void main_()
{
    int64_t N, A, B;
    cin >> N >> A >> B;

    int64_t dist = B - A;

    int64_t ans;
    if (dist % 2 == 0) {
        ans = dist / 2;
    } else {
        if (B - 1 < N - A) {
            ans = A + (B - A - 1) / 2;
        } else {
            ans = (N - B + 1) + (B - A - 1) / 2;
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


// ------------debug用------------
#define FALSE cout<<"false"<<endl;
#define TRUE cout<<"true"<<endl;
// ------------debug用------------


// ------------計算用------------
#define ALL(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)
// ------------計算用------------


// ------------出力用------------
#define PRINT(x) cout<<x<<endl;
// ------------出力用------------


using namespace std;
typedef long long ll;

int main(){
  int N;
  cin>>N;
  vector<int> a(20);
  FOR(N)cin>>a[i];
  
  int ans = 0;
  for(int i = 1;i < N - 1;i++){
  	int tmp1 = min(a[i - 1],min(a[i + 1],a[i]));
    int tmp2 = max(a[i - 1],max(a[i + 1],a[i]));
    if(tmp1 != a[i] && tmp2 != a[i]){ans++;continue;}

    if(a[i - 1] == a[i] || a[i + 1] == a[i] || a[i - 1] == a[i + 1]){
    	if(a[i] != tmp1)ans++;
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }
    let t1 = (h * 60. + m) / 720. * PI * 2.;
    let t2 = m / 60. * PI * 2.;
    let x1 = a * t1.cos();
    let y1 = a * t1.sin();
    let x2 = b * t2.cos();
    let y2 = b * t2.sin();
    let dx = x1 - x2;
    let dy = y1 - y2;
    println!("{}", (dx * dx + dy * dy).sqrt());
}


Measured memory_bytes: 2952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> a(N+1);
  rep(i, N) cin >> a[i+1];
  vector<int> ans(N+1, 0);

  for(int i=N; i>0; i--) {
    int b = 0;
    int k = 2;
    while(i*k <= N) {
      b += ans[i*k];
      k++;
    }
    b %= 2;
    if(b == 0 && a[i] == 1) ans[i] = 1;
    if(b == 1 && a[i] == 0) ans[i] = 1;
  }
  
  int c = count(all(ans), 1);
  cout << c << endl;
  rep(i, N) if(ans[i+1] == 1) cout << i+1 << " ";
  cout << endl;

}

Measured memory_bytes: 3968