akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
const int mod = 1e9 + 7;
const int N = 202;
const int M = 1e5 + 1;
long long f[N][M], C[N][N], to[M];
int a[N];
long long b[N];
int n, X;
bool cmp(const int x, const int y)
{
    return x > y;
}
int main()
{
    C[0][0] = 1;
    for (int i = 1; i < N ; i++){
        C[i][0] = 1;
        for (int j = 1; j <= i ; j ++) {
            C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            if (C[i][j] >= mod) C[i][j] -= mod;
        }
    }
    b[0] = 1;
    for (int i = 1; i < N ; i++)
        b[i] = b[i - 1] * i % mod;
    scanf("%d %d", &n, &X);
    for (int i = 1; i <= n ; i ++)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1, cmp);
    int x = n + 1;
    for (int i = 0; i <= X ; i ++) {
        while (x - 1 && a[x - 1] <= i) x--;
        to[i] = x;
    }
    if (to[X] == n + 1){
        printf("%d\n", (long long)X * b[n] % mod);
        return 0;
    }
    f[to[X]][X] = C[n][to[X] - 1] * b[to[X] - 1] % mod;
    long long ans = 0;
    for (int i = 1; i <= n ; i ++)
        for (int j = 0; j <= X ; j ++)
            if (f[i][j])
                for (int k = i; k <= n ; k ++)
                {
                    int y = j % a[k];
                    if (to[y] == n + 1)
                        ans =  (ans + f[i][j] * y % mod * b[n - i] % mod) % mod;
                    else
                        f[to[y]][y] = (f[to[y]][y] + f[i][j] * C[n - i][to[y] - i - 1] % mod * b[to[y] - i - 1] % mod ) % mod;
                }
    printf("%lld\n", ans);
    return 0;
}

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

int main()
{
  string T, A;//Aは出力する文字列
  char a;
  cin >> T;
  
  for(int i = 0; i < T.size(); i++)
  {
    if(T.at(i) == '?'){a = 'D';}
    else{a = T.at(i);}
    A += a;
  }
  
  cout << A << endl;
}

Measured memory_bytes: 3924
#include<cstdio>

int main()
{
  long long a,b;
  scanf("%lld",&a);
  getchar();
  b=(getchar()-'0')*100ll;
  getchar();
  b+=(getchar()-'0')*10ll;
  b+=getchar()-'0';
  a=a*b;
  //if(a%100>44)a+=100;
  printf("%lld",a/100);
  return 0;
}

