akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>


const int GCM(const int a,const int b){
	int x(a),y(b);
	while(x%=y){
		std::swap(x,y);
	}
	return y;
}

const int LCM(const int a,const int b){
	int x(a),y(b);
	while(x%=y){
		std::swap(x,y);
	}
	int tmp(a/y);
	tmp*=b;
	return tmp;
}


int main(int,char**){
	int a,b;
	while(std::cin >>a){
		std::cin >> b;
		std::cout << GCM(a,b) << ' ' << LCM(a,b)<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int Euler_Phi(int n){
      int res = n;
      for(int i=2; i*i <= n;  i++){
            if(n%i == 0) {
                  res  = res / i * (i-1);
                  for(; n%i == 0 ; n /= i);
            }
      }
      if(n!=1) res = res / n * (n-1);
      return res;
 
}
 
int main(){
      int n; cin >> n;
      cout << Euler_Phi(n) << endl;
 
}

Measured memory_bytes: 3100
n = int(input())
b = list(map(int, input().split()))
removed = []

while len(b) > 0:
    for i, v in zip(b[::-1], range(len(b), 0, -1)):
        if i == v:
            removed.append(b.pop(i - 1))
            break
    else:
        removed = [-1]
        break

for r in removed[::-1]:
    print(r)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - 1 - i])
      cnt++;
  }
  cout << cnt << endl;
}

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

ss = input()
#print(ss)

s = []
for i in range(len(ss)):
    s.append(int(ss[i]))
#print(s)

