akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc172
{
    class ModularFactorial
    {
        long mod;
        long[] factorial;
        long[] inverse;

        public ModularFactorial(int maxN, int maxK, long mod)
        {
            this.mod = mod;

            factorial = new long[maxN + 1];
            factorial[0] = 1;
            for (int i = 1; i <= maxN; i++)
                factorial[i] = factorial[i - 1] * i % mod;

            int maxInvN = Math.Max(maxN - maxK, maxK);
            inverse = new long[maxInvN + 1];
            inverse[0] = 1;
            for (int i = 1; i <= maxInvN; i++)
                inverse[i] = Inverse(factorial[i]);
        }

        public long GetCombination(int n, int k)
            => (factorial[n] * inverse[k]) % mod * inverse[n - k] % mod;

        public long GetPermutation(int n, int k)
            => factorial[n] * inverse[n - k] % mod;

        public long GetPermutation(int n)
            => factorial[n];

        public long Inverse(long a)
        {
            while (a < 0)
                a += mod;
            a %= mod;
            long p = mod;
            long ya = 0;
            long yp = 1;
            while (a > 0)
            {
                long n = p / a;
                long r = p % a;
                long yr = ya - n * yp;
                ya = yp;
                yp = yr;
                p = a;
                a = r;
            }
            return ya < 0 ? ya + mod : ya % mod;
        }
    }

    class E
    {
        static long mod = 1000000007;

        public static void Main()
        {
            var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n = nm[0];
            var m = nm[1];
            var factorial = new ModularFactorial(m, n, mod);

            var mPn = factorial.GetPermutation(m, n);

            long ans = mPn;
            bool keven= false;
            for (int k = 1; k <= n; k++)
            {
                var diff = factorial.GetPermutation(m - k, n - k) * factorial.GetCombination(n, k) % mod;
                ans = keven ? (ans + diff) % mod : (ans - diff) % mod;
                keven = !keven;
            }
            ans = ans * mPn % mod;
            Console.WriteLine(ans < 0 ? ans + mod : ans);
        }
    }
}


Measured memory_bytes: 36156
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>S;
    N = S.size();
    string ans = "aaaaaaaaaaa";
    int id = 0;
    rep(i,N){
        if(S[i] != 'B'){
            ans[id++] = S[i];
        }else{
            id = max(0, id - 1);
        }
        //cout<<id<<endl;
    }
    rep(i,id) cout<<ans[i];
    cout<<endl;
}

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

