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

using namespace std;

struct pkt
{
    int x, y;
};

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

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    pkt start, meta;
    cin >> start.x >> start.y;
    cin >> meta.x >> meta.y;
    --start.x;
    --start.y;
    --meta.x;
    --meta.y;
    vector<string> G(n);
    for (int i = 0; i < n; ++i)
        cin >> G[i];
    vector< vector<int> > odl(n, vector<int>(m, -1));
    odl[start.x][start.y] = 0;
    queue<pkt> Q;
    Q.push(start);
    while (!Q.empty())
    {
        pkt akt = Q.front();
        Q.pop();
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 1; j <= k; ++j)
            {
                pkt nast = {akt.x + dx[i] * j, akt.y + dy[i] * j};
                if (nast.x >= 0 && nast.x < n && nast.y >= 0 && nast.y < m && G[nast.x][nast.y] == '.' &&
                    (odl[nast.x][nast.y] == -1 || odl[nast.x][nast.y] == odl[akt.x][akt.y] + 1))
                {
                    if (odl[nast.x][nast.y] == -1)
                    {
                        odl[nast.x][nast.y] = odl[akt.x][akt.y] + 1;
                        Q.push(nast);
                    }
                }
                else
                    break;
            }
        }
    }
    cout << odl[meta.x][meta.y];
    return 0;
}


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

"""
参考：http://drken1215.hatenablog.com/entry/2018/07/22/133200
　　　https://www.hamayanhamayan.com/entry/2018/06/16/091039
・自力ACできたけど、メモをもう一歩深く書けば
　メインのループ1つ落とせるのが分かったのでそっちもやってみる。
"""
 
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
cN = [list(map(int, input().split())) for i in range(N)]

# [mod 3でどれになるか][今度の色] = そうなった時の違和感の総和
memo = [[0] * C for i in range(3)]
for c in range(C):
    for i in range(N):
        for j in range(N):
            memo[(i+j+2)%3][c] += D[cN[i][j]-1][c]

ans = float('inf')
# 変わる色を全組み合わせループ
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or k == i:
                continue
            # メモで違和感の合計まで出してあるので、ここではループなし
            sm = memo[0][i] + memo[1][j] + memo[2][k]
            ans = min(sm, ans)
print(ans)


Measured memory_bytes: 46172
line = gets.split(' ').map(&:to_i)
l = line[0]
r = line[1]
min = 2019
for i in l..r do
  for j in l..r do
    if i==j 
      break
    end
    if (i*j)%2019 == 0
      puts("0")
      exit
    end
    if min >=(i*j)%2019
      min = (i*j)%2019
    end
  end
end
puts min
      

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

#整数値龍力　複数の入力
n = int(input())

s_new = 'a'
kind_new = [1]
litter =["a","b","c","d","e","f","g","h","i","j"]


for i in range(n-1):
    s_old = s_new
    kind_old = kind_new
    s_new = []
    kind_new=[]
    for j in range(len(s_old)):
        for k in range(kind_old[j]+1):
            s_new.append(s_old[j]+litter[k])
            if k > kind_old[j]-1:
            	kind_new.append(kind_old[j]+1)
            else:
            	kind_new.append(kind_old[j])

for s in s_new:
	print(s)


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

long long MOD = 1000000007;
int main() {
  int n, m;
  cin>>n>>m;
  int a[m];
  for (int i=0; i<m; i++) cin>>a[i];

  long long ans[n+1];
  int idx_a = 0;
  ans[0] = 1;
  if (a[0] == 1) {
    ++idx_a;
    ans[1] = 0;
  } else {
    ans[1] = 1;
  }
  for (int i=2; i<=n; ++i) {
    if (idx_a >= m) {
      ans[i] = (ans[i-1] + ans[i-2]) % MOD;
      continue;
    }
    if (a[idx_a] == i) {
      ans[i] = 0;
      ++idx_a;
      continue;
    }
    ans[i] = (ans[i-1] + ans[i-2]) % MOD;
  }
  cout<<ans[n]<<endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
	double ax1,ax2,ay1,ay2,bx1,bx2,by1,by2;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&ax1,&ay1,&ax2,&ay2,&bx1,&by1,&bx2,&by2)==8)
		puts(ax1<=bx2&&bx1<=ax2&&ay1<=by2&&by1<=ay2?"YES":"NO");
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        char[] str = S.toCharArray();

        int count = 0;
        for (int i = 0; i < str.length / 2; i++) {
            if (str[i] == str[str.length - 1 - i]) {
                continue;
            } else {
                count++;
            }
        }

        System.out.println(count);

        sc.close();
    }
}

Measured memory_bytes: 23124
N,K = list(map(int,input().split()))
cnt = 0
a = [True for i in range(N)]
for i in range(K):
    b = input()
    c = list(map(int,input().split()))
    for j in c:
        a[j-1] = False
