akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll gcd(ll a, ll b)
{
    if (a == 0)
        return (ll)b;
    return gcd(b % a, a);
}

int main(){
    ll a,b;
    cin >> a >> b;
    cout << (ll)(a*b)/gcd(a,b);
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int d, g;
  cin >> d >> g;
  int p[15], c[15];
  rep(i, d) cin >> p[i] >> c[i];
  int ans = 1e6;
  rep(i, (1<<d)) {
    bitset<10> b(i);
    int total=0, num=0, r=-1;
    rep(j, d) {
      if (b.test(j)) {
        total += p[j]*100*(j+1) + c[j];
        num += p[j];
      } else {
        r = j;
      }
    }
    if (total < g) {
      int need = (g-total+100*(r+1)-1) / (100*(r+1));
      if (need >= p[r]) continue;
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int main()
{
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if(H%h==0&&W%w==0)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	int s=555;
	for(int i=1;i<=H;++i)
	{
		for(int j=1;j<=W;++j)
		{
			if(i%h==0&&j%w==0)
				cout<<-s*(h*w-1)-1<<" ";
			else cout<<s<<" ";
		}
		cout<<"\n";
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


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

int main()
{
    int D, T, S;
    io >> D >> T >> S;

    bool ans = S * T >= D;
    cout << YesNo(ans) << BR;
}

Measured memory_bytes: 3772
K,N = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i).sort
max = 0

(1..N-1).each do |i|
  count = 0
  count = A[i] - A[i-1]
  max = count if count > max
end

cnt = K + A[0] - A[N-1]
max = cnt if cnt > max

puts K - max

Measured memory_bytes: 19824
#include <bits/stdc++.h>
#define FR first
#define SE second
//minamoto
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define pb push_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
using namespace std;
const int N=1e6+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot=1;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
typedef pair<int,int> pr;

vector <int> E[2005];
int d[2005];

int fa[2005],dep[2005];

int sum[2005];
void dfs(int u){dep[u]=dep[fa[u]]+1;go(u)if(v!=fa[u])fa[v]=u,dfs(v);}
void fsd(int u){go(u)if(v!=fa[u])fsd(v),sum[u]+=sum[v];}
inline int LCA(R int u,R int v){
	while(u!=v){
		if(dep[u]<dep[v])swap(u,v);
		u=fa[u];
	}
	return u;
}

int p[2005];
bool col[2005],vis[2005];

pr num[2005],fir[2005];

int main() {
//	freopen("testdata.in","r",stdin);
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	E[x].push_back(y);
  	E[y].push_back(x);
  	d[x]++;d[y]++;
  	add(x,y),add(y,x);
  }
  dfs(1);
  for(int i=1;i<=m;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	fir[i]=num[i]=pr(x,y);
  	sum[x]++;sum[y]++;
  	sum[LCA(x,y)]-=2;
  }
  fsd(1);
  int ans=0;
  for(int i=1;i<=n;i++) ans+=min(sum[i],2);
  printf("%d\n",ans);
  for(int i=2;i<=n;i++) {
  	int u=0;
  	for(int j=2;j<=n;j++)
  	  if (d[j]==1&&!vis[j]) {
  	  	  u=j;
  	  	  break;
		}
	vis[u]=1;
	int v=0;
	for(int j=0;j<E[u].size();j++)
	  if (!vis[E[u][j]]) {
	  	v=E[u][j];
	  	break;
	  }
	d[v]--;
	int id1=0,id2=0;
	for(int j=1;j<=m;j++)
	  if ((num[j].FR==u)^(num[j].SE==u)) {
	  	if (!id1) id1=j;
	  	else if (!id2) id2=j;
	  }
//	  printf("%d %d %d\n",i,id1,id2);
	if (!id1&&!id2) continue;
	if (!id2) {
		if (num[id1].FR==u) num[id1].FR=v;
		else num[id1].SE=v; 
		continue;
	}
	if (num[id1].FR==u) {
		if (num[id2].FR==u) {
			num[id1].FR=num[id2].SE;
			col[id2]^=1;
		}
		else num[id1].FR=num[id2].FR;
	}
	else {
		if (num[id2].SE==u) {
			num[id1].SE=num[id2].FR;
			col[id2]^=1;
		}
		else num[id1].SE=num[id2].SE;
	}
	num[id2].FR=num[id2].SE;
	p[id2]=id1;
	for(int j=1;j<=m;j++)
	  if ((num[j].FR==u)^(num[j].SE==u)) {
	  	if (num[j].FR==u) num[j].FR=v;
	  	else num[j].SE=v;
	  }
  }
  for(int i=1;i<=m;i++)
    if (p[i]) col[i]^=col[p[i]];
  for(int i=1;i<=m;i++) {
  	if (col[i]) swap(fir[i].FR,fir[i].SE);
  	printf("%d %d\n",fir[i].FR,fir[i].SE);
  }
  return 0;
}

Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,m;
char s[N],si[N][2],di[N][2];

bool check(int mid,int k) {
	if (mid<1 || mid>n) return 1;
	for (int i=1;i<=m;i++) {
		if (s[mid]!=si[i][0]) continue;
		if (di[i][0]=='L') mid--; else mid++;
		if (k==1) if (mid<1) return 1;
		if (k==2) if (mid>n) return 1;
	}
	return 0;
}

int main()
{
	cin>>n>>m;
	scanf("%s",s+1);
	for (int i=1;i<=m;i++) scanf("%s%s",&si[i],&di[i]);
	
	int L=0,R=n,ans=0;
	while (L<R) {
		int mid=L+R+1>>1;
		if (check(mid,1)) L=mid; else R=mid-1;
	}
	ans+=L;
	
	L++; R=n+1;
	while (L<R) {
		int mid=L+R>>1;
		if (check(mid,2)) R=mid; else L=mid+1;
	} 
	ans+=(n-R+1);
	
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int H, W, K;cin >> H >> W >> K;
  char cake[H][W];
  rep(i, H)rep(j, W) cin >> cake[i][j];
  int ans[H][W];
  rep(i, H)rep(j, W) ans[i][j] = 0;
  int num = 0;
  rep(i, H){
    bool flag = false;
    rep(j, W){
      ans[i][j] = max(num, 1);
      if (cake[i][j] == '#'){
        flag = true;
        num++;
        break;
      }
    }
    if (flag){
      rep(j, W) ans[i][j] = max(num, 1);
    }
  }
  int sec[num];
  rep(i, num)sec[i] = 0;
  rep(j, W){
    rep(i, H){
      if(j > 0 && i > 0 && ans[i][0] == ans[i-1][0]) ans[i][j] = ans[i-1][j];
      else if (j > 0) ans[i][j] = ans[i][j-1];
      if (cake[i][j] == '#'){
        sec[ans[i][0]-1]++;
        if (sec[ans[i][0]-1] > 1){
          num++;
          ans[i][j] = num;
        }
      }
    }
    for (int i = H-1; i > 0 ; i--){
      if (ans[i][0] == ans[i-1][0]){
        ans[i-1][j] = ans[i][j];
      }
    }
  }
  rep(i, H){
    rep(j, W){
      cout << ans[i][j] << " ";
    }
    cout <<endl;
  }
}

Measured memory_bytes: 4032
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    auto get_num = [](char ch) -> int {
        if(ch == 'U')   return 0;
        else if(ch == 'R')  return 1;
        else if(ch == 'D')  return 2;
        else    return 3;   // ch == 'L'
    };
    vector<int> X(N), Y(N), dir(N);
    for(int i = 0; i < N; ++i){
        char ch;
        cin >> X[i] >> Y[i] >> ch;
        dir[i] = get_num(ch);
    }
    int ans = INF;
    for(int loop = 0; loop < 4; ++loop){
        map<int, vector<P>> mp, manhattan_mp;
        for(int i = 0; i < N; ++i){
            if(~dir[i] & 1) mp[X[i]].emplace_back(Y[i], dir[i]);
            if(dir[i] < 2)  manhattan_mp[X[i] + Y[i]].emplace_back(Y[i], dir[i]);
        }
        for(auto& it : mp){
            vector<P>& table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto& p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 5);
            }
        }
        for(auto& it : manhattan_mp){
            vector<P>& table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto& p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 10);
            }
        }
        swap(X, Y);
        for(int i = 0; i < N; ++i){
            Y[i] = -Y[i];
            if(++dir[i] == 4)   dir[i] = 0;
        }
    }
    if(ans == INF)  cout << "SAFE\n";
    else    cout << ans << '\n';
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

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

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
MOD=10**9+7
p=[]
n=[]
for i in range(N):
    if A[i]<=0:
        n.append(A[i])
    else:
        p.append(A[i])