Measured memory_bytes: 1732
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum, a[310000], b[310000];
string str;
bool f[11000];
char c[210000];
int main() {
	cin >> n >> p >> q >> w >> h;
	p--, q--, h--, w--;
	//p->w,q->h
	rep(i, n) {
		cin >> c[i];
	}
	if (w < p || h < q) {
		cout << "No" << endl;
		return 0;
	}
	if (w > h) {
		for (int i = p; i <= min(w, n - 2); i++) {
			if (c[i] == '#'&&c[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		for (int i = max(q-1,(LL)0); i <= min(h-1, n - 3); i++) {
			if (c[i] == '.'&&c[i + 1] == '.'&&c[i + 2] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
	else {
		for (int i = p; i <= min(h, n - 2); i++) {
			if (c[i] == '#'&&c[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 512
/*
joisinoお姉ちゃんは、劇場の受付を担当しています。

この劇場には、席 
1
 から席 
100000
 までの、
100000
 個の席があります。

彼女のメモ書きによると、今までの間に 
N
 組の団体が来て、
i
 組目の団体は席 
l
i
 から席 
r
i
 までの連続した席に座っています。

今、劇場の席には何人座っているか求めてください。
*/

#include <iostream>
using namespace std;

int N;
int A[110];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> N;
    int L[N], R[N];
    for (int i = 0; i < N; ++i){
    	cin >> L[i];
    	cin >> R[i];
    }
    int res = 0;
    
    for (int i = 0; i < N; ++i){
    	res += R[i] - L[i] + 1;
    }
    cout << res;
}

Measured memory_bytes: 256
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
	int n, m;
	cin >> n >> m;
	double a[n], sum = 0;
	for(double &i : a) cin >> i, sum+=i;
	int count = 0;
	for(int i = 0; i < n; i++){
		if(a[i] >= (sum/(4.0*m)))count++;
	}
	if(count >= m)
		cout << "Yes";
	else
		cout << "No";
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}	
	


Measured memory_bytes: 256
#include<stdio.h>

void takahashi(int a, int b){
	if(a > 9 || b > 9){
		printf("-1\n");
	}else{
		printf("%d\n", a*b);
	}
}

int main(){
	int x, y;
	scanf("%d", &x); scanf("%d", &y);
	takahashi(x, y);
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
namespace IO{
	const int BS=(1<<20)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
const double D=11.4159265358979323846264338328;
const double K=-4.2920367320510338076867830836;
int n,m,maxy,sx,sy,ex,ey,tot,c[M],pos[M],now;
double ans;
struct pot{
	int X,Y; void gtin(){X=read(),Y=read(),maxy=max(maxy,Y+1);}
	bool ft(){return X>=sx&&X<=ex&&Y>=sy&&Y<=ey;}
	bool operator <(const pot&ot)const{return X<ot.X;}
}p[M],t[M];
int main(){
	sx=read(),sy=read(),ex=read(),ey=read(),maxy=max(sy,ey);
	if(sx>ex) swap(sx,ex),swap(sy,ey); n=read();
	for(int i=1;i<=n;i++) p[i].gtin();
	if(sy>ey){
		for(int i=1;i<=n;i++) p[i].Y=maxy-p[i].Y;
		sy=maxy-sy,ey=maxy-ey;
	} sort(p+1,p+n+1),ans=(ey+ex-sy-sx)*100.0;
	for(int i=1;i<=n;i++) if(p[i].ft()) t[++tot]=p[i];
	memset(c,0x3f,sizeof(c)),c[0]=now=0;
//	printf("S ( %d %d )   E ( %d %d )\n",sx,sy,ex,ey);
//	for(int i=1;i<=tot;i++) printf("%d %d \n",t[i].X,t[i].Y);
//	printf("maxy = %d\n",maxy);
	for(int i=1;i<=tot;i++){
		int l=1,r=now,md,res=0;
		while(l<=r){md=((r+l)>>1);if(c[md]<t[i].Y) res=md,l=md+1;else r=md-1;}
		if(res==now) now++; c[res+1]=min(c[res+1],t[i].Y);
	}
//	printf("now = %d\n",now);
	if(now<=ex-sx&&now<=ey-sy) ans+=now*K;
	else ans+=(now-1)*K+D; printf("%.13lf\n",ans);
	return 0;
}

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

int h, w;
char grid[55][55];

int main() {
  cin >> h >> w;
  rep(i, h)rep(j, w)cin >> grid[i][j];
  char res[h][w];
  rep(i, h)rep(j, w)res[i][j] = 0;
  rep(i, h){
    rep(j, w){
      if(grid[i][j] == '#'){
        res[i][j] = '#';
        continue;
      }
      int cnt = 0;
      for(int dy = -1; dy <= 1; dy++){
        for(int dx = -1; dx <= 1; dx++){
          if(dx == 0 && dy == 0){
            continue;
          }
          int nx = j + dx, ny = i + dy;
          if(nx < 0 || ny < 0 || nx >= w || ny >= h){
            continue;
          }
          if(grid[ny][nx] == '#'){
            cnt++;
          }
        }
      }
      res[i][j] = '0' + cnt;
    }
  }
  rep(i, h){
    rep(j, w){
      cout << res[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
  string s;
  cin >> s;

  sort(s.begin(),s.end());
  vector<char>t;
  t.push_back(s[0]);
  for (int i = 0; i < s.size()-1; i++) {
    if (s[i]!=s[i+1]) {
      t.push_back(s[i+1]);
    }
  }

  for (char i = 'a'; i < 'z'+1; i++) {
    if (i==t[i-'a']) {
      continue;
    }
    else {
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}




Measured memory_bytes: 512
def show r
  puts (('%5d' * r.size) % r)
end
until (n = gets.to_i) == 0
  show n.times
    .lazy
    .map { gets.split(' ').map(&:to_i) }
    .map {|r| (r << r.reduce(:+)).tap(&method(:show)) }
    .reduce {|m, r| m.zip(r).map {|p| p.reduce(:+) } }
end

Measured memory_bytes: 6148
/************************************/
/* NoobM							*/
/* File Name : cha.cpp				*/
/* Date : 13.07.2020 02:20:47 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	int n;
	cin >> n;
	
	int k = log2(n);
	
	cout << (int)pow(2, k) << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 4096
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007
int main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'E') {
			cnt++;
		}
	}

	int minv = cnt;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			cnt++;
		}else if (s[i] == 'E') {
			cnt--;
		}
		//cout << cnt << endl;
		if (min(cnt, minv) == cnt) {
			minv = cnt;
		}
	}
	cout << minv << endl;
	return 0;
}


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

const long double PI = acos(-1);
 
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); }

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main(){
    int n;
    string s;
    cin >> n >> s;

    for (int i = 0; i < s.size(); i++){
        if(s[i] + n > 65+25){
            s[i] = s[i] - 26 + n;
        }else{
            s[i] += n;
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f;
    pair<lli, lli> ans = make_pair(100 * a, 0);
    double now = 0;
    rep(i, 30) rep(j, 30)
    {
        lli wa = 100 * (a * i + b * j);
        if (wa > f)
            continue;
        lli toke = e * (a * i + b * j);
        rep(k, 3011)
        {

            if (c * k > toke)
                break;
            rep(l, 3011)
            {
                if (l * d + c * k + wa > f)
                    break;
                if (c * k + d * l > toke)
                    break;
                lli hoge = l;
                if (double(hoge * d + c * k) / double(wa) > now) {
                    now = double(hoge * d + c * k) / double(wa);
                    ans.first = wa;
                    ans.second = hoge * d + c * k;
                }
            }
        }
    }
    cout << ans.first + ans.second << " " << ans.second << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  for(int i=0;i<n;i++){
    string str,str2;
    cin>>str>>str2;
    int a=0,b=0;
    int num=1;
    for(int j=0;j<str.size();j++){
      if(str[j]>='0'&&str[j]<='9')num=str[j]-'0';
      else{
	switch(str[j]){
	case 'm':a+=1000*num;num=1;break;
	case 'c':a+=100*num;num=1;break;
	case 'x':a+=10*num;num=1;break;
	case 'i':a+=num;num=1;break;
	}
	num=1;
      }
    }
    num=1;
    for(int j=0;j<str2.size();j++){
      if(str2[j]>='0'&&str2[j]<='9')num=str2[j]-'0';
      else{
	switch(str2[j]){
	case 'm':b+=1000*num;num=1;break;
	case 'c':b+=100*num;num=1;break;
	case 'x':b+=10*num;num=1;break;
	case 'i':b+=num;num=1;break;
	}
	num=1;
      }
    }
    int c=a+b;
    while(c>0){
      if(c/1000>0){
	if(c/1000==1)
	  cout<<'m';
	else{
	  cout<<c/1000<<'m';
	}
	c=c%1000;
      }else if(c/100>0){
	if(c/100==1)
	  cout<<"c";
	else
	  cout<<c/100<<'c';
	c=c%100;
      }else if(c/10>0){
	if(c/10==1)
	  cout<<'x';
	else
	  cout<<c/10<<'x';
	c=c%10;
      }else if(c>0){
	if(c==1)
	  cout<<'i';
	else
	  cout<<c<<'i';
	c=0;
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
    int n, ans;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    double avg, d_min;
    avg = 0;
    d_min = 1000.0;
    for (int i=0; i<n; ++i){
        avg += (double)a[i];
    }
    avg = avg / (double)n;
    for (int i=0; i<n; ++i){
        if(fabs(a[i] - avg) < d_min){
            ans = i;
            d_min = fabs(a[i] - avg);
        }
    }
    cout << ans << endl;
}

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

int Manipulate(int, int);

int main(){
	const int WIDTHMIN = 1;
	const int HEIGHTMIN = 1;
	const int WIDTHMAX = 9;
	const int HEIGHTMAX = 9;
	int i, j;
	for(i=WIDTHMIN; i<=WIDTHMAX; i++){
		for(j=HEIGHTMIN; j<=HEIGHTMAX; j++){
			cout << i << "x" << j << "=" << Manipulate(i, j) << "\n" << flush;
		}
	}
	return 0;
}

int Manipulate(int num1, int num2){
	return num1 * num2;
}

Measured memory_bytes: 1112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int x = sc.nextInt();
			int y = sc.nextInt();
if(x == 0 && y == 0) {
				break;
			}
			if(x>=y) {
				System.out.printf("%d %d\n",y,x);
			}
			else {
				System.out.printf("%d %d\n",x,y);
			}
			
		}
	}

}



Measured memory_bytes: 41560
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{

int n , x;
cin>>n>>x;

int arr[n+1];
arr[0]=0;
int ans =0;
for(int index = 1 ;index <= n;index++)
{
    int c ;
    cin>>c;

    arr[index]=arr[index-1]+c;
    if(arr[index]<=x)
        ans = index;
}
cout<<ans+1<<endl;


 return 0;
}


Measured memory_bytes: 3636
use std::io;
use std::io::*;
use std::str::FromStr;
use std::fmt;
 
fn abc(a: i32, b: i32, c: i32, X: i32) -> i32 {
    let mut result = 0;
    for i_a in (0..a+1) {
        for i_b in (0..b+1) {
            for i_c in (0..c+1) {
                if i_a*500 + i_b*100 + i_c*50 == X {
                    result +=1;
                }
            }
        }
    }
    return result
}
 
fn main() {
    /*
    assert_eq!(abc(5,1,0,150), 0);
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let X: i32 = read();
 
    let result = abc(a, b, c, X);
 
    println!("{}", result);
}
 
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n;
double ans;
int v[51];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	sort(v+1,v+n+1);
	ans=v[1];
	for(int i=2;i<=n;i++)
	{
		ans=(ans+v[i])/2;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), l = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		Arrays.sort(s);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(s[i]);
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(); ;
        var K = int.Parse(input[0]);
        var X = int.Parse(input[1]);

        var blackList = new List<int>();
        for (int i = X - K + 1; i < X + K; i++)
        {
            if (i < -1000000 || 1000000 < i)
            {
                continue;
            }
            blackList.Add(i);
        }

        var ans = string.Join(" ", blackList);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
const int XY_MAX = pow(10, 5);
int main (void) {
    int A, B, C;
    int X, Y;

    cin >> A >> B >> C >> X >> Y;

    int ans = INT_MAX;
    for (int i = 0; i <= XY_MAX; i++) {
        ans = min(ans, 2 * C * i + max(0, X - i) * A + max(0, Y - i) * B);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,r,p,c;
    while(true){
        cin>>n>>r;
        if(n==0&&r==0){
            break;    
        }else{
            int A[n];
            for(int i=0;i<n;i++){
                A[i]=n-i;   
            }
            for(int j=0;j<r;j++){
                cin>>p>>c;
                int B[p-1];
                for(int i=0;i<p-1;i++){
                    B[i] = A[i];  
                }
                for(int i=0;i<c;i++){
                    A[i]=A[p-1+i];   
                }
                for(int i=0;i<p-1;i++){
                    A[c+i]=B[i];   
                }
            }
            cout<<A[0]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <stdio.h>
#define ll long long
#define NIL -1
#define MAX 10000
using namespace std;

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL)
    return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL)
    return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL)
    return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)
      T[l].p = v;
    if(r != NIL)
      T[r].p = v;
  }
  for(i = 0; i < n;i++)
    if(T[i].p == NIL)
      root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
}

Measured memory_bytes: 3212
n = gets.to_i
list = []
n.times do |i|
  a,b = gets.split
  b = b.to_i
  list << [i+1,a,b]
end
list.sort_by!{|t| [t[1],-t[2]]}
list.each do |t|
  p t[0]
end

Measured memory_bytes: 1788
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int a = 0;
		int b = 0;
		if(n == 2){
		    a = sc.nextInt();
		    b = sc.nextInt();
		}
		
		// 計算
		if(n == 1) System.out.println("Hello World");
		if(n == 2) System.out.println(a + b);
		
	}
}

Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <iomanip>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

typedef long double ld;

class Point {
public:
	ld x, y;
	Point(ld x, ld y) :
			x(x), y(y) {
	}

	Point operator +(Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator *(ld a) {
		return Point(x * a, y * a);
	}

};

typedef Point Vector;

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2) :
			p1(p1), p2(p2) {
	}
};

ld norm(Point p1) {
	return p1.x * p1.x + p1.y * p1.y;
}

ld dot(Point p1, Point p2) {
	return p1.x * p2.x + p1.y * p2.y;
}

Point project(Segment s, Point p) {
	Vector base = s.p1 - s.p2;
	ld r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base * r;
}

int main() {

	int p1x, p1y, p2x, p2y;
	scanf("%d %d %d %d", &p1x, &p1y, &p2x, &p2y);
	Point p1(p1x, p1y);
	Point p2(p2x, p2y);
	Segment segment(p1, p2);

	int q;
	scanf("%d", &q);

	for (int i = 0; i < q; ++i) {
		int qx, qy;
		scanf("%d %d", &qx, &qy);

		Point p(qx, qy);
		Point ans = project(segment, p);
		cout << fixed << setprecision(10) << ans.x << " " << ans.y << endl;
	}

	return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
int main() {
  char S[1000000] = {0};
  vector<int> s_v, s_01v, s_10v;
  cin >> S;
  //cout << strlen(S) << endl;
  for (int i = 0; i < strlen(S); i++) {
    s_v.push_back(S[i] - '0');
    switch(i%2) {
    case 0:
      s_01v.push_back(0);
      s_10v.push_back(1);
      break;
    case 1:
      s_01v.push_back(1);
      s_10v.push_back(0);
      break;
    }
  }
  long long int cnt_01 = 0, cnt_10 = 0;

  for (int i = 0; i < strlen(S); i++) {
    if (s_01v[i] != s_v[i]) cnt_01++;
    if (s_10v[i] != s_v[i]) cnt_10++;
  }
  if (cnt_01 > cnt_10) {
    cout << cnt_10 << endl;
  }
  else {
    cout << cnt_01 << endl;
  }
  // for (int i = 0; i < strlen(S); i++) {
  //   printf("%d ", s_v[i]);
  // }
  return 0;
}


Measured memory_bytes: 2796
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};



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

   

int n,k;
cin>>n>>k;
int cnt=0;
while(n)
{
   cnt++;
   n=n/k;
}
cout<<cnt<<"\n";



}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int k,a,b;
	cin>>k>>a>>b;
	if( b-a <= 2){
		cout<<k+1<<endl;
		return 0;
	}
	else{
		int kaisu = (k-a+1)/2;
		if( kaisu <= 0 ){
			cout<<k+1<<endl;
		}
		else{
			cout<< a + kaisu * ( b - a ) + ( k-a+1 ) % 2;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("C:\\Users\\BOG\\Desktop\\path.txt");ofstream out("C:\\Users\\BOG\\Desktop\\crd.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int a, u,v, TIME = 0;
vec<vec<int>> l;
vec<int> dep, p, mxd, tin, tout;

void dfs(int V, int P, int d){
    tin[V] = TIME++;
    mxd[V] = 1;
    dep[V] = d;
    p[V] = P;
    for(int h : l[V]){
        if(h!=P){
            dfs(h, V, d+1);
            mxd[V] = max(mxd[V], mxd[h]+1);
        }
    }
    tout[V] = TIME-1;
}

int dst(int x, int y){
    return abs(dep[x]-dep[y]);
}

int main(){
    fast;
    cin>>a>>u>>v; u--, v--;
    dep = vec<int>(a);
    tin = vec<int>(a);
    tout = vec<int>(a);
    mxd = vec<int>(a);
    p = vec<int>(a);
    l = vec<vec<int>>(a, vec<int>());
    for(int q=0; q<a-1; q++){
        int x,y; cin>>x>>y; x--, y--;
        l[x].pb(y);
        l[y].pb(x);
    }
    dfs(v, -1, 0);
    int o = 0;
    //for(int q=0;q <a; q++)cout<<q+1<<": "<<tin[q]<<" "<<tout[q]<<endl;
    for(;;){
        //cout<<u<<" "<<v<<endl;
        if(dst(u,v)==0) break;
        if(dst(u,v)>2) u = p[u];
        else{
            int num=-1, val = -1;
            for(int h : l[u]){
                if(h==p[u]) continue;
                if(mxd[h] > val) val = mxd[h], num = h;
            }
            if(num==-1) u = p[u];
            else u = num;
        }

        //cout<<u<<" "<<v<<endl;
        if(dst(u,v)==0) break;
        int num = -1;
        for(int h : l[v]){
            if(h==p[v]) continue;
            if(tin[h]<=tin[u] && tin[u]<=tout[h]){
                assert(num==-1);
                num = h;
            }
        }
        assert(num>-1);
        v = num; o++;
    }
    cout<<o;
}

Measured memory_bytes: 15360
/* ex3_3
   offNaria */
#include <stdio.h>
#include <math.h>

int main(void){
  int N, K; //整数N,Kを定義
  scanf("%d %d", &N, &K); //入力を変数に代入
  int output = log(N) / log(K) + 1; //桁数はKを底とするNの対数に1を加えたもの
  printf("%d\n", output);
  return 0;
}


Measured memory_bytes: 512
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, V = il()
    B, W = il()
    T = ii()

    dist = abs(B - A)
    run = T * (V - W)
    print('YES' if run >= dist else 'NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 37400
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#define endl '\n'
#define ll long long

using namespace std;

struct ST{
    int num;
    int fre;
};

int arr[200001];


int N, K, cur_diff, ret;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N >> K;
    for(int i = 0; i < N; i++)
    {
        int a; cin >> a;
        arr[a] += 1;
    }
    vector<ST> vec;
    for(int i = 1; i < 200001; i++)
    {
        if(arr[i] == 0) continue;
        cur_diff += 1;
        vec.push_back(ST{i, arr[i]});
    }
    sort(vec.begin(), vec.end(), [](ST a, ST b) -> bool { return a.fre > b.fre; });
    
    while(K < cur_diff)
    {
        auto bk = vec.back();
        ret += bk.fre;
        cur_diff -= 1;
        vec.pop_back();
    }
    
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N + 1);
    for(int i = 0; i <= N; i++) cin >> A[i];
    vector<ll> sum(N + 2);
    for(int i = N; i >= 0; i--) {
        sum[i] = sum[i+1] + A[i];
    }
    ll ans = 0;
    if(N == 0) {
        if(A[0] == 1) {
            cout << 1 << endl;
            return 0;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    if(A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    ans++;
    ll now = 1;
    for(int i = 1; i <= N; i++) {
        now *= 2;
        chmin(now, sum[i]);
        ans += now;
        now -= A[i];
        if(now < 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4784
//42
#include<iostream>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<string> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  vector<int> vv(3,100000000);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j!=i){
	int c=atoi((v[i]+v[j]).c_str());
	int x=max_element(vv.begin(),vv.end())-vv.begin();
	vv[x]=min(vv[x],c);
      }
    }
  }
  cout<<*max_element(vv.begin(),vv.end())<<endl;
  return 0;
}

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

struct edge{int s,t,n;}e[200010];
int n,a[100010],h[100010],d[100010];

int dfs(int x,int f)
{
	int s=0,mx=0,_=0;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=f)  _=dfs(y,x),s+=_,mx=max(mx,_),_=1;
	if (!_)  return a[x];
	if ((s>=a[x])&&(s-a[x]<=(2*mx>s?s-mx:s/2)))
		return 2*a[x]-s;
	else  puts("NO"),exit(0);
}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v),d[u]++,d[v]++;
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	for (int i=1; i<=n; i++)
		if (d[i]!=1)
			puts(dfs(i,0)?"NO":"YES"),exit(0);
	puts(a[1]!=a[2]?"NO":"YES");
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String ans = "";
		if(s.equals("Sunny")) ans = "Cloudy";
		else if(s.equals("Cloudy")) ans = "Rainy";
		else ans = "Sunny";
		System.out.println(ans);
		in.close();

	}

}


Measured memory_bytes: 19796
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using ld = long double;
using namespace std;

int dp[10010][100][2];

int main(){
	string k; cin >> k;
	int n = k.l_ength();
	int d; cin >> d;
	dp[0][0][0] = 1;
	for( int i = 0; i < n; ++i ){
		for( int kleiner = 0; kleiner <= 1; ++kleiner ){	
			for( int r = 0; r < d; ++r ){
				int bound = kleiner ? 9 : k[i] - '0'; 
				for( int m = 0; m <= bound; ++m ){
					( dp[i+1][(r+m)%d][ kleiner || m < bound ] += dp[i][r][kleiner] ) %= mod;
				}
			}
		}
	}
	cout << ( dp[n][0][0] + dp[n][0][1] + (mod-1) ) % mod << endl;
}

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

int total(int card[], int num) {
	int total = 0;
	for (int i = 1; i <= num; i++) {
		total += card[i];
	}
	return total;
}

int main(void) {
	for (;;) {
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0) {
			break;
		}
		int taro[101], hanako[101];
		for (int i = 1; i <= n; i++) {
			cin >> taro[i];
		}
		for (int i = 1; i <= m; i++) {
			cin >> hanako[i];
		}
		int c1=101, c2=101;
		bool flag = false;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				int tmp = taro[i];
				taro[i] = hanako[j];
				hanako[j] = tmp;
				if ((total(taro, n) == total(hanako, m)) && (i + j < c1 + c2)) {
					flag = true;
					tmp = taro[i];
					taro[i] = hanako[j];
					hanako[j] = tmp;
					c1 = taro[i];
					c2 = hanako[j];			
				}
				else {
					tmp = taro[i];
					taro[i] = hanako[j];
					hanako[j] = tmp;
				}
			}
		}
		if (flag) {
			printf("%d %d\n", c1, c2);
		} else {
			printf("-1\n");
		}
	}
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vi G[MAX_N];
int ans[MAX_N];
int c[MAX_N];
int f[MAX_N];

void dfs(int x, int sum){
    sum += c[x];
    ans[x] = sum;
    f[x] = 1;
    rep(i,G[x].size()){
        if(f[G[x][i]]==0){
            dfs(G[x][i], sum);
        }
        
    }
}

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

    rep(i,n-1){
        int a,b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p,x; cin >> p >> x;
        c[p] += x;
    }
    dfs(1,0);

    srep(i,1,n+1){
        cout << ans[i] << endl;
    }

    return 0;
}
 
 


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define maxn 200005
using namespace std;
int vis[maxn];
int rec[maxn];
int main()
{
    int n,k,i;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        vis[x]++;
    }
    int index=0;
    for(i=1;i<=200000;i++)
    {
        if(vis[i])
        {
            rec[index++]=vis[i];
        }
    }
    int ans=0;
    sort(rec,rec+index);
    int last=index-k;
    for(i=0;i<last;i++)
    {
        ans+=rec[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans1=a*x+b*y;
    int ans2=(x>y)?c*y*2+a*(x-y)
                  :c*x*2+b*(y-x);
    int ans3=c*std::max(x,y)*2;
    cout << std::min({ans1,ans2,ans3}) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
int di[4]={-1,0,0,1};
int dj[4]={0,-1,1,0};

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> s(h,vector<char>(w));
  rep(i,h){
    rep(j,w)
    cin>>s[i][j];
    
  }                          
  //////////////////////入力　.#.孤立形を探す
  bool ans=true;    //題意　
  rep(i,h){
    rep(j,w){           //全部のマスを考える
           if(s[i][j]!='#'){ continue;}       //'#'でなければ飛ばす
      bool ok=false;     // '#'が連続しているかどうか
             for(int k=0;k<5;k++){    //上、左、右、したのマス
             int ni=i+di[k]; 
             int nj=j+dj[k];
             if(ni<0  || ni>=h  ||  nj<0  ||  nj>=w ) {continue;}  //枠外は飛ばす
             
               if(s[ni][nj]=='#') { //'#'が隣り合っていれば
                 ok=true; //ok=trueにする
               }
                                   
           }
         if(!ok){ //okじゃなければ
           ans=false;     
            
         }
      }
  }
   //cout<<s[0][0]<<endl;
  if(ans) cout<<"Yes"<<endl; 
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
N,M,Q=list(map(int,input().split()))
Map = [[0]*500 for i in range(500)]
for i in range(M):
    l,r=list(map(int,input().split()))
    l,r=l-1,r-1
    Map[r][l]+=1

S = [[0]*501 for i in range(501)]

for i in range(500):
    s=0
    for j in range(500):
        s+=Map[i][j]
        S[i+1][j+1]=S[i][j+1]+s

for i in range(Q):
    p,q = list(map(int,input().split()))
    print(S[q][500]-S[q][p-1])

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
// using Graph = vector<vector<Edge>>;
const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

// 配るdp
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N + 200);
    vector<int> dp(N + 200, INF_32);

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

    dp[0] = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 1; j <= K; 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: 4004
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

string s, t;

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	cin >> s >> t;
	for (int i = 0; i < n; i++)
		cout << s[i] << t[i];
	cout << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = map(int,input().split())
A = sorted([(b,a) for a, b in enumerate(a)])[::-1]
dp = [[-1 for _ in range(N+10)]for _ in range(N+10)]
#dp[x][y]: 活発度順でx+y人詰めた時,左にx人右にy人詰めたときの最大値
dp[0][0] = 0
import sys
sys.setrecursionlimit(100000000)

def memo(x, y):
    if x < 0 or y < 0: return -1000000000000 #ありえん
    if dp[x][y] != -1: return dp[x][y]
    val, pre = A[x+y-1][0], A[x+y-1][1]
    dp[x][y] = max(
            #x-1からくるパターン
            memo(x - 1,y) + abs(pre - (x - 1)) * val,
            #y-1からくるパターン
            memo(x, y - 1) + abs(pre - (N - y )) *val,
            )
    return dp[x][y]
ans = 0
for i in range(N): ans = max(ans, memo(i,N - i))
print(ans)


Measured memory_bytes: 173412
from fractions import gcd
a,b,c,d=map(int,input().split())
cnt1,cnt2=0,0
cnt1=(a-1)//c+(a-1)//d-((a-1)*gcd(c,d))//(c*d)
cnt2=b//c+b//d-(b*gcd(c,d))//(c*d)
print(b-a+1-cnt2+cnt1)

Measured memory_bytes: 5304
// https://atcoder.jp/contests/abc132/tasks/abc132_d

fun main() {
    abc132d()
}

fun abc132d() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val base = 1_000_000_007L
    val red = n - k
    val com = List(n + 1) { LongArray(n + 1) { 0 } }
    com[0][0] = 1L
    for (i in 1 .. n) {
        for (j in 0..i) {
            if (j == 0 || j == i) {
                com[i][j] = 1L
            } else {
                com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]) % base
            }
        }
    }
    for (i in 1..k) {
        if (red < i - 1) {
            println(0)
            continue
        }
        println(com[k - 1][i - 1] * com[red + 1][i] % base)
    }
}

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

int main(){
    int h1,h2,k1,k2;
    cin>>h1>>h2;
    cin>>k1>>k2;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=h1*a+h1/10*c+h2*b+h2/20*d;
    int y=k1*a+k1/10*c+k2*b+k2/20*d;
    if(x<y) cout<<"kenjiro"<<endl;
        else if(x>y) cout<<"hiroshi"<<endl;
        else cout<<"even"<<endl;
    return 0;
    
}


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

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

    int total = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        int d1 = x;
        int d2 = abs(k - x);
        total += (min(d1, d2) * 2);
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<iomanip>
using namespace std;
char a[101];
int main()
{
	int i,l;
gets(a);
l=strlen(a);
for(i=0;i<l;i++)
{cout<<a[0]<<l-2<<a[l-1];break;
}
return 0;
}

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

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

string str_base(int n, int base) {
    assert(n >= 0 && base > 1 & base <= 10);

    if (n == 0) {
        return "0";
    }
    
    string ret = "";
    while (n > 0) {
        ret += to_string(n % base);
        n /= base;
    }

    reverse(ret.begin(), ret.end());

    return ret;
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> switches(m, vector<int>());
    
    int tmp;
    int tmp_2;
    rep(i, m) {
        cin >> tmp;
        rep(j, tmp) {
            cin >> tmp_2;
            switches[i].push_back(tmp_2 - 1);
        }
    }

    vector<int> on_status(m);
    rep(i, m) {
        cin >> on_status[i];
    }

    string tmp_s;
    int cnt = 0;
    rep(i, (int) pow(2, n)) {
        tmp_s = str_base(i, 2);
        int shortage = n - tmp_s.size();
        tmp_s = string(shortage, '0') + tmp_s;
        int light_cnt = 0;
        rep(j, m) {
            int on_cnt = 0;
            for (auto sw : switches[j]) {
                if (tmp_s[sw] == '1') {
                    on_cnt++;
                }
            }

            if (on_cnt % 2 == on_status[j]) {
                light_cnt++;
            }
        }

        if (light_cnt == m) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

int main(void){
    int n;
    int d[100];

    cin >> n;
    for (int i = 0; i < n; i++) cin >> d[i];

    sort(d, d + n);

    int ans = 0;
    int p = 0;

    for (int i = 0; i < n; i++){
        if (p != d[i]) {
            ans++;
            p = d[i];
        }
    }

    cout << ans;
    cout << "\n";
}

Measured memory_bytes: 256
#include<iostream>
//#include<algorithm>
//#include<cmath>
//#include<string>
//#include<cctype>
#include <vector>
using namespace std;
int main() {
    int i, c, m, n, b;
    while (cin >> m >> n, n) {
        vector<int> a(7368792,0);
        b = m;
        while (1) {
            if (!a[b]) {
                if (!n) { cout << b << endl; break; }
                for (i = b; i < 7368792; i += b)
                    a[i] = 1;
                n -= 1;
            }
            b++;
        }
    }
    return 0;
}

Measured memory_bytes: 31812
#include <iostream>
#include <math.h>
using namespace std;
 
int main(void){
    double X,money;
  int count;
  money = 100;
  	scanf("%lf",&X);
  for(count=0;money<X;count++){
    money = floor(money*1.01);
}
   printf("%d",count);
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int a,b,c,d,e,f;

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>a>>b>>c>>d>>e>>f;
  double maxn=0;
  int memo_x=100*a,memo_y=0;
  REP(ia,31){
    REP(ib,31){
      REP(ic,101){
        REP(id,101){
          int sum=100*a*ia+100*b*ib+c*ic+d*id;
          if(sum>f)continue;
          if(e*(a*ia+b*ib)<(c*ic+d*id))continue;
          // P(sum);
          if(maxn<(double)100*(c*ic+d*id)/(double)sum){
            maxn=(double)100*(c*ic+d*id)/(double)sum;
            memo_x=sum;
            memo_y=c*ic+d*id;
          }

        }
      }
    }
  }
  cout<<memo_x<<" "<<memo_y<<"\n";
  return 0;
}


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

typedef struct {
    int i;
    int j;
    int d;
} NODE;

int main() {

    int H, W;
    cin >> H >> W;

    int sharp = 0;
    string MAP[50];
    for (int i=0; i<H; i++) {
        cin >> MAP[i];
        for (int j=0; j<MAP[i].size(); j++)
            if (MAP[i][j] == '#') sharp++;
    }

    MAP[0][0] = '#';
    NODE start;
    start.i = 0;
    start.j = 0;
    start.d = 1;

    queue<NODE> Q;
    Q.push(start);

    int shortest = 0;

    while (!Q.empty()) {
        NODE Now = Q.front();
        Q.pop();

        if (Now.i == H-1 && Now.j == W-1) {
            shortest = Now.d;
            break;
        }

        int I = Now.i;
        int J = Now.j;
        int D = Now.d;
        //MAP[I][J] = '#';
        //cout << I << "," << J << "," << D << endl;

        // 右
        if (J+1 < W && MAP[I][J+1] == '.') {
            NODE next;
                next.i = I;
                next.j = J+1;
                next.d = D+1;
            MAP[I][J+1] = '#';
            Q.push(next);
        }

        // 左
        if (J-1 >= 0 && MAP[I][J-1] == '.') {
            NODE next;
                next.i = I;
                next.j = J-1;
                next.d = D+1;
            MAP[I][J-1] = '#';
            Q.push(next);
        }

        // 下
        if (I+1 < H && MAP[I+1][J] == '.') {
            NODE next;
                next.i = I+1;
                next.j = J;
                next.d = D+1;
            MAP[I+1][J] = '#';
            Q.push(next);
        }

        // 上
        if (I-1 >= 0 && MAP[I-1][J] == '.') {
            NODE next;
                next.i = I-1;
                next.j = J;
                next.d = D+1;
            MAP[I-1][J] = '#';
            Q.push(next);
        }

    }

    if (shortest == 0) {
        cout << -1 << endl;
        exit(0);
    }

    int result = H * W - sharp - shortest;
    cout << result << endl;

}


Measured memory_bytes: 256