if len(s)%2 == 0:
    s0 = [0,1] *(len(s)//2)
    s1 = [1,0] *(len(s)//2)
else:
    s0 = [0,1] *(len(s)//2)
    s0.append(0)
    s1 = [1,0] *(len(s)//2)
    s1.append(1)

#print(s0)
#print(s1)

sum0 = 0
sum1 = 0
for i in range(len(s)):
    
    if s0[i] != s[i]:
        #print(s0[i] , s[i])
        sum0 = sum0 +1

    if s1[i] != s[i]:
        #print(s1[i] , s[i])
        sum1 = sum1 +1

ans = min(sum0, sum1)
print(ans)


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=1000000;
const ll inf=1e18;
const ll mod=1e9+7;

int main()
{
    FasterIO;
    ll n, m, a, b;
    cin>>a>>b;
    for(int i=1; i<=10000000; i++)
    {
        ll x=i;
        if(floor(x*0.08)==a && floor(x*0.1)==b)
        {
            cout<<x<<endl; return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int n;
    int x, y, h, w;
    int sum;
    int i;

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }

        sum = 0;
        for (i = 0; i < n; i++){
            scanf("%d %d %d %d", &x, &y, &h, &w);
            if (x + y + h <= 60 && w <= 2){
                sum += 600;
            }
            else if (x + y + h <= 80 && w <= 5){
                sum += 800;
            }
            else if (x + y + h <= 100 && w <= 10){
                sum += 1000;
            }
            else if (x + y + h <= 120 && w <= 15){
                sum += 1200;
            }
            else if (x + y + h <= 140 && w <= 20){
                sum += 1400;
            }
            else if (x + y + h <= 160 && w <= 25){
                sum += 1600;
            }
        }
        printf("%d\n", sum);
    }

    return (0);
}

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

int factorial(int n) {
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  vector<vector<double>> s(n, vector<double>(n));
  rep(i, n) {
    rep(j, n) {
      s[i][j] = sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
    }
  }
  
  vector<int> v(n);
  rep(i, n) v[i] = i;
  double sum = 0;
  do {
    rep(i, n-1) {
      sum += s[v[i]][v[i+1]];
    }
  } while (next_permutation(v.begin(), v.end()));
  
  printf("%0.9lf\n", sum / factorial(n));
  
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  if(k>17){
    cout << 0 << endl;
    return 0;
  }
  vector<vector<LL>> dp(n+1,vector<LL>(18,0));
  dp[1][1]=1;
  for(int i=2;i<=n;i++){
    dp[i][1]=1;
    for(int l=2;l<18;l++){
      dp[i][l]+=dp[1][l-1];
    }
    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){
        for(int l=2;l<18;l++){
          dp[i][l]+=dp[i/j][l-1];
          if(i/j!=j) dp[i][l]+=dp[j][l-1];
        }
      }
    }
  }
  LL ans=0;
  for(int i=1;i<=n;i++){
    ans+=dp[i][k];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 20808
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	float ss=0.0;
	for(int i=1;i<=a;i++)
	{
		int s;
		cin>>s;
		ss+=1.0/s;
	}
	ss=1.0/ss;
	cout<<ss;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=998244353;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}
 
int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
 
const int N=500002;

vector<int>fc,inv;

int nCr(int n,int r){
  if(n<r){
    return 0;
  }
  return mul(mul(fc[n],inv[r]),inv[n-r]);
}

void prec(int n){
  fc.resize(n);
  inv.resize(n);
  fc[0]=1;
  for(int i=1;i<n;i++){
    fc[i]=mul(fc[i-1],i);
  }
  inv[n-1]=powz(fc[n-1],mod-2);
  for(int i=n-2;i>=0;i--){
    inv[i]=mul(inv[i+1],i+1);
  }
}

void solve(){
  prec(5000);
  int k,n;
  cin>>k>>n;
  for(int i=2;i<=2*k;i++){
    int sm=i;
    int ans=0;
    if(i%2==0){
      int val=0;
      int rem=0;
      set<pii>st;
      for(int j=1;j<=k;j++){
	if((i-j)<=k&&(i-j)>=1){
	  st.insert({min(i-j,j),max(i-j,j)});
	}
      }
      st.erase({i/2,i/2});
      rem=st.size();
      val=st.size();
      for(int used=0;used<=val;used++){
	int tot=k-rem*2-1;
	int left=tot+used;
	int times=n-used;
	add(ans,mul(mul(nCr(val,used),powz(2,used)),nCr(left+times-1,left-1)));
	if(times>0){
	  add(ans,mul(mul(nCr(val,used),powz(2,used)),nCr(left+times-2,left-1)));
	}
       }
    }
    else{
      int val=0;
      int rem=0;
      set<pii>st;
      for(int j=1;j<=k;j++){
	if((i-j)<=k&&(i-j)>=1){
	  st.insert({min(i-j,j),max(i-j,j)});
	}
      }
      rem=st.size();
      val=st.size();
      for(int used=0;used<=val;used++){
	int tot=k-rem*2;
	int left=tot+used;
	int times=n-used;
	add(ans,mul(mul(nCr(val,used),powz(2,used)),nCr(left+times-1,left-1)));
      }
    }
    cout<<ans<<'\n';
  }
  
  
}
 
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), h = in.ni(), w = in.ni();
        out.println((n-h+1)*(n-w+1));
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

 public static void main(String[] args) {
  Scanner no=new Scanner(System.in);
  String s=no.next();
  int y=s.length()-1;
  int i=y;
  for(i=y;i>=0;i--){
    if(s.charAt(i)=='m'){
      if(i-4<0){
        System.out.println("NO");
      }
      else{
       String r=s.substring(i-4,i+1);
       if(r.equals("dream")){
        i=i-4;
       }
       else{
        System.out.println("NO");
        break;
       }
      }
    }
    else if(s.charAt(i)=='e'){
     if(i-4<0){
       System.out.println("NO");
     }
     else{
      String r=s.substring(i-4,i+1);
      if(r.equals("erase")){
        i=i-4;
      }
     }
    }
    else if(s.charAt(i)=='r'){
     boolean t=false;
     boolean t1=false;
     String r="";
     String r1="";
     if(i-6>=0){
      r=s.substring(i-6,i+1);
      t=true;
     }
     if(i-5>=0){
      r1=s.substring(i-5,i+1);
      t1=true;
     }
      if(t==true&&r.equals("dreamer")){
        i=i-6;
      }
      else if(t1==true&&r1.equals("eraser")){
        i=i-5;
      }
      else{
        System.out.println("NO");
        break;
      }
    }
    else{
      System.out.println("NO");
      break;
    }
  }
  //System.out.println(i);
  if(i==-1){
    System.out.println("YES");
  }
 }

}


Measured memory_bytes: 40240
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=1000000000000000003;
const int32_t LOG=21;
const int MOD=MOD1;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {  
            int n,x,y;
            cin>>n>>x>>y;
            int ans[n+1]={0};
            rep(i,1,n+1)
            {
            	rep(j,i+1,n+1)
            	{
            		int dist1=(abs(i-x)+1+abs(j-y));
            		int dist2=(abs(i-y)+1+abs(j-x));
            		int dist3=j-i;
            		int dist=min({dist1,dist2,dist3});
            		ans[dist]++;	
            	}
            }
            rep(i,1,n)cout<<ans[i]<<endl;
        
      }

      return 0;     
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF 1000000000
using namespace std;

int MAX(int a,int b,int c){
    return max(max(a,b),max(b,c));
}

int maxHappiness(vector<vector<int>>& v, int index,int notChoose,vector<vector<int>>&m){
    
    if(m[index][notChoose]!=-1){
        return m[index][notChoose];
    }
    
    if(index==0){
        if(notChoose==3){
            return m[index][notChoose] =  MAX(v[index][0],v[index][1],v[index][2]);
        }
        else{
            if(notChoose==0){
                return m[index][notChoose] =  max(v[index][1],v[index][2]);
            }
            else if(notChoose == 1){
                return m[index][notChoose] =  max(v[index][0],v[index][2]);
            }
            else if(notChoose == 2){
                return m[index][notChoose] =  max(v[index][1],v[index][0]);
            }
        }
        
    }
    else{
        if(notChoose == 3){
            int a = v[index][0] + maxHappiness(v,index-1,0,m);
            int b = v[index][1] + maxHappiness(v,index-1,1,m);
            int c = v[index][2] + maxHappiness(v,index-1,2,m);
            return m[index][notChoose] =  MAX(a,b,c);
        }
        else{
            if(notChoose==0){
                int b = v[index][1] + maxHappiness(v,index-1,1,m);
                int c = v[index][2] + maxHappiness(v,index-1,2,m);
                return m[index][notChoose] =  max(b,c);
            }
            else if(notChoose==1){
                int a = v[index][0] + maxHappiness(v,index-1,0,m);
                int c = v[index][2] + maxHappiness(v,index-1,2,m);
                return m[index][notChoose] =  max(a,c);
            }
            else if(notChoose==2){
                int a = v[index][0] + maxHappiness(v,index-1,0,m);
                int b = v[index][1] + maxHappiness(v,index-1,1,m);
                return m[index][notChoose] =  max(a,b);
            }
        }
        
    }
}

int32_t main(){
    int n;
    cin>>n;
    vector<vector<int>> happ;
    for(int i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        vector<int> x;
        x.push_back(a);
        x.push_back(b);
        x.push_back(c);
        happ.push_back(x);
    } 

    vector<vector<int>> maxHappy;
    for(int i=0;i<n;i++){
        vector<int> x;
        for(int i=0;i<4;i++){
            x.push_back(-1);
        }
        maxHappy.push_back(x);
    }
    
    cout<<maxHappiness(happ,happ.size()-1,3,maxHappy);

    return 0;
}

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

int main() {
  int x, y, A, B, C;
  cin >> x >> y >> A >> B >> C;
  vector<int> Red(A), Green(B), Non(C);
  for (int &e : Red) cin >> e;
  for (int &e : Green) cin >> e;
  for (int &e : Non) cin >> e;
  sort(Red.begin(),Red.end(),greater<int>());
  sort(Green.begin(),Green.end(),greater<int>());
  sort(Non.begin(),Non.end(),greater<int>());
  long long ans = 0;
  priority_queue<int,vector<int>,greater<int>> eat;
  for (int i = 0; i < x; i++) {
    ans += Red[i];
    eat.push(Red[i]);
  }
  for (int i = 0; i < y; i++) {
    ans += Green[i];
    eat.push(Green[i]);
  }
  for (int i = 0 ; i < C; i++) {
    if (eat.top() > Non[i]) break;
    ans += Non[i]-eat.top();
    eat.pop();
    eat.push(Non[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5472
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  long long y;
  cin >> n >> y;


  long long y_1000 = y / 1000;

  bool dp[n + 1][y_1000 + 1];

  for (long long k = 0; k < n + 1; ++k) {
    for (long long i = 0; i < y_1000 + 1; ++i) {
      dp[k][i] = false;
    }
  }

  const int ten_thousand_yen = 2;
  const int five_thousand_yen = 1;
  const int thousand_yen = 0;

  int ans_table[n + 1][y_1000 + 1];

  for (long long l = 0; l < n + 1; ++l) {
    for (long long i = 0; i < y_1000 + 1; ++i) {
      ans_table[l][i] = -1;
    }
  }

  dp[0][0] = true;

  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= y_1000; ++j) {
      if (j >= 10 && dp[i - 1][j - 10]) {
        dp[i][j] = true;
        ans_table[i][j] = ten_thousand_yen;
      } else if (j >= 5 && dp[i-1][j-5]) {
        dp[i][j] = true;
        ans_table[i][j] = five_thousand_yen;
      } else if (j >= 1 && dp[i-1][j-1]) {
        dp[i][j] = true;
        ans_table[i][j] = thousand_yen;
      } else {
        dp[i][j] = false;
      }
    }
  }

//  for (int k = 0; k < n + 1; ++k) {
//    for (long long i = 0; i < y_1000 + 1; ++i) {
//      cout << dp[k][i];
//    }
//    cout << endl;
//  }

  if (!dp[n][y_1000]) {
    cout << "-1 -1 -1" << endl;
  } else {
    int ans[3] = {0, 0, 0};
    long long ans_b = n;
    long long ans_y = y_1000;
    while (ans_b > 0) {
      int choice = ans_table[ans_b][ans_y];
      if (choice == ten_thousand_yen) {
        ans[0]++;
        ans_y -= 10;
      } else if (choice == five_thousand_yen) {
        ans[1]++;
        ans_y -= 5;
      } else {
        ans[2]++;
        ans_y--;
      }
      ans_b--;
    }

    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
  }

  return 0;
}

Measured memory_bytes: 195712
#include <bits/stdc++.h>
 #include <string> 
 #include <math.h>
 #include <bitset>
 using namespace std;

 int main(){
    string S;
    bool   result = true;
    cin >> S;

    for (int i=0; i < S.size(); i++){
        if ((i+1)%2==0){
            if (S[i]=='R')
                result = false;
        }
        else{
            if (S[i]=='L')
                result = false;
        }
        if (result == false)
            break;
    }

    if (result == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;        
        
    return 0;
 }



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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

typedef unsigned int uint;
typedef long long ll;
typedef pair<int,int> pii;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

char p[500][501],r[500][501],b[500][501];

int main(){
	int h=read(),w=read();
	REP(i,h)REP(j,w)r[i][j]=b[i][j]='.';
	REP(j,w)r[0][j]='#';
	REP(i,h-1)
		for(int j=0;j<w;j+=2)
			r[i][j]='#';
	REP(j,w)b[h-1][j]='#';
	FOR(i,1,h)
		for(int j=1;j<w;j+=2)
			b[i][j]='#';
	REP(i,h){
		scanf("%s",p[i]);
		REP(j,w)if(p[i][j]=='#')
			r[i][j]=b[i][j]='#';
	}
	REP(i,h)
		printf("%s\n",r[i]);
	printf("\n");
	REP(i,h)
		printf("%s\n",b[i]);
}


Measured memory_bytes: 1408
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(n: number) {
  let a = [];
  for (let i = 0; i < n; i++) a.push(i);
  return a;
}
function Main({ int, str, strs, ints }: NormalInput) {
  const [K, N] = ints(2);
  const A = ints(N);
  let min = A[N - 1] - A[0];
  rep(N - 1).forEach(i => {
    min = Math.min(min, K - A[i + 1] + A[i]);
  });
  console.log(min);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 40936
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 100000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,M;
    int A[114514],B[114514];
    vector<int> V[114514];
    vector<int> Sum,Ans;
    cin >> N >> M;
    REP(i,M){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        V[A[i]].push_back(B[i]);
        V[B[i]].push_back(A[i]);
    }
    bool cont[114514]={};
    REP(i,114514){cont[i]=false;}
    
    Sum.push_back(A[0]);
    Sum.push_back(B[0]);
    cont[A[0]]=true;
    cont[B[0]]=true;
   
    
    while(1){
        int E=Sum.size();
        bool c=true;
        REP(i,V[Sum[E-1]].size()){
            if(cont[V[Sum[E-1]][i]]==false){
                c=false;
                Sum.push_back(V[Sum[E-1]][i]);
                cont[V[Sum[E-1]][i]]=true;
                break;
            }
        }
        if(c==true){
            break;
        }
    }
    int E=Sum.size();
    REP(i,E){
        Ans.push_back(Sum[E-1-i]);
    }
    
    while(1){
        int E=Ans.size();
        bool c=true;
        REP(i,V[Ans[E-1]].size()){
            if(cont[V[Ans[E-1]][i]]==false){
                c=false;
                Ans.push_back(V[Ans[E-1]][i]);
                cont[V[Ans[E-1]][i]]=true;
                break;
            }
        }
        if(c==true){
            break;
        }
    }
    
    cout << Ans.size() << endl;
    REP(i,Ans.size()){
        if(i!=0)cout << " ";
        cout << Ans[i]+1;
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 9332
import scala.io.StdIn.readLine
object Main {
    def main(args: Array[String]): Unit = {
        readLine.split(" ").map(_.toInt) match {
            case Array(a, b) =>  if (a > b){
                    println("a > b")
                } else if (a < b) {
                    println("a < b")
                } else {
                    println("a == b")
                }
        }
    }
}


Measured memory_bytes: 43904
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int masu[] = new int[n];
		int count = 1;
		int countMax = 0;
		for(int i = 0; i < n; i++) {
			if(sc.nextInt() == 1) count++;
			else {
				countMax = Math.max(countMax, count);
				count = 1;
			}

			if(i == n - 1) countMax = Math.max(countMax, count);
		}
		System.out.println(countMax);
	}

}


Measured memory_bytes: 26484
#pragma GCC optimize("O3")
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using pii = pair<int,int>;
using ll = long long;

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

    int N, M, Q;
    int cum[505][505] {};

    cin >> N >> M >> Q;
    rep(i, M) {
        int l, r;
        cin >> l >> r;
        ++cum[l][r];
    }

    for(int i=1; i<=N; ++i) {
        for (int j=1; j<=N; ++j) {
            cum[i][j] += cum[i-1][j] + cum[i][j-1] - cum[i-1][j-1];
        }
    }


    while (Q--) {
        int l, r;
        cin >> l >> r;
        outl(cum[r][r] - cum[r][l-1] - cum[l-1][r] + cum[l-1][l-1]);
    }

    return 0;
}



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

const int N = 10010;

typedef long long LL;

int flag[N], prime[N], pcnt;

inline void sieve() {
    for (int i = 2; i <= N - 10; i++) {
        if (!flag[i]) prime[++pcnt] = i;
        for (int j = 1; j <= pcnt && i * prime[j] <= N - 10; j++) {
            flag[i * prime[j]] = 1;
            if (i % prime[j] == 0) break;
        }
    }
}

LL G[510][510];

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

inline LL lcm(LL a, LL b) {
    return a / gcd(a, b) * b;
}

template<typename... T>
inline LL lcm(LL a, T... b) {
    LL t = lcm(b...);
    return a / gcd(a, t) * t;
}

int main() {
    int n; scanf("%d", &n), sieve();
    if (n == 2) return puts("4 7\n23 10"), 0;
    for (int i = 0; i <= n + 1; i++)
        for (int j = 0; j <= n + 1; j++) G[i][j] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) if ((i + j) & 1) {
            int a = i + j, b = i - j; a = (a - 1) / 2, b = (b + n + 1) / 2;
            G[i][j] = (LL)prime[a] * prime[b + n - 1];
        }
    for (int i = 1; i <= n; i++, puts(""))
        for (int j = 1; j <= n; j++) {
            if (!((i + j) & 1)) G[i][j] = (LL)lcm(G[i - 1][j], G[i][j - 1], G[i + 1][j], G[i][j + 1]) + 1;
            printf("%lld ", G[i][j]);
        }
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  N -= K;
  ans = N / (M + K);
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M >> K;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

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

int main(){
    int n;cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(to_string(i).length()%2==1){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    for(int i=0; i<M; i++){
        int k;
        cin >> k;
        s[i].resize(k);
        for(int j=0; j<k; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(M);
    for(int i=0; i<M; i++)
        cin >> p[i];

    int ans = 0;
    for(int i=0; i<(1<<N); i++){
        bool ok = true;
        for(int j=0; j<M; j++){
            int sz = s[j].size();
            int cnt = 0;
            for(int k=0; k<sz; k++){
                int l = s[j][k];
                cnt += (i >> l) & 1;
            }
            if(cnt % 2 != p[j]){
                ok = false;
                break;
            }
        }
        if(ok)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int 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; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << " " << 2*a+2*b << endl;
    return 0;
}


Measured memory_bytes: 3012
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int  h,w;
    cin >> h >> w;
    vector<vector<char>> img;
    for (int i = 0; i < h;i++) {
        vector<char> vec;
        for (int j = 0; j < w;j++) {
            char c;
            cin >> c;
            vec.push_back(c);
        }
        img.push_back(vec);
        img.push_back(vec);
    }

    for (int i = 0; i < 2 * h;i++) {
        for (int j = 0; j < w;j++) {
            cout << img[i][j];
        }
        cout << endl;

    }
    return 0;
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char str;
	int acounter=0,bcounter=0,ccounter=0,dcounter=0,ecounter=0,fcounter=0,gcounter=0,hcounter=0;
	int icounter=0,jcounter=0,kcounter=0,lcounter=0,mcounter=0,ncounter=0,ocounter=0,pcounter=0;
	int qcounter=0,rcounter=0,scounter=0,tcounter=0,ucounter=0,vcounter=0,wcounter=0,xcounter=0;
	int ycounter=0,zcounter=0;

	while(scanf("%c",&str)!=EOF){
		if(str=='a' || str=='A'){
			acounter++;
		}else if(str=='b' || str=='B'){
			bcounter++;
		}else if(str=='c' || str=='C'){
			ccounter++;
		}else if(str=='d' || str=='D'){
			dcounter++;
		}else if(str=='e' || str=='E'){
			ecounter++;
		}else if(str=='f' || str=='F'){
			fcounter++;
		}else if(str=='g' || str=='G'){
			gcounter++;
		}else if(str=='h' || str=='H'){
			hcounter++;
		}else if(str=='i' || str=='I'){
			icounter++;
		}else if(str=='j' || str=='J'){
			jcounter++;
		}else if(str=='k' || str=='K'){
			kcounter++;
		}else if(str=='l' || str=='L'){
			lcounter++;
		}else if(str=='m' || str=='M'){
			mcounter++;
		}else if(str=='n' || str=='N'){
			ncounter++;
		}else if(str=='o' || str=='O'){
			ocounter++;
		}else if(str=='p' || str=='P'){
			pcounter++;
		}else if(str=='q' || str=='Q'){
			qcounter++;
		}else if(str=='r' || str=='R'){
			rcounter++;
		}else if(str=='s' || str=='S'){
			scounter++;
		}else if(str=='t' || str=='T'){
			tcounter++;
		}else if(str=='u' || str=='U'){
			ucounter++;
		}else if(str=='v' || str=='V'){
			vcounter++;
		}else if(str=='w' || str=='W'){
			wcounter++;
		}else if(str=='x' || str=='X'){
			xcounter++;
		}else if(str=='y' || str=='Y'){
			ycounter++;
		}else if(str=='z' || str=='Z'){
			zcounter++;
		}
	}

	printf("a : %d\n",acounter);
	printf("b : %d\n",bcounter);
	printf("c : %d\n",ccounter);
	printf("d : %d\n",dcounter);
	printf("e : %d\n",ecounter);
	printf("f : %d\n",fcounter);
	printf("g : %d\n",gcounter);
	printf("h : %d\n",hcounter);
	printf("i : %d\n",icounter);
	printf("j : %d\n",jcounter);
	printf("k : %d\n",kcounter);
	printf("l : %d\n",lcounter);
	printf("m : %d\n",mcounter);
	printf("n : %d\n",ncounter);
	printf("o : %d\n",ocounter);
	printf("p : %d\n",pcounter);
	printf("q : %d\n",qcounter);
	printf("r : %d\n",rcounter);
	printf("s : %d\n",scounter);
	printf("t : %d\n",tcounter);
	printf("u : %d\n",ucounter);
	printf("v : %d\n",vcounter);
	printf("w : %d\n",wcounter);
	printf("x : %d\n",xcounter);
	printf("y : %d\n",ycounter);
	printf("z : %d\n",zcounter);

	return 0;
}

Measured memory_bytes: 540
#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++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
vl v;



int main(){
	ll n,ans=0,tmp=1;
	cin>>n;
	REP(i,1,21){
		if(n==1)break;
		tmp*=3;
		ans=i;
		if(tmp>=n)break;
	}
	print(ans);
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

class UnionFind {
public:
    explicit UnionFind(int N) : root(N, -1), size(N, 1) {}
    int getRoot(int u){ return root[u] == -1 ? u : root[u] = getRoot(root[u]); }
    int getSize(int u){ return size[getRoot(u)]; }
    bool same(int a, int b){
        return getRoot(a) == getRoot(b);
    }
    bool merge(int a, int b){
        int u = getRoot(a);
        int v = getRoot(b);
        if(u == v) return false;
        root[u] = v;
        size[v] += size[u];
        return true;
    }
private:
    vector<int> root;
    vector<int> size;
};

int main(){
    int N; cin >> N;
    UnionFind uf(N);
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin >> P[i];
        if(P[i] != -1){
            --P[i];
            uf.merge(i, P[i]);
        }
    }
    vector<int> size;
    vector<int> checked(N, 0);
    for(int i=0;i<N;i++){
        if(P[i] == -1){
            int r = uf.getRoot(i);
            checked[r] = 1;
            size.push_back(uf.getSize(r));
        }
    }
    long long res = N;
    for(int i=0;i<N;i++){
        if(uf.getRoot(i) != i) continue;
        if(checked[i]) continue;
        --res;
    }
    for(int i=0;i<size.size();i++) res = (res * (N-1)) % MOD;
    vector<long long> dp(size.size()+1, 0);
    dp[0] = 1;
    for(auto& s : size){
        for(int i=dp.size()-1;i>0;i--){
            dp[i] = (dp[i] + dp[i-1] * s) % MOD;
        }
    }
    long long f = 1;
    for(int i=2;i<dp.size();i++){
        dp[i] = (dp[i] * f) % MOD;
        f = (f * i) % MOD;
    }
    dp[1] = 0;
    for(auto& s : size) dp[1] += s-1;
    long long m = 1;
    for(int i=dp.size()-1;i>0;i--){
        res = (res + MOD - dp[i] * m % MOD) % MOD;
        m = (m * (N-1)) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 3720
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int pop_count(int x) { return __builtin_popcount(x); }

struct L {
  int sw;
  int odd;
  L(): sw(0), odd(0) {}
  bool ok(int in_sw) const {
    int on = (sw&in_sw);
    return (pop_count(on)&1) == odd;
  }
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<L> ls(M);
  for(auto& l: ls) {
    int k; std::cin >> k;
    for(int i = 0; i < k; ++i) {
      int s; std::cin >> s; --s;
      l.sw |= (1<<s);
    }
  }
  for(auto& l: ls) std::cin >> l.odd;
  int ans = 0;
  for(int sw = 0; sw < (1<<N); ++sw) {
    bool ok = true;
    for(auto& l: ls) if(!l.ok(sw)) { ok = false; break; }
    if(ok) ++ans;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;

LL march[6];

int main()
{
	LL n,sum = 0;
	map <string, int> mp;
	map <string, int>::iterator iter;
	cin >> n;
	for(LL i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		mp[s] = 1;
	}
	for(iter = mp.begin(); iter != mp.end(); iter++)
	{
		string s = iter -> first;
		if(s[0] == 'M') march[1]++;
		else if(s[0] == 'A') march[2]++;
		else if(s[0] == 'R') march[3]++;
		else if(s[0] == 'C') march[4]++;
		else if(s[0] == 'H') march[5]++;
	}
	for(int j = 1; j <= 5; j++)
		if(march[j] > 0) sum++;
	if(sum < 3) cout << 0 << endl;
	else
	{
		double ans = 1;
		for(int j = 1; j <= 5; j++) if(march[j] > 0) ans *= march[j];
		if(sum == 3) printf("%.0f\n",ans);
		else if(sum == 4)
		{
			double num = 0;
			for(int j = 1; j <= 5; j++)
				if(march[j] > 0) num += (ans / march[j]);
			printf("%.0f\n",num);
		}
		else if(sum == 5)
		{
			double num = 0;
			for(int j = 1; j <= 4; j++)
			{
				for(int k = j + 1; k <= 5; k++)
					num += (ans / (march[j] * march[k]));
			}
			printf("%.0f\n",num);
		}
	}
	return 0;
}

Measured memory_bytes: 11648
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;


ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll N;
int main(){
    cin>>N;
    ll ans=(modpow(10,N,MOD)-modpow(9,N,MOD)+MOD)%MOD;
    ans=(ans-modpow(9,N,MOD)+MOD)%MOD;
    ans=(ans+modpow(8,N,MOD))%MOD;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#ifdef BIZON
	#define rr(x) cerr << "\e[1;38;5;172m" << #x << "\e[0m = " << (x) << endl;
#else
	#define rr(x)
	#define endl '\n'
#endif
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

struct dsu {
	vector<int> p, sz;
	dsu(int n): sz(n,1), p(n) {
		iota(ALL(p),0);
	}
	int get(int i){
		int v = i;
		while(v!=p[v]) v = p[v];
		while(i!=p[i]) i = exchange(p[i],v);
		return v;
	}
	bool unite(int i, int j){
		i = get(i);
		j = get(j);
		if(i==j) return false;
		if(sz[i]<sz[j]) swap(i,j);
		p[j] = i;
		sz[i]+=sz[j];
		return true;
	}
};

int main(){
	if(auto f="in.txt"; fopen(f,"r") && freopen(f,"r",stdin));
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(9);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	vector<pair<int,int>> p(n);
	for(int i=0;i<n;++i){
		int x,y;
		cin>>x>>y;
		--x; --y;
		p[x] = {y,i};
	}
	
	set<pair<int,int>> sy;
	for(int i=0;i<n;++i) sy.insert({p[i].first, i});
	
	int my = -1, mi = -1;
	dsu q(n);
	for(int k=n-1;k>=0;){
		rr(k)
		auto it = *begin(sy);
		int i = it.second;
		rr(i)
		
		if(my>p[i].first){
			q.unite(p[i].second, mi);
		}
		
		while(k>=i){
			if(p[k].first > my){
				my = p[k].first;
				mi = p[k].second;
			}
			q.unite(p[k].second, p[i].second);
			sy.erase({p[k].first, k});
			--k;
		}
	
	}
	
	
	for(int i=0;i<n;++i){
		int k = q.get(i);
		cout<<q.sz[k]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 15568
package main

import (
  "fmt"
)

var (
  a, b, c, d, e, k int
)

func main() {
  fmt.Scanf("%d", &a)
  fmt.Scanf("%d", &b)
  fmt.Scanf("%d", &c)
  fmt.Scanf("%d", &d)
  fmt.Scanf("%d", &e)
  fmt.Scanf("%d", &k)
  
  if (IsCommunicable(a, b, k) && IsCommunicable(a, c, k) && IsCommunicable(a, d, k) && IsCommunicable(a, e, k) && 
      IsCommunicable(b, c, k) && IsCommunicable(b, d, k) && IsCommunicable(b, e, k) &&
      IsCommunicable(c, d, k) && IsCommunicable(c, e, k) ) {
    fmt.Println("Yay!")
  } else {
    fmt.Println(":(")
  }
}

func IsCommunicable(i, j, k int) bool {
  if k < j - i {
    return false
  }
  return true
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int x[n], y[n], h[n];
    repi(i, n, 0)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    repi(cx, 101, 0)
    {
        repi(cy, 101, 0)
        {
            repi(i, n, 0)
            {
                int H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
                bool state = true;
                repi(j, n, 0)
                {
                    if (h[j] != max(0LL, H - abs(x[j] - cx) - abs(y[j] - cy)))
                    {
                        state = false;
                        break;
                    }
                }
                if (state && H > 0)
                {
                    cout << cx << " " << cy << " " << H << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
let m = 998244353
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)
let inv2 = power ( *^ ) 1 2 (m - 2)

let () = Scanf.scanf "%d %d\n" @@ fun n s ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let dp = Array.make (s + 1) 0 in
  dp.(0) <- power ( *^ ) 1 2 n;
  Array.iter (fun a ->
    for i = s downto a do
      dp.(i) <- dp.(i) +^ inv2 *^ dp.(i - a)
    done) as_;
  Printf.printf "%d\n" dp.(s)


Measured memory_bytes: 4584
#include<iostream>
using namespace std;
int main()
{
	string s;
	int n;
	cin>>n>>s;
	for(int i=0;i<s.size();i++)
	{
		char t = s[i];
		t = (t-'A'+n)%26+'A';
		s[i] = t;
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

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

typedef long long ll;
const ll MOD = ll(1e9 + 7);
const int MAX_N = int(3e5) + 5;
#define REP(i, n) for (int i = 0; i < n; i++)

ll factrial[MAX_N], inverse[MAX_N];

ll power(ll x, ll n) {
    ll ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}

void init(ll n) {
    factrial[0] = 1;
    inverse[0] = 1;
    for (ll i = 1; i <= n; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;
        inverse[i] = power(factrial[i], MOD - 2) % MOD;
    }
}

ll nCk(ll n, ll k) {
    if (n<0 || k<0 || n-k<0)return 0;
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

bool ck[MAX_N]{};
ll num[MAX_N];

int main() {
    ll n, a, x, y;
    cin >> n;
    n++;
    REP(i,n){
        cin >> a;
        if(!ck[a]){
            ck[a] = true;
            num[a] = i;
        }
        else{
            x = num[a];
            y = n-i-1;
        }
    }
    init(n);
    ll ans;
    for(ll k = 1;k<=n;k++){
        ans = nCk(n,k) - nCk(x+y,k-1) + MOD;
        cout << ans%MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n,ans = 0,ct = 1;
    cin >> n;
    
    vector<int>v(n);

    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        if(a == ct){
            ct++;
        }else{
            ans++;
        }
       
    }


    if(ct <= 1)cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int judgeInclude3(int a);

int main(int argc, const char * argv[]) {
    
    int n;
    scanf("%d",&n);
    
    int i;
    for(i=3;i<=n;i++){
        if(judgeInclude3(i)){
            printf(" %d",i);
        }
    }
    
    printf("\n");
    
    return 0;
}


int judgeInclude3(int a){
    
    if(a % 3 == 0){
        return 1;
    }
    
    while (1) {
        if(a==0){
            return 0;
        }
        else if(a % 10 == 3){
            return 1;
        }
        a/=10;
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top;
int S[100];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top + 1];
}


int main(int argc, char** argv) {
    
    int a,b;
    top = 0;
    char op[99];
    
    while(scanf("%s", op) !=EOF){
        if (op[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(op[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }
        else if(op[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }
        else{
            push(atoi(op));
        } 
    }
    
    printf("%d\n", pop());
    
    return 0;
}




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

int main(){
    int n;
    cin >> n;
    if(n%1000 != 0){
        cout << 1000 - (n % 1000) << endl;
    }else{
        cout <<  (n % 1000) << endl;
    }
    return 0;
}

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

int main() {
	string s;
  	cin >> s;
  	int A_pos = 0;
  	int Z_pos = 0;
  
  	for (int i=0; i<s.size(); i++) {
    	if (s[i] == 'A' && A_pos == 0) A_pos = i+1;
      	if (s[i] == 'Z' && A_pos > 0) Z_pos = i+1;
    }
  	int len = Z_pos - A_pos + 1;
  
  	cout << len << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    long long K;
    cin >> S >> K;
    
    long long i;
    char ans;
    for (i = 0; i < K; i++)
    {
        if (S[i] != '1')
        {
            cout << S[i] << endl;
            return 0;
        }

    }
    
    cout << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		int e = s.length();
		while(true) {
			if (e==0) {
				break;
			} else if (e<5) {
				System.out.println("NO");
				return;
			}

			if (s.substring(e-5, e).equals("erase")) {
				e -= 5;
			} else if (s.substring(e-5, e).equals("dream")) {
				e -= 5;
			} else if (s.substring(e-6, e).equals("eraser")) {
				e -= 6;
			} else if (s.substring(e-7, e).equals("dreamer")) {
				e -= 7;
			} else {
				System.out.println("NO");
				return;
			}
		}

		System.out.println("YES");
	}
}


Measured memory_bytes: 16288