akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

char str[15];
int n;

void track(int ind,char maxi) {
	if (ind==n-1) {
		printf("%s\n",str);
		return;
	}
	for(char i='a';i<=maxi+1;i++) {
		str[ind+1]=i;
		track(ind+1,max(maxi,i));
	}
}

int main(void) {
	scanf("%d",&n);
	str[0]='a';
	track(0,'a');
}

Measured memory_bytes: 1536
#include<stdio.h>

int main(void){
  int n,m,s=0;

  scanf("%d",&n);

  m = n;

  while(n!=0){
    s+=n % 10;
    n /= 10;
  }

  if(m % s==0)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


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

int main() {
    long long N;
    cin >> N;

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

    /*vector<ll> dp(6, 0);
    long long tim = 0;

    dp[0] = N;

    while(dp[5] < N){

        for(int i = 4; i >= 0; i--)
        {
            if(dp[i] >= a[i]){
            dp[i+1] += a[i];
            dp[i] -= a[i];
            }
            else {
                dp[i+1] += dp[i];
                dp[i] = 0;
            }
        }
        cout << dp[5] << endl;

        tim += 1;
        
    }*/

    ll min = a[0];
    int pos = 0;
    for(int i = 0; i < 5; i++)
    {
        if(a[i] < min){
            pos = i;
            min = a[i];
        }
    }

    ll tim = pos + (N + min - 1)/min + 4 - pos;
    
    

    cout << tim << endl;
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,k;
int mmp=10000;
vector<int> l;
int rec(int pi,int la,int lb,int lc,int pmp){
 if(pi==n){
   if(la&&lb&&lc){
   mmp=min(mmp,pmp+abs(la-a)+abs(lb-b)+abs(lc-c));return mmp;}else{
     return mmp;
   }
 }
 rec(pi+1,la,lb,lc,pmp);
 rec(pi+1,la+l[pi],lb,lc,pmp+(la?10:0));
 rec(pi+1,la,lb+l[pi],lc,pmp+(lb?10:0));
 rec(pi+1,la,lb,lc+l[pi],pmp+(lc?10:0));
 return mmp;
}
int main(){
cin>>n>>a>>b>>c;
for(int i=0;i<n;i++){
  cin>>k;
l.push_back(k);
}
  cout<<rec(0,0,0,0,0)<<endl;

}

Measured memory_bytes: 256
def cost(i, y):
    if i == 1:
        return 5 * y
    else:
        return (2*i+1) * y


n, x = [int(_) for _ in input().split()]
xl = [int(_) for _ in input().split()]
xl.reverse()
sl = [0] * (n+1)
for i in range(n):
    sl[i+1] = sl[i] + xl[i]
answer = float('inf')
for k in range(1, n+1):
    sum = (n+k)*x
    c = n//k
    for i in range(c):
        sum += cost(i+1, (sl[k*(i+1)]-sl[k*i]))
    sum += cost(c+1, sl[n]-sl[k*c])
    answer = min(answer, sum)
print(answer)


Measured memory_bytes: 26376
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int x,a,b,d;
int main(){
	cin>>x>>a>>b;
	d=x-a;
	if((x-a)%b==0)cout<<"0";
	else cout<<(x-a)%b;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int n,m;
const int Mod=1e9+7;
long long f[1010][1010];

int main()
{
	scanf("%d%d",&n,&m);
	f[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char c;
			cin>>c;
			if(c=='#' || (i==1 && j==1)) continue;
			f[i][j]=f[i-1][j]+f[i][j-1];
			f[i][j]%=Mod;	
		}
	}
	printf("%lld",f[n][m]%Mod);
	return 0;
}





Measured memory_bytes: 8192
from collections import defaultdict
MOD = 998244353
n, s = map(int, input().split())
a = list(map(int, input().split()))

two_inv = pow(2, MOD - 2, MOD)

# dp[i][j] = i番目まで見て和がjとなるような場合の数
dp = [[0] * (s + 1) for _ in range(n + 1)]
dp[0][0] = pow(2, n, MOD)
for i, ai in enumerate(a):
    for j in range(s + 1):
        if j - ai >= 0:
            dp[i + 1][j] = (dp[i][j] + dp[i][j - ai] * two_inv) % MOD
        else:
            dp[i + 1][j] = dp[i][j]

# print(*dp, sep='\n')
print(dp[n][s])
# # dp[i][j] = i個使って和がjとなるような場合の数
# dp = [[defaultdict(int)] * (s + 1) for _ in range(n + 1)]
# dp[0][0][0] = 1
# for ai in a:
#     dp[1][ai] += 1


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

int main()
{
    int K;
    cin >> K;
    
    int N[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    cout << N[K-1] << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vi v(n, 1), ok(n);
	ok[0] = 1;
	rep(i, m){
		int a, b; cin >> a >> b; a--; b--;
		ok[b] |= ok[a];
		v[b]++;
		if(--v[a] == 0) ok[a] = 0;
	}
	cout << accumulate(all(ok), 0) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;
#define ALL(obj) (obj).begin(),(obj).end()
struct edge{
    ll to, cost;
};

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;
}

// 数字の桁数
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

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

int main(){
    ll x;
    cin>>x;
    if(x == 0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;


int main() {
  int n;
  cin >> n;
  vector <string> s(n);
  vector <int> t(n);
  REP(i, n) {
	cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;
  bool flg = false;
  int ans  = 0;
  REP(i, n) {
	if (flg) {
		ans += t[i];
	  }
	if (s[i] == x) {
		flg = true;
	  }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n, m;
	cin >> n >> m;
	
	int x;
	priority_queue<int> pq;
	long long res = 0;
	for(int i = 0; i < n; ++i){
		cin >> x;
		pq.push(x);
		res += x;
	}

	while(m--){
		int top = pq.top();
		pq.pop();
		int after = top / 2;
		res -= (top - after);
		pq.push(after);
	}

	cout << res;
    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){
    
  char s[258] = {}, tmp[258] = {};
  int m, h, i, l;
  while(scanf("%s", s) && s[0] != '-'){
    scanf("%d", &m);
    while(m--){
      scanf("%d", &h);
      strcpy(tmp, s + h);
      s[h] = '\0';
      strcat(tmp, s);
      strcpy(s, tmp);
    }
    puts(s);
  }

    return 0;
}


Measured memory_bytes: 2108
package main

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

func main() {
	// s[i + 2] = s[i] + s[i+1]
	const mod = 1000000007
	var n, m int
	fmt.Scan(&n, &m)
	s := make([]int64, n+1)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var a int
	for i := 0; i < m; i++ {
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		s[a] = -1 // broken floor
	}
	if s[0] >= 0 {
		s[0] = 1
	}
	if s[1] >= 0 {
		s[1] = 1
	}
	for i := 0; i < n-1; i++ {
		if s[i+2] < 0 {
			continue
		}
		if s[i] >= 0 {
			s[i+2] = s[i]
		}
		if s[i+1] >= 0 {
			s[i+2] = (s[i+2] + s[i+1]) % mod
		}
	}
	fmt.Println(s[n])
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

int nyan(int x){
	int cnt = 0;
	while(x % 2 == 0){
		x /= 2;
		cnt++;
	}
	return cnt;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a[3], b[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}

	if(a[0]==a[1] and a[1]==a[2]){
		if(a[0] % 2 == 0){
			cout << -1 << endl;
		} else {
			cout << 0 << endl;
		}
		return 0;
	}

	int ans = 0;
	while(1){
		b[0] = a[0]; b[1] = a[1]; b[2] = a[2];
		int sum = a[0]+a[1]+a[2];
		if((sum-a[0])%2 != 0) break;
		if((sum-a[1])%2 != 0) break;
		if((sum-a[2])%2 != 0) break;

		for (int i = 0; i < 3; i++) {
			a[i] = (sum-b[i]) / 2;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main(){
	int a[100050]={0},times[100050]={0},i,j,n;
	scanf("%d",&n);
	int max=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]!=0){
			times[a[i]-1]++;
		}
		times[a[i]]++;
		times[a[i]+1]++;
	}
	for(i=0;i<100050;i++){
		if(max<times[i]){
			max=times[i];
		}
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 896
//  main.cpp
//  CppTest

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

int main(int argc, const char * argv[]) {
    // input from txt （提出時にこの箇所は削除すること）
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////

    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout<<"vowel"<<endl;
    }
    else{
        cout<<"consonant"<<endl;
    }
    
    
    return 0;
}


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

using namespace std;

int main(){
  int n,w,v;
  while(cin >> n >> w, n){
    int N = 0;
    double p[11] = {0};
    for(int i = 0 ; i < n ; i++){
      cin >> v; p[v/w]++;
      N = max(N,v/w);
    }
    double d = *max_element(p,p+11),ans = 0.0;
    for(int i = 0 ; i < N ; i++){
      ans += (p[i]/d)*((double)(N-i)/N);
    }
    printf("%.10f\n",ans+0.01);
  }
  return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int max = 0;

    rep(i, s.size())
    {
        if (s[i] == 'I')
            ++x;
        else
            --x;
        max = x > max ? x : max;
    }

    cout << max << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int EPS = 1e-10;

int main() {
	ll n;
	cin >> n;
	int c = 0;
	ll x = 100;
	while (x < n) {
		c++;
		x += x / 100 + EPS;
	}
	cout << c << endl;
}

Measured memory_bytes: 3636
let input=require("fs").readFileSync("/dev/stdin","utf8");
let cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
//input from catoonさん


class UnionFind {
    p: number[]; 
    sizes: number[];
    tmpsize:number;
    constructor(n: number) {
        this.p = [];
        this.sizes = [];
        for (let i = 0; i <  n; i++) {
            this.p.push(i);
            this.sizes.push(1);
        }
        this.tmpsize = n;
    }
    find(x:number){
        if(this.p[x] ===x){
            return x;
        }else{
            let tmp  = this.find(this.p[x]);
            return tmp;
        }
    }
    unite(x:number,y:number){
        if(this.find(x) === this.find(y))return;
        
            let [large,small] = this.sizes[this.find(x)]>=this.sizes[this.find(y)]?[this.find(x),this.find(y)]:[this.find(y),this.find(x)];
        
        this.p[small] = large;
        this.sizes[large] += this.sizes[small];
        this.tmpsize--;

    }
    is_same(x:number,y:number){
        return this.find(x) === this.find(y);
    }
}
function main(){
    let n  = next();
    let q = next();
    let uf = new UnionFind(n);
    while(q--){
        let condition = next();
        let tmp = next();
        let tmp1 = next();
        if(condition === 0){
            uf.unite(tmp,tmp1);
        }
        else{
            if(uf.is_same(tmp,tmp1)){
                console.log(1);
            }
            else{
                console.log(0);
            }
            
        }
    }
    return;
}
main();


Measured memory_bytes: 104000
MOD = 1000000007

H, W = map(int, input().split())
A = [input() for _ in range(H)]

dp = [[0 for j in range(W)] for i in range(H)]
dp[0][0] = 1

for i in range(1, H):
    if A[i][0] == '.':
        dp[i][0] = dp[i - 1][0]

for j in range(1, W):
    if A[0][j] == '.':
        dp[0][j] = dp[0][j - 1]

for i in range(1, H):
    for j in range(1, W):
        if A[i][j] == '.':
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
            dp[i][j] %= MOD

print(dp[H - 1][W - 1])

Measured memory_bytes: 83556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int x = sc.nextInt();
			if (x == 0 && n == 0){
				break ;
			}
			int count = 0;
			for(int i = 1; i <= n - 2; i++){
				for(int j = i + 1; j <= n - 1 ; j++){
					for(int k = j + 1; k <= n; k++){
						if(i + j + k == x){
							count ++;
						}
					}
				}
			}

			System.out.println(count);
		}
	}
}


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

int dfs(int flg, long long n){
    int cnt=0;
    if(n > N){
        return 0;
    }
    else{
        if (flg==0b111) {
            //cout << n << " " << bitset<3>(flg) << endl;
            cnt++;
        }

    }

    cnt += dfs(flg|0b001,  10*n + 3);
    cnt += dfs(flg|0b010,  10*n + 5);
    cnt += dfs(flg|0b100,  10*n + 7);

    return cnt;

    



}

int main()
{
    cin >> N;

    cout << dfs(0,0) << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void swap(long int v[], int i, int j){
	int temp;
	temp = v[i];
	v[i] = v[j];
	v[j] = temp;
}
void qsort(long int v[], int left, int right){
	int i, last;
	if(left >= right)
		return;
	swap(v, left, (left + right) / 2);
	last = left;
	for(i = left+1; i <= right; i++)
		if(v[i] < v[left])
			swap(v, ++last, i);
	swap(v, left, last);
	qsort(v, left, last-1);
	qsort(v, last+1, right);
}
int main(){
	long int L[101];
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%ld", &L[i]);
	qsort(L, 1, N);
	int n = N;
	long int ans = 0;
	while(n >= 1){
		int s = n - 1;
		while(s - 1 >= 1){
			if(L[n] > L[s]){
				for(int t = s - 1; t >= 1; t--){
                      if(L[s] + L[t] > L[n])
                        if(L[s] > L[t])
						 ans++;
					  //else
						//break;
                }
			}
			s--;
		}
		n--;
	}
	printf("%ld", ans);
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

struct mint {
    ll x;
    mint(ll x=0): x(x%MOD){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) {
            x -= MOD;
        }
        return *this;
    }
    mint& operator-=(const mint a) {
        if (x += MOD-a.x >= MOD) {
            x -= MOD;
        }
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
};

#define SIZE 4010
mint c[SIZE][SIZE];
void init() {
    c[0][0] = 1;
    for (int i = 0; i <= 4000; i++) {
        for (int j = 0; j <= i; j++) {
            c[i+1][j] += c[i][j];
            c[i+1][j+1] += c[i][j];
        }
    }
}

mint comb(int n, int k) {
    return c[n][k];
}

mint f2(int n, int k) {
    return comb(n+k-1, k-1);
}

mint f(int n, int k) {
    if (n < k) {
        return 0;
    }
    if (n == 0 && k == 0) {
        return 1;
    }
    if (k < 1) {
        return 0;
    }
    return f2(n-k, k);
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    init();
    int N, K;
    cin >> N >> K;

    for (int i = 1; i <= K; i++) {
        mint blue = f(K, i);
        mint red = f2(N-K-(i-1), i+1);
        mint ans = blue*red;
        cout << ans.x << endl;
    }
    return 0;
}

Measured memory_bytes: 125952
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX 100000

int main(void){
    int num;
    pair<int,int> times[MAX];
    cin >> num;
    
    for(int i = 0;i < num;++i){
        cin >> times[i].second >> times[i].first;
    };
    
    sort(times,times + num);
    
    int ans = 0,t = -1;
    for(int i = 0;i < num;++i){
        // 終了時間が最も早いものを選び続ける
        if(t < times[i].second){
            ++ans;
            t = times[i].first;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3904
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val countH = Array(h) {0}
    val countV = Array(w) {0}
    val a = (0 until h).map {i->
        val line = sc.next()
        for (j in line.indices) {
            if (line[j] == '.') {
                countH[i]++
                countV[j]++
            }
        }
        line
    }
    for (i in 0 until h) {
        if (countH[i] == w) {
            continue
        }
        for (j in 0 until w) {
            if (countV[j] != h) {
                print(a[i][j])
            }
        }
        println()
    }
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli x, y, z, k;
    cin >> x >> y >> z >> k;
    lli a[x];
    lli b[y];
    lli c[z];
    ncin1(x, a);
    ncin1(y, b);
    ncin1(z, c);

    priority_queue<lli> que;
    REP(i, 0, x) {
        REP(j, 0, y) {
            que.push(a[i] + b[j]);
        }
    }

    sort_r(c, c+z);
    priority_queue<lli> que2;
    REP(i, 0, min(k, x*y)) {
        lli x = que.top();
        que.pop();
        REP(j, 0, z) {
            que2.push(x+c[j]);
        }
    }
    REP(i, 0, k) {
        lli x = que2.top();
        cout << x << endl;
        que2.pop();
    }
}


Measured memory_bytes: 42980
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion

static int  a[200001];
int main(void)
{
	int n,i;

	scanf("%d", &n);

	qsort(a, n, sizeof(int), i_dsort);

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

	qsort(a, n, sizeof(int), i_dsort);
		
	ll ans = a[0];
	
	for (i = 1; i < n/2; i++) 
		ans += (a[i] * 2);
	if (n % 2) ans += a[i];
	printf("%lld\n", ans);
	return 0;

}

Measured memory_bytes: 3296
#include<stdio.h>

int main(void){
  unsigned int n,i,j,k,count;
  while(scanf("%u",&n) && n){
    count=0;
    while(n!=1){
      count+=1;
      n=(n%2)?3*n+1:n/2;
    }
    printf("%u\n",count);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void) {
	int k;
	int odd=0;
	int even = 0;
	int i, c;
	scanf("%d", &k);
	for (i = 1; i < k + 1; i++) {
		if (i % 2 == 0) {
			odd++;
		}
	}
	for (i = 1; i < k + 1; i++) {
		if (i % 2 == 1) {
			even++;
		}
	}
	c = odd * even;
	printf("%d", c);

	return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    long int ans = 0, b = 0;
    for (long int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'W')
        {
            ans += i - b;
            b++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
//----->|try=0; while(!success) try++;|<------
//----->|Belief Yourself,Respect Yourself|<----
//----->|Be Proud Of Yourself,You're Doing Your best|<-----
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
 {
    T r=1;
    while(p) {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
{
    T r=1;
    while(p) {
        if(p&1)r=(r*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return r;
}

//||--------------------------->||Main_Code_Start_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    stack<char>a,b,c;
    string s1,s2,s3;
    while(cin>>s1>>s2>>s3)
    {
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        reverse(s3.begin(),s3.end());
        for(int i=0;i<s1.size();i++) a.push(s1[i]);
        for(int i=0;i<s2.size();i++) b.push(s2[i]);
        for(int i=0;i<s3.size();i++) c.push(s3[i]);
        char ans,ch='a';


        while(true)
        {
           if(ch=='a')
           {
               if(a.empty())
               {
                   ans='A';
                   break;
               }
               else
               {
                   ch=a.top();
                   a.pop();
               }
           }



          else if(ch=='b')
           {
               if(b.empty())
               {
                   ans='B';
                   break;
               }
               else
               {
                   ch=b.top();
                   b.pop();
               }
           }


           else
           {
               if(c.empty())
               {
                   ans='C';
                   break;
               }
               else
               {
                   ch=c.top();
                   c.pop();
               }
           }


        }
        cout<<ans<<endl;


    }
}




Measured memory_bytes: 256
from sys import stdin
import math
import fractions

n, k = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]

w = 0
for i in range(k):
    if i != k - 1:
        temp = a[i+1] - a[i]
    else:
        temp = a[0] + n - a[i]
    if w < temp:
        w = temp
        
print(n - w)

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  string S;
  cin >> S;
  int ans = S.size();
  REP(i, S.size()-1){
    if(S[i] != S[i+1]){
      ans = min(ans, max(i+1, (int)S.size()-(i+1)));
    }
  }
  cout << ans << endl;
  return 0;
}


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

ll n,k,x,y;
void solve(){
    cin >> n >> k >> x >> y;
    ll ans = min(n,k)*x + (n-min(n,k))*y;
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    public static void main (String[] args) {new Main();}

    Main() {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int n = fs.nextInt();
        int[] a = fs.nextIntArray(2 * n);
        Arrays.sort(a);
        int res = 0;
        for(int i = 0; i < 2 * n; i += 2) {
            res += a[i];
        }
        out.println(res);

        out.close();
    }

    void sort (int[] a) {
        int n = a.length;
        for(int i = 0; i < 1000; i++) {
            Random r = new Random();
            int x = r.nextInt(n), y = r.nextInt(n);
            int temp = a[x];
            a[x] = a[y];
            a[y] = temp;
        }
        Arrays.sort(a);
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner() {
            try	{
                br = new BufferedReader(new InputStreamReader(System.in));
//                br = new BufferedReader(new FileReader("testdata.out"));
                st = new StringTokenizer("");
            } catch (Exception e){e.printStackTrace();}
        }
        public String next() {
            if (st.hasMoreTokens())	return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }
        public int nextInt() {return Integer.parseInt(next());}
        public long nextLong() {return Long.parseLong(next());}
        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            try {line = br.readLine();}
            catch (Exception e) {e.printStackTrace();}
            return line;
        }
        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for(int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for(int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        public char[] nextCharArray() {return nextLine().toCharArray();}
    }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
vector<int> par;
 
int find(int n){
	if(par[n]==n)
        return n;
	else 
        return par[n]=find(par[n]);
}
 
void uni(int a,int b){
	a=find(a);
	b=find(b);
	if(a!=b)
        par[b]=a;
}
 
int main(){

    int i,j,n,m,a,b;
    cin>>n>>m;

    par=vector<int>(n+1);

    for(i=1;i<=n;i++)
        par[i]=i;

    while(m--){
    	cin>>a>>b;
    	uni(a,b);
    }
    
    set<int> s;
    for(i=1;i<=n;i++)
        s.insert(find(i));

    cout<<s.size()-1;
	return 0;
}

Measured memory_bytes: 7636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n , k;
  cin >> n >> k;
  int h[n];
  int dp[n];
  for(int i = 0 ; i <n ; i++){
    cin >> h[i] ;
    dp[i] = INT_MAX ;
  }
  dp[0] = 0;
  for(int i = 0 ; i <n ; i++){
    for(int j = 1 ; j <= k && i+j<n ; j++){
    	dp[i+j] = min(dp[i+j] , dp[i] + abs(h[i+j] - h[i]));
    }
  }
  cout << dp[n-1] << endl ;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    int n,x;
    cin >>n >>x;

    int sum = 0;
    int ct = 1;
    for(int i = 0; i < n; i++){
        int l;
        cin >>l;
        sum += l;
        if(sum > x){
            break;
        }
        ct++;
    }

    printf("%d\n", ct);
    return 0;
}

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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> x >> y; //xひき

    lint mins = x * 2;
    lint maxs = x * 4;

    if(mins <= y && maxs >= y && y % 2 == 0)
    {
        cout << "Yes" << endl; 
    }
    else
    {
        cout << "No" << endl;
    }

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


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

typedef long long ll;
typedef pair <int, int> ii;
typedef long double ld;

const int Maxn = 100001;
const ll Inf = 1000000000000ll;

int mx[Maxn];
vector <int> pr;
int n;
ll a;
map <ll, ii> M;
bool one;
int res;

ll Multiply(ll num, ll wh, int cnt)
{
    while (cnt--)
        if (num <= Inf / wh) num *= wh;
        else return Inf;
    return num;
}

int main()
{
    for (int i = 2; i < Maxn; i++) if (mx[i] == 0) {
        pr.push_back(i);
        for (int j = i; j < Maxn; j += i)
            mx[j] = i;
    }
    scanf("%d", &n);
    while (n--) {
        scanf("%lld", &a);
        ll my = 1, oth = 1;
        for (int i = 0; i < pr.size() && ll(pr[i]) * pr[i] * pr[i] <= a; i++) if (a % pr[i] == 0) {
            int cnt = 0;
            while (a % pr[i] == 0) { cnt++; a /= pr[i]; }
            cnt %= 3;
            if (cnt == 1 || cnt == 2) {
                my = Multiply(my, pr[i], cnt);
                oth = Multiply(oth, pr[i], 3 - cnt);
            }
        }
        if (a == 1) ;
        else {
            ll sqr = sqrt(ld(a));
            while (sqr * sqr < a) sqr++;
            while (sqr * sqr > a) sqr--;
            if (sqr * sqr == a) { my = Multiply(my, sqr, 2); oth = Multiply(oth, sqr, 1); }
            else { my = Multiply(my, a, 1); oth = Multiply(oth, a, 2); }
        }
        if (my == 1) one = true;
        else if (my < oth) M[my].first++;
        else M[oth].second++;
    }
    res = int(one);
    for (auto it: M)
        res += max(it.second.first, it.second.second);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 6912
#include <stdio.h>
int main(){
  int i,j;
  int n,u,k,v,a[1000][1000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      a[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j<n-1){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {

			int x = scan.nextInt();
			int y = scan.nextInt();
			if ((x == 0) && (y == 0)) {
				break;
			} else {
				if (x < y) {
					System.out.println(x + " " + y);
				} else if (x > y) {
					System.out.println(y + " " + x);
				} else {
					System.out.println(x + " " + y);
				}
			}
		}
	}
}

Measured memory_bytes: 35120
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e6 * 2 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    long double dist = abs((h / 12.0 + (m/60.0)/12.0) - (m / 60.0));
    long double rad = 2 * PI * dist;

    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);

    printf("%20.20Lf\n", sqrtl(rsq));

    return 0;
}

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

int fact[] = {1,1,2,6,24,120,720,5040,40320};
int cantor(int a[],int l);

int main() {

    int n, i;
    scanf("%d\n", &n);
    int a[n], b[n];

    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }

    printf("%d", abs(cantor(a, n) - cantor(b, n)));

    return 0;
}

int cantor(int a[],int l) {

    int sum = 0, s, i, j;

    for (i = 0; i <= l; i++) {
        s = 0;
        for (j = i + 1; j < l; j++) {
            if (a[j] < a[i]) {
                s++;
            }
        }
        sum += s * fact[l - i - 1];
    }

    return sum;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long 
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;
#define ll long long
#define endl '\n'
#define x first
#define y second
#define pb push_back
#define all(k) (k).begin(),(k).end()
#define fr(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define db(k) cerr << #k<< " = " << k << endl



#define get(a) scanf("%d",&a)
int32_t main(){
 	//ios::sync_with_stdio(0); cin.tie(0);
	int n;
	get(n);
	stack<int> q;
	fr(i,1,n){
		int a;
		get(a);
		q.push(a);
	}	
	int ans=0,c=0;
	while(q.size()){
		c=0;
		int aux = q.top();
		q.pop();
		while(q.size() and aux<=q.top()){
			aux = q.top();
			q.pop();
			c++;
		}
		ans=max(ans,c);


	}


	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll n;
    cin>>n;
    ll temp=n;
    ll total=0;
    while(n>0)
    {
        total+=(n%10);
        n=n/10;
    }
    //cout<<total<<endl;
    if(temp%total==0)
        cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

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

int main() {
	int H, W, D, A, Q, L, R;
	cin >> H >> W >> D;
	vector<pair<int, int>> a(H * W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A;
			a[A - 1].first = i;
			a[A - 1].second = j;
		}
	}
	cin >> Q;
	vector<int> b(H * W);
	for (int i = D; i < H * W; i++) {
		b[i] += abs(a[i - D].first - a[i].first);
		b[i] += abs(a[i - D].second - a[i].second);
		b[i] += b[i - D];
	}
	for (int i = 0; i < Q; i++) {
		cin >> L >> R;
		cout << b[R - 1] - b[L - 1] << endl;
	}
}

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

int n, x, l, h=0, ans=1;

int main(){
  cin>>n>>x;
  for(int i=0; i<n; i++){
    cin>>l;
    h+=l;
    if(h<=x){
      ans++;
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0

	for i := 0; i <= n/1000; i++ {
		var flag3, flag5, flag7 int
		flagSatisfied := true
		tmp := i
		for tmp != 0 {
			switch tmp % 10 {
			case 3:
				flag3 = 1
			case 5:
				flag5 = 1
			case 7:
				flag7 = 1
			default:
				flagSatisfied = false
				break
			}
			tmp /= 10
		}

		if flagSatisfied == false {
			continue
		}

		if i == n/1000 {
			for j := n - (n % 1000); j <= n; j++ {
				var flag3_2, flag5_2, flag7_2 bool
				flagSatisfied_2 := true
				tmp2 := j
				for tmp2 != 0 {
					switch tmp2 % 10 {
					case 3:
						flag3_2 = true
					case 5:
						flag5_2 = true
					case 7:
						flag7_2 = true
					default:
						flagSatisfied_2 = false
						break
					}
					tmp2 /= 10
				}

				if flagSatisfied_2 == false {
					continue
				}

				if flag3_2 == true && flag5_2 == true && flag7_2 == true {
					sum++
				}
			}
			break
		}

		switch flag3 + flag5 + flag7 {
		case 1:
			sum += 12
		case 2:
			sum += 19
		case 3:
			sum += 27
		default:
			sum += 6
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
x = input()
S1 = []
S2 = []
current_position = 0
total_area = 0

for i in x:
    if i == '\\':
        S1.append(current_position)

    elif i == '/':
        try:
            start_position = S1.pop()
            distance = current_position - start_position
            total_area += distance
            S2.append([start_position, distance])

        except:
            continue

    current_position += 1

print(total_area)

S2.insert(0, [-1, -1])
S3 = []
if len(S2) == 1:print(0)
else:
    for i in range(len(S2)-1, -1, -1):
        x, y = S2[i]
        px, py = S2[i-1]
        if x < px:
            S2[i-1] = [x, y + py]
        else:
            S3.append(S2[i])

    print(len(S3), *[j for i, j in S3[::-1]])


Measured memory_bytes: 6648
S = input()
T = input()
N = len(S)
M = len(T)
#dp[i][j] -> Sのi文字目、Tのj文字目までみるとき、最長共通部分列の長さ
dp = [[0]*(M+1) for _ in range(N+1)]
for i in range(1,N+1):
    s = S[i-1]
    for j in range(1,M+1):
        t = T[j-1]
        if s == t:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
ans = []
while N and M:
    if dp[N][M] > max(dp[N-1][M],dp[N][M-1]):
        ans.append(S[N-1])
        N -= 1
        M -= 1
    elif dp[N][M] == dp[N-1][M]:
        N -= 1
    else:
        M -= 1

ans = ans[::-1]

ans = "".join(ans)
print(ans)

Measured memory_bytes: 144668
N = int(input())
S = list(input())
data = []
data.append((0, 0))
for i in range(N):
    # looking left
    if S[i] == 'W':
        data.append((data[i][0]+1, data[i][1]))
    # looking right
    elif S[i] == 'E':
        data.append((data[i][0], data[i][1]+1))
#print(data)

answer = N-1
for i in range(N):
    count = 0
    count += data[N][1] - data[i+1][1]
    count += data[i][0]
    if answer > count:
        answer = count

print(answer)


Measured memory_bytes: 42228
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010, inf=1e9;
int n, ansmx1, ansmx2;
int a[maxn], cnt1[maxn], cnt2[maxn];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

inline void getmx(int cnt[])
{
	int mx1=0, mx1pos=0, mx2=0, mx2pos=0;
	for(int i=1;i<=100000;i++)
	if(mx1<cnt[i])
	{
		mx2=mx1; mx2pos=mx1pos;
		mx1=cnt[i]; mx1pos=i;
	}
	else if(mx2<cnt[i])
	{
		mx2=cnt[i]; mx2pos=i;
	}
	ansmx1=mx1pos; ansmx2=mx2pos;
}

int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i+=2) cnt1[a[i]]++;
	for(int i=2;i<=n;i+=2) cnt2[a[i]]++;
	getmx(cnt1);
	int tmp1=ansmx1, tmp2=ansmx2;
	getmx(cnt2);
//	printf("%d %d %d %d\n", tmp1, tmp2, ansmx1, ansmx2);
	if(tmp1!=ansmx1) printf("%d\n", n-cnt1[tmp1]-cnt2[ansmx1]);
	else 
	{
		printf("%d\n", min(n-cnt1[tmp1]-cnt2[ansmx2], n-cnt1[tmp2]-cnt2[ansmx1]));
	}
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
	string s;
	cin >> s;
	int d = 1000, x;
	for(int i = 0; i < s.size()-2; i++){
		x = (s[i] - '0')*100 + (s[i+1] - '0')*10 + (s[i+2] - '0');
		d = abs(x-753) < d ? abs(x-753) : d;
	}
	cout << d << endl;
	return 0;
}


Measured memory_bytes: 256