for i in range(len(a)):
    if a[i]:
        cnt+=1
print(cnt)

Measured memory_bytes: 9208
N = int(input())
B = list(map(int, input().split()))

result = 0
for i in range(N):
    if i == 0:
        result += B[i]
    elif i == N-1:
        result += B[i-1]
    else:
        result += min(B[i-1], B[i])

print(result)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = 3003;
int n,m;
ld dp[N][N];
ld p[N];
ld f(int i,int j)
{
       if(i==n){
              if(j==1){
                     return p[i];
              }
              if(j==0){
                     return 1-p[i];
              }
              return 0;
       }
       if(dp[i][j] != -1.0){return dp[i][j];}
       return dp[i][j] = f(i+1,j)*(1-p[i])+f(i+1,j-1)*(p[i]);
}

int main()
{
       cin>>n;
       fri(i,1,n+1){
              cin>>p[i];
       }
       fri(i,0,N){
              fri(j,0,N){
                     dp[i][j] = -1.0;
              }
       }
       ld ans = 0;
       fri(i,(n/2)+1,n+1){
              ans += f(1,i);
       }
       cout<<setprecision(12)<<fixed;
       cout<<ans<<endl;
}


Measured memory_bytes: 141440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		String str = null;
	    String strSplit = null;
		String[] strs;
		int point = 0;
		int a = 0;
		int b = 0;
		int ans = 0;
		int n = 0;
		double f = 0;

		while(stdin.hasNext()) {
			a = stdin.nextInt();
			b = stdin.nextInt();
			n = stdin.nextInt();
			f = (double)a / (double)b;
 			str = String.valueOf(f);
			point = str.indexOf(".");
			strSplit = str.substring(point + 1);
			strs = strSplit.split("");
			for(int i = 0; i < n; i++) {
				if(i < strs.length) {
					ans += Integer.parseInt(strs[i]);
				}
				
			}
		
			System.out.println(ans);
			ans = 0;
		}
	}

}

Measured memory_bytes: 26500
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    string s;
    cin >> s;

    ll ans = 0;
    rep(i,sz(s))
    {
        if(s[i] == '1')
            ans++;
    }

    cout << ans << endl;
    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

long long Combi::nPk_modp(long long n, long long k, long long p)
{
  ll ans = 1;
  for(long long i = k; i <= n; i++)
  {
    ans = (ans * i) % p;
  }

  return ans;
};


Measured memory_bytes: 256
fn main() {
	use std::io::Write;
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: i64 = s.next().unwrap().parse().unwrap();
	let k: i64 = s.next().unwrap().parse().unwrap();
	let blue = k;
	let red = n - k;
	let fmod = FactorialMod::new(3000);
	let out = std::io::stdout();
	let mut out = std::io::BufWriter::new(out.lock());
	for i in 1..k + 1 {
		let ans = fmod.combination(red + 1, i) * fmod.combination(i + (blue - i) - 1, blue - i) % MOD;
		writeln!(out, "{}", ans).unwrap();
	}
}

const MOD: i64 = 1000000007;

struct FactorialMod {
	value: Vec<i32>,
	inverse: Vec<i32>,
}

impl FactorialMod {
	fn new(n: usize) -> FactorialMod {
		let n = n as i64;
		let value: Vec<i32> = (0..n + 1).scan(1i64, |s, i| {
			let r = *s as i32;
			*s = *s * (i + 1) % MOD;
			Some(r)
		}).collect();
		let inverse = (0..n + 1).rev().scan(mod_pow(value[n as usize] as i64, MOD - 2, MOD), |s, i| {
			let r = *s as i32;
			*s = *s * i % MOD;
			Some(r)
		}).collect::<Vec<_>>().into_iter().rev().collect();
		FactorialMod { value: value, inverse: inverse }
	}

	fn combination(&self, n: i64, r: i64) -> i64 {
		if n < 0 || r < 0 || r > n {
			0
		} else {
			(self.value[n as usize] as i64 * self.inverse[r as usize] as i64 % MOD) * self.inverse[(n - r) as usize] as i64 % MOD
		}
	}
}

