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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> A) {
  set<ll> s;

  rep(i, N) {
    if (s.count(A.at(i))) {
      s.erase(A.at(i));
    } else {
      s.insert(A.at(i));
    }
  }

  cout << size(s) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 8772
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://onlinejudge.u-aizu.ac.jp/challenges/sources/JAG/Summer/2440>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
void solve(){
    int N; cin >> N;
    map<string,int> mp;
    set<string> s;
    for(int i = 0; i < N;i++) { string U; cin >> U; mp[U] = 0; s.insert(U);}
    int M; cin >> M;
    bool state = false;
    for(int i = 0; i < M;i++){
        string T; cin >> T;
        if(s.find(T) == s.end()){
            cout << "Unknown " << T << endl;
        }else{
            if(state == 0){
                state = 1;
                cout << "Opened by " << T << endl;
            }else{
                state = 0;
                cout << "Closed by " << T << endl;
            }
        }
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
using namespace std;

int N;
string input, keitai[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
stack<char> st;

int main(void){
  cin >> N;
  while(N--){
    cin >> input;
    for(int i = 0; i < input.size(); i++){
      if(input[i] == '0' && !st.empty()){
        int cnt = 0, b = st.top() - '0';
        while(!st.empty()){
          st.pop(); cnt++;
        }
        cout << keitai[b][(cnt - 1) % keitai[b].size()];
      }else if(input[i] != '0'){
        st.push(input[i]);
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<unordered_map>
#include<map>
#include<set>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define nl cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007

int main()
{
	ios :: sync_with_stdio(false);
	cin.tie(nullptr);
	// ios_base :: sync_with_stdio(false);
	// cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b;
	cin >> a >> b;

	int x = (4 * a - b);

	int y = (b - 2 * a);

	if (x >= 0 && y >= 0 && x % 2 == 0 && y % 2 == 0)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
int n;
long long x, t;
long long a[200000];
long long b[200001];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lld", a + i);
	for (int i = 0; i < n; i++)b[i + 1] = b[i] + a[i];
	std::sort(b, b + n + 1);
	t = 1;
	for (int i = 0; i < n; i++) {
		if (b[i] != b[i + 1]) {
			x += t * (t - 1) / 2;
			t = 1;
		}
		else t++;
	}
	x += t * (t - 1) / 2;
	printf("%lld\n", x);
}

Measured memory_bytes: 3328
#include<iostream>

using namespace std;

int main(){
  int a,b,c;
  

  cin >> a  >> b >> c;
  
  if(b-a==c-b){
    cout << "YES" << endl;
    
  }else { 
    cout << "NO" << endl;
  }

  
  return 0;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define fin for(i=0;i<n;i++)
#define vec vector<ll>
#define pb push_back
#define vecit vector<ll>::iterator
#define vecp vector<pair<ll,ll> >
#define vecpit vector<pair<ll,ll> >::iterator
#define mapp map<ll,ll>
#define mapr map<ll,pair<ll,ll> >
#define maprit map<ll,pair<ll,ll> >::iterator
#define mapit map<ll,ll>::iterator
#define mod1 1000000007
#define INF 1000000000000
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll i,j,l;
    vec v;
    fin
    {
        cin>>j;
        v.pb(j);
    }
    ll a[100001];
    a[0]=0;
    a[1]=abs(v[1]-v[0]);
    for(i=2;i<k;i++)
    {
        a[i]=abs(v[i]-v[0]);
    }
    ll q;
    for(i=k;i<n;i++)
    {
        q=INF;
        for(j=1;j<=k;j++)
        {

             ll p=abs(v[i]-v[i-j])+a[i-j];
             if(p<q)
                q=p;
        }
       a[i]=q;
    }
    cout<<a[n-1];
}



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

void solve()
{
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    while (x <= y)
    {
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3588
MOD = 10**9+7
s = input()

cumsum = {}
for key in ['A', 'B', 'C', '?']:
    cumsum[key] = [0]*(len(s)+1)
for i, ss in enumerate(s):
    for key in cumsum.keys():
        if key == ss:
            cumsum[key][i+1] = cumsum[key][i]+1
        else:
            cumsum[key][i+1] = cumsum[key][i]

ans = 0
for i in range(1, len(s)-1):
    if s[i] == 'A' or s[i] == 'C':
        continue
    
    n_a = cumsum['A'][i]
    n_c = cumsum['C'][-1] - cumsum['C'][i+1]
    n_q_left = cumsum['?'][i]
    n_q_right = cumsum['?'][-1] - cumsum['?'][i+1]

    n_left = (n_a*pow(3, n_q_left, MOD))%MOD + (n_q_left*pow(3, max(n_q_left-1, 0), MOD))%MOD
    n_left %= MOD
    n_right = (n_c*pow(3, n_q_right, MOD))%MOD + (n_q_right*pow(3, max(n_q_right-1, 0), MOD))%MOD
    n_right %= MOD
    ans += (n_left*n_right)%MOD
    ans %= MOD

print(ans)


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

int main(){
  //ツ素ツ青板青カツ青ャ
  const int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  while(true){
    int n,x;
    cin>>n>>x;
    if(!n&&!x)break;
    int menu[n];
    for(int i=0;i<n;i++)cin>>menu[i];
    bool money[x+1];
    money[0] = true;
    for(int i=1;i<x+1;i++){
      money[i] = false;
      for(int j=0;j<n;j++){
	if(i>=menu[j]&&money[i-menu[j]]){
	  money[i] = true;
	  break;
	}
      }
    }
    int p = -1;
    for(int i=x;i>0;i--){
      if(prime[i]&&money[i]){
	p=i;
	break;
      }
    }
    if(p==-1)cout<<"NA"<<endl;
    else cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 2820
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <fstream>
#include <algorithm>


using namespace std;

typedef long long ll;

const int maxn=1e5+10;
int a[maxn];
map<int,int> m;
int main()
{
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    m[a[i]]++;
  }
  vector<pair<int,int>> v;
  for(pair<int,int> p: m)
    v.push_back(p);
  int res=0;
  for(int i=0;i<v.size();i++)
  {
    int cnt=v[i].second;
    if(i+1<v.size()&&v[i].first+1==v[i+1].first)
    {
      cnt+=v[i+1].second;
      if(i+2<v.size()&&v[i+2].first==v[i+1].first+1)
        cnt+=v[i+2].second;
    }
    res=max(cnt,res);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
using namespace std;;
int main()
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
        
    }
	return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {

	
	int n, l;
	cin >> n >> l;
	VI v(n);
	REP(i, n) {
		v[i] = l + i;
	}

	int k = INF;
	int ans = 0;


	REP(i, n) {
		if (abs(v[i]) < abs(k)) {
			k = v[i];
		}
		ans += v[i];
	}

	cout << ans - k << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

int main() {
    string S;
    cin >> S;
    int ans = 1e8;
    for(int i = 0; i <= S.size() - 3; i++) {
        ans = min(ans, abs(753 - stoi(S.substr(i, 3))));
    }
    cout << ans << endl;
    return 0;
}

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

bool w[100000];
int ww[100000];

int main()
{
	int n,c;
	scanf("%d%d",&n,&c);
	if(c < 0)
	{
		if(n == 1)
		{
			printf("11\n");
		}
		else
		{
			for(int i = 0; i < n * 2; i++)
			{
				printf("9");
			}
			printf("\n");
		}
	}
	else
	{
		int ma = 1;
		for(int i = 0; i < n; i++)
		{
			ma *= 10;
		}
		int las = sqrt((double)(ma * ma * 10)) + 1;
		for(int i = 0; i <= las; i++)
		{
			w[i] = true;
		}
		int num = 0;
		for(int i = 2; i <= las; i++)
		{
			if(w[i])
			{
				for(int j = 2; i * j <= las; j++)
				{
					w[i * j] = false;
				}
				ww[num] = i;
				num++;
			}
		}
		for(int i = ma - 1; i >= 0; i--)
		{
			int s = i * ma * 10 + c * ma;
			int q = i;
			int k = ma / 10;
			for(int j = 0; j < n; j++)
			{
				s += k * (q % 10);
				k /= 10;
				q /= 10;
			}
			bool so = true;
			for(int j = 0; j < num; j++)
			{
				if(s % ww[j] == 0)
				{
					so = false;
					break;
				}
			}
			if(so)
			{
				printf("%d\n",s);
				break;
			}
		}
	}
	return 0;
}

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

vector<int> graph[100005];  // 木の情報を格納

int dfs(int parent){
    if(graph[parent].size() == 0)    return 0;

    vector<int> depth;  // 親ノードparentの子ノードの部分木の深さ
    for(int i = 0; i < (int)graph[parent].size(); ++i){
        int child = graph[parent][i];
        depth.push_back(dfs(child));
    }
    sort(depth.begin(), depth.end(), greater<int>());

    int ret = 0;
    for(int i = 0; i < (int)depth.size(); ++i){
        ret = max(ret, depth[i] + i + 1);
    }

    return ret;
}

int main(){
    int n;
    cin >> n;
    for(int i = 1; i < n; ++i){
        int a;
        cin >> a;
        --a;
        graph[a].push_back(i);
    }

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


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

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

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s,t;
	cin >> s >> t;
	int ssize = s.size();
	int tsize = t.size();
	FORR(i,ssize - tsize,0){
		bool able = true;
		FOR(j,0,tsize){
			if(s[i + j] != t[j] && s[i + j] != '?')able = false;
		}
		if(able){
			FOR(j,0,tsize){
				s[i + j] = t[j];
			}
			FOR(j,0,ssize){
				if(s[j] == '?'){
					cout << 'a';
				}else{
					cout << s[j];
				}
			}
			cout << endl;
			return 0;
		}
	}
	ANS("UNRESTORABLE");
	return 0;
}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 0);
  for (int i = 0; i < n - 1; i++) {
    int in;
    cin >> in;
    ++a[in];
  }

  for (int i = 1; i < n + 1; i++) {
    cout << a[i] << endl;
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3992
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <complex>

#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define rtr(c, i) for (typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); --i)
#define contains(c, x) ((c).find(x) != (c).end())
#define Contains(c, x) (find(all(c), x) != (c).end())
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, (n))
#define To_String to_string< char,std::char_traits<char>,std::allocator<char> >

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

int dr[] = { -1, 0, 1, 0 }, dc[] = { 0, 1, 0, -1 };
int a[110][110];
int main()
{
	ios_base::sync_with_stdio(0);
	int d; cin >> d;
	while (d--) {
		int n; cin >> n;
		int cnt = n;
		if (n % 2 == 0) {
			for (int i=1; n-i>1; i+=2) cnt += 2*(n-i);
			cnt++;
		}
		else {
			for (int i=1; n-i>1; i+=2) cnt += 2*(n-i);
		}
		memset(a, 0, sizeof(a));
		int r = n, c = 1, k = 0, x = 0;
		while (x < cnt) {
			a[r][c] = ++x;
			r += dr[k], c += dc[k];
			if (r <= 0 || r >= n+1 || c <= 0 || c >= n+1) {
				r -= dr[k], c -= dc[k];
				k = (k + 1) % 4;
				r += dr[k], c += dc[k];
			}
			else if (a[r+dr[k]][c+dc[k]]) {
				a[r][c] = 0;
				r -= dr[k], c -= dc[k];
				k = (k + 1) % 4;
				r += dr[k], c += dc[k];
			}
		}
		REP(i, 1, n+1) {
			REP(j, 1, n+1) putchar(a[i][j] ? '#' : ' ');
			//REP(j, 1, n+1) printf("%3d", a[i][j]);
			puts("");
		}
		if (d) puts("");
	}
	return 0;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	long long lcm = (c * d) / __gcd(c, d);
	long long abc = (b / c - a / c);
	long long abd = (b / d - a / d);
	long long ablcm = (b / lcm - a / lcm);
	long long cnt = b - a - abc - abd + ablcm;
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,M,A[1000],i,j,k;

int main()
{
cin>> N>>M;
for(i=0;i<M;i++)
{
cin>>k;
N+=-k;
}

if(N>=0)cout <<N;
else cout<<-1;








}

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

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double S = x / a;
    if (S == a * b) {
        cout << "0.0000000000" << endl;
        return 0;
    }
    else {
        if (S <= a * b / 2) {
            double a2 = 2 * S / b;
            double r = atan(b / a2);
            cout << fixed << setprecision(10) << r * (180.0 / M_PI) << endl;
        }
        else {
            double b2 = 2*S / a - b;
            b -= b2;
            double r = atan(b / a);
            cout << fixed << setprecision(10) << r * (180.0 / M_PI) << endl;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// 標準入力からデータを読み込む準備
		Scanner sc = new Scanner(System.in);
		// 2つの文字の固まりをそれぞれ整数値と想定して読み込む 
		double r = sc.nextDouble();
		double pi = Math.PI;
		double area = r*r*pi;/* ここを変えて面積を求めよう */
		double length = r*2*pi;/* ここを変えて周囲の長さを求めよう */ 
		System.out.printf("%f %f", area, length);
		sc.close();
		}
}


Measured memory_bytes: 28104
#include "bits/stdc++.h"
using namespace std;

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

const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
ll inv[maxn], fact[maxn];

ll C(int n, int r) {
    return fact[n] * (inv[r] * inv[n - r] % mod) % mod;
}
ll way(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1, dy = y2 - y1;
    return C(dx + dy, dx);
}

void pre() {
    fact[0] = fact[1] = inv[0] = inv[1]= 1;
    for(int i = 2; i < maxn; ++i) {
        inv[i] = -(mod / i) * inv[mod % i] % mod;
        inv[i] += mod;
    }
    for(int i = 2; i < maxn; ++i) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = inv[i] * inv[i - 1] % mod;
    }
}
int main(int argc, char const *argv[]) { pre();
    int h, w, a, b;
    scanf("%d %d %d %d", &h, &w, &a, &b);
    ll ans = 0;
    for(int i = 0; i <= h - a; i++) {
        ans += (way(1, 1, i, b) * way(i, b + 1, h, w)) % mod;
        if(ans >= mod) ans -= mod;
    }
    printf("%lld\n", ans);
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    string S, T;
    cin >> S>> T;

    if (S.length() < 11 && S.length() + 1 == T.length() && T.substr(0, S.length()) == S)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int A, B, C;
    cin >> A >> B >> C;

    cout << max(0, C - (A-B)) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import collections
import itertools

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
c = collections.Counter(s)
cc = c.most_common()

ans = []

num = cc[0][1]
for i in cc:
    if i[1] == num:
        ans.append(i[0])

ans = sorted(ans)

for i in ans:
    print(i)



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  #define int long long
  int n;
  cin >> n;
  int gu = 0, ki = 0;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
    if(v[i] % 2 == 0) gu++;
    else ki++;
  }
  gu += ki / 2;
  // cout << gu << endl;
  ki %= 2;
  // cout << ki << endl;
  if(ki == 0)cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ans = 0
    while N > 0:
        N = N // K
        ans += 1
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 int main() {
 	int n;
 	cin>>n;
	vector<long long> v(n);
	long long ans=0;
	for(int i=0; i<n; i++)
	   cin>>v[i];
	   
	for(int i=1; i<n; i++) {
		if(v[i]<v[i-1]) {
			ans+=abs(v[i]-v[i-1]);
			v[i]+=v[i-1]-v[i];
		}
	}
	cout<<ans<<endl;
	return 0;
 }

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);

  int n,m;
  cin>>n>>m;
  // adj[from] = to,cost;
  V<V<PL>> adj(n);
  rep(i,m){
    int l,r,d;
    cin>>l>>r>>d;
    l--,r--;
    adj[l].eb(r,d);
    adj[r].eb(l,-d);
  }

  VL cost(n,0);
  V<bool> visited(n,false);
  queue<ll> que;
  rep(i,n){
    if(visited[i])continue;
    que.push(i);
    while(!que.empty()){
      int now = que.front();
      que.pop();
      for(auto v:adj[now]){
        if(visited[v.fi]){
          if(cost[v.fi]!=cost[now]+v.se){
            No;
            return 0;
          }
        }
        else {
          cost[v.fi]=cost[now]+v.se;
          visited[v.fi]=true;
          que.push(v.fi);
        }
       
      }
    }
  }
  Yes;
  
  /*
  rep(i,n){
    for(auto v: adj[i]){
      if(cost[v.fi]==0)cost[v.fi]=cost[i]+v.se;
      else {
        if(cost[v.fi]!=cost[i]+v.se){
          No;
          return 0;
        }
      }
    }
  }
  Yes;
  */
  
  return 0;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
const int MOD = pow(10,9)+7;
int main(){
  int N,K,a;
  cin >> N >> K;
  vector<int> cnt(K+1);
  cnt[0] = 1;
  for(int i = 0; i < N; ++i){
    cin >> a;
    int psum = 0;
    for(int k = K-1; k >= max(0,K-a); --k) psum = (psum+cnt[k])%MOD;
    cnt[K] = (cnt[K]+psum)%MOD;
    for(int j = K-1; j > 0; --j){
      psum = (psum-cnt[j])%MOD;
      if(j-a >= 0) psum = (psum+cnt[j-a])%MOD;
      cnt[j] = (cnt[j]+psum)%MOD;
    }
  }
  cout << (cnt[K]+MOD)%MOD;
  return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> b(B);
  REP(i, A) { cin >> a.at(i); }
  REP(i, B) { cin >> b.at(i); }

  vector<int> x(M);
  vector<int> y(M);
  vector<int> c(M);
  REP(i, M) { cin >> x.at(i) >> y.at(i) >> c.at(i); }

  int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  REP(i, M) { ans = min(ans, a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i)); }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

    int n,k;
    cin >> n >> k;

    int ar[n];

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

    int dp[n];
    dp[0] = 0;

    for(int i = 1; i < n; i++)
    {
        dp[i] = INT_MAX;
        for(int j = i-1; j >= max(i-k,0); j--)
        {
            dp[i] = min(dp[i], dp[j] + abs(ar[i] - ar[j]));
        }
    }

    cout << dp[n-1];
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
	Scanner sc;
	int L;
	
	private void calc() {
		sc = new Scanner(System.in);
		L = sc.nextInt();
		double l = L / 3d;
		System.out.println(l*l*l);
	}

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


Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, c=1;
    double a=0;
    cin >> n;
    
    while(c != n+1){
        if(c%2 == 1) {
            a++;
        }
        c++;
    }
    cout<<fixed<<setprecision(10) << double(a/n) << endl;
    
    return 0;
}


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

using namespace std;

typedef long long LL;
#define N 1200000

const LL mod=1000000007;
LL n,m,p,fac[N],sum,f[N],F[N];

void upd(LL &x,LL y){x=(x+y+mod)%mod;}

LL inv(LL x){return x==1?1:(mod-mod/x)*inv(mod%x)%mod;}

int main(){
	scanf("%lld%lld%lld",&n,&m,&p);
	fac[0]=1; for (LL i=1;i<=n;++i){fac[i]=fac[i-1]*i%mod; upd(sum,fac[i]);}
	f[0]=fac[n]; F[0]=f[0];
	for (LL i=1;i<=m;++i){
		f[i]=F[i-1];
		if (i>p) upd(f[i],-F[i-p-1]);
		f[i]=f[i]*sum%mod;
		F[i]=(F[i-1]+f[i])%mod;
	}
	printf("%lld\n",f[m]*inv(sum)%mod);
	
	return 0;
}
			

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

int H, W;
vector<vector<char>> S(20, vector<char>(20));
vector<vector<int>> d(20, vector<int>(20));
queue<int> qx;
queue<int> qy;
vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

void search();

int BFS(int sx, int sy, int gx, int gy) {
  rep(i, H) rep(j, W) d[i][j] = -1;
  qx.push(sx);
  qy.push(sy);
  d[sy][sx] = 0;
  
  search();
  
  return d[gy][gx];
}

int main() {
  cin >> H >> W;
  rep(i, H) rep(j, W) cin >> S[i][j];
  
  int ans = -1;
  rep(sy, H) rep(sx, W) {
    rep(gy, H) rep(gx, W) {
      if (S[sy][sx] == '.' && S[gy][gx] == '.') {
        ans = max(ans, BFS(sx, sy, gx, gy));
      }
    }
  }
  cout << ans << endl;
}

void search() {
  int x = qx.front();
  int y = qy.front();
  qx.pop();
  qy.pop();
  
  rep(i, 4) {
    if (x + dx[i] >= 0 && x + dx[i] < W && y + dy[i] >= 0 && y + dy[i] < H) {
      if (S[y + dy[i]][x + dx[i]] == '.' && d[y + dy[i]][x + dx[i]] == -1) {
        qx.push(x + dx[i]);
        qy.push(y + dy[i]);
        d[y + dy[i]][x + dx[i]] = d[y][x] + 1;
      }
    }
  }
  
  if (qy.size() > 0) search();
  
  return;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int L,R;
int ans=2019*2019;
int MOD=1000000007;
vector<int> mod2019;
signed main(){
    scanf("%lld %lld",&L,&R);
    for(int i=L;i<=R;i++){
        if(i!=L&&i%2019==L%2019)break;
        mod2019.pb(i%2019);
    }
    rep(i,mod2019.size()){
        for(int j=i+1;j<mod2019.size();j++){
            ans=min(ans,(mod2019[i]*mod2019[j])%2019);
        }
    }
    printf("%lld\n",ans);
}


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

int main() {
    int64_t X, K, D;
    cin >> X >> K >> D;

    if(X < 0) X *= -1;

    int64_t temp = K;
    temp -= X / D;

    if(temp <= 0) cout << X - K*D << endl;
    else{
        X %= D;
        if(temp % 2 == 0)cout << X << endl;
        else cout << D - X << endl;
    }
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
    public static void main(String args[]){
        String b="";        
        Scanner kbd=new Scanner(System.in);
        b=kbd.nextLine();
        while(!b.equals(".")){
            LinkedList<Character> a=new LinkedList<Character>();
            boolean ans=true;
            char[] c=b.toCharArray();
            for(int i=0;i<c.length;i++){
                if(c[i]=='[' || c[i]=='(') a.add(c[i]);
                else if(c[i]==']' || c[i]==')') {
                    if(a.size()==0){ans=false;break;}
                    else if(a.peekLast()=='('&&c[i]==')')a.pollLast();
                    else if(a.peekLast()=='['&&c[i]==']')a.pollLast();
                    else {ans=false;break;}
                }
                
            }
            if(a.size()>0)ans=false;
            if(!ans) System.out.println("no");
            else  System.out.println("yes");
            b=kbd.nextLine();
        }
    }
}

Measured memory_bytes: 13000
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 1000005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef map<ll, ll> Map;

int main(void) {
    
    ll a, b;
    cin >> a >> b;
    cout << a+b/2 << endl;
    
    
    
    
    
    
    
    
    
    

}


Measured memory_bytes: 256
class abc_153:
    
    def __init__(self):
        pass
    def A(self):
        pass
    def B(self):
        pass
    def C(self):
        pass
    def D(self):
        H=int(input())
        count=1
        att_count=0
        
        while H>0:
            att_count+=count
            count*=2
            H>>=1
        print(att_count)
        
    def E(self):
        pass
    def F(self):
        pass
    
if __name__=='__main__':
    obj=abc_153()
    obj.D()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a1,a2,a3,s=0;
    cin>>a1>>a2>>a3;
    if(a1>=1 && a1<=13 && a2>=1 && a2<=13 && a3>=1 && a3<=13)
        s=a1+a2+a3;
    else
        printf("wrong input");
    if(s>=22)
        printf("bust");
    else
        printf("win");
}


Measured memory_bytes: 256
/* Kadai3_3
   saitomo*/
#include<stdio.h>

int main(void){
  int num_10,num_k,count=1;//countは桁数を求める際に用いる。最初は1(桁)
  scanf("%d %d",&num_10,&num_k);
  while(num_10/num_k>0){//num_10をnum_kで割って小数点以下を切り捨てる。num_10>0の間に割った回数を数える
    num_10=num_10/num_k;
    count=count+1;
  }
  printf("%d\n",count);
  return 0;
}
  

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int i, j;
	
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return 0;
}

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

const int INF = 1001001001;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i,n) {
    cin >> c[i];
    rep(j,m) {
      cin >> a[i][j];
    }
  }
  int ans = INF;
  rep(bi, 1<<n) {
    vector<int> u(m);
    int tp = 0;
    rep(i,n) {
      if (bi>>i & 1) {
        rep(j,m) u[j] += a[i][j];
        tp += c[i];
      }
    }
    bool can = true;
    rep(i,m) {
      if (u[i] < x) can = false;
    }
    if (can) ans = min(ans, tp);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = "APPROVED";
        int a = sc.nextInt();
        for(int i = 0; i < a; i++){
            int n = sc.nextInt();
            if(n % 2 == 0 && (n % 3 != 0 && n % 5 != 0)){
                str = "DENIED";
            }
        }
        System.out.println(str);
    }
}

Measured memory_bytes: 23508
S=input()
ans="No"
flg=0
flg1=0

if len(S) == 1:
  ans="No"
elif len(S) < 11:
  flg1=1
  for i in range(len(S)):
    if flg==0:
      if S[i] == 'h':
        flg=1
      else:
        flg=2
        break
    elif flg==1:
      if S[i] == 'i':
        flg=0
      else:
        flg=2
        break
else:
  ans="No"
        
if flg==0 and flg1 == 1:
  ans="Yes"
          
print(ans)


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

int main() {
	string s;cin>>s;
  	long long int n=s.size(),sum=0,subtotal=0,res=0;
  
  	for(long long int i=0;i<(1<<(n-1));i++){//ｎ-1の全探索
  	  	sum=0;
      	subtotal=stoi(s.substr(0,1));
      for(int j=0;j<(n-1);j++){
        if(i&(1<<j)){//j-1桁目が1だったら
          sum+=subtotal;
          subtotal=0;       
        }
        subtotal=subtotal*10+stoi(s.substr(j+1,1));
      }
      sum+=subtotal;
      res+=sum;
    }
  cout<<res<<endl;
}


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

int main() {
    int n;
	cin >> n;
	vector<string> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == "E869120") {
			ans++;
		}
	}
	cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
 char a = S[0];
   char b = S[1];
   char c = S[2];
  if(a=='R' && b=='R' && c=='R'){
    cout << 3<<endl;
 }
  else if(a=='R' && b=='R' || b=='R' && c=='R'){
    cout << 2<<endl;
  }
  else if(a=='S' && b=='S' && c=='S'){
    cout<<0<<endl;
  }
  else{
    cout << 1<< endl;
  }
}

Measured memory_bytes: 3592
main = do
  line <- getLine
  let totalSec = read line :: Int
  let sec = mod totalSec 60
  let min = mod (div totalSec 60) 60
  let hr = div totalSec 3600
  putStrLn $ fmt hr min sec
  where
    fmt hr min sec = (show hr) ++ ":" ++ (show min) ++ ":" ++ (show sec)




Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	long long int n=100, x, cnt=0;

	cin>> x;

	while (n<x) {
		n += n / 100;
		cnt++;
	}

	cout << cnt << endl;

}


Measured memory_bytes: 3640
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)
#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c))
#define     M             32000
int main()
{
   ll n,s=0;
   cin>>n;
   for(int i=1;i<=n;++i)
   {
       if(i%3==0 && i%5==0) continue;
       if(i%3==0)continue;
       else if(i%5==0)continue;
       else s+=i;


   }
   cout<<s<<endl;

return 0;

}


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

using namespace std;

int n, a[(int)2e5], d[(int)2e5], k;

int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 2; i <= n; i++)
        d[i] = INT_MAX;
    d[2] = abs(a[2] - a[1]);
    for(int i = 3; i <= n; i++)
        for(int j = i - 1; j > 0 && j >= i - k; j--)
            d[i] = min(d[i], d[j] + abs(a[j] - a[i]));
    cout << d[n];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int X, Y;
  while (cin >> X >> Y, X) {
    int c[20][20];
    int dp[20][20] = {};
    for (int i = 0; i < Y; i++) {
      for (int j = 0; j < X; j++) {
        cin >> c[i][j];
      }
    }
    for (int i = 0; i < X; i++) {
      if (c[0][i] == 0) dp[0][i] = 1;
    }
    for (int i = 0; i < Y - 1; i++) {
      for (int j = 0; j < X; j++) {
        if (c[i][j] == 0) {
          if (j > 0 && c[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
          if (c[i + 1][j] != 1) dp[i + 1][j] += dp[i][j];
          if (j + 1 < X && c[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
        } else if (c[i][j] == 2 && i + 2 < Y) {
          if (c[i + 2][j] != 1) dp[i + 2][j] += dp[i][j];
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < X; i++) {
      if (c[Y - 2][i] == 2) ans += dp[Y - 2][i];
      ans += dp[Y - 1][i];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0430_atcoder問題_11
{
    class Program
    {
        static void Main(string[] args)
        {
            string hoge = Console.ReadLine();
            int sum = 0;
            if (hoge[0] == '1') sum += 900;
            else sum += 100;
            if (hoge[1] == '1')sum += 90;
            else sum += 10;
            if (hoge[2] == '1')sum+= 9;
            else  sum += 1;
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9+7;
using ll = long long;
int main()
{
    ll a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f >> g;
    ll ans = b;
    if(a == 0 || d == 0 || e == 0)
    {
        ans += a / 2 * 2;
        ans += d / 2 * 2;
        ans += e / 2 * 2;
    }
    else
    {
        int ap = a % 2;
        int dp = d % 2;
        int ep = e % 2;
        int sum = ap + dp + ep;
        if(sum % 2 != 0)
        {
            // even :0
            if(ap == 1 && dp == 1 && ep == 1)
            {
                ans += a + d + e;
            }
            // even :2
            else
            {
                ans += a / 2 * 2;
                ans += d / 2 * 2;
                ans += e / 2 * 2;
            }
        }
        else
        {
            // even:3
            if(ap == 0 && dp == 0 && ep == 0)
            {
                ans += a + d + e;
            }
            // even:1
            else
            {
                ans += 3;
                a--;d--;e--;
                ans += a / 2 * 2;
                ans += d / 2 * 2;
                ans += e / 2 * 2;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll dp[200005];
ll ksm(ll a,ll b,ll mod)
{
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
int main()
{
    dp[1]=1;dp[2]=1;
    for(int i=3;i<200001;i++)
    {
        ll t=0;
        ll n=i;
        for(;n;n>>=1) if(n&1) t++;
        dp[i]=dp[i%t]+1;
    }
    ll n;cin>>n;
    string s; cin>>s; ll mod=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='1') mod++;
    }
    ll sum1=0;ll sum2=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='1')
        {
            sum1=(sum1+ksm(2,s.size()-i-1,mod+1))%(mod+1);
            if(mod>1)
                sum2=(sum2+ksm(2,s.size()-i-1,mod-1))%(mod-1);
        }
    }
    for(int i=0;i<s.size();i++)
    {
        if(mod==1&&s[i]=='1')
        {
            cout<<0<<endl;
            continue;
        }
        else if(s[i]=='1')
        {
            ll t=((sum2+mod-1)-(ksm(2,s.size()-i-1,mod-1)))%(mod-1);
            cout<<dp[t]+1<<endl;
        }
        else
        {
            ll t=(sum1+ksm(2,s.size()-i-1,mod+1))%(mod+1);
            cout<<dp[t]+1<<endl;
        }

    }

    return 0;
}



Measured memory_bytes: 5248
from functools import reduce
from fractions import gcd

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // gcd(t, l[i])
    return t

# input
N, M = map(int, input().split())
A = list(map(lambda x: x//2, map(int, set(input().split()))))

# process
ans = 0
lc = lcm(A)

if lc <= M:
    f = True
    for a in A:
        if lc//a%2 == 0:
            f = False
            break

    if f:
        ans = int(M/lc-1)//2+1

# output
print(ans)


Measured memory_bytes: 13300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class60
    {
        static void Main()
        {
            var I = Console.ReadLine().Split();
            int N = int.Parse(I[0]);
            int K = int.Parse(I[1]);
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Dictionary<int, int> Table = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                if (Table.ContainsKey(A[i]))
                {
                    Table[A[i]]++;
                }
                else
                {
                    Table[A[i]] = 1;
                }
            }
            var Table2 = Table.OrderBy(x => x.Value);
            int sum = 0;
            int count = 0;
            foreach(KeyValuePair<int,int> i in Table2)
            {
                if (Table.Count() - count <= K) break;
                sum += i.Value;
                count++;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 41680
import sys
import itertools

def countcombi(n):
    r = 0
    p = list(itertools.product(range(0,10),repeat = 4))
    for tmp in p:
        if sum(tmp) == n:
            r += 1
    return r


if __name__ == '__main__':
    for line in sys.stdin:
        n = (int)(line)
        print(countcombi(n))

Measured memory_bytes: 8456
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(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 repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

vector<ll> runrun;

int main() {
    int K; cin >> K;
    repp(i,1,10) runrun.push_back(i);
    int i = 0;
    while(runrun.size() < K) {
        string s = to_string(runrun[i]);
        int n = s.size();
        if (s[n-1] != '0') runrun.push_back(stol(s+to_string(runrun[i]%10-1)));
        runrun.push_back(stol(s+s[n-1]));
        if (s[n-1] != '9') runrun.push_back(stol(s+to_string(runrun[i]%10+1)));
        ++i;
    }
    cout << runrun[K-1] << endl;
}


Measured memory_bytes: 1400
# include <iostream>
using namespace std;
# define ll long long

int main(){
  ll n; int p;
  cin >> n >> p; 

  bool allEven = true;
  for(int i=0; i<n; i++){
    ll num;
    cin >> num;
    if(num % 2 == 1) allEven = false;
  }

  if(allEven) cout << (p ? 0 : (1ll<<n)) << endl;
  else cout << (1ll<<(n-1)) << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
vs = list(map(int, input().split()))
#print(vs)
max_sum_v = -1 * 10 ** 10

for n_l in range(n):
	sum_v = sum([x for x in vs[:n_l] if x >= 0])
	neg_vs = [x for x in vs[:n_l] if x < 0]
	for n_r in range(n_l, n + 1):
		if n_l + (n - n_r) > k:
			continue
		sum_v2 = sum_v + sum([x for x in vs[n_r:] if x >= 0])
		neg_vs2 = neg_vs + [x for x in vs[n_r:] if x < 0]
		neg_vs2.sort()
		rest = k - n_l - (n - n_r)
		if len(neg_vs2) > rest:
			sum_v2 += sum(neg_vs2[rest:])

		#print(n_l, n_r, sum_v2)

		max_sum_v = max(max_sum_v, sum_v2)

print(max_sum_v)

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    char t = s[k-1];
    for (auto& v : s) {
        if (v != t) v = '*';
    }
    cout << s << endl;
}

Measured memory_bytes: 256