akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_HUMAN_MAX		200005									// 最大人数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Human[D_HUMAN_MAX];								// 人
static int siHCnt;												// 人数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 比較関数 - int降順
int
fCmpFncId(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// int降順
	if (*lipVal1 > *lipVal2) {
		return -1;
	}
	else if (*lipVal1 < *lipVal2) {
		return 1;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 人数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siHCnt);

	// 人 - 取得
	si1Human[0] = 0;
	for (i = 0; i < siHCnt; i++) {
		fscanf(szpFpI, "%d", &si1Human[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	qsort(si1Human, siHCnt, sizeof(int), fCmpFncId);

	// 合計 - 取得
	long long llSum = 0;
	for (i = 1; i < siHCnt; i++) {
		llSum += si1Human[i / 2];
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llSum);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i;i<N;i++){
        cin >> A.at(i);
    }

    sort(A.begin(),A.end());
    int MD = A.at(N-1)-A.at(0);

    cout << MD << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll x,y,t[200];
int main(){
	for(int i=1; i<=3; i++){
		cin>>x>>y;
		t[x]++;
		t[y]++;
		if(t[x] > 2 || t[y]>2){
			cout <<"NO";
			return 0;
		}
	}
	
	
	cout <<"YES";
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    int k;cin>>k;
    int ans=0;
    while(n--){
        int in;cin>>in;
        ans+=(in>=k);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>
#include <stack>
#include <queue>

using namespace std;

int main() {
	queue<int> Q;
	int n;
	int u, v;
	int AdjList[101][99];
	int Deg[101];
	bool Visited[101];
	int d[101];
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) {
		d[i] = -1;
		Visited[i] = false;
		cin >> u;
		cin >> Deg[u];
		for (j = 0; j < Deg[u]; j++) {
			cin >> v;
			AdjList[u][j] = v;
		}
	}

	d[1] = 0;
	Q.push(1);
	Visited[1] = true;
	while (Q.empty() != true) {
		v = Q.front();
		Q.pop();
		for (i = 0; i < Deg[v]; i++) {
			u = AdjList[v][i];
			
			if (Visited[u] != true) {
				Visited[u] = true;
				d[u] = d[v] + 1;
				Q.push(u);
			}
		}
	}
	for (i = 1; i <= n; i++) {
		printf("%d %d\n", i, d[i]);
	}

	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  
  while(true){
    int n = (sqrt(N));
    bool flag = true;
    for (int i = 2; i <= n; i++){
      if(N % i == 0) flag = false;
    }
    if(!flag) N++;
    else{
      cout << N << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);
using namespace std;

int main()
{
 //   OJ;
    int ans=0;
string a,b;
cin>>a>>b;
for(int i=0;i<a.size();i++)
{
    if(a[i]!=b[i])
    {
      ans++;
    }
}
cout<<ans<<endl;
}


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

#define ll long long
#define eb emplace_back
#define nl '\n'
#define deb(x) cerr << #x" = " << x << nl
#define in() ( { int a ; scanf("%d", &a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;


int32_t main()
{
    int a, b, c; cin >> a >> b >> c;
    int ok = 0;
    if(a == b && b != c) ok = 1;
    if(a == c && a != b) ok = 1;
    if(b == c && a != b) ok = 1;
    if(ok) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	owo
	int n,k;
	cin>>n>>k;
	vector<ll>h(n),dp(n,INF);
	for(ll &x:h)cin>>x;
	dp[0] = 0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j >= 0)dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	//for(int i=0;i<n;i++)cout<<dp[i]<<" ";
	//cout<<endl;
	cout<<dp[n-1];
}



Measured memory_bytes: 4728
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE-SWE^19)

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read freopen("blue.txt","r",stdin);
#define write freopen("red.txt","w",stdout);
#define pie 2*acos(0.0);

typedef long long ll;

using namespace std;


int main()

{

    fastio;

    int N,M;
    cin>>N>>M;

    int sivan[M+1];

    int sum=0;

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

    if(sum<=N)
        cout<<N-sum;
    else
        cout<<"-1";

    return 0;

}


Measured memory_bytes: 3692
#include <stdio.h>

int ball[10];

bool can(int n,int left,int right){
	bool flag;
	
	if(n==10) return true;
	if(ball[n]>right && can(n+1,left ,ball[n])) return true;
	if(ball[n]>left  && can(n+1,ball[n],right)) return true;
	
	return false;
}


int main(){
	
	int N;
	
	scanf("%d",&N);
	
	for(int i=0;i<N;i++){
		for(int j=0;j<10;j++){
			scanf("%d",&ball[j]);
		}
		
		printf(can(0,0,0)?"YES\n":"NO\n");
		
		
	}
}

Measured memory_bytes: 2724
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=0;
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			if(j/10>1&&j%10>1&&i==(j/10)*(j%10))ret++;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#define LL long long

using namespace std;

int n,m;

int main()
{
	cin>>n;
	if (n<1200) puts("ABC");
	else puts("ARC");
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
n=int(input())
z=[]
p=[i+1 for i in range(n)]
for i in permutations(p,n):
    z.append(list(i))
z.sort()
s=list(map(int,input().split()))
t=list(map(int,input().split()))
for i in range(len(z)):
    if z[i]==s:
        a=i
    if z[i]==t:
        b=i
print(abs(a-b))

Measured memory_bytes: 47196
fun main(args: Array<String>) {
    val nNum = readLine()!!.toInt()
    val numLine = readLine()!!
    val numbers = numLine.split(" ").map { s -> s.toInt() }.toIntArray()

    var swapCount =0
    var flag = true
    while (flag) {
        flag = false
        for (i in nNum-1 downTo 1) {
            if (numbers[i-1] > numbers[i]) {
                val rightNum = numbers[i]
                numbers[i] = numbers[i-1]
                numbers[i-1] = rightNum

                swapCount++
                flag = true
            }
        }
    }

    printNumbers(numbers)
    println(swapCount)
}

private fun printNumbers(numbers: IntArray) {
    for (i in 0..numbers.size-1) {
        print(numbers[i])
        if (i != numbers.size-1) {
            print(" ")
        }
    }
    println()
}



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

#define INF 1e9
#define MOD 1000000007
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }




int main() {
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    REP(i, N) cin >> A[i];
    vector<int> cnt(3,0);
    if (A[0]!=0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans=1;
    REP(i,N) {
        int p=0,idx;
        REP(j,3) {
            if (cnt[j]==A[i]) {
                p++;
                idx=j;
            }
        }
        ans*=p;
        ans%=(ll(1e9)+7);
        cnt[idx]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n;
	cin >> n;
	string s;
	ll cnt[5]={};
	for(int k=0;k<n;k++){
		cin >> s;
		if (s[0]=='M') cnt[0]++;
		else if (s[0]=='A') cnt[1]++;
		else if (s[0]=='R') cnt[2]++;
		else if (s[0]=='C') cnt[3]++;
		else if (s[0]=='H') cnt[4]++;
	}
	ll ans = 0;
	FOR(i,0,3){
		FOR(j,i+1,4){
			FOR(k,j+1,5){
				ans += cnt[i]*cnt[j]*cnt[k];
			}}}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

///==================================================================================///

///for
#define F(i,n) for(int i=0;i<n;i++)
#define Fb(i,n) for(int i=n-1;i>=0;i--)
#define Fi(i,l,r) for(int i=l;i<=r;i++)
#define Fbi(i,r,l) for(int i=r;i>=l;i--)
///push and pop
#define pusb push_back
#define pusf push_front
#define popb pop_back
#define popf pop_front
///pair
#define fi first
#define se second
#define mp make_pair
///values
#define INF 2000000000
#define llINF (long long)9000000000000000000

///types
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
///pairs
typedef pair<int,int> II;
typedef pair<int,II> III;
typedef pair<double,double> DD;
typedef pair<string,string> SS;
///vectors
typedef vector<int> VI;
typedef vector<II> VII;
typedef vector<III> VIII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef vector<string> VS;
///queues
typedef priority_queue<int,vector<int>,greater<int> > PQI_min;
typedef priority_queue<int> PQI_max;
typedef priority_queue<II,vector<II >,greater<II > > PQII_min;
typedef priority_queue<II > PQII_max;
typedef queue<int> QI;
typedef queue<II > QII;
///stack
typedef stack<int> SI;
typedef stack<II > SII;

///functions
template<class T> T modulo(T x, T p) {
    if(x>=0) return x%p;
    return p + x%p;
}
template<class T> T gcd(T a, T b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
template<class T> T lcm(T a, T b) {
    return a*b/gcd(a,b);
}

///==================================================================================///

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    //freopen("1.in","r",stdin);
    //freopen("out.out","w",stdout);
    ///==================================================///
    
    int l,r,k;
    cin>>l>>r>>k;
    cout<<r/k - l/k + (l%k==0);

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s,d;
  int n;
  cin>>n;
  cin>>s>>d;
  for(int i=0;i<n;i++){
    cout<<s[i]<<d[i];
  }
}


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

int main() {
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
    if(x1 == 0) {
     cout << 1 << endl;
    }
    if(x2 == 0) {
     cout << 2 << endl;
    }
    if(x3 == 0) {
     cout << 3 << endl;
    }
    if(x4 == 0) {
     cout << 4 << endl;
    }
    if(x5 == 0) {
     cout << 5 << endl;
    }
}

Measured memory_bytes: 3628
import sys
# sys.setrecursionlimit(100000)
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, m = input_int_list()
    nodes = defaultdict(int)
    for _ in range(m):
        a, b = input_int_list()
        nodes[a] += 1
        nodes[b] += 1

    for k, v in nodes.items():
        if v % 2 == 1:
            print("NO")
            return
    print("YES")

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 85884
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#define MAX 1000000000000000000LL

using namespace std;
int main(){
    string n,m;
    int key=0;
    cin>>n>>m;
    if(n.length()>m.length()){
        cout<<"GREATER"<<endl;
    }
    else if(n.length()<m.length()){
        cout<<"LESS"<<endl;
    }
    else if(n.length()==m.length()){
        for(int i=0; i<n.length(); i++){
            if(n[i]>m[i]){
                cout<<"GREATER"<<endl;
                key=1;
                break;
            }
            if(n[i]<m[i]){
                cout<<"LESS"<<endl;
                key=1;
                break;
            }
           
        }
        if(key==0)cout<<"EQUAL"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

auto input(size_t n) {
    return InputType2(n);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t k = input();
    size_t n = input();
    vector<size_t> a = input(n);
    sort(begin(a), end(a));
    size_t c = numeric_limits<size_t>::max();
    for (size_t i = 0; i < n; ++i) {
        auto last = (i + n - 1) % n;
        if (last < i) {
            c = min(c, k - a[i] + a[last]);
        } else {
            c = min(c, a[last] - a[i]);
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin>>N;
	vector <int> vect(N+1,0);
	int i,j,k;
	for(i=0;i<N-1;i++)
	{
		cin>>j;
		vect[j]++;
	}
	for(i=1;i<=N;i++)
	{
		cout<<vect[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> c(1001);
    FOR(i,1,n+1){
        int num=i;
        for(int j=2;j*j<=i;j++){
            while(num%j==0){
                c[j]++;
                num/=j;
            }
        }
        if(num!=1) c[num]++;
    }
    ll ans=1;
    REP(i,1001){
        (ans*=c[i]+1)%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc120/tasks/abc120_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << min(b / a, c) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int A, B, C, D; cin >> A >> B >> C >> D;
	int L = A + B, R = C + D;
	if (L > R) cout << "Left" << endl;
	else if (L < R) cout << "Right" << endl;
	else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}
template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T,int>>> que;que.push(P(0,s));
  while(!que.empty()){
    pair<T,int> p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(make_pair(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<double>


int n,m;deque<int> g[110000],ans;
bool inc[110000];

void dfs(int x, bool b){
  if(!inc[x]){
    if(!b)ans.push_back(x);
    else ans.push_front(x);
  }
  inc[x] = true;
  int c = true;
  rep(i,g[x].size()){
    if(!inc[g[x][i]]){
      dfs(g[x][i], b);
      return;
    }
  }
}

signed main(){
  cin>>n>>m;int s;
  rep(i,m){
    int a, b;cin>>a>>b;a--;b--;s = a;
    g[a].push_back(b);g[b].push_back(a);
  }
  ans.push_back(s);inc[s] = true;
  dfs(g[s][0], false);
  dfs(s, true);
  cout << ans.size() << endl;
  rep(i,ans.size())cout << ans[i]+1 << (ans.size()-1 == i ? "\n" : " ");
}


Measured memory_bytes: 79360
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(f) printf("%lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
int D[15];
int main(){
  int N,K,i,Di,flag,tmp;
  scanf("%d %d",&N,&K);
  FOR(K){
    scanf("%d",&Di);
    D[Di]=1;
  }
  for(i=N;;i++){
    flag=1;
    tmp=i;
    while(tmp>0){
      if(D[tmp%10]){
        flag=0;
        break;
      }
      tmp/=10;
    }
    if(flag){
      PRN(i);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	int n;cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	if(a[0]!=0){
		cout<<"-1\n";
		return 0;
	}
	ll ret=a[n-1];
	for(int i=n-1;i>0;i--){
		if(a[i-1]>=a[i])ret+=a[i-1];
		else if(a[i-1]!=a[i]-1){
			cout<<"-1\n";
			return 0;
		}	
	}
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    vector<int> a(5, 0);
    int ans = 0, b;
    for(int i = 0; i < 5; i++){
        cin >> b;
        if(b % 10 != 0) a[i] += 10 - (b % 10);
        ans += b + a[i];
    }
    sort(a.begin(), a.end());
    cout << ans - a[4] << endl;
    return 0;
}

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

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};
int main(){
    int H,W; cin>>H>>W;
    vector<vector<char>>a(H,vector<char>(W));
    int cnt=0;
    rep(i,H){
        rep(j,W){
            cin>>a[i][j];
            if(a[i][j]=='#')cnt++;
        }
    }
    vector<vector<int>>dist(H,vector<int>(W,-1));
    dist[0][0]=0;
    queue<pair<int,int>>q;
    q.push(make_pair(0,0));
    while(!q.empty()){
        int y=q.front().first,x=q.front().second;
        q.pop();
        rep(k,4){
            int ny=y+dy[k];
            int nx=x+dx[k];
            if(ny<0||nx<0||ny>=H||nx>=W)continue;
            if(dist[ny][nx]!=-1)continue;
            if(a[ny][nx]=='#')continue;
            q.push(make_pair(ny,nx));
            dist[ny][nx]=dist[y][x]+1;
        }
    }
    if(dist[H-1][W-1]==-1){
        cout<<-1<<endl;
        return 0;
    }
    int mn=dist[H-1][W-1];
    //cout<<mn<<" "<<cnt<<endl;
    int ans =H*W-mn-cnt-1;
    cout<<ans<<endl;
}


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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	ll n;
	in n;
	vector<ll> P(n);
	ll count = 0;
	ll min = INF;
	rep(i, n)
	{
		in P.at(i);
		if (min > P.at(i))
		{
			count++;
			min = P.at(i);
		}
	}
	out count en;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dbg
#define dprintf      printf
#define dout(x)      printf(#x" = %d\n",(x))
#define dary(x,n)    {int i;for(i=0;i<(n);i++)printf(#x"[%d] = %d\n",i,*((x)+i));}
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#else
#define dbg          (1)?0:
#define dprintf      (1)?0:printf
#define dout(x)
#define dary(x,n)
#define dloop(i,s,g) if(0)
#define drep(i,n)    if(0)
#define dary(x,n)
#endif

#define INF  (0x7fffffff)
#define LINF (0x7fffffffffffffff)

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())

//#define int long long;
typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

signed main(void)
{
  char a[BUFSIZ]={};
  char b[BUFSIZ]={};
  int i=-1;
  int n;
  char g[]="GREATER";
  char l[]="LESS";
  char e[]="EQUAL";

  scanf("%s %s",a,b);
  int alen=strlen(a);
  int blen=strlen(b);
  if(alen<blen)
    puts(l);
  else if(alen>blen)
    puts(g);
  else
    {
      n=max(alen,blen);
      rep(i,n)
	{
	  if(a[i]>b[i])
	    {
	      puts(g);
	      break;
	    }
	  else if(a[i]<b[i])
	    {
	      puts(l);
	      break;
	    }
	}
    }
  if(i==n)
    puts(e);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int H,W;
cin >> H >> W;
vector<string> a(H);
rep(h,H) cin >> a[h];

rep(w,W+2) cout << '#';
cout << "\n" ;
rep(h,H) cout << '#' << a[h] << '#' << endl;
rep(w,W+2) cout << '#';
cout << "\n" ;

return 0;
}

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

int main(){
	/*
	int a,b,c,d,e;

	cin >> a >> b >> c >> d >> e;

	int x;

	if(a > 0){
		x = e*(b-a);
	}
	if(a == 0){
		x = e*b + d;
	}
	if(a < 0){
		x = -c*a + e*b + d;
	}

	cout << x <<endl;
	*/

	/*
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	int m,n;
	int x = a + b + c + d + e + f;


	
	if(e<f)
	{
		x = x - e;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	else
	{
		x = x - f;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	*/
/*
	int n;
	cin >> n;
	int a;
	cin >> a;
	int max = a,min = a;
	int i = 1;
	while(i<n){
		cin >> a;
		if(a > max){
			max = a;
		}
		if(a < min){
			min = a;
		}
		i++;
	}
	cout << max << endl << min << endl;
	*/
	/*
	string s;
	cin >> s;
	int j,o,i;
	for(int i;i < s.size;i++){
		
	}
	*/
	/*
	int n;
	cin >> n;
	int A;
	int X[100000];
	int n=0;
	for(int i=0;i<n;i++){
		cin >> A;
		
	}
	*/

	int a,b,c,d,p;
	cin >> a >> b >> c >> d >> p;
	int X,Y=b;

	X = a*p;
	
	if(p>c){
		Y += d*(p-c);
	}

	if(X > Y){
		cout << Y << endl;
	}
	else{
		cout << X << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <math.h>

int main() {
    
    double r;
    
    std::cin >> r;
    
    std::cout << std::fixed;
    std::cout << std::setprecision(6) << M_PI * r * r << " " << 2 * M_PI * r << "\n";
    return 0;
}



Measured memory_bytes: 3292
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll X; cin >> X;
  ll ans = X / 500 * 1000;
  X %= 500;
  ans += X / 5 * 5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((V).begin(), (V).end())
#define RSORT(v) sort((V).rbegin(), (V).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (V.erase(remove((V).begin(), (V).end(), (a)), (V).end()))
#define REVERSE(v) (reverse((V).begin(), (V).end()))
#define LOWER_BOUND(v,a) (lower_bound((V).begin(), (V).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((V).begin(), (V).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	int n;
	cin >> n;
	int a = n;
	int sum = 0;
	while (a != 0)
	{
		sum += a % 10;
		a /= 10;
	}
	if (n % sum == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math/big"
	"os"
	"sort"
	"strconv"
)

func main() {
	a := readi64()
	b := readf()
	// https://twitter.com/kyopro_friends/status/1267095064804638720
	// 誤差が出たら嫌な問題はできるだけ整数の範囲で計算するのがよくて、
	// 今回はA×(B×100)/100みたいに計算すればいいんだけど、B×100を整数に変換するときの誤差にも気をつけないとダメだね。
	// 例えばB=2.51のとき、B×100=250.999999999999971…になるよー
	B := big.NewInt(int64(b*100 + 0.001))

	A := big.NewInt(a)
	A.Mul(A, B)
	A.Div(A, big.NewInt(100))
	fmt.Println(A)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

// func searchInts(a []int, k int) int {
// 	return binarySearch(len(a), func(i int) bool {
// 		return a[i] >= k
// 	})
// }

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1916
#include<stdio.h>

int main()
{
	int l,r;
	long long i,j;
	scanf("%d%d",&l,&r);
	if (r-l>2019) printf("0\n");
	else {
		int mm=2019;
		for (i=l;i<=r;i++)
		for (j=i+1;j<=r;j++) {
			int tt=(i*j)%2019;
			if (tt<mm) mm=tt;
		}
		printf("%d\n",mm);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int n,q,i;
  int cnt = 0;

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

  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;++i)
    scanf("%d",&T[i]);
  
  for(i=0;i<q;++i){
    int left = 0;
    int right = n;
    while(left<right){
      int center = (left+right)/2;
      if(S[center]==T[i]){
	cnt++;
	break;
      }
      else if(S[center]>T[i]){
	right = center;
      }
      else{
	left = center+1;
      }
    } 
  }
  printf("%d\n",cnt);
  
  return 0;
}



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

int main(){
    int n,m;
    cin >> n >> m;
    int res = -1;
    int s[m];
    char c[m];
    for(int j =0; j < m; j++){
        cin >> s[j] >> c[j];
    }
    if(n==1){
        for(int i = 0; i < 10; i++){ //0出てくるとうまくいかん
            string number = to_string(i);
            bool p = true;
            for(int j =0; j < m; j++){
                if(number.at(s[j]-1) != c[j]){
                    p =false;
                    break;
                }
            }
            if(p){
                res = i;
                break;
            }
        }
    }
    else{
        for(int i =pow(10,n-1); i < pow(10, n); i++){ //0出てくるとうまくいかん
            string number = to_string(i);
            bool p = true;
            for(int j =0; j < m; j++){
                if(number.at(s[j]-1) != c[j]){
                    p =false;
                    break;
                }
            }
            if(p){
                res = i;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main () {
    int n;
    cin >> n;
    call(n);
}


Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    long long n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    for (int k = 0; k < n; k++) {
        long long ub = a + d * k - c * (n - k - 1);
        long long lb = a + c * k - d * (n - k - 1);
        if (lb <= b && b <= ub) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  scc_graph scc(n);
  rep(i, m) {
    int a, b; cin >> a >> b;
    scc.add_edge(a, b);
  }
  auto ret = scc.scc();
  cout << ret.size() << endk;
  for(auto group: ret) {
    cout << group.size() << ' ';
    for(auto v: group) cout << v << ' ';
    cout << endk;
  }
  return 0;
}


Measured memory_bytes: 40628
a, b, c = map(int, input().split())

ans = 0

# まずは毒入りクッキーを食べきる
eat = min(b, c)
b -= eat
c -= eat
ans += 2 * eat

# 残った枚数に応じて食べ方が違う
if b == 0:
    if a >= c - 1:
        ans += c
    else:
        ans += a+1
else:
    ans += b

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	string s;
	cin>>s;
	int t;
	int q;
	deque<char> de;
	forn(i,s.size())de.pb(s[i]);
	int cnt=0;
	cin>>q;
	while(q--)
	{
		int f;
		char c;
		cin>>t;
		if(t==2){
			cin>>f>>c;
			if(cnt%2==0)
			{
				if(f==1)de.push_front(c);
				else de.pb(c);
			}
			else
			{
				if(f==1)de.pb(c);
				else de.push_front(c);
			}
		}
		else cnt++;
	}
	string str;
	for(auto i:de)
	{
		str+=i;
	}
	if(cnt%2==0)
	{
	cout<<str;

	}
	else
	{
		reverse(str.begin(),str.end());
		cout<<str;

	}
	
	return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main()
{
    std::string str;
    int num;
    int a;

    cin >> num;
    
    str = to_string(num);
    a = str.find("7");
    if (a < 0)
        cout << "No\n";
    else
        cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3704
//12:25 13:24 13:30
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define mp make_pair
#define pb pushback

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vp;

typedef long long ll;

int dx[4] = {1, 0, 0, 0};
int dy[4] = {1, 2, 1, 0};
int mx[4] = {1, 0, -1, 0};
int my[4] = {0, 1, 0, -1};
int ss[80][40];



int main() {

    while(1){
        int w,h;
        int ss[80][40];
        cin >> w >> h;
        if(w==0)break;
        rep(j,h*2){
            rep(i,w){
                if(j==0){
                    rep(s,w){
                        ss[0][s] = 1;
                        ss[h*2][s] = 1;
                    }
                    continue;
                }
                if(j%2==1){
                    if(i==0){
                        ss[j][0] = 1;
                        ss[j][w] = 1;
                        continue;
                    }
                }
                cin >> ss[j][i];

            }
        }
        /*
        cout << "debug roop " << endl;
        rep(j,h*2+1){
            if(j%2==0){
                cout << " ";
            }
            rep(i,w+1){
                if(j%2==0){
                    if(i==w){
                        break;
                    }
                }
                cout << ss[j][i] << " ";
            }
            cout << endl;
        }*/
        //??????????????¢?´¢
        
        queue<int> x;
        queue<int> y;
        queue<int> res;
        x.push(0);
        y.push(0);
        res.push(0);
        int resres;
        while(1){
            int xx = x.front();
            int yy = y.front();
            resres = res.front();
            // cout << "debug xx,yy"<<xx<<","<<yy<<endl;
            x.pop();
            y.pop();
            res.pop();
            if(xx==w-1 && yy==h-1){
                break;
            }
            //dsaw
            rep(i,4){
                // cout<<"de:"<<ss[yy*2+dy[i]][xx+dx[i]]<<endl;
                if(ss[yy*2+dy[i]][xx+dx[i]] == 0){
                    x.push(xx+mx[i]);
                    y.push(yy+my[i]);
                    res.push(resres+1);
                    ss[yy*2+dy[i]][xx+dx[i]] = 1;
                };
            }
            if(x.empty()==1){
                resres = -1;
                break;
            }
        }
        cout << resres+1 << endl;
    }



    return 0;
}

Measured memory_bytes: 3120