p.sort(reverse=True)
n.sort()
numplus=len(p)
if numplus==0:
    ans=1
    if K%2==1:
        for i in range(1,K+1):
            ans=(ans*n[i*(-1)])%MOD
    else:
        for i in range(K):
            ans=(ans*n[i])%MOD
elif N==K:
    ans=1
    for i in range(N):
        ans=(ans*A[i])%MOD
else:
    if numplus>=K:
        x=K
        if 0 in p:
            zero=p.index(0)
            len(p)-zero-1
    else:
        if (K-numplus)%2==1:
            x=numplus-1
        else:
            x=numplus
    ans=1
    for i in range(x):
        ans=(ans*p[i])%MOD
    for i in range(K-x):
        ans=(ans*n[i])%MOD
    temp=ans
    while x>1:
        if len(n)<(K-x+2):
            break
        if n[K-x]*n[K-x+1]<p[x-1]*p[x-2]:
            break
        temp=(temp*n[K-x]*n[K-x+1])%MOD
        temp=(temp*pow(p[x-1]*p[x-2],MOD-2,MOD))%MOD
        ans=temp
        x-=2
print(ans)
        



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

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

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  for (ll i = 0; i < n; ++i) {
    if (a[i]%2 != 0) {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;

  return 0;
}


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

void swap(int &a, int &b){
	int dum = a;
	a = b;
	b = dum;
	return;
}

int main(){
	int x,y,z;
	cin >> x >> y >> z;
	if (x > y){
		swap(x, y);
	}
	if (y > z){
		swap(y, z);
	}
	if (x > y){
		swap(x, y);
	}
	cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 3080
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, m = Is()
a = m//n
for i in reversed(range(a+1)):
    if m % i != 0:
        continue
    else:
        print(i)
        exit()


Measured memory_bytes: 65000
#include<bits/stdc++.h>
#define MAXN 233333
using namespace std;

int n,m,k;
int a[MAXN];
vector<int> b[MAXN];
int fa[MAXN],siz[MAXN];


int find(int x){
	if(fa[x] == x){
		return x;
	}
	int t = find(fa[x]);
	fa[x] = t;
	siz[x] = siz[t];
	return t;
}
void join(int x,int y){
	int xx = find(x),yy = find(y);
	if(xx == yy) return;
	siz[xx] += siz[yy];
	fa[yy] = xx;
}
int count(int x){
	int res = 0;
	for(int i = 0;i<b[x].size();i++){
		if(find(b[x][i])==find(x))
			res++;
	}
	return res;
}
int main()
{
	cin>>n>>m>>k;
	for(int i = 1;i<=n;i++){
		fa[i] = i;
		siz[i] = 1;
	}
	for(int i = 1;i<=m;i++){
		int t1,t2;
		cin>>t1>>t2;
		a[t1]++;
		a[t2]++;
		join(t1,t2);
	}
	for(int i = 1;i<=k;i++){
		int t1,t2;
		cin>>t1>>t2;
		b[t1].push_back(t2);
		b[t2].push_back(t1);
	}
	for(int i = 1;i<=n;i++){
		find(i);
		//cout<<siz[i]<<" "<<a[i]<<" "<<count(i)<<endl;
		cout<<max(siz[i]-a[i]-count(i)-1,0)<<" ";
	}
	
}

Measured memory_bytes: 11392
S = input()
head, tail = int(S[:2]), int(S[2:])
if 0 < head < 13:
    if 0 < tail < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < tail < 13:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	string str;
	vector<string> v;
	int n, l;
	scanf("%d %d", &n, &l);
	for(int i=0; i<n; i++){
		string s;
		cin>>s;
		v.push_back(s);
	}
	sort(v.begin(), v.end());
	for(int i=0; i<n; i++){
		str+=v[i];
	}
	cout<<str;
    return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	if( A+B== C+D ){
		cout << "Balanced" << endl;
	}else if( A+B < C+D ){
		cout << "Right" << endl;
	}else{
		cout << "Left" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n,k;
    cin >> n >> k;
    cout << (n-k+1) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

ans = pow(2, n, mod) - 1

fact = [1]*(2*10**5+1)
for i in range(1, 2*10**5+1):
	fact[i] = i*fact[i-1]%mod

def C(n, k):
	tmp = 1
	for i in range(n, n-k, -1):
		tmp = tmp*i%mod
	return (tmp*pow(fact[k], mod-2, mod))%mod

ans = (ans - C(n, a) - C(n, b))%mod
print(ans)



Measured memory_bytes: 17692
import bisect
import itertools
from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
d = defaultdict(int)

for key, value in itertools.groupby(a):
    d[key] = len(list(value))

ans = 0
for i in range(N):
    now = a[i]
    if d[now] > 0:
        pair = 2**((now).bit_length()) - now
        if now == pair:
            if d[pair] >= 2:
                ans += 1
                d[pair] -= 2
        elif d[pair] > 0:
            ans += 1
            d[now] -= 1
            d[pair] -= 1
print(ans)


Measured memory_bytes: 56312
# UnionFindでつなげていく
# [所属する木の頂点数]-[1（自分）]-[自分とブロック関係にある人の数]

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
    def show_parents(self):
      print(self.parents)

# ここまでUnionFind
N,M,K=map(int,input().split())

UF=UnionFind(N)
from collections import defaultdict
dic=defaultdict(set)
friends=[0]*N
for i in range(M):
  a,b=map(int,input().split())
  UF.union(a-1,b-1)
  friends[a-1]+=1
  friends[b-1]+=1

for i in range(N):
  dic[UF.find(i)].add(i)

block=defaultdict(set)
for i in range(K):
  c,d=map(int,input().split())
  block[c-1].add(d-1)
  block[d-1].add(c-1)

# UF.show_parents()
# 同じ木に所属する人数のうち、ブロック関係にない人数
ans=[0]*N
for i in range(N):
  candi=dic[UF.find(i)]
  #print("i",candi,"block",block[i])
  ans[i]=len(candi)-friends[i]-1
  for b in block[i]:
    if UF.same(i,b):
      ans[i]-=1
  if ans[i]<0:
    ans[i]=0
print(*ans)


Measured memory_bytes: 83560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        String S = sc.next(); 
        
        int ans = 753;
        
		for (int i = 0; i < S.length() - 2; i++) {
			
			String XString = S.substring(i,i + 3);
			int X = Integer.parseInt(XString);
			
			if (Math.abs(X - 753) < ans) {
				ans = Math.abs(X - 753);
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21588
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		for(int i = 0; i < n; ++i)
		{
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			if(pm == 100 || pe == 100 || pj == 100 || (pm + pe >= 180) || (pm + pe + pj >= 240))
			{
				cout << "A" << endl;
			}
			else if((pm + pe + pj >= 210) || (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)))
			{
				cout << "B" << endl;
			}
			else
			{
				cout << "C" << endl;
			}
		}
	}
}

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

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

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

char t[10][10];

int getSum(int x,int y, char c)
{
	int sum = 0;
	for(int i=0;i<8;i++)
	{
		int cnt=0;
		int nx=x;
		int ny=y;
		while(true)
		{
			nx+=dx[i];
			ny+=dy[i];
			if(t[nx][ny]=='.')
			{
				cnt = 0;
				break;
			}
			else if(t[nx][ny]==c)
			{
				sum+=cnt;
				break;
			}
			else
				cnt++;
		}
	}
	return sum;
}

void changedResult(int x,int y, char c)
{
	for(int i=0;i<8;i++)
	{
		int cnt=0;
		int nx=x;
		int ny=y;
		while(true)
		{
			nx+=dx[i];
			ny+=dy[i];
			if(t[nx][ny]=='.')
			{
				cnt = 0;
				break;
			}
			else if(t[nx][ny]==c)
			{
				break;
			}
			else
				cnt++;
		}
		if(cnt>0)
		{
			nx = x;
			ny = y;
			while(true)
			{
				nx+=dx[i];
				ny+=dy[i];
				if(t[nx][ny]=='.')
					break;
				else if(t[nx][ny]==c)
				{
					break;
				}
				else
					t[nx][ny] = c;
			}
				
		}
	}
}


int main()
{
	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
			t[i][j]='.';
	
	for(int i=1;i<=8;i++)
	{
		string s;
		cin >> s;
		for(int j=1;j<=8;j++)
			t[i][j]=s[j-1];
	}
	/*
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++)
			cout << t[i][j];
		cout << endl;
	}
	*/

	char turn='o';
	int pass=0;
	while(true)
	{
		int high=0;
		int nx=0;
		int ny=0;
		if(turn=='o')
		{
			for(int i=1;i<=8;i++)
			for(int j=1;j<=8;j++)
				if(t[i][j]=='.')
				{
					int tmp=getSum(i,j,turn);
					if(tmp>high)
					{
						high=tmp;
						nx=i;
						ny=j;
					}
				}
		}
		else if(turn=='x')
		{
			for(int i=8;i>=1;i--)
			for(int j=8;j>=1;j--)
				if(t[i][j]=='.')
				{
					int tmp=getSum(i,j,turn);
					if(tmp>high)
					{
						high=tmp;
						nx=i;
						ny=j;
					}
				}
		}

		if(high==0)
		{
			pass++;
		}
		else
		{
			changedResult(nx,ny,turn);
			t[nx][ny] = turn;
			pass=0;
		}
		if(turn=='o')turn='x';
		else if(turn=='x')turn='o';
		if(pass>=2)break;
	}
	for(int i=1;i<9;i++)
	{
		for(int j=1;j<9;j++)
			cout << t[i][j];
		cout << endl;
	}

}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

long long N;
vector<pair<long long,long long>> V[100100];
long long Q,K,cost = 0,T[100100];
bool used[100100];

void dfs(long long X){
    used[X] = 1;
    T[X] = cost;
    REP(i,V[X].size()){
        if(used[V[X][i].first]) continue;
        cost += V[X][i].second;
        dfs(V[X][i].first);
        cost -= V[X][i].second;
    }
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N;
    REP(i,N-1){
        long long A,B,C;cin >> A >> B >> C;
        A--;B--;
        V[A].pb({B,C});V[B].pb({A,C});
    }
    cin >> Q >> K;K--;
    dfs(K);
    REP(i,Q){
        long long x,y;cin >> x >> y;x--;y--;
        cout << T[x] + T[y] << endl;
    }
}

Measured memory_bytes: 14464
#include <stdio.h>
#include <vector>
using namespace std;
const int C=100001;

int n, a[C], dp[C];

int abs(int a){return (a>0)?(a):(-a);}

int main(){
	scanf ("%d", &n);
	for (int i=1;i<=n;i++)	{
		scanf ("%d", &a[i]);
		if (i==1)	continue;
		if (i==2)	dp[i]=abs(a[i]-a[i-1]);
		else		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
	}
	printf ("%d\n", dp[n]);
	
return 0;}

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

struct vec {
  double x, y;
  vec(double x, double y) : x(x), y(y) {}
  vec() : x(0), y(0) {}
  const vec operator+(const vec &v) const { return vec(x + v.x, y + v.y); }
  const vec operator-() const { return vec(-x, -y); }
  const vec operator-(const vec &v) const { return *this + (-v); }
  const vec operator*(const double d) const { return vec(x * d, y * d); }
  const vec operator/(const double d) const { return *this * (1 / d); }
  const vec unit() const { return *this / len(); };
  const double len() const { return sqrt(x * x + y * y); }
  const double dot(const vec &v) const { return x * v.x + y * v.y; }
};

typedef vec point;

point p1, p2;
vec v;

int main() {
  cin >> p1.x >> p1.y >> p2.x >> p2.y;
  v = p2 - p1;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    point p;
    cin >> p.x >> p.y;
    vec v2 = p - p1;
    vec v3 = v.unit() * v.dot(v2) / v.len();
    point x = p1 + v3;
    point y = x + (x - p);
    printf("%.10lf %.10lf\n", y.x, y.y);
  }
}


Measured memory_bytes: 3272
N,K=map(int, input().split())


class SegmentTree:
    def __init__(self, init_value: list, segfunc, ide_ele):
        n = len(init_value)
        self.N0 = 1 << (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i, x in enumerate(init_value):
            self.data[i + self.N0 - 1] = x
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    # k: index , x: value
    def update(self, k: int, x):
        k += self.N0 - 1
        ############################
        self.data[k] = x
        ###########################
        while k:
            k = (k - 1) // 2
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])

    def get(self, k):
        return self.query(k,k+1)
    
    # rightは開区間  l<=x<r
    def query(self, left: int, right: int):
        L = left + self.N0
        R = right + self.N0
        res = self.ide_ele
        ##########################
        a, b = [], []
        while L < R:
            if L & 1:
                a.append(L - 1)
                L += 1
            if R & 1:
                R -= 1
                b.append(R - 1)
            L >>= 1
            R >>= 1
        for i in a + b[::-1]:
            res = self.segfunc(res, self.data[i])
        ##########################
        return res



