akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	while(true) {
		auto NM = readln().split();
		int N = to!int(NM[0]);
		int M = to!int(NM[1]);
		if(N == 0)
			break;
		const int INF = 200*1000*1000*2;
		int[200][200] ldist;
		int[200][200] sdist;
		for(int i; i < N; ++i){
			for(int j; j < N; ++j) {
				if(i == j) {
					ldist[i][j] = sdist[i][j] = 0;
				} else {
					ldist[i][j] = sdist[i][j] = INF;
				}
			}
		}
		for(int i; i < M; ++i) {
			auto s = readln().split();
			int x = to!int(s[0])-1;
			int y = to!int(s[1])-1;
			int t = to!int(s[2]);
			auto sl = s[3];
			if(sl == "L") {
				ldist[x][y] = ldist[y][x] = min(ldist[x][y], t);
			} else {
				sdist[x][y] = sdist[y][x] = min(sdist[x][y], t);
			}
		}
		for(int k; k < N; ++k){
			for(int i; i < N; ++i){
				for(int j; j < N; ++j){
					ldist[i][j] = min(ldist[i][k] + ldist[k][j], ldist[i][j]);
					sdist[i][j] = min(sdist[i][k] + sdist[k][j], sdist[i][j]);
				}
			}
		}
		int R = to!int(readln().chomp());
		auto sz = readln().chomp().split();
		int[1000] z;
		for(int i; i < R; ++i){
			z[i] = to!int(sz[i])-1;
		}

		long[200][1000] dp;
		for(int i; i < R; ++i){
			for(int j; j < N; ++j){
				dp[i][j] = INF;
			}
		}
		dp[0][z[0]] = 0;
		for(int i = 1; i < R; ++i){
			for(int j = 0; j < N; ++j){
				for(int k = 0; k < N; ++k){
					if(j == k) {
						dp[i][j] = min(dp[i][j], dp[i-1][j] + ldist[z[i-1]][z[i]]);
					} else {
						dp[i][j] = min(dp[i][j], dp[i-1][k] + ldist[z[i-1]][k] + sdist[k][j] + ldist[j][z[i]]);
					}
				}
			}
		}
		long ans = dp[R-1][0];
		for(int i; i < N; ++i) {
			ans = min(ans, dp[R-1][i]);
		}
		writeln(ans);
	}
}

Measured memory_bytes: 3960
#include<stdio.h>
#include<string.h>
#define A 100005

typedef struct {
  char name[100];
  int time;
}pro;

pro que[A];
int head,tail,n;

void enter(pro );
pro out(void);
int minimam(int,int);

void enter(pro a)
{
  que[tail] = a;
  tail = (tail + 1) % A;
}

pro out(void)
{
  pro a = que[head];
  head = (head +1) % A;
  return a;
}

int minimam(int a,int b)
{
  return a < b ? a:b;
}

int main()
{
  int i,q,x,timed=0;
  pro cess;

  scanf("%d%d",&n,&q);
  
  head = 1;
  tail = n + 1;

  for(i=1;i<=n;i++) {
    scanf("%s%d",que[i].name,&que[i].time);
  }

  while(head != tail) {
    cess = out();
    x = minimam(q,cess.time);
    cess.time -= x;
    timed += x;
    if(cess.time > 0){
      enter(cess);
    }else{
      printf("%s %d\n",cess.name,timed);
    }
  }

  return 0;
}



Measured memory_bytes: 11844
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int n,ans=1,x,f=1;
	cin>>n;
	long double l=1;
	int a[n];
	for(int i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]==0) f=0;
	}
	if(f==0){
		cout<<0;
		return 0;
	}
	for(int i=0;i<n;i++){
		x=a[i];
		l*=x;
		if(l>1e18){
			f=-1;
			break;
		}
		ans*=x;
		f=ans;
	}
	
	cout<<f;
	return 0;
}




Measured memory_bytes: 4424
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
typedef unsigned int uint;
typedef long long ll;