int main(){
    int n;
    cin >> n;
  	map<int,int> mp;
    rep(i,n){
        int a;
        cin >> a;
        mp[a]++;
        if(mp[a] > 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vi p(N);
  vi c(N);
  rep(i,N) {
    cin >> p[i];
    p[i]--;
  }
  rep(i,N) {
    cin >> c[i];
  }
  ll ans = -LINF;
  rep(s,N) {
    ll res = -LINF;
    ll now = 0;
    vl sc(N,0);
    int pos = s;
    vi visited(N,0);
    int len=-1;
    rep(i,K) {
      visited[pos]++;
      pos = p[pos];
      now += c[pos];
      sc[i]=now;
      chmax(res,now);
      if(visited[pos]) {
        len=i+1;
        break;
      }
    }
    chmax(ans,res);
    if(len<0) {
      continue;
    }
    ll r = sc[len-1] * ((K/len)-1);
    if(((K/len)-1)>0) {
      chmax(ans,r);
    }
    rep(i,len) {
      chmax(ans,r+sc[i]);
    }
    r += sc[len-1];
    chmax(ans,r);
    rep(i,K%len) {
      chmax(ans,r+sc[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

bool isNumber(string s)
{
    rep(i,s.size())
    {
        if(!('0'<=s[i] && s[i]<='9')) return false;
    }
    return true;
}

string solve()
{
    int m;
    cin >>m;

    map<string,vi> var;

    rep(i,m)
    {
        string name;
        int lb,rb;
        cin >>name >>lb >>rb;

        vi valid(256,0);
        for(int j=lb; j<=rb; ++j) valid[j]=1;

        var[name] = valid;
    }

    int n;
    cin >>n;
    vector<string> e(n);
    rep(i,n) cin >>e[i];

    string res="temporary_variable_for_calculation";
    int res_ct=0;
    stack<string> st;
    rep(i,n)
    {
        if(e[i]=="+" || e[i]=="-" || e[i]=="*" || e[i]=="/")
        {
            if(st.size()<2) return "error";

            string B=st.top();
            st.pop();
            string A=st.top();
            st.pop();

            // cout << A << " " << e[i] << " " << B << '\n';

            vi valA(256,0),valB(256,0);
            if(isNumber(A))
            {
                int tmp = atoi(A.c_str());
                valA[tmp] = 1;
            }
            else valA = var[A];
            if(isNumber(B))
            {
                int tmp = atoi(B.c_str());
                valB[tmp] = 1;
            }
            else valB = var[B];


            if(e[i]=="/")
            {
                if(valB[0]==1) return "error";
            }

            vi valC(256,0);
            rep(a,256)rep(b,256)if(valA[a] && valB[b])
            {
                int c=0;
                if(e[i]=="+") c=a+b;
                else if(e[i]=="-") c=a-b;
                else if(e[i]=="*") c=a*b;
                else if(e[i]=="/") c=a/b;

                c = (c+256)%256;
                valC[c] = 1;
            }

            st.push(res+to_string(res_ct));
            var[res+to_string(res_ct)] = valC;
            ++res_ct;
        }
        else st.push(e[i]);
    }

    return "correct";
}

int main()
{
    cin.tie(0);ios::sync_with_stdio(false);
    cout << solve() << '\n';
    return 0;
}

Measured memory_bytes: 3308
#include <iostream>

using namespace std;

int s_n(string str) {
  if (str == "S") {return 0;}
  else if (str == "H") {return 1;}
  else if (str == "C") {return 2;}
  else if (str == "D") {return 3;}
}

string n_s(int n) {
  if (n == 0) {return "S";}
  else if (n == 1) {return "H";}
  else if (n == 2) {return "C";}
  else if (n == 3) {return "D";}
}

int main() {
  int trump[4][13] = {};
  int n, h, i, j, rank;
  string type;
  
  cin >> n;

  for (h = 0; h < n; h++) {
	cin >> type >> rank;
	trump[s_n(type)][rank - 1] = 1;
  }

  for (i = 0; i < 4; i++) {
	for(j = 0; j < 13; j++) {
	  if (trump[i][j] == 0) {
		cout << n_s(i) << " " << j + 1 << endl;
	  }
	}
	}
  return 0;
}

Measured memory_bytes: 3132
#include<iostream>
using namespace std;
int main () {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b || b == c || c == a) {
    if (a + b + c != 3 * a) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}



int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a));
  int zero = 0;
  int cnt = 0;
  rep(i,n){
    if(!a[i]){
      zero++;
      continue;
    }
    if(a[i] == a[i+1])cnt++;
    else {
      if(cnt != 1){
        zero = 1000;
        break;
      }
      cnt = 0;
    }
  }
  if(zero > 1){
    print(0);
    return 0;
  }
  n -= zero;
  n /= 2;
  ll ans = 1;
  rep(i,n)ans = (ans << 1)%INF;
  print(ans);
  return 0;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int Prime_L(int N, int res[], void *mem=wmem){
  bool *isprime;
  const int r=23000;
  int a, b, i, *sf, ss=1, sz=1;
  isprime = (bool*)mem;
  sf = (int*)(isprime + r);
  N /= 2;
  res[0] = 2;
  b =min_L(r, N);
  for(i=1;i<b;i++){
    isprime[i] = 1;
  }
  for(i=1;i<b;i++){
    if(isprime[i]){
      res[sz++] = 2*i+1;
      sf[ss] = 2*i*(i+1);
      if(sf[ss] < N){
        while(sf[ss] < r){
          isprime[sf[ss]] = 0;
          sf[ss] += res[ss];
        }
        ss++;
      }
    }
  }
  for(a=r; a<N; a+=r){
    b =min_L(a + r, N);
    isprime -= r;
    for(i=a;i<b;i++){
      isprime[i] = 1;
    }
    for(i=1;i<ss;i++){
      while(sf[i] < b){
        isprime[sf[i]] = 0;
        sf[i] += res[i];
      }
    }
    for(i=a;i<b;i++){
      if(isprime[i]){
        res[sz++] = 2*i+1;
      }
    }
  }
  return sz;
}
char memarr[96000000];
int N;
int ps;
int p[100];
int up[100];
int main(){
  int i, j, k, res=0;
  wmem = memarr;
  rd(N);
  ps =Prime_L(N, p);
  for(i=0;i<ps;i++){
    j = 0;
    k = N;
    while(k){
      j += (k /= p[i]);
    }
    up[j]++;
  }
  for(i=N-1;i>=0;i--){
    up[i] += up[i+1];
  }
  res += up[75-1];
  res += up[25-1] * (up[3-1]-1);
  res += up[15-1] * (up[5-1]-1);
  res += up[5-1] * (up[5-1]-1) / 2 * (up[3-1]-2);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N;
// int ps, p[100], up[100];
// {
//   int i, j, k;
//   int res = 0;
//   rd(N);
//   ps = Prime(N, p);
//   rep(i,ps){
//     j = 0;
//     k = N;
//     while(k) j += (k /= p[i]);
//     up[j]++;
//   }
//   for(i=N-1;i>=0;i--) up[i] += up[i+1];
// 
//   res += up[75-1];
//   res += up[25-1] * (up[3-1]-1);
//   res += up[15-1] * (up[5-1]-1);
//   res += up[5-1] * (up[5-1]-1) / 2 * (up[3-1]-2);
// 
//   wt(res);
// }


Measured memory_bytes: 256
package main

import "fmt"

func powmod(m, n, mod int) int {
	ans := 1
	for i := 0; i < n; i++ {
		ans = (m * ans) % mod
	}
	return ans
}

func powr(m, n int) int {
	// fmt.Printf("powr(%d,%d) en:\n", m, n)
	if n == 0 {
		return 1
	}
	if n%2 == 0 {
		return powr(m*m, n/2)
	}
	return m * powr(m*m, (n-1)/2)
}

func powrmod(m, n, mod int) int {
	//fmt.Printf("powrmod(%d,%d) en:\n", m, n)
	if n == 0 {
		return 1
	}
	if n%2 == 0 {
		return powrmod((m*m)%mod, n/2, mod) % mod
	}
	return m * powrmod((m*m)%mod, (n-1)/2, mod) % mod
}

func main() {
	var m, n int
	fmt.Scan(&m, &n)
	mod := int(1e9) + 7
	// fmt.Printf("powrmod(%d,%d)=%d\n", m, n, powrmod(m, n, mod))
	fmt.Println(powrmod(m, n, mod))
}



Measured memory_bytes: 1160
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int a[100005];
int s[100005];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n)scanf("%d", &a[i]);
	REP(i, n) {
		s[i + 1] = (s[i] + a[i]) % m;
	}
	sort(s, s + n+1);
	s[n+1] = -1;
	int x = -1;
	LL ret = 0, cnt = 0;
	REP(i, n+2) {
		if (x != s[i]) {
			ret += ((cnt - 1)*cnt) / 2;
			x = s[i];
			cnt = 0;
		}
		cnt++;
	}
	cout << ret << endl;
	return 0;
}

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

main(){
  int a,r = 0;
  cin >> a;
  for(int i=1;i<=a;i++){
    for(int j=1; j<=a;j++){
      
      if ((i%2==1) &&(j%2==0)){
        r+=1;
      }
    }
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()

	if N%1000 == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - N%1000)
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

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

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


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

//#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;

mt19937 rnd(time(0));

#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("lights.in", "r", stdin); freopen("lights.out", "w", stdout);
#define s second
#define f first
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pll pair<ll,ll>
#define pii pair<int,int>

const ll INF = 1e18;
constexpr ll mod = 1e9 + 7;

ll x0r(ll x, ll y) { return (x | y) & (~x | ~y); }


void solve() {
    int n, h;
    cin >> h >> n;
    vector<pair<int, int>> v(n);
    for(auto &i : v)cin>>i.f>>i.s;
    vector<int> dp(h + 10, 1e9);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= h; j++) dp[min(v[i].f + j, h)] = min(dp[min(v[i].f + j, h)], dp[j] + v[i].s);
    cout << dp[h] << '\n';

}


signed main() {
    //ioss
    //clock_t time = clock();
    //if ((double) (clock() - time) / CLOCKS_PER_SEC > 0.96) {
    //file
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


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

using namespace std;
#define ll long long
const int N = 16, MOD = 1e9 + 7;
int a[N], dp[1<<N][N+1], fac[1<<N] = {1}, inv[1<<N];

int sum(int a, int b) {return a + b - (a + b >= MOD ? MOD : 0);}
int mul(ll  a, ll  b) {return a * b % MOD;}
int Pow(int a, int b) {
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b&1) res = mul(res, a);
    return res;
}
int C(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return mul(fac[n], mul(inv[k], inv[n - k]));
}

int main() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> a[i];
    int ans = 0, M = 1<<n;
    for (int i = 1; i < M; i++) fac[i] = mul(fac[i - 1], i);
    inv[M - 1] = Pow(fac[M - 1], MOD - 2);
    for (int i = M - 2; i >= 0; i--) inv[i] = mul(inv[i + 1], i + 1);
    dp[0][m] = 1;
    for (int mask = 0; mask < M; mask++) {
        for (int i = m - 1; i >= 0; i--) {
            dp[mask][i] = dp[mask][i + 1];
            for (int j = 0; j < n; j++) if (((mask>>j)&1)) {
                dp[mask][i] = sum(dp[mask][i],
                    mul(dp[mask^(1<<j)][i + 1],
                        mul(fac[1<<j], C(M - a[i] - mask + (1<<j), (1<<j) - 1))));
            }
        }
        dp[mask][0] = mul(dp[mask][0], fac[M - mask - 1]);
        if (__builtin_popcount(mask)&1) ans = sum(ans, MOD - dp[mask][0]);
        else ans = sum(ans, dp[mask][0]);
    }
    cout << mul(ans, M) << "\n";

    return 0;
}


Measured memory_bytes: 8480
# xy  平面があり、その上に N 人の学生がいて、M 個のチェックポイントがあります。
# i 番目の学生がいる座標は (ai,bi)(1≦i≦N) であり、
# 番号 j のチェックポイントの座標は (cj,dj)(1≦j≦M) です。
# これから合図があり、各学生はマンハッタン距離で一番近いチェックポイントに集合しなければなりません。
# 2つの地点 (x1,y1) と (x2,y2) 間のマンハッタン距離は |x1−x2|+|y1−y2| で表されます。
# ここで、|x| は x の絶対値を表します。
# ただし、一番近いチェックポイントが複数ある場合には、
# 番号が最も小さいチェックポイントに移動することとします。
# 合図の後に、各学生がどのチェックポイントに移動するかを求めてください。

nm = gets.chomp.split
n = nm[0].to_i
m = nm[1].to_i

a = []
b = []
n.times do
    input = gets.chomp.split
    a << input[0].to_i
    b << input[1].to_i
end

c = []
d = []
m.times do
    input = gets.chomp.split
    c << input[0].to_i
    d << input[1].to_i
end

n.times do |i|
    distances = []
    m.times do |j|
        distances << (a[i] - c[j]).abs + (b[i] - d[j]).abs
    end
    puts distances.index(distances.min) + 1
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';
const int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };

int N, K, a[20];
ll DP[1001], f[1001], inv[1001];

ll pw(ll x, ll y) {
	ll a = 1;
	while (y) {
		if (y & 1)a = a*x%mod;
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll comb(int n, int r) {
	return f[n] * inv[r] % mod*inv[n - r] % mod;
}

ll invcomb(int n, int r) {
	return inv[n] * f[r] % mod*f[n - r] % mod;
}

int main() {
	f[0] = 1;
	for (ll i = 1; i <= 1000; i++) {
		f[i] = f[i - 1] * i%mod;
	}
	for (int i = 0; i <= 1000; i++) {
		inv[i] = pw(f[i], mod - 2);
	}
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		cin >> a[i];
	}
	DP[0] = 1;
	for (int i = 0; i < K; i++) {
		for (int j = N - 1; j >= 0; j--) {
			for (int k = min(a[i], N - j); k > 0; k--) {
				DP[j + k] += DP[j] * comb(N - k, j) % mod*invcomb(N, j) % mod*comb(a[i], k);
				DP[j + k] %= mod;
			}
		}
	}
	for (int i = 0; i < K; i++) {
		DP[N] *= comb(N, a[i]);
		DP[N] %= mod;
	}
	cout << DP[N] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
  char a[4];
  cin >> a ;
  if(a[0] == a[1] && a[1] == a[2]){
    cout << "Yes" << endl;
  }
  else if(a[1] == a[2] && a[2] == a[3]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
int modpow(int x, int k, int MOD) {
  int a = 1;
  while (k > 0) {
    if (k & 1) a = (1LL*a*x) % MOD;
    x = (1LL*x*x) % MOD;
    k >>= 1;
  }
  return a;
}
 
int N, MOD;
int nCr[3001][3001];
int fact[3001];
int dp[3001][3001];
inline int mul(int x, int y) { return (1LL*x*y)%MOD; }
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }
 
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> MOD;
 
  nCr[0][0] = 1;
  for (int i=1; i<=3000; i++) {
    nCr[i][0] = 1;
    for (int j=1; j<=3000; j++) nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j])%MOD;
  }
  fact[0] = 1;
  for (int i=1; i<=3000; i++) fact[i] = (1LL*i*fact[i-1])%MOD;
 
  dp[0][0] = 1;
  rep(i, 3000) {
    rep(y, i+1) {
      add(dp[i+1][y+1], dp[i][y]);
      add(dp[i+1][y], mul(y+1, dp[i][y]));
    }
  }
 
  int sum = 0;
  for (int S=0; S<=N; S++) {
    int base = modpow(2, N-S, MOD);
    int s = 0;
    int w = 1; // base^num
    rep(num, S+1) {
      add(s, mul(dp[S][num], w));
      w = mul(w, base);
    }
    s = mul(s, modpow(2, modpow(2, N-S, MOD-1), MOD));
    s = mul(s, nCr[N][S]);
    if (S%2) s = (MOD-s)%MOD;
    sum = (sum+s)%MOD;
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 69376
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
long long cnt;
int l,n;
int A[1000009];
vector<int> G;
//指定了间隔g的插入排序
void InsertionSort(int A[],int n,int g){
    for (int i = g; i < n; ++i) {
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}
void shellSort(int A[],int N){
    //生成数列G={1,4,13,40,121,364,1093,...}
    for(int h=1;;){
        if(h>n) break;
        G.push_back(h);
        h=3*h+1;
    }
    for (int i = G.size()-1; i >= 0 ; --i) {
        InsertionSort(A,n,G[i]);
    }
}
int main(){
    cin>>n;
    for (int i = 0; i < n; ++i) scanf("%d",&A[i]);
    cnt=0;
    shellSort(A,n);
    cout<<G.size()<<endl;
    for (int i = G.size()-1; i >= 0; --i) {
        printf("%d",G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for (int i = 0; i < n; ++i) printf("%d\n",A[i]);
    return 0;
}


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

using namespace std;
using ll = long long;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

int main() {
    ll m, i, j;
    cin >> m;
    ll ret1 = 0, ret2 = 0;
    for(i = 0; i < m;i++){
        ll x, y;
        cin >> x >> y;
        ret1 += x * y;
        ret2 += y;
    }
    cout << ret2 - 1 + (ret1 - 1) / 9 << endl;
    return 0;
}

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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf  1e18
#define mk(arr,n,type) type *arr=new type[n];
#define ti(arr,n) for(ll i=0;i<n;++i)cin>>a[i];
#define ot(arr,n) for(ll i=0;i<n;++i)cout<<a[i]<<" ";
#define str(a) string a;cin>>a;
#define w(x) int x;cin>>x;while(x--)
int main()
{
   string a;cin>>a;
   ll sum=0;
   for(auto i:a)
   {
      sum=sum+(int)(i-48);
   }
   if(sum%9==0)cout<<"Yes";
   else
      cout<<"No";
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>seq(n);
  for(int i=0;i<n;i++){
  	cin>>seq[i];
  }
  int tot = 0;
  for(int i=0;i<n;i++){
  	if(i+1==seq[i]&&i<n-1){
  		swap(seq[i],seq[i+1]);
  		tot++;
  	}else if(i==n-1){
  		if(i+1==seq[i]){
  			swap(seq[i],seq[i-1]);
  			tot++;	
  		}		
  	}
  }
  cout<<tot<<endl;
}




Measured memory_bytes: 640
n, k = map(int, input().split())

def twice(now, cnt):
    #print(now)
    if now >= k:
        return cnt
    cnt += 1
    return twice(now * 2, cnt)

if __name__ == '__main__':
    ans = 0
    for i in range(1, n+1):
        cnt = 0
        #print(twice(i, cnt))
        #print((1/2)**int(twice(i)))
        #print(float(1/n))
        ans += float(1/n) * float((1/2)**int(twice(i, cnt)))
    print(ans)
    

Measured memory_bytes: 2940
w,h,n = map(int,input().split())
minx = 0
maxx = w
miny = 0
maxy = h

for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    minx = max(minx,x)
  if a == 2:
    maxx = min(maxx,x)
  if a == 3:
    miny = max(miny,y)
  if a == 4:
    maxy = min(maxy,y)

if minx >= maxx or miny >= maxy:
  print(0)
else:
  print((maxx - minx)*(maxy - miny))

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
 
  int n;cin>>n;
  int arr[n][3];
  for(int i =0; i < n ; i++) {
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
  }
 
  vector<vector<int>> dp(n, vector<int>(3,0));
  // dp.assign(0, vector<int>);

  dp[0][0] = arr[0][0]; dp[0][1] = arr[0][1]; dp[0][2] = arr[0][2];
  for(int i=1; i<n; i++){
    for(int j =0 ; j < 3 ; j++){
      for(int k = 0; k<3 ; k++){
        if(k != j)
          dp[i][j] = max(dp[i][j], dp[i-1][k] + arr[i][j]);
      }
    }
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
  return 0;
}

Measured memory_bytes: 6912
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    int hako1 = x;
    x = y;
    y = hako1;
    int hako2 = x;
    x = z;
    z = hako2;

    System.out.println(x + " " + y + " " + z);



    
    
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

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

    ll g = gcdll(c, d);
    g = c * d / g;

    ll dc = 0, dd = 0, dcd = 0;
    dc = b / c - (a - 1) / c;
    dd = b / d - (a - 1) / d;
    dcd = b / g - (a - 1) / g;
    cout << b - a + 1 - (dc + dd - dcd) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

int main(void)
{
	int d,t,s;
	scanf("%d%d%d",&d,&t,&s);
	if((ll)t * s >= d) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

const int maxn=105;

int n,m;
int a[maxn][maxn],b[maxn][maxn];
int ecnt,dep[1005],head[1005];
struct Edge{int v,next,flow;}edge[100005];
stack<int> c[maxn][maxn];

inline int get_col(int x){return (x-1)/m+1;}
inline void add_edge(int u,int v,int flow){
	edge[ecnt]=(Edge){v,head[u],flow},head[u]=ecnt++;
	edge[ecnt]=(Edge){u,head[v],0},head[v]=ecnt++;
}

bool bfs(int s,int t){
	memset(dep+1,0,4*t);
	queue<int> Q;dep[s]=1,Q.push(s);
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(int i=head[u],v;~i;i=edge[i].next){
			v=edge[i].v;
			if(edge[i].flow&&!dep[v])
				dep[v]=dep[u]+1,Q.push(v);
		}
	}
	return dep[t];
}

int dfs(int u,int flow,const int &t){
	if(u==t)return flow;
	int used=0;
	for(int i=head[u],v,rlow;~i;i=edge[i].next){
		v=edge[i].v;
		if(edge[i].flow&&dep[v]==dep[u]+1){
			rlow=dfs(v,min(edge[i].flow,flow-used),t);
			if(rlow)edge[i].flow-=rlow,edge[i^1].flow+=rlow,used+=rlow;
			if(used==flow)break;
		}
	}
	if(!used)dep[u]=-1;
	return used;
}

int main(){
	scanf("%d%d",&n,&m);
	memset(head+1,0xff,4*(n*2+2));
	for(int i=1;i<=n;i++)
		for(int j=1,x;j<=m;j++){
			scanf("%d",&a[i][j]),x=get_col(a[i][j]);
			c[i][x].push(a[i][j]),add_edge(i,n+x,1);
		}
	int s=n*2+1,t=s+1;
	for(int id=1;id<=m;id++){
		for(int i=1;i<=n;i++)
			add_edge(s,i,1),add_edge(i+n,t,1);
		while(bfs(s,t))dfs(s,0x3f3f3f3f,t);
		for(int i=n+1;i<=2*n;i++)
			for(int j=head[i],v;~j;j=edge[j].next)
				if(edge[j].flow){
					edge[j].flow=0,v=edge[j].v;
					b[v][id]=c[v][i-n].top(),c[v][i-n].pop();
				}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			cout<<b[i][j]<<' ',a[get_col(b[i][j])][j]=b[i][j];
		cout<<'\n';
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)cout<<a[i][j]<<' ';
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 11896
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  // At first, calculate the histgram
  vector<ll> hist(200050); // larger than N
  // vector<ll> hist(10); // larger than N
  rep(i, n) {
    ++hist[a[i]];
  }
  // printvec(hist);

  // Next, calculate the whole result
  ll total = 0;
  rep(i, 200050) {
    ll cnt = hist[i];
    // cnt C 2
    if (cnt > 0) {
      total += cnt * (cnt-1) / 2;
    }
  }
  // cout << total << endl;

  rep(i, n) {
    ll j = a[i]; // target

    ll cnt = hist[j] - 1; // Here, at i, hist is hist[i] - 1.
    ll ans = total;
    ans -= (hist[j] * (hist[j]-1))/2;
    ans += cnt * (cnt-1)/2;
    cout << ans << endl;
  }
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7, N = 1e6 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n, m, x, sum = 0 ;
    cin >> n >> m ;
    for (int i = 0; i < m; i++) {
        cin >> x ;
        sum += x ;
    }
    if (sum > n)    cout << -1 ;
    else {
        cout << (n - sum) ;
    }

    return 0 ;
}


Measured memory_bytes: 3636
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	//static final long MOD = 998244353;
	static final long MOD = 1000000007;
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.ni();
		for (int a = 1; a < 10; a++) {
			for (int b = 1; b < 10; b++) {
				if (a*b==N) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
    
    public static long power(long x, long y, long p) { 
        // Initialize result
        long res = 1;
         
        // Update x if it is more   
        // than or equal to p 
        x = x % p;  
      
        while (y > 0) 
        { 
            // If y is odd, multiply x 
            // with result 
            if((y & 1)==1) 
                res = (res * x) % p; 
      
            // y must be even now 
            // y = y / 2 
            y = y >> 1;  
            x = (x * x) % p;  
        } 
        return res; 
    }
    
    public static long dist(int[] point, int[] point2) {
    	return (long)(Math.pow((point2[1]-point[1]),2)+Math.pow((point2[0]-point[0]),2));
    }
    
    public static long gcd(long a, long b) {
    	if (b == 0)
    		return a;
    	else
    		return gcd(b,a%b);
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr2[1]-arr1[1];
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

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

using namespace std;

typedef vector<int> vi;

const int maxn = 2e5 + 2;

int n, m;

struct UF
{

  int sz;
  vi r, p;
  UF(int n) : r(n, 0), p(n, 0), sz(n)
  {
    iota(p.begin(), p.end(), 0);
  }

  int f(int x)
  {
    return (p[x] == x ? x : p[x] = f(p[x]));
  }

  void u(int i, int j)
  {
    int x = f(i), y = f(j);
    if (x == y)
      return;

    --sz;
    if (r[x] >= r[y])
      {
        p[y] = x;
        if (r[x] == r[y])
          r[x]++;
      }
    else
      p[x] = y;
  }

  bool s(int i, int j)
  {
    return f(i) == f(j);
  }
};


int main()
{
  cin >> n >> m;
  UF uf(n);
  for (int i = 0, x, y, z; i < m; ++i)
    {
      cin >> x >> y >> z;
      uf.u(x - 1, y - 1);
    }

  cout << uf.sz;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int cnt_d(ll n) {
    int ans = 0;
    while (n) {
        n /= 10;
        ++ans;
    }
    return ans;
}

int main(){
    ll n, a, b;
    cin >> n;
    int min = cnt_d(n);
    for (a=1LL; a*a<=n; ++a) {
        if (n%a!=0) continue;
        b = n / a;
        int max_d = max(cnt_d(a), cnt_d(b));
        if (max_d<min) min = max_d;
    }
    cout << min << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma region
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
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int MOD = 1E9 + 7;
int power(int a, int n)
{
    int ret = 1;
    int now = a;
    while(n)
    {
        if (n&1)ret = (ret * now)%MOD;
        now = (now * now)%MOD;
        n >>= 1;
    }
    return ret%MOD;
}
int inv(int a)
{
    return power(a, MOD - 2);
}

int comp[1'000'001];
int memo[1'000'001];
vector<int> prm;
bitset<1'000'001> ina;
void solve()
{
    int n; cin>>n;
    vector<int> a(n);
    forn(i, n) cin>>a[i], ina[a[i]] = 1;
    prm.reserve(111'111);
    for(int i = 2; i < 1'000'001;++i)
    {
        if (comp[i]) continue;
        prm.pb(i);
        for (int k = i, c = 1; k < 1'000'001; k *= i, ++c)
        {
            for (int j = k; j < 1'000'001; j += k)
            {
                comp[j] = 1;
                if (ina[j])
                {
                    memo[sz(prm) - 1] = max(memo[sz(prm) - 1], c);
                }
            }
        }
    }
    int lcm = 1;
    forn(i, sz(prm))
    {
        while(memo[i]--)
        {
            lcm = (lcm * prm[i])%MOD;
        }
    }
    //debug(lcm);
    int ans = 0;
    forn(i, n)
    {
        int ad = lcm * inv(a[i])%MOD;
        ans = (ans + ad)%MOD;
    }
    cout << ans << '\n';
}


signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 12400
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, G;
int a[maxn];
long long ans;
long long lcm(long long a, long long b) {
	long long g = __gcd(a, b);
	return a / g * b;
}
void solve() {
	ios::sync_with_stdio(false);

	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ans = 1;
	G = a[1];
	for (int i = 2; i <= n; ++i) {
		G = __gcd(G, a[i]);
	}
	for (int i = 1; i <= n; ++i) {
		a[i] /= G;
	}
	for (int i = 1; i <= n; ++i) {
		if (a[i] % 2 == 0) {
			cout << 0 << endl;
			return;
		}
	}
	for (int i = 1; i <= n; ++i) {
		ans = lcm(ans, a[i]);
		if (ans > m) {
			cout << 0 << endl;
			return;
		}
	}
	G /= 2;
	ans = ans * G;
	if (ans > m) {
		cout << 0 << endl;
		return;
	}
	//cerr << ans << endl;
	//cerr << ans << endl;
	ans = m / ans;
	if (ans & 1)ans = ans / 2 + 1;
	else ans = ans / 2;
	cout << ans << endl;
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 640
N=int(input())
l=[]
c=0
while True:
  if N==0:
    break
  else:
    c+=1
    if N%(2**c)==0:
      l.append(0)
    else:
      l.append(1)
      N-=(-2)**(c-1)
if l==[]:
  print(0)
else:
  ans=0
  for i in range(len(l)):
    ans+=int(l[i]*(10**(i)))
  print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

int main()
{
	int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", (a+b)*c/2);
	return 0;
}

Measured memory_bytes: 256
def read():
    return int(input())

def readmap():
    return map(int, input().split())

def readlist():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n , k = readmap()
    A = readlist()

    cnt = 0
    for a in A:
        if a >= k:
            cnt += 1
    
    print(cnt)


Measured memory_bytes: 11896
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

LLI h[51];

LLI solve(LLI L, LLI x){
  if(x==0) return 0;
  if(L==0) return 1;
  if(x == h[L]){
    return 1LL + 2*solve(L-1,(h[L]-3)/2);
  }
  if(x > h[L]/2){
    return 1LL + solve(L-1,(h[L]-3)/2) + solve(L-1,x-h[L]/2-1);
  }
  return solve(L-1,x-1);
}

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

  h[0] = 1;
  FORE(i,1,50){
    h[i] = 3+2*h[i-1];
  }

  LLI n,x; cin >> n >> x;

  cout << solve(n,x) << endl;
  
  return 0;
}


Measured memory_bytes: 256
let ans n a =
  let rec f i b s r =
    if i = n then r
    else
      let x = s + a.(i) in
      if b * x > 0 then f (i + 1) ~-b x r
      else f (i + 1) ~-b b (r + abs x + 1)
  in min (f 0 1 0 0) (f 0 ~-1 0 0)

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
  print_int (ans n a)

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
void solve() { 
	string a, b;
	cin>>a>>b;
	cout<<b<<a;   
}


Measured memory_bytes: 256