fn mod_pow(a: i64, n: i64, m: i64) -> i64 {
	let mut r = 1;
	let mut a = a;
	let mut n = n;
	while n > 0 {
		if n & 1 != 0 {
			r = r * a % m;
		}
		a = a * a % m;
		n >>= 1;
	}
	r
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static int Max(int a, int b, int c) {
		int m = a;
		if (m < b)
			m = b;
		if (m < c)
			m = c;
		return m;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = a + b + c;
		int max = Max(a, b, c);
		System.out.println(ans + 9 * max);
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef pair<int, int> PAIR;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    vector<vector<int>> jobs(M+1);
    rep(i, N) {
        int a, b; cin >> a >> b;
        if (a <= M) jobs[M-a].push_back(b);
    }

    ll ans = 0;
    priority_queue<int> pq;
    // for (int i = 1; i <= M; ++i) {
    // for (int i = M-1; i >= 0; --i) {
    for (int i = M; i >= 0; --i) {
        for (auto job : jobs[i]) pq.push(job);

        if (pq.size()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

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

bool feasible(vector<int> &vec, int c, int k) {
  vector<int> x;
  for(int i =0; i<vec.size(); i++) {
    x.push_back(vec.at(i) % c);
  }
  int s_x = accumulate(x.begin(), x.end(), 0);
  int s_y = 0;
  sort(x.begin(), x.end());
  for(int i =0; i<vec.size(); i++) {
    if(s_x == s_y && s_x <= k){
      return true;
    }
    s_x -= x.at(x.size()-i-1);
    s_y += c - x.at(x.size()-i-1);
  }
  return false;   
}
  
int main() {
  int n, k;
  cin >> n >> k;  
  vector<int> vec(n);
  vector<int> yakusu;
  for(int i = 0; i<n; i++) cin >> vec.at(i);
  int sum = 0;
  for(int i = 0; i<n; i++) sum+=vec.at(i);
  for(int i = 1; i<=sum; i++) {
    if((sum % i)==0){
      yakusu.push_back(i);
     }
  }
  int m = yakusu.size();
  int ret = 0;
  for(int i; i<m; i++){
    int candidate = yakusu.at(yakusu.size()-1);
    yakusu.pop_back();
    if (feasible(vec, candidate, k)) {
      ret = candidate;
      break;
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
const LL mo = 998244353;
const int N = 2002;
int n,k;
LL c[N][N],f[N][N],g[N][N];

int main() {
    for(int i=0;i<N;i++)c[i][0]=1;
    for(int i=1;i<N;i++)for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mo;
    f[0][0]=g[0][0]=1;
    f[1][0]=g[1][0]=1;
    for(int i=1;i<N;i++){
        f[1][i]=1; g[1][i]=2;
    }
    for(int i=2;i<N;i++){
        f[i][0]=g[i][0]=1;
        LL s1[N]={0},s2[N]={0};
        s1[0]=f[i-1][0],s2[0]=g[i-1][0];
        for(int j=1;j<N;j++){
            s1[j]=(s1[j-1]+f[i-1][j])%mo;
            s2[j]=(s2[j-1]+g[i-1][j])%mo;
        }
        for(int j=1;j<N;j++){
            f[i][j]=s1[j];
            g[i][j]=(s2[j-1]*2+g[i-1][j])%mo;
        }
    }
    scanf("%d%d",&k,&n);
    LL ans[N<<2];
    for(int i=2;i<=2*k;i++){
        if(i>2*k+2-i){
            printf("%lld\n", ans[2*k+2-i]); continue;
        }
        ans[i]=0;
        if(i%2==1){
            // 1....i-1 i....k
            for(int j=0;j<=n;j++){
                LL c1=f[k-i+1][j];
                LL c2=g[(i-1)/2][n-j];
                (ans[i]+=c1*c2)%=mo;
            }
        } else {
            for(int j=0;j<=n;j++){
                LL c1=f[k-i+1][j];
                LL c2=g[i/2-1][n-j]+((j!=n)?g[i/2-1][n-j-1]:0);
                //printf("j=%d, c1=%lld, c2=%lld\n", j,c1,c2);
                (ans[i]+=c1*c2)%=mo;
            }
        }
        printf("%lld\n", ans[i]);
    }
}





Measured memory_bytes: 94208
//This code is solely the property of StarnyC

#include<bits/stdc++.h>
using namespace std;
int main()

{int h,w;
cin>>h>>w;
char p[h+2][w+2];
for(int j=0;j<h+2;j++)
{for(int i=0;i<w+2;i++)
 if(i==0||i==w+1||j==0||j==h+1){p[j][i]='#';}




 else{cin>>p[j][i];};
 
 
}



for(int m=0;m<h+2;m++){
	for(int n=0;n<w+2;n++){
		cout<<p[m][n];
	}
	cout<<endl;
}




}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[500000];    //    p---|  Unit
int *left2 = new  int[500000]; // left2 --|--------> T
int *right2 = new int[500000];//right2---|
int *key = new int[500000];  // key----|
 
void Init(){
  rep(i,500000){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
 
 
int FindRoot(){
  rep(i,n){
    if(p[i] == NIL){
      return i;
    }
  }
}
 
 
 
void TREE_INSERT(int z){
  int y = NIL; 
  int x = root;
 
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
 
}
 
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
 
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
 
 
int main(){
  int val;
  string op;
  int zr;                    
 
 
  scanf("%d",&n);
  Init(); 
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;        
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
  }
 
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
 
  return 0;
}

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

int main() {
    int64_t n;
    cin >> n;
    int64_t ans = 1e12;
    for(int64_t i = 1; i * i <= n; i++) {
        int64_t j = n / i;
        if(i * j == n) ans = min(ans, i + j - 2);
    }
    cout << ans << endl;
}


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

ll mod = 1e9+7;
ll calc(ll a,ll p){
  if(p==0) return 1;
  if(p%2==0){
    ll d = calc(a,p/2);
    return d*d%mod;
  }else{
    return a*calc(a,p-1)%mod;
  }
}
ll comb(ll n, ll k){
  if(n<k) return 0;
  ll mo = 1;
  ll ch = 1;
  for(int i=0;i<k;i++){
    mo *= n-i;
    mo %= mod;
    ch *= i+1;
    ch %= mod;
  }
  ll res = mo*calc(ch,mod-2);
  return res%mod;
}
int main(){
  ll N,K; cin >> N >> K;
  for(int i=1;i<=K;i++){
    ll ans = comb(K-1,i-1)*comb(N-K+1,i);
    cout << ans%mod << endl;
  }
}


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

long long p[20], q[20], power[20];

void solve(long long V) {
	for (int i = 0; i <= 17; i++) q[i] = p[i];
	long long S = 0; for (int i = 0; i <= 17; i++) S += q[i];

	if (S == V) return;
	if (S > V) {
		for (int i = 0; i < 17; i++) {
			if (q[i] != 0) {
				q[i + 1]++; q[i] = 0;
				int c = i + 1;
				while (q[c] >= 10) { q[c] -= 10; q[c + 1]++; c++; }
			}
			int S = 0;
			for (int j = 0; j < 17; j++) S += q[j];
			if (S <= V && V <= S + (i + 1) * 9) {
				for (int j = 0; j < 17; j++) {
					while (q[j] < 9 && S != V) { q[j]++; S++; }
				}
				return;
			}
		}
		return;
	}
	if (S < V) {
		for (int i = 0; i < 17; i++) {
			int S = 0;
			for (int j = 0; j < 17; j++) S += q[j];
			if (S <= V && V <= S + (9 - q[i])) {
				q[i] += (V - S);
				return;
			}

			q[i] = 9;

			if (q[i] != 0) {
				q[i + 1]++;
				int c = i + 1;
				while (q[c] >= 10) { q[c] -= 10; q[c + 1]++; c++; }
			}
		}
		return;
	}
}

long long FixNum() {
	long long s = 0, t = 1;
	for (int i = 0; i < 17; i++) {
		s += 1LL * q[i] * t; t *= 10;
	}
	return s;
}

long long K, rem = 1;

int main() {
	cin >> K;
	for (int i = 1; i <= K; i++) {
		long long minx = (1LL << 60); long double minid = 1e18;
		for (int j = 1; j <= 135; j++) {
			solve(j);
			long long J = FixNum();
			long double E = 1.0L*J / j;
			if (minid > E) {
				minid = E; minx = J;
			}
		}
		printf("%lld\n", minx); minx++;
		for (int j = 0; j < 19; j++) {
			p[j] = minx % 10; minx /= 10;
		}
	}
	return 0;
}

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

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    
    int hp=a.at(0);
    for(int i=1; i<n; i++){
        hp=gcd(a.at(i),hp);
    }
    cout << hp << endl;
    
}

Measured memory_bytes: 3760
import statistics as st
n = int(input())
s = input()
NGs = 0
r = set()
g = set()
b = set()
for i in range(n):
  if s[i] == "R":
    r.add(i)
  elif s[i] == "G":
    g.add(i)
  else:
    b.add(i)
for i in range(n-2):
  for d in range((n-i-1)//2+1):
    j = i+d
    k = j+d
    if i in r and j in g and k in b:
      NGs += 1
    elif i in r and j in b and k in g:
      NGs += 1
    elif i in g and j in r and k in b:
      NGs += 1
    elif i in g and j in b and k in r:
      NGs += 1
    elif i in b and j in r and k in g:
      NGs += 1
    elif i in b and j in g and k in r:
      NGs += 1
print(len(r)*len(g)*len(b)-NGs)

Measured memory_bytes: 11176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n,p,ans,cur=0,t=1,i,cnt[10005];
string s;
int main(){
    cin>>n>>p>>s;
    if(p==2 || p==5){
        for(i=0;i<n;i++)
            if((s[i]-'0')%p==0) ans+=i+1;
    }
    else{
        cnt[0]=1;
        for(i=n-1;i>=0;i--){
            cur=(cur+(s[i]-'0')*t)%p;
            ans+=cnt[cur]++;
            t=t*10%p;
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 644
#include<iostream>
using namespace std;
main(){
string s,u="[<++++++++++>-]>",c=">+++++[<++++++>-]>+++++[<++++++++>-]>+++++"+u+"++++++"+u+"+++++++"+u+"++++++++"+u+"+++++++++"+u+"++++++++++"+u+"+++++++++++"+u+"++++++++++++"+u+"<<<<<<<<<<<";
int p=0,i,j,a,b,d;
for(cin>>s,i=0;i<s.length();++i){
a=s[i]/10-3,b=a-p,p=a,d=s[i]-(a+3)*10;
for(j=b>0?b:-b;j--;)c+=(b>=0?62:60);
for(j=d;j--;)c+=43;
c+=46;
for(j=d;j--;)c+=45;
}
cout<<c<<endl;
}

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

#define lint long long

lint MOD = 1000000007;

using namespace std;

int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; ++i){
        cin >> p[i];
    }
    
    int cnt = 0;
    for(int i = 1; i < N - 1; ++i){
        if(p[i-1] < p[i] && p[i] < p[i+1]) cnt++;
        if(p[i-1] > p[i] && p[i] > p[i+1]) cnt++;
    }
    cout << cnt << endl;
    
}

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

int main() {
  int N;
  cin >> N;
  int l, r;
  int x = 0;
  
  for(int i = 0; i < N; i++) {
    cin >> l >> r;
    x += r - l + 1;
  }
  
  cout << x << endl;  
  
}

Measured memory_bytes: 3592
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import           Data.Ratio
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- map read.words <$> getLine :: IO [Integer]
    print $ solve xs


solve :: [Integer] -> Double
solve (L.sort -> xs) = go $ map (%1) xs
  where
    go (x:y:xs) = go $ L.insert ((x+y)/2) xs
    go [x] = fromRational x



Measured memory_bytes: 892
import java.util.*;
import java.util.Map.Entry;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {	
	static char[] tank = new char[] {'^','>','v','<'};
	static int[] vx = new int[] {0,1,0,-1};
	static int[] vy = new int[] {-1,0,1,0};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int TIME = 0; TIME < t; TIME++) {
			if(TIME != 0) 			System.out.println();
			int h = sc.nextInt();
			int w = sc.nextInt();
			char[][] map = new char[h][w];
			for(int i = 0; i < h; i++) {
				map[i] = sc.next().toCharArray();
			}
			int n = sc.nextInt();
			char[] cmd = new char[n];
			cmd = sc.next().toCharArray();
			int x = 0;
			int y = 0;
			int d = 0;
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(map[i][j] == '^') {
						x = j;
						y = i;
						d = 0;
						continue;
					}
					else if(map[i][j] == '>') {
						x = j;
						y = i;
						d = 1;
						continue;
					}
					else if(map[i][j] == 'v') {
						x = j;
						y = i;
						d = 2;
						continue;
					}
					else if(map[i][j] == '<') {
						x = j;
						y = i;
						d = 3;
						continue;
					}
				}
			}
			for(int i = 0; i < n; i++) {
				char CMD = cmd[i];
				if(CMD == 'U') {
					dChange(map,y,x,0);
					d = 0;
					boolean check = rangeCheck(map,y-1,x);
					boolean change = false;
					if(check) change = move(map,y,x,0);
					if(change) {
						y = y + vy[d];
						x = x + vx[d]; 
					}
				}
				if(CMD == 'D') {
					dChange(map,y,x,2);
					d = 2;
					boolean check = rangeCheck(map,y+1,x);
					boolean change = false;
					if(check) change = move(map,y,x,2);
					if(change) {
						y = y + vy[d];
						x = x + vx[d]; 
					}
				}
				if(CMD == 'R') {
					dChange(map,y,x,1);
					d = 1;
					boolean check = rangeCheck(map,y,x+1);
					boolean change = false;
					if(check) change = move(map,y,x,1);
					if(change) {
						y = y + vy[d];
						x = x + vx[d]; 
					}
				}
				if(CMD == 'L') {
					dChange(map,y,x,3);
					d = 3;
					boolean check = rangeCheck(map,y,x-1);
					boolean change = false;
					if(check) change = move(map,y,x,3);
					if(change) {
						y = y + vy[d];
						x = x + vx[d]; 
					}
				}
				if(CMD == 'S') {
					shot(map,y,x,d);
				}
			}
			for(int i = 0; i < h; i++) {
				System.out.println(String.valueOf(map[i]));
			}
		}
	}
	static void dChange(char[][] map, int y, int x, int d) {
		map[y][x] = tank[d];
	}
	static boolean rangeCheck(char[][] map, int y, int x) {
		if(y < 0 || x < 0 || y >= map.length || x >= map[y].length) return false;
		return true;
	}
	static boolean move(char[][] map ,int y, int x, int d) {
		int ty = y + vy[d];
		int tx = x + vx[d];
		if(map[ty][tx] == '.') {
			map[y][x] = '.';
			map[ty][tx] = tank[d];
			return true;
		}
		return false;
	}
	static void shot(char[][] map, int y, int x, int d) {
		int Y = y + vy[d];
		int X = x + vx[d];
		while(true) {
			if(!rangeCheck(map,Y,X)) {
				break;
			}
			if(map[Y][X] == '*') {
				map[Y][X] = '.';
				break;
			}
			if(map[Y][X] == '#') {
				break;
			}
			Y = Y + vy[d];
			X = X + vx[d];
		}
	}
	
 }

Measured memory_bytes: 36864
from copy import copy
import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    for i in range(k):
        imos = [0] * (n+1)
        for i in range(n):
            imos[max(0, i-a[i])] += 1
            imos[min(n, i+a[i]+1)] -= 1
        for i in range(n):
            imos[i+1] += imos[i]
        a = copy(imos[:-1])
        if all((a[i]==n for i in range(n))):
            break

    for i in a:
        print(i, end = ' ')

if __name__ == '__main__':
    main()


Measured memory_bytes: 169576
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r()) for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)


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

int main() {
	int length;
  	int count;
  	cin >> count >> length ;
  	string str[count];
  	for(int i = 0; i < count ; i++){
      cin >> str[i];
      //cout << str[i]<<endl ;
    }
  	for (int j = 0; j< count ; j++){
      for(int k = j+1;k <count ;k++){
        //cout << j <<" "<<str[j] << " "<<k<< " "<<str[k]<<endl;
        if(str[k] < str[j]){
          swap(str[j],str[k]);
          //cout << str[j] <<str[k]<<endl;
        }
      }
    }
  string ans;
  for(int l = 0; l < count ; l++){
  	ans += str[l];
  }
  cout << ans <<endl;
	
}

Measured memory_bytes: 256
def join(xs, N):
    n = len(xs)
    r = ""
    s = 0
    for i, x in enumerate(xs):
        x = x.strip()
        t = len(x.split())
        S,E="."*s,"."*(N-t-s)
        for l in x.split():
            r+=S+l+E+"\n"
        s += t
    return r
s7="""
.bc.a..
.bc.a..
..aabba
aab...a
x.baa..
x..b.aa
aa.b.xx
"""
s6="""
..aabx
d...bx
dla...
.lab..
xx.bxx
ddaall"""
s5="""
aa.bx
d..bx
dee.a
i.rra
ijjxx
"""
s4="""
xyzz
xyrr
zzxy
rrxy"""
s3="""
jj.
..j
..j"""

s=[s4,s5,s6,s7]
N=int(input())
if N<3:
    print(-1)
elif N==3:
    print(s3.strip())
elif N<=7:
    print(s[N-4].strip())
else:
    print(join([s[0]]*(N//4-1)+[s[N%4]],N))


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

int main(){
  int ans = 0;
  string s;
  
  cin >> s;
   
  for(int i = 0; i < s.size()/2; i++){
    if(s[i] != s[s.size()-1-i]){
      ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static long VALUE = 1000000007;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int num = scan.nextInt();

		long count = 1;

		for (long i = 1; i <= num; i++) {
			count *= i;
			count %= VALUE;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
int main(void){
        int n, a[10000], i;
    
    scanf("%d\n", &n);
    for(i = 0; i < n; i++) {
        scanf("%d ", &a[i]);
    }
    
    long min = a[0], max = a[0];
    long sum = 0;
    for(i = 0; i < n; i++) {
        if (a[i] < min) min = a[i];
        if (a[i] > max) max = a[i];
        sum += a[i];
    }
    
    printf("%ld %ld %ld\n", min, max, sum);
    
    return 0;
}


Measured memory_bytes: 2048
import java.util.*;
public class Main {
	static int dp[]=new int[100001];
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		ArrayList<ArrayList<Integer>> g=new ArrayList<ArrayList<Integer>>();
		for(int i=0;i<n;i++){
			g.add(new ArrayList<Integer>());
		}
		for(int i=0;i<m;i++){
			int x=sc.nextInt();
			int y=sc.nextInt();
			g.get(x-1).add(y-1);
		}
		int ans=0;
		for(int i=0;i<n;i++){
			ans=Math.max(ans,dfs(i,g));
		}
		System.out.println(ans);
	}
	public static int dfs(int i,ArrayList<ArrayList<Integer>> g){
		int temp=0;
		if(dp[i]!=0){
			return dp[i];
		}
		for(int z:g.get(i)){
			temp=Math.max(temp,dfs(z,g)+1);
		}
		dp[i]=temp;
		return temp;
	}
}

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

vector<pair<int, int>> edges[100000];

bitset<100000> visited;
int sign[100000];
int64_t V[100000], offset;
bool offset_fixed;

void fail(){
    cout << 0 << endl;
    exit(0);
}

void dfs(int i){
    for(auto& p : edges[i]){
        int j = p.first, c = p.second;
        if(!visited[j]){
            sign[j] = -sign[i];
            V[j] = c-V[i];
            visited[j] = 1;
            dfs(j);
        }else{
            if(sign[i] == sign[j]){
                if(offset_fixed){
                    int64_t v = V[i] + V[j] + 2*sign[i]*offset;
                    if(v != c) fail();
                }else{
                    int64_t diff = c - ( V[i] + V[j]);
                    if(diff%2) fail();
                    offset = diff/2*sign[i];
                    offset_fixed = true;
                }
            }else{
                if(V[i] + V[j] != c) fail();
            }
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }

    sign[0] = 1;
    dfs(0);

    int64_t ans;
    if(offset_fixed){
        for(int i=0; i<N; i++) if(V[i] + sign[i] * offset <= 0) fail();
        ans = 1;
    }else{
        int64_t mn1 = 1e18, mn2 = 1e18;
        for(int i=0; i<N; i++){
            if(sign[i] == 1){
                mn1 = min(mn1, V[i]);
            }else{
                mn2 = min(mn2, V[i]);
            }
        }
        ans = max(int64_t(0), mn1+mn2-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11648
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;


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

	int n;
	cin >> n;
	
	vector<int> ls(n);
	FOR(i,0,n){
    	cin >> ls[i];
    }
    sort(ls.begin(), ls.end());
    
    

    //最大辺取り出し、削除
    int lmax = ls.back();
    ls.pop_back();
    //cout << lmax << endl;
    
    //FOR(i, 0, ls.size()) cout << ls[i] << endl;
    
    int sum = accumulate(ls.begin(), ls.end(), 0);
    //cout << sum << endl;
    
    if (lmax < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
use proconio::{ input, fastout };

#[fastout]
fn main() {
    input! {
        n: usize,
    };
    if (n % 1000) == 0 {
        println!("{}", 0);
    } else {
        let r = n % 1000;
        println!("{}", 1000 - r);
    }
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
bool vis[441];
ll n,m,P,Q,f,lev[441];
char s[441]; 
vec adj[441];
ll bfs(ll i)
{
	queue<ll> q;
	q.push(i);
	vis[i]=true;
	lev[i]=0;
	while(!q.empty())
	{
		P=q.front();
		q.pop();
		rep(j,0,adj[P].size())
		{
			Q=adj[P][j];
			if(!vis[Q])
			{
				lev[Q]=lev[P]+1;
				f=max(f,lev[Q]);
				q.push(Q);
				vis[Q]=true;
			}
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,d,k,ac,J;
    	cin>>n>>m;
    	k=0; d=0;
    	rep(i,0,n*m)
    	{
    		cin>>s[i];
    		vis[i]=false;
    		lev[i]=0;
		}
		rep(i,0,n)
		{
			rep(j,0,m-1)
			{
				if(s[m*i+j]!='#' && s[m*i+j+1]!='#')
				{
					adj[m*i+j].pb(m*i+j+1);
					adj[m*i+j+1].pb(m*i+j);
				}
			}
		}
		rep(j,0,m)
		{
			rep(i,0,n-1)
			{
				if(s[m*i+j]!='#' && s[m*(i+1)+j]!='#')
				{
					adj[m*i+j].pb(m*(i+1)+j);
					adj[m*(i+1)+j].pb(m*i+j);
				}
			}
		}
		f=0;
		rep(i,0,n*m)
		{
			if(s[i]!='#')
			bfs(i);
			rep(j,0,n*m)
			{
				vis[j]=false;
				lev[j]=0;
			}
		}
    	cout<<f;
    }
	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){
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	}
	private static String shuffle(String order){
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	}
}

Measured memory_bytes: 26492
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func numberToString(input int) string {
	temp := strconv.Itoa(input)
	length := 3 - len(temp)
	for i := 0; i < length; i++ {
		temp = "0" + temp
	}
	return temp
}

func main() {
	sc.Split(bufio.ScanWords)
	X := nextInt()
	sc.Scan()
	S := sc.Text()
	ans := 0
	for i := 0; i <= 999; i++ {
		temp := numberToString(i)
		check := 0
		for j := 0; j < X; j++ {
			if temp[check] == S[j] {
				check++
				if check == 3 {
					ans++
					break
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

int main() {
	int n, k;
	cin >> n >> k;
	if(k <= (n+1)/2) puts("YES");
	else puts("NO");
	return 0;
}

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

int main() {

  string text1="abcdefghijklmnopqrstuvwxyz";
  string text2="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char X,Y,Z;
  
  cin >> Z; 

   for (int i=0; i<26; i++) {
    
     X = text1.at(i);
     Y = text2.at(i);
     
     if(Z==X){
       cout << "a" << endl;
     }
     if(Z==Y){
       cout << "A" << endl;
     }
   }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int a, b, c;

	cin >> a >> b >> c;
	
	if (a == b && b == c)
		cout << '1';
	else if (a != b && b != c && a != c)
		cout << '3';
	else
		cout << '2';

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

const int p=1000000007;

int i,n1,n2,s;

int main()
{
	scanf("%d%d",&n1,&n2);
	if (abs(n1-n2)>1)
		printf("0");
	else
	{
		s=1;
		if (n1==n2)
			s=2;
		for (i=1;i<=n1;i++)
			s=1LL*s*i%p;
		for (i=1;i<=n2;i++)
			s=1LL*s*i%p;
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
int a[100000], b[100000];

P p[200000];
void solve(){
	sort(p, p + N * 2);
	ll c = 0;
	ll ans = 1;
	rep(i, N * 2){
		if(abs(c) > abs(c + p[i].second)){
			ans *= abs(c);
			ans %= MOD;
		}
		c += p[i].second;
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N) {
		cin >> a[i];
		p[i] = P(a[i], 1);
	}
	rep(i, N) {
		cin >> b[i];
		p[i + N] = P(b[i], -1);
	}
		solve();
	return 0;
}


Measured memory_bytes: 2560
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=3e3+5;
ll n  ;
ld p[maxN] , dp[maxN][maxN];
void solve(){
	cin>> n ;
	for(ll i=0;i<n ;i++)cin>>p[i];
	dp[0][0]=1-p[0]; dp[0][1]=p[0];
	for(ll i=1;i<n ;i++){
		for(ll j=0 ; j<maxN ; j++){
			dp[i][j]+=(1-p[i])*(dp[i-1][j]);
			if(j-1>=0){
				dp[i][j]+=p[i]*(dp[i-1][j-1]);
			}
		}
	}
	ld ans=0;
	for(ll i=n/2+1;i<maxN ; i++){
		ans +=(dp[n-1][i]);
	}
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;
}
int main(){
	//mahakal();
	fast;
	ll t =1 ;
	//cin>> t ; 
	while(t--)solve();
	//cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 144612
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
bool a[3] ;
int main()
{
    ll a , b  ;
    cin>>a>>b ;
    if (a<b)
        swap(a,b) ;
    for (ll i = 1 ; ; i++)
    {
        if ((a*i)%b==0)
        return cout<<a*i, 0 ;
    }
}




Measured memory_bytes: 256
from functools import cmp_to_key
n, m = map(int, input().split())
a = [int(e) for e in input().split()]
bc = [[int(e) for e in input().split()] for _ in range(m)]
bc.sort(key = cmp_to_key(lambda x, y: y[1] - x[1]))
t = 0
for v in bc:
  b, c = v
  t += b
  a.extend([c] * b)
  if t > n:
    break
a.sort(reverse = True)
print(sum(a[:n]))


Measured memory_bytes: 30696
#include <iostream>
#include <map>

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;
int n, w;

pi items[100];
ll memo[100][100000];
ll dp(int i, ll c)
{
	if(i < 0)
		return 0;
	else if(memo[i][c] != 0)
		return memo[i][c];
	else
	{
		int weight = items[i].first;
		int value = items[i].second;
		ll best = dp(i-1, c);
		if(c+weight <= w)
			best = max(best, value + dp(i-1, c+weight));
		return memo[i][c] = best;
	}
}

int main()
{
	cin >> n >> w;
	for(int i = 0; i < n; i++)
	{
		pi pa;
		cin >> pa.first >> pa.second;
		items[i] = pa;
	}
	cout << dp(n-1, 0LL) << endl;
}


Measured memory_bytes: 75012
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = ReadLine().ToCharArray();
            Array.Sort(S);
            Write(S[0] ==S[1] && S[1] != S[2] && S[2] == S[3] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan= new Scanner(System.in);
int b=scan.nextInt();
int[] c;
c =new int[10001];

for(int a=3;a<=b;a++){
int d=a;
if(d%3==0)
	c[a]=1;
else
	c[a]=0;
while(true){
	if(d%10==3){
		
		c[a]=1;
		break;
	}
d=d/10;
if(d==0)
	break;

}
}
for(int i=3;i<=b;i++){
	if(c[i]==1)
		System.out.print(" "+i);
}
System.out.println();
}
}

Measured memory_bytes: 29064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] != t[i]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

}

Measured memory_bytes: 35480