int main() {
	int N, L;
	scanf("%d%d", &N, &L);
	//味の絶対値が１番小さいリンゴを食べればいい
	if(L<=0&&L+N-1>=0)printf("%d", (L - 1)*N + (N*(N + 1)) / 2 );
	if(L>0)printf("%d", (L - 1)*N + (N*(N + 1)) / 2 -L);
	if(L+N-1<0)printf("%d", (L - 1)*N + (N*(N + 1)) / 2 - (L+N-1));


	




}


/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#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++)
int main()
{
    int x;
    cin >> x;

    int minval=INT_MAX , maxval=INT_MIN;
    REP(i, x){
        int a;
        cin>> a;
        minval=min(minval, a);
        maxval=max(maxval, a);
    }


    cout << maxval-minval << endl;

   return 0;
}

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

int main(){
  int k, s, cnt = 0;
  cin >> k >> s;

  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      int ij = i + j;
      if(s - ij <= k && s - ij >= 0){
        //        cout << i << j << s - ij << endl;
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


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

int m,d;
int cnt;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>m>>d;
    for(int i=1;i<=m;i++){
        for(int j=22;j<=d;j++){
            if(j/10>1&&j%10>1&&(j/10)*(j%10)==i){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;

    return 0;
}

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


class UnionFind {
public:
	vector<int> par;
	vector<int> rank;
	UnionFind(int n) {
		init(n);
	}
	void init(int n) {
		par.resize(n);
		for (int i = 0; i<n; i++) {
			par[i] = i;
		}
		rank.assign(n, 0);
	}
	int find(int x) {
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main() {
	int N, M;
	cin >> N >> M;

	vector<int> p(N);
	for(int i=0;i<N;i++) {
		cin >> p[i];
		p[i]--;
	}

	UnionFind uf(N);
	for(int i=0;i<M;i++) {
		int x, y;
		cin >> x >> y;
		uf.unite(x - 1, y - 1);
	}

	int ans = 0;
	for(int i=0;i<N;i++) {
		if(uf.same(p[i], i)) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
typedef long long ll;
typedef double db;
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p) memset(p,0,sizeof(p))
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
ll n,a[N],b,ans=0;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,1,n+1)
       cin>>a[i];
    rep(i,1,n){
    	cin>>b;
    	if(a[i]>b){
    		ans+=b;
		}
		else{
			b-=a[i];ans+=a[i];
			int temp=min(a[i+1],b);
			a[i+1]-=temp;ans+=temp;
		}
	}
	cout<<ans;
    	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	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;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// For prime mod.
	// Do not use if MOD is not prime number !!
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

typedef vector<mint> vm;

int main() {
//	cout << fixed << setprecision(15);
    int n;
    string s;
    cin >> n >> s;

    vector<vm> dp(2, vm(n + 1));
//    vector<vi> dp(2, vi(n + 1));
    auto &cur = dp[0], &nxt = dp[1];
    rep1(i, n) cur[i] = 1;
    rep(i, s.size()) {
        rep1(j, n) cur[j] += cur[j - 1];
        rep1(j, n) nxt[j] = 0;
        rep1(j, n - 1 - i) {
            if(s[i] == '<') nxt[j] += cur[j] - cur[0];  // previously take p(1)~p(j)
            else nxt[j] += cur[n - i] - cur[j]; // previously take p(j+1)~p(n-i)
        }
        swap(cur, nxt);
    }
    cout << cur[1].x << endl;
}


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

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int n,i;
	int ans = 0;
	int old_ai=-1;
	int a[21], b[21], c[21];
	scanf("%d", &n);
	for (i = 1;i <= n;i++)scanf("%d", &a[i]);
	for (i = 1;i <= n;i++)scanf("%d", &b[i]);
	for (i = 1;i <= n-1;i++)scanf("%d", &c[i]);
	for (i = 1;i <= n;i++)
	{
		
		ans += b[a[i]];
		if (old_ai + 1 == a[i])ans += c[old_ai];
		old_ai = a[i];
		
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

set<lint> divisor(lint N){
    set<lint> res;
    for(int i=1;i<=11000;i++){
        if(N%i==0){
            res.insert(i);
            res.insert(N/i);
        }
    }
    return res; 
}

int main(void){
  lint N,K;
  lint ans=1;
  cin >> N >> K;
  lint A[N];
  rep(i,N) cin >> A[i];
  lint sum=accumulate(A,A+N,0LL);
  set<lint> div=divisor(sum);
  while(!div.empty()){
    lint D=*div.begin();
    div.erase(div.begin());
    lint B[N];
    rep(i,N) B[i]=A[i]%D;
    sort(B,B+N);
    lint posi=0,nega=0;
    rep(i,N) posi+=D-B[i];
    if(posi==nega){
      ans=D;
    }
    rep(i,N){
      posi-=D-B[i];
      nega+=B[i];
      if(posi==nega && posi<=K) ans=D;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
"use strict"

function main(input) {
  //
  input = input.split(/\n/).map(v => v.split(" ").map(v => ~~v))
  const N = input[0][0]
  const K = input[1][0]
  const balls = input[2]
  let ans = 0

  for (let i = 0; i < N; i++) {
    ans += balls[i] < Math.abs(balls[i] - K) ? balls[i] : Math.abs(balls[i] - K)
  }
  ans *= 2

  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 21448
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    string s;
    int k;
    cin >> s >> k;
    // vector<string> v;
    set<string> st;
    for (int i=0; i<s.size(); ++i)
    {
        for (int j=1; j<s.size()-i+1; ++j)
        {
            if(s.substr(i,j).size()>k) continue;
            // v.push_back(s.substr(i,j));
            st.insert(s.substr(i,j));
        }
    }

    // sort(v.begin(),v.end());
    // v.erase(unique(v.begin(), v.end()), v.end());
    // cout << v[k-1] << endl;

    vector<string> ans;
    for(auto x:st)
    {
        ans.push_back(x);
    }
    sort(ans.begin(),ans.end());
    cout << ans[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
n = int(input())
a = list(map(int,input().split()))

ma = max(a)
m = [0]*(ma + 1)

for i in a:
    if m[i] == 1:
        m[i] = 2
        continue
    for j in range(i,ma+1,i):
        m[j]+=1
ans = 0
for i in a:
    if m[i] == 1:
        ans += 1
print(ans)

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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)

int main(){
  string s; cin >> s;
  vector<int> a(2);
  rep(i,s.size()) a[s[i]-'0']++;
  cout << 2*min(a[0],a[1]) << endl;
}


Measured memory_bytes: 512
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
// #ifndef RAHUL
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

 int a,b;

 cin>>a>>b;
 std::vector<int> v(a);

 for (int i = 0; i < a; ++i)
 {
 	/* code */
 	cin>>v[i];
 }

 sort(v.begin(),v.end());
int count=0;
 for (int i = 0; i < b; ++i)
 {
 	/* code */
 	count+=v[i];
 }

 cout<<count<<endl;

 return 0;
}

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

using namespace std;

struct cake
{
	long long x, y, z;
};

int i, j, k;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<cake> v;
	for(int i = 0; i < n; i++)
	{
		long long x, y, z;
		cin >> x >> y >> z;
		v.push_back(cake{x,y,z});
	}
	long long ans = -10000000000000;
	for(i = 0; i < 2; i++)
		for(j = 0; j < 2; j++)
			for(k = 0; k < 2; k++)
			{
				sort(v.begin(), v.end(),
						 [](const cake&l, const cake&r)
						 {
							 long long left = (i == 0 ? -1 : 1)*l.x + (j == 0 ? -1 : 1)*l.y + (k == 0 ? -1 : 1)*l.z;
							 long long right = (i == 0 ? -1 : 1)*r.x + (j == 0 ? -1 : 1)*r.y + (k == 0 ? -1 : 1)*r.z;
							 return left < right;
						 });
				long long tmp[3] = {};
				for(int l = 0; l < m; l++)
				{
					tmp[0] += v[l].x;
					tmp[1] += v[l].y;
					tmp[2] += v[l].z;
				}
				ans = max(ans, (long long)abs(tmp[0]) + abs(tmp[1]) + abs(tmp[2]));
			}
	cout << ans << endl;

	return 0;
}


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.size() == 3){
        char a = s.at(0);
        s.at(0) = s.at(2);
        s.at(2) = a;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
/**
Code by Nitin1184
**/
# include <bits/stdc++.h>
# define ll long long
# define pi 3.14159265358979323846
# define M 1000000007
# define pb push_back
# define mp make_pair
# define ff first
# define ss second

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s.compare("AC")==0)
            ac++;
        else if(s.compare("WA")==0)
            wa++;
        else if(s.compare("TLE")==0)
            tle++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<"\nWA x "<<wa<<"\nTLE x "<<tle<<"\nRE x "<<re<<endl;
    return 0;
}

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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 2e5 + 5;




int solve() {
    int n, k; Int(n, k);
    vector<int> dp(n + 1, inf);
    dp[1] = 0;
    vector<int> h(n + 1);
    for(int i = 1; i <= n; i++) {
        Int(h[i]);
    }
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n && j <= i + k; j++) {
            smin(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n]);
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




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

int main() {
   string S;
  cin >> S;
  if(S=="SUN"){cout<<7<<endl;}
  if(S=="MON"){cout<<6<<endl;}
  if(S=="TUE"){cout<<5<<endl;}
  if(S=="WED"){cout<<4<<endl;}
  if(S=="THU"){cout<<3<<endl;}
  if(S=="FRI"){cout<<2<<endl;}
  if(S=="SAT"){cout<<1<<endl;}

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int cnt[200010];
set<int> ch;

int main() {
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n+5; i++)cnt[i] = INF;

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t; ch.insert(t);
		if (cnt[t] == INF)cnt[t] = 0;
		cnt[t]++;
	}

	int num = ch.size();

	if (num <= k) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	sort(cnt, cnt + n + 1);

	for (int i = 0; i < num - k; i++) {
		ans += cnt[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10368
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	long n;
	cin >> n;
	vector<long>a = vector<long>(n);
	rup(i, 0, n)cin >> a[i];
	const long range = 1e5 + 1;
	vector<long>bucket = vector<long>(range, 0);
	for (int i = 0; i < n; i++) {
		bucket[a[i]]++;
	}
	vector<long>fixed = vector<long>(range, 0);
	fixed[0] = bucket[0] + bucket[1];
	fixed[range - 1] = bucket[range - 2] + bucket[range - 1];
	for (long i = 1; i < range-1; i++) {
		fixed[i] = bucket[i - 1] + bucket[i] + bucket[i + 1];
	}
	long max = *max_element(fixed.begin(), fixed.end());
	cout << max<<endl;
	return 0;
}





Measured memory_bytes: 2560
#include <stdio.h>
#define N 100000

int main(void) {

    int i = 0, j = 0;
    int a, b, ans[N];
    char op;

    for (i = 0; i < N; i++) {
        ans[i] = 0;
    }

    i = 0;
    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') {
            break;
        } else {
            switch (op) {
                case '+': ans[i] = a + b;       break;
                case '-': ans[i] = a - b;       break;
                case '*': ans[i] = a*b;         break;
                case '/': ans[i] = (int)(a/b);  break;
            }
        }
        i++;
    }
    j = i;

    for (i = 0; i < j; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;

}

Measured memory_bytes: 992
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem064b(n, a))
}

fun problem064b(n: Int, a: List<Int>): Int {
    val a2 = a.sorted()
    var count = 0
    for (i in 0 until n - 1) {
        count += a2[i + 1] - a2[i]
    }
    return count
}

Measured memory_bytes: 34128
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

int main(void)
{
	// input
	std::vector<int> v;
	std::string s, buf;
	std::getline(std::cin, s);
	std::stringstream ss(s);
	
	while(std::getline(ss, buf, ' ')) {
		v.push_back(std::stoi(buf));
	}
	
	/*
	for(int i = 0; i < v.size(); i++) {
		std::cout << v[i] << std::endl;
	}
	*/

	// solve
	if(v[0]%v[1] != 0) {
		std::cout << v[0] << std::endl;
	} else {
		std::cout << -1 << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

typedef long long signed int ll;

constexpr ll NIL = -20000000000;

string s[2];
int dp[1001][1001];

int lcs(int x,int y) {
    if(x < 0 || y < 0) return 0;
    if(x >= s[0].size() || y >= s[1].size()) return 0;
    if(dp[x][y] == -1) {
        dp[x][y] = max(lcs(x+1,y),dp[x][y]);
        dp[x][y] = max(lcs(x,y+1),dp[x][y]);
        if(s[0][x] == s[1][y]) dp[x][y] = max(lcs(x+1,y+1) + 1,dp[x][y]);
    }
    return dp[x][y];
}

int main() {
    int n;
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> s[0] >> s[1];
        int res = -1;
        for(int j = 0;j < 1001 * 1001;j++)(reinterpret_cast<int*>(dp))[j] = -1;
        for(int j = 0;j < 1001 * 1001;j++)res = max(res,(reinterpret_cast<int*>(dp))[j]);
        cout << lcs(0,0) << endl;
    }
}


Measured memory_bytes: 7124
def calc(n,a):
    return n//a

def gcd(a,b):
    return a if b==0 else gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())

ca = calc(a-1,c)
cb = calc(a-1,d)
cc = calc(a-1,lcm(c,d))
an1 = ca+cb-cc

ca = calc(b,c)
cb = calc(b,d)
cc = calc(b,lcm(c,d))
an2 = ca+cb-cc

print(b-a+1-(an2-an1))

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll x;
    ll t = 0;
    ll p;
    cin >> p;
    for (int i = 0; i < n - 1; i++) {
        cin >> x;
        t += ((x - p) * a < b ? (x - p) * a : b);
        p = x;
    }
    cout << t << endl;
}


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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	priority_queue<long long> q;

    while (n--) {
    	int x; cin >> x;
    	q.push(x);
    }
     
    while (m--) {
    	long long value = q.top();
    	q.pop();
    	q.push(value / 2);
    }
    long long ans = 0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define random_shuffle asdasdd

int k, x;

int main() { 

  cin >> k >> x;

  if (k * 500 >= x) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]//2
ll=a[0]
for i in range(1,n):
  if a[i]%2:odd=True
  else:even=True
  l=lcm(l,a[i]//2)
  ll=lcm(ll,a[i])
  if l>m:print(0);exit()
for i in range(n):
  if l%a[i]==0:print(0);exit()
print((m-l)//ll+1)

Measured memory_bytes: 15060
#include <iostream>

using namespace std;

#define ll long long 

int main () {
    int n, l;
    cin>>n>>l;
    int sum = (n*(n-1)/2 )+ (n)*l;
    if (l > 0) {
        sum -= l ;
    } else if (abs(l) < n-1) {
        sum = sum;
    } else {
        sum -= l + n-1; 
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a, b, c, d = [], [], [], []
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
for i in range(M):
    x, y = map(int, input().split())
    c.append(x)
    d.append(y)
    
for i in range(N):
    ans = 0
    tmp = 10 ** 10
    for j in range(M):
        if abs(a[i] - c[j]) + abs(b[i] - d[j]) < tmp:
            tmp = abs(a[i] - c[j]) + abs(b[i] - d[j])
            ans = j + 1
    print(ans)

Measured memory_bytes: 3064
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,v = na()
b,w = na()
t = ni()

dif = abs(a-b)
k = v-w

if k*t >= dif:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9196
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var a = new int[N];
		for (var i = 0; i < N; i++) a[i] = F;
		WriteLine(a.Any(x => x % 2 == 1) ? "first" : "second");
	}
}


Measured memory_bytes: 17500
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	string S;
	int a;
	
	cin >>S>> a;
	for (int i = 0; i < S.size(); i += a) {
		cout << S.at(i);
	}




	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cfloat>
using namespace std;
int main(){
        int n;
        cin>>n;
        double p[n], q[n+1];
        for(int i=0;i<n;i++) cin>>p[i];
        for(int i=0;i<n+1;i++) cin>>q[i];

        double dp[n+1][n+1];
        double psum[n][n];
        double qsum[n+1][n+1];
        for(int i=0;i<n+1;i++) dp[i][i] = q[i];
        for(int i=0;i<n;i++) {
                psum[i][i] = p[i];
                for(int j=i+1;j<n;j++){
                        psum[i][j] = psum[i][j-1]+p[j];
                }
        }
        for(int i=0;i<n+1;i++) {
                qsum[i][i] = q[i];
                for(int j=i+1;j<n+1;j++){
                        qsum[i][j] = qsum[i][j-1]+q[j];
                }
        }

        for(int i=1;i<n+1;i++){
                for(int j=0;j+i<n+1;j++){
                        dp[j][j+i] = DBL_MAX;
                        for(int k=0;k<i;k++){
                                double tmp = dp[j][j+k]+dp[j+k+1][j+i]+psum[j][j+i-1]+qsum[j][j+i];
                                dp[j][j+i] = min(dp[j][j+i], tmp);
                        }
                }
        }
        cout<<dp[0][n]<<endl;

        return 0;
}


Measured memory_bytes: 9168
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	string s;
	int s1,s2=0;
	cin>>s1>>s;
	int n=s.size();
	for(int i=0;i<n;i++){
		s2=s2*10+(s[i]-'0');
		s1*=10;
	}
	s1+=s2;
	if(int(sqrt(s1))*int(sqrt(s1))==s1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

struct Tree {
    int n; // number of nodes
    vector<int> parent; //parent
    vector<vector<int>> g; //graph for the tree
    vector<int> depth; //depth
    
    Tree(int n): n(n) {
       parent.assign(n, -2);
       g.assign(n, vector<int>());
       depth.assign(n, 0);
    }
    
    void addEdge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
        parent[v] = u;
    }
    
    void dfs(int u, int p, int d) {
        parent[u] = p;
        depth[u] = d;
        for (int v : g[u]) {
           if (v != p && parent[v] == -2) {
               dfs(v, u, d + 1);
           } 
        }    
    }

    string formatChildren(int i){
        string children = "[";
        for (int v : g[i]) {
            if (v != parent[i]) {
                if (children.size() > 1) {
                    children += ", "; 
                }
                children += to_string(v);
            }
        }
        children += "]";
        return children;
    }

    string formatNodeType(int i){
        string type = "";
        if (parent[i] == -1) {
            type = "root";
        } else if (g[i].size() > 1) {
            type = "internal node";
        } else {
            type = "leaf";
        }
        return type;
    }
    
    void solve() {
        int root = -1;
        for (int i = 0; i < n; i++) {
            if (parent[i] == -2) {
                root = i;
                break;
            }
        }
        parent.assign(n, -2);
        dfs(root, -1, 0);
        
        for (int i = 0; i < n; i++) {
            printf("node %d: parent = %d, depth = %d, %s, %s\n", 
                    i, parent[i], depth[i], formatNodeType(i).c_str(), 
                    formatChildren(i).c_str());
        }
    }
};

int main() {
    int n;
    cin >> n;
    Tree tree(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            tree.addEdge(u, v);
        }
    }
    tree.solve();
    
    return 0;
}

Measured memory_bytes: 10544
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	//for(int i=0;i<N;i++) {}
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt()	;
		int v[]=new int[N+1];
		
		for(int i=1;i<=N;i++) {
			int t=i;
			for(int a=2;true;a++) {
				
				if(t==1)break;
				if(t%a==0) {
					
					v[a]++;
					t/=a;
					a=1;
				}
			}
			
		}
		long ans=1;
		
		for(int i=0;i<=N;i++) {
			ans=(ans*(v[i]+1))%mod;
		}
		p(ans);
	}
	

	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

bool solve(ll a, ll b, ll c, ll d){
  if(a<b)return false;
  if(c+d+1 <= b)return false;
  if(d<b)return false;
  if(a>c){
    // while(a>c)a -= b;
    ll rest = a-c;
    ll sub = (rest+b-1)/b;
    a -= sub*b;
    if(a<0)return false;
    a += d;
  }
  if(a<=c){
    // while(a<c+1)a += d-b;
    ll rest = c+1-a;
    ll add = (rest+(d-b)-1) / (d-b);
    a += add*(d-b);
  }
  // DEBUG(a);
  // assert(a>c);
  // DEBUG(a);
  // DEBUG(b);
  // DEBUG(c);
  // DEBUG(d);
  if(a<=b+c && a<2*b-d)return false;
  if(b+c<a && a<2*b)return false;
  ll g = __gcd(b,d);
  // DEBUG(g);
  // DEBUG(2*b-d);
  // DEBUG(c);
  // DEBUG(b+c+1);
  // DEBUG(2*b);
  // DEBUG((b+c+1)/g);
  // DEBUG(2*b/g);
  if((2*b-d)/g <= (c+g-1)/g && (b+c+1+g-1)/g >= 2*b/g)return true;
  if(d==b)return true;
  return false;
  // return false; // ?
  // a /= g;
  // b /= g;
  // c /= g;
  // d /= g;
}

void f(){
  ll a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  if(solve(a,b,c,d)){
    puts("Yes");
  }else{
    puts("No");
  }
}

int main(){
  int t;
  scanf("%d",&t);
  while(t--)f();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int d, n; cin >> d >> n;
    string s[] = {"", "00", "0000"};

    if (n != 100) cout << n << s[d] << endl;
    else cout << (n+1) << s[d] << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;

template <class T>
T fexp(T x, long long e) {
	T ans(1);
	for(; e > 0; e /= 2) {
		if(e & 1) ans = ans * x;
		x = x * x;
	}
	return ans;
}

template <int mod = MOD>
struct modBase {
	modBase(int v = 0) : val(v) {}
	int val;
 
	void operator += (modBase<mod> o) { *this = *this + o; }
	void operator -= (modBase<mod> o) { *this = *this - o; }
	void operator *= (modBase<mod> o) { *this = *this * o; }
	modBase<mod> operator * (modBase<mod> o) { return (int)((long long) val * o.val % mod); }
	//modBase<mod> operator / (modBase<mod> o) { return *this * fexp(o, mod - 2); }
	modBase<mod> operator + (modBase<mod> o) { return val + o.val >= mod ? val + o.val - mod : val + o.val; }
	modBase<mod> operator - (modBase<mod> o) { return val - o.val < 0 ? val - o.val + mod : val - o.val; }
};

const int ms = 1010;

modBase<> fat[ms], ifat[ms], inv[ms];

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	fat[0] = ifat[0] = 1;
	for(int i = 1; i < ms; i++) {
		inv[i] = fexp(modBase<>(i), MOD - 2);
		fat[i] = fat[i-1] * i;
		ifat[i] = ifat[i-1] * inv[i];
		assert((fat[i] * ifat[i]).val == 1);
	}
	int n, a, b, c, d;
	std::cin >> n >> a >> b >> c >> d;
	std::vector<modBase<>> ans(n+1, 0);
	ans[0] = fat[n];
	for(int i = a; i <= b; i++) {
		std::vector<modBase<>> nxt = ans;
		for(int j = c; j <= d && i * j <= n; j++) {
			modBase<> ways = fexp(ifat[i], j) * ifat[j];
			for(int k = 0; k + j*i <= n; k++) {
				nxt[k+j*i] = nxt[k+j*i] + ways * ans[k];
			}
		}
		nxt.swap(ans);
	}
	std::cout << ans.back().val << '\n';
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			int k = sc.nextInt();
			HashSet<Integer> h = new HashSet<Integer>();
			int[] a = new int[n];
			int max =0;
			
			for(int i=0;i<n;i++) {
				a[i] = sc.nextInt();
				max =Math.max(max, a[i]);
			}
			
			for(int i=0;i<n;i++) {
				h.add(a[i]);
			}
			
			int pat = h.size();
			
			if(k>=pat) {
				System.out.println(0);
				return;
			}
			
			int red = pat - k;
			
			ArrayList<Integer> num = new ArrayList<Integer>(max+1);
			
			for(int i=0;i<max+1;i++) {
				num.add(i, 0);
			}
			
			for(int i=0;i<n;i++) {
				int pula = num.get(a[i])+1;
				num.set(a[i], pula);	
				
			}



			Collections.sort(num);
			
			int rednum = 0;
			int ret = 0;

			int i =0;
			while(rednum<red) {
				if(num.get(i)>0) {
					rednum++;
					ret+=num.get(i);
				}
				
				i++;
			}
			
			System.out.println(ret);
		
	    }
				
	}


Measured memory_bytes: 64716
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e15+100))
#define ARRS ((ll)(1e6+100))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)

ll n,m,k,p,q,h;
ll d,b;
ll a[ARRS];
	string s;

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	if(n>=2&&m>=2){
		k=(n-2)*(m-2);
	}
	else {
		if(n>m)swap(n,m);
		if(m==1){
			cout<<1;
			return 0;
		}
		else k=m-2;
	}


	cout<<k;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

int n;
int a[20][20];
ll dp[1 << 16], group_point[1 << 16];

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

    cin >> n;
    rep(i, 0, n) rep(j, 0, n) cin >> a[i][j];

    rep(mask, 0, 1 << n) {
        rep(i, 0, n) rep(j, i + 1, n) {
            if(mask & (1 << i) and mask & (1 << j)) {
                group_point[mask] += a[i][j];
            }
        }
    }


    rep(mask, 0, 1 << n) {
        for(int mask2 = mask; mask2 > 0; mask2 = (mask2 - 1) & mask) {
            chmax(dp[mask], dp[mask - mask2] + group_point[mask2]);
        }
    }

    cout << dp[(1 << n) - 1] << endl;


}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
       {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}
 
  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
    {
      if(i>1&&i<a&&j<b&&j>1)printf(".");
      else printf("#");
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}