dp=[0]*(3*10**5+1)
seg=SegmentTree(dp, max, 0)
length=len(dp)
for i in range(N):
    a=int(input())
    if i==0:
        seg.update(a,1)
    else:
        left=max(0, a-K)
        right=min(length, a+K+1)
        now=seg.query(left, right)
        seg.update(a, now+1)

print(seg.query(0,length))

Measured memory_bytes: 82856
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
#include <fstream>
#include <random>
#include <set>
#include <queue>
#include <complex>
#include <stack>
#include <numeric>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
using namespace std;
bool f[100][100]={};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //std::ifstream in("input.txt");std::cin.rdbuf(in.rdbuf());
    int a,b;
    cin>>a>>b;
    for(int i=50;i<100;++i){
        for(int j=0;j<100;++j){
            f[i][j]=1;
        }
    }
    for(int i=0;i<25;++i){
        for(int j=0;j<50;++j){
            if(b==1){goto end1;}
            f[i*2][j*2]=1;
            b--;
        }
    }
end1:;
    for(int i=25;i<50;++i){
        for(int j=0;j<50;++j){
            if(a==1){goto end2;}
            f[i*2+1][j*2]=0;
            a--;
        }
    }
end2:;
    cout<<100<<" "<<100<<endl;
    rep(i,100){
        rep(j,100){
            if(f[i][j]==0){cout<<".";}
            else{cout<<"#";}
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll out = 0;
	string s; cin >> s; int n = s.length();
	int c = 0;
	per(i, n) {
		if (s[i] == 'W')c++;
		else out += c;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <math.h>

using namespace std;

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

    int x[100];
    int b;
    int i = 0;
    while (cin >> b || i < 100) {
        x[i] = b;
        i++;
    }

    int min = INT32_MAX;
    for (int p = 0; p < 1000; p++) {
        int total = 0;
        for (int i = 0; i < num; i++) {
            total += pow(abs(x[i] - p), 2);
        }

        if (total < min) {
            min = total;
        }
    }

    cout << min << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  string ans = "APPROVED";
  for (int i=0;i<N;++i){
    int A;
    cin >> A;
    if(A%2==0){
      if(A%3==0 || A%5==0){
        ans ="APPROVED";
      }
      if(A%3 !=0 && A%5!=0){
        ans ="DENIED";
        break;
      }
    }
  }
  cout << ans;
}

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

int main(){
  int n;
  cin >> n;
  int d[n];
  for(int i = 0; i < n; i++){
    cin >> d[i];
  }
  
  sort(d, d+n);
  
  int res = 1;
  for(int j = 1; j < n; j++){
    if(d[j-1] < d[j]){
      res += 1;
    }else{
      continue;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;  
  
    while (y > 0) 
    { 
      
        if (y & 1) 
            res = (res*x) % p; 
  
      
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
typedef pair<int,int> ii;
// bool cmp(ii a,ii b)
// {
// 	if(a.ff==b.ff)
// 	{
// 		return a.ss>b.ss;
// 	}
// 	else
// 		a.ff<b.ff;
// }
   ll dp[27][200004]={0};
ll largestPower(ll n, ll p) 
{ 
    // Initialize result 
    ll x = 0; 
  
    // Calculate x = n/p + n/(p^2) + n/(p^3) + .... 
    while (n) 
    { 
        n /= p; 
        x += n; 
    } 
    return x; 
} 
int  main()
{
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//    #endif
   IOS;
 	ll n;
 	cin>>n;
 	if(n%2!=0)
 	{
 		cout<<"0";
 		return 0;
 	}
 	ll r=largestPower(n,2);
 	ll k=5;
 	ll p=0;
 	while(1)
 	{
 		ll w=n/(k*2);
 		p+=w;
 		k=k*5;
 		if(w==0)
 			break;
 	}
 	cout<<min(p,r);
 	
}


Measured memory_bytes: 256
#include <stdio.h>

int yakusuu(int a, int b)
{
  while(1) {
    if (a > b) {
      a %= b;
      if (a == 0) {
	return b;
        break;
      }
    } else {
      b %= a;
      if (b == 0) {
	return a;
        break;
      }
    }
  }
}

int main(void)
{
  int a, b, k, i;
  int count = 0;
  scanf("%d %d %d", &a, &b, &k);
  for (i = yakusuu(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      count++;
      if (count == k)
	break;
    }
  }
  printf("%d\n", i);
}
 
  


Measured memory_bytes: 128
q=int(input())

all=[]

#素数判定関数
def sosu(x):
  flag=True
  r=2
  while r*r<=x:
    if x%r==0:
      flag=False
      break
    r+=1
  return flag

for i in range(2,10**5+1):
  if i%2:
    if sosu(i)==True and (sosu((i+1)//2))==True:
      all.append(i)

import bisect

#print(all)

for i in range(q):
  l,r=map(int,input().split())
  x=bisect.bisect_left(all,l)
  y=bisect.bisect_right(all,r)
  print(y-x)

Measured memory_bytes: 3444
S = list(input())

for i in range(len(S)):
  if (i+1)%2 == 1 and S[i] not in ['R', 'U', 'D']:
    print('No')
    exit()
  elif (i+1)%2 == 0 and S[i] not in ['L', 'U', 'D']:
    print('No')
    exit()

print('Yes')




Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll N,K;
string S,T;
ll A[100007];

int main(){
  cin >> N >> K;
  cout << min(N%K,K-(N%K)) << endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        List<String> listS=new ArrayList<String>();
        List<String> listT=new ArrayList<String>();
        List<String> listFinal = new ArrayList<String>();

        for(int i=0;i<S.length();i++){
            listS.add(String.valueOf(S.charAt(i)));
        }
        for(int i=0;i<T.length();i++){
            listT.add(String.valueOf(T.charAt(i)));
        }
        for(int i=0;i<N;i++){
            listFinal.add(listS.get(i));
            listFinal.add(listT.get(i));
        }
        listFinal.forEach(System.out::print);
    }
}

Measured memory_bytes: 35788
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#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++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
int main(){
    ll N,M;
    cin>>N>>M;
    ll Ans=0;
    vl vec(M);
    rep(i,M){
        cin>>vec.at(i);
    }
    sort(all(vec));
    if(N>=M){
        cout<<0<<endl;
        return 0;
    }
    else
    {
        vl dis(M-1);
        rep(i,M-1){
            dis.at(i)=vec.at(i+1)-vec.at(i);
        }
        sort(all(dis));
        reverse(all(dis));
        rep(i,N-1){
            dis.at(i)=0;
        }
        rep(i,M-1){
            Ans+=dis.at(i);
        }
        cout<<Ans<<endl;
    }
    
    }


Measured memory_bytes: 1792
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();

    stdin.read_line(&mut buf).unwrap();
    let s_vec: Vec<char> = buf.trim().chars().collect();

    let parity = s_vec.len() +
        if s_vec.first() == s_vec.last() { 1 } else { 0 };

    match parity % 2 {
        1 => println!("First"),
        _ => println!("Second"),
    }
}


Measured memory_bytes: 4352
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var mx = n, mn = 1;
  for(var i = 0; i < m; i++){
    var t = o.l();
    if(t[0] > mn)mn = t[0];
    if(t[1] < mx)mx = t[1];
  }
  return Math.max(0,mx-mn+1);
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    int n, k;
    cin >> n >> k;
    set<char> NG;

    rep(i, k) {
        char d;
        cin >> d;
        NG.insert(d);
    }

    int i = n;
    while (1) {
        string s = to_string(i);
        bool can = true;
        for (auto c : s) {
            if (NG.count(c)) {
                can = false;
                break;
            }
        }
        if (can) {
            cout << i << endl;
            return 0;
        }
        i++;
    }

    return 0;
}

Measured memory_bytes: 256
use std::cmp::max;


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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        X: i64,
        K: i64,
        D: i64,
    }

    let absX = X.abs();
    let div = absX / D;
    let ans = absX % D;
    if div > K {
        println!("{}", absX - K * D);
    } else if (K - div) % 2 == 0 {
        println!("{}", ans);
    } else {
        println!("{}", (ans - D).abs());
    }
}


Measured memory_bytes: 2136