Measured memory_bytes: 2048
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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



int main(){
  ll n; string s,t ; cin >> n >> s >> t; ll ans = 2*n;
  
  for(ll i=0; i < n; i++){
    bool flag = true;
    
    for(ll j = 0; j < n-i; j++){
     
      if(t[j] != s[i+j]){
        flag = false;
        break;
      }
    }
    
    if(flag){
      ans = n + i;
      break;
    }
    
  }
  
  cout << ans << endl;
}

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

int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(b-a<=0)
    {
        cout<<"delicious\n";
    }
    else if(b-a<=x)
    {
        cout<<"safe\n";
    }
    else
    {
        cout<<"dangerous\n";
    }
    return 0;
}


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

int main() {
  string s, t; cin >> s;
  t = "ACGT";
  int ans = 0;
  int now = 0;
  for (char c: s) {
    bool isACGT = false;
    for (int i = 0; i < 4; i++) {
      if (c == t.at(i)) isACGT = true;
    }
    if (!isACGT) {
      now = 0;
    }
    else {
      now++;
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}

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

int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if( x <= 0 || y <= 0) cout << "No" << endl;
  else if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i,d){
        cin >> p[i] >> c[i];
    }

    int ans = 10000;
    for(int bit = 0; bit < (1<<d); bit++){
        int sum = 0;
        int score = 0;
        int j = -1; //解かれていない問題で最も得点が高いもののindex
        for(int i = 0; i < d; i++){
            if(bit & (1<<i)){
                sum += p[i];
                score += c[i] + p[i]*(i+1)*100;
            }else{
                j = i;
            }
        }
        if(score >= g){
            ans = min(ans,sum);
        }else{
            if(j == -1) break;
            for(int i = 0; i < p[j]-1; i++){
                score += (j+1)*100;
                sum++;
                if(score >= g){
                    ans = min(ans, sum);
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int main()
{
	//File("");
	int x = 0;
	cin >> x;
	LL a = 0, b = 0;
	a = x / 500, b = x % 500;
	LL ans = a * 1000;
	ans += (b / 5) * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256