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


#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mii               map<int,int>
#define pqb               priority_queue<int>
#define pqs               priority_queue<int,vi,greater<int> >
#define setbits(x)        __builtin_popcountll(x)
#define zrobits(x)        __builtin_ctzll(x)
#define mod               1000000007   //10^9 + 7
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type*arr = new type[n]
#define w(x)              int x;cin>>x;while(x--)
#define ti(n)             int n;cin>>n
#define rep(i,n)          for(int i=0;i<(n);++i)
#define repA(i,a,n)       for(int i=a;i<=(n);++i)
#define repD(i,a,n)       for(int i=a;i>=(n);--i)
#define itr(type,it,x)    for(type it = x.begin();it!=x.end();it++)
#define endl              "\n"
mt19937                  rng(chrono::steady_clock::now().time_since_epoch().count());  // to shuffle an array randomly viz. shuffle(arr,arr+n,rng)

//typedef tree<int , null_type , less<int> , rb_tree_tag, tree_order_statistics_node_update> pbds;  //policy based data structure


void c_p_c() {

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

}

int minCost(vector<int> h, int n)
{

	vector<int> dp(n+1);

	dp[1] = 0;

	for (int i = 2; i <= n; ++i)
	{
		int op1 = abs(h[i] - h[i - 1]) + dp[i - 1];
		int op2 = (i == 2) ? 1e9 : abs(h[i] - h[i - 2]) + dp[i - 2];

		dp[i] = min(op1, op2);
	}

	return dp[n];
}

int32_t main(int32_t argc, char const *argv[]) {

	c_p_c();

  int n;cin>>n;
  
  vector<int> h(n+1);
  for(int i=1;i<=n;++i)
  {
      cin>>h[i];
  }
cout<<minCost(h,n);

	
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		 Scanner sc = new Scanner(System.in);
		 int n=sc.nextInt();
		 int[] s=new int[n+1];
		 int count=0;
		 for(int i=0; i<n; i++){
			 s[i]=sc.nextInt();
		 }
		 int q=sc.nextInt();
		 int[] t=new int[q];
		 for(int i=0; i<q; i++){
			 t[i]=sc.nextInt();
		 }
		 for(int i=0; i<q; i++){
			 if(linears(s,t[i])!=-1){
				 count++;
			 }
		 }
		 System.out.println(count);

	}
	public static int linears(int[] s,int key){
		int i=-1;

		for(int j=0; j<s.length; j++){
			if(s[j]==key){
				i=j;
				break;
			}
		}

		return i;
	}


}


Measured memory_bytes: 40152
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int T; cin >> T;
	while (T--) {
		int H, W; cin >> H >> W;
		vector<string> s(H);
		for (int i = 0; i < H; i++)
			cin >> s[i];
		for (;;) {
			char c;
			int l, r, u, d;
			for (c = 'A'; c <= 'Z'; c++) {
				l = W; r = 0; u = H; d = 0;
				for (int i = 0; i < H; i++)
					for (int j = 0; j < W; j++)
						if (s[i][j] == c) {
							l = min(l, j); r = max(r, j + 1);
							u = min(u, i); d = max(d, i + 1);
						}
				if (l == W) continue;
				bool rect = true;
				for (int i = u; i < d; i++)
					for (int j = l; j < r; j++)
						if (s[i][j] != c && s[i][j] != '?')
							rect = false;
				if (rect) break;
			}
			if (c > 'Z') break;
			for (int i = u; i < d; i++)
				for (int j = l; j < r; j++)
					s[i][j] = '?';
		}
		bool safe = true;
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				if (s[i][j] != '.' && s[i][j] != '?')
					safe = false;
		cout << (safe ? "SAFE" : "SUSPICIOUS") << endl;
	}
}

Measured memory_bytes: 1220
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto S = RD!string;

	long ans;
	if (S == "RSR")
		ans = 1;
	else
	{
		foreach (c; S)
		{
			if (c == 'R')
				++ans;
		}
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2716
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<bits/stdc++.h>

using namespace std ;
int sumDigit(int n){
   int sum =0 ;
   while(n!=0){
      sum+=n%10 ;
      n/=10 ;
   }
   return sum ;

}

int main(){
 int n ; cin >> n ;
 int k ; cin >> k ;
 double a = ceil(((double)(n-1))/((double)(k-1)));
 int ans = (int)a ;
 printf("%d",ans) ;




return 0 ;
}


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

#define MAX 30

int ans,x,y;
int t[MAX][MAX],size[MAX];
int flg[MAX];

int isDomSet(void){
	int i,j;

	for(i=0;i<x;i++){
		if(!flg[i]){
			for(j=0;j<size[i];j++) if(flg[t[i][j]]) break;
			if(j == size[i]) return 0;
		}
	}

	return 1;
}

void solve(int idx,int cost){
	if(idx == x){
		if(ans > cost && isDomSet()) ans = cost;
		return;
	}

	flg[idx] = 0;
	solve(idx+1,cost);
	flg[idx] = 1;
	solve(idx+1,cost+1);
}

int main(void){
	int i,from,to;

	while(scanf("%d%d",&x,&y) && (x||y)){
		memset(t,0,sizeof(t));
		memset(size,0,sizeof(size));

		for(i=0;i<y;i++){
			scanf("%d%d",&from,&to);
			t[from][size[from]++] = to;
			t[to][size[to]++]= from;
		}

		ans = x;
		solve(0,0);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 412
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};



int main(){
    Stream io;

    int N;
    io.read(N);
    auto c = io.read_vec<char>(N);

    int cred = 0;
    for(int i = 0; i < N; i++){
        if(c[i] == 'R') cred++;
    }
    int cred_ok = 0;
    for(int i = 0; i < cred; i++){
        if(c[i] == 'R') cred_ok++;
    }
    cout << cred - cred_ok;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  string word;
  cin >> word;
  A = (word.at(0) - '0');
  B = (word.at(1) - '0');
  C = (word.at(2) - '0');
  D = (word.at(3) - '0');
  
  int total;
  char op1, op2, op3;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        total = 0;
        if (i == 0) {
          total = A + B;
        }
        else {
          total = A - B;
        }
        if (j == 0) {
          total += C;
        }
        else {
          total -= C;
        }
        if (k == 0) {
          total += D;
        }
        else {
          total -= D;
        }
        if (total == 7) {
          if (i == 0) {
            op1 = '+';
          }
          else {
            op1 = '-';
          }
          if (j == 0) {
            op2 = '+';
          }
          else {
            op2 = '-';
          }
          if (k == 0) {
            op3 = '+';
          }
          else {
            op3 = '-';
          }
        }
      }
    }
  }
  cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
  
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll n, memo = 0, ans = 0, p;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		p = i;
		while (p >= 10) {
			p /= 10;
			memo++;
		}
		if (memo % 2 == 0)ans++;
		memo = 0;
	}
	cout << ans << endl;
	ggr
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int a[200009];

void solve()
{
	int n,k,i;
	cin>>n>>k;
	for(i=1;i<=n;i++) cin>>a[i];
	int prev=1;
	for(i=k+1;i<=n;i++,prev++)
	{
		if(a[i]>a[prev]) cout<<"Yes\n";
		else cout<<"No\n";
	}
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4436
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

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

    int a[n],b[n],c[m],d[m];
    int ans[n];
    int tmp = 500000000;//その時の最小の値
    int manh;//マンハッタン距離

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

    for(int j=0; j<m; j++){
        cin >> c[j] >> d[j];
    }
    
    for(int l=0; l<n; l++){

        for(int t=0; t<m; t++){
            manh = abs(a[l] - c[t]) + abs(b[l] - d[t]);
            if(manh < tmp){
                tmp = manh;
                ans[l] = t + 1;
            }

        }
        tmp = 500000000;//ループごとに初期化
    }

    for(int u=0; u<n; u++){
        cout << ans[u] << endl;
    }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 50;
int n, k, a[maxn + 10];
vector<int> ans;
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	int p = min_element(a + 1, a + n + 1) - a;
	for (int i = 1; i <= n; ++i) --a[i];
	--k;
	for (int i = 1; i <= n; ++i)
		if (i != p) ans.push_back(i);
	ans.push_back(p);
	while (1) {
		int minpos = 0;
		for (int j = 1; j <= n; ++j)
			if (j != p && (!minpos || a[j] < a[minpos])) minpos = j;
		if (!a[minpos]) break;
		--k;
		for (int j = 1; j <= n; ++j)
			if (j != p && j != minpos) ans.push_back(j);
		ans.push_back(minpos);
		for (int j = 1; j <= n; ++j)
			if (j != p) --a[j];
		p = minpos;
	}
	if (k < 0) {
		printf("%d\n", (int)ans.size());
		for (auto i: ans) printf("%d ", i);
	} else printf("-1");
}


Measured memory_bytes: 256
/* basic header */
#include <bits/stdc++.h>
/* define */
#define ll long long
#define dou double
#define pb emplace_back
#define mp make_pair
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;++i)
#define rep0(i,a,b) for(int i=a;i<b;++i)
#define eps 1e-8
#define int_inf 0x3f3f3f3f
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lson curPos<<1
#define rson curPos<<1|1
/* namespace */
using namespace std;
/* header end */

const int maxn = 2000000;
struct Edge
{
    int u, v, w;
} edge[maxn];
int n, cnt, ans[maxn], vis[maxn];
vector<int> g[maxn];

void addedge(int u, int v, int w)
{
    edge[++cnt].u = u;
    edge[cnt].v = v;
    edge[cnt].w = w;
    g[u].push_back(cnt);
}

void bfs()
{
    queue<int> Q;
    Q.push(1);
    while (!Q.empty())
    {
        int x = Q.front();
        Q.pop();
        if (vis[x]) continue;
        vis[x] = 1;
        for (int i = 0; i < g[x].size(); i++)
        {
            int cur = g[x][i];
            if (!vis[edge[cur].v])
            {
                if (edge[cur].w % 2 == 0)
                {
                    ans[edge[cur].v] = ans[x];

                }
                else
                {
                    ans[edge[cur].v] = 1 - ans[x];
                }
                Q.push(edge[cur].v);
            }
        }
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i < n; i++)
    {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        addedge(u, v, w); addedge(v, u, w);
    }
    bfs();
    for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 58880
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <char cmp = '<'>
    bool icmp(ll a, ll b){ if(cmp=='>') return a > b; else return a < b;}
namespace enhanced_pair{
    typedef pair<ll,ll> pll;
    ostream& operator << (ostream& o, const pll a){
        o<<a.first<<" "<<a.second;
        return o;
    }
    istream& operator >> (istream& i, pll& p){
        i>>p.first>>p.second;
        return i;
    }
    template <char cmp1 = '<', char cmp2 = '<'>
        bool pcmp(pll a, pll b){ return icmp<cmp1> (a.first,b.first) || (a.first==b.first && icmp<cmp2> (a.second,b.second));}
} using namespace enhanced_pair;
const size_t NMAX = 200009;
const ll MOD = 1e9+7;
ll lastbit(ll num){
    return num & -num;
}
ll binPow(ll num, ll p, ll mod = MOD){
    if(!p) return 1;
    ll aux = binPow(num,p/2);
    return aux*aux%mod*(p%2?num:1)%mod;
}

void tc()
{

}
int main()
{
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}



Measured memory_bytes: 3632
#include <deque>
#include <iostream>
#include <algorithm>
 
int main()
{
using namespace std;
deque<int> edge;
int iedge[3];
int j;
int a,b,c;
 
cin >> j;
 
for(int l=0;l<j;l++){
for(int i=0;i<3;i++){
cin >> iedge[i];
edge.push_back(iedge[i]);
}
 
sort(edge.begin(),edge.end());
a = edge[0];
b = edge[1];
c = edge[2];
if(c*c == (a*a+b*b))cout << "YES\n";
else cout << "NO\n";

edge.clear();
}
 
return 0;
}

Measured memory_bytes: 1180
#include<cstdio>
#include<cstring>
int a[200005],n,b[200005];
int c[200005],d[200005];
long long int k;
int t=1;
int main(){
memset(c,0,sizeof(c));
scanf("%d%lld",&n,&k);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
b[d[a[i]]]=i;
if(c[a[i]]==0)c[a[i]]=i;
b[i]=c[a[i]];
d[a[i]]=i;
}
if(n>1){
int p=1;
while(1){
if(b[p]<=p)t++;
p=b[p];
if(p==n)break;
p++;
}
k%=t;
p=1;
t=1;
while(t<=k){
if(b[p]<=p)
t++;
if(t<=k){
p=b[p];
p++;
}
}
for(int i=p;i<=n;i++)
if(b[i]>i)i=b[i];
else 
printf("%d ",a[i]);
}
else {
if(k%2)
printf("%d ",a[1]);
}
}

Measured memory_bytes: 4480
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int x,y;
    while(scanf("%d%d",&x,&y)==2)
    {
        if(x==y)printf("Yes\n");
        else if(x==2||y==2)printf("No\n");
        else
        {
         if(((x%2==1&&x<=7)||(x>7&&x%2==0))&&((y%2==1&&y<=7)||(y>7&&y%2==0)))printf("Yes\n");
         else if(((x%2==0&&x<=6)||(x>=9&&x%2==1))&&((y%2==0&&y<=6)||(y>=9&&y%2==1)))printf("Yes\n");
         else printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll MOD = 1e9 + 7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h, w;
  cin >> h >> w;
  ll a[h], b[w];
  for (int i = 0; i < h; i++) cin >> a[i];
  for (int i = 0; i < w; i++) cin >> b[i];
  sort(a,a+h);
  reverse(a,a+h);
  sort(b,b+w);
  reverse(b,b+w);

  ll ok = 0;
  ll ans = 1;
  ll hh = 0, ww = 0;

  for (int i = h * w; i > 0; i--) {
    if (a[hh] == i && b[ww] == i) {
      ok++;
      hh++;
      ww++;
      continue;
    }

    if (i == a[hh] && hh < h) {
      if (ww == w) {
        ans *= w;
        ans %= MOD;
      } else {
      ll tmp = min(w, ww + 1);
      if (i > b[ww]) tmp--;
      ans *= tmp;
      ans %= MOD;
      }
      hh++;
    }

    else if (i == b[ww] && ww < w) {
      if (hh == h) {
        ans *= h;
        ans %= MOD;
      } else {
      ll tmp = min(h, hh + 1);
      if (i > a[hh]) tmp--;
      ans *= tmp;
      ans %= MOD;
      }
      ww++;
    }

    else {
      ans *= ww * hh - ok;
      ans %= MOD;
    }
    ok++;
  }
  cout << ans % MOD << endl;
  return 0;
}


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

int main() {
    string S, T; cin >> S >> T;
    int a, b; cin >> a >> b;
    string U; cin >> U;

    if (S == U) a--;
    else b--;

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  char str[4];
  scanf("%s", str);
  if (str[0] == str[1]) {
    if (str[2] == str[3]) {
      if (str[0] != str[2]) {
        printf("Yes\n");
        return 0;
      }
    }
  } else if (str[0] == str[2]) {
    if (str[1] == str[3]) {
      if (str[0] != str[1]) {
        printf("Yes\n");
        return 0;
      }
    }
  } else {
    if (str[1] == str[2]) {
      if (str[0] != str[1]) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vll A(N);
    map<tuple<ll,ll,bool>, ll> dp;
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    dp[{0, 0, false}] = dp[{1, 0, false}] = 0;
    dp[{0, 1, true}] = A[0];
    dp[{1, 1, true}] = A[1];
    dp[{1, 1, false}] = A[0];
    for (int i = 0; i+2 < N; i++)
    {
        for (int j = i / 2; j <= i / 2 + 1; j++)
        {

            dp[{i + 2, j + 1, true}] = max(dp[{i, j, true}], dp[{i, j, false}]) + A[i + 2];
            dp[{i + 2, j + 1, false}] = dp[{i, j, false}] + A[i + 1];
            dp[{i+2,j,true}]=max(dp[{i,j-1,true}],dp[{i,j-1,false}])+A[i+2];
            dp[{i+2,j,false}]=max(dp[{i+1,j,false}],dp[{i+1,j,true}]);
        }
    }
    cout<<max(dp[{N-1,N/2,false}],dp[{N-1,N/2,true}]);
    return 0;
}

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

int main() {
    int n; scanf("%d", &n);
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }

    int ret = 0;
    for (int i = 0; i < n; i++) {
        while (h[i] > 0) {
            for (int j = i; j < n; j++) {
                if (h[j] > 0) {h[j]--;}
                else {break;}
            }
            ret++;
        }
    }

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

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 3010;
const double pi = acos(-1.0);
int n,L,a[N];

int main(){
	n=read(),L=read();
	For(i,1,n) a[i]=read();
	double sx=0,sy=0;
	FOR(i,1,n)
		For(j,i+1,n){
			sx+=(n-2*(j-i))*cos(pi*(a[i]+a[j])/L);
			sy+=(n-2*(j-i))*sin(pi*(a[i]+a[j])/L);
		}
	ll c=1ll*n*(n-1)*(n-2)/6;
	printf("%0.15lf %0.15lf\n",sx/c,sy/c);
}

Measured memory_bytes: 4120
void main() {
	auto ip = readAs!(int[]), a = ip[0], b = ip[1], c = ip[2], d = ip[3];
	if((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) {
		"Yes".writeln;
	} else "No".writeln;

}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int h,w;
ll ans = 0;
int a[404][404];
int v[404][404];
int dx[4] = {0,-1,0,1};
int dy[4] = {-1,0,1,0};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> h >> w;
    rep(i,h)rep(j,w){
        char c;
        cin >> c;
        (c=='#'?a[i][j]=1:a[i][j]=0);
    }
    rep(i,h)rep(j,w){
        if(v[i][j])continue;
        if(a[i][j]==0)continue;
        v[i][j] = 1;
        ll bnum = 0;
        ll wnum = 0;
        queue<pair<int,int>> q;
        q.push({i,j});
        while(!q.empty()){
            auto p = q.front();q.pop();
            (a[p.first][p.second]==1?bnum++:wnum++);
            rep(k,4){
                int nx = p.first + dx[k];
                int ny = p.second + dy[k];
                if(nx<0 || ny < 0 || nx >= h || ny >= w)continue;
                if(v[nx][ny])continue;
                if(a[p.first][p.second]!=a[nx][ny]){
                    v[nx][ny] = 1;
                    q.push({nx,ny});
                }
            }
        }
        ans += bnum * wnum;
    }
    cout << ans << endl;
}

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  
  int ans = 0;
  for(int i=l; i<=r; i++) {
    if(i%d==0) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << "\n";
    }else{
        long long sum=0;
        if(k<=b) cout << k << "\n";
        else{
            sum+=a;
            sum+=(k-a-b)*-1;
            cout << sum << "\n";
        }
    }
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int l = nextInt();
        int  r = nextInt();
        int d = nextInt();
        int con = 0;
        for(int i=l;i<=r;i++){
            if(i%d==0){
                con += 1;
            }
        }
        print(con);
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

Measured memory_bytes: 35632
#include<iostream>
using namespace std;
int A1,A2,B1,B2;
int main(){
	cin>>A1>>A2>>B1>>B2;
	if(A1+A2>B1+B2) cout<<"Left"<<endl;
	else{
		if(A1+A2==B1+B2) cout<<"Balanced"<<endl;
		else cout<<"Right"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())

a = list(map(int, input().split()))

dic = defaultdict(int)

ans = 0

# j - aj = ai + iとして、jを固定して考える
# jを一つずつみていって、それまでに出会った物の中からj-ajに等しい物の数を数える。ai + iは記録しておく。
for i in range(len(a)):
    
    t = i - a[i]
    ans += dic[t]
    dic[a[i]+i] += 1

print(ans)


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

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    const double PI = acos(-1);
    double rad_A = (H + M / 60) / 6 * PI;
    double rad_B = M / 30 * PI;

    double x_A = A * sin(rad_A);
    double y_A = A * cos(rad_A);
    double x_B = B * sin(rad_B);
    double y_B = B * cos(rad_B);

    double diff = pow(x_A - x_B, 2) + pow(y_A - y_B, 2);
    cout << setprecision(10) << sqrt(diff) << endl;
}

Measured memory_bytes: 4152
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int dp [10100][1100];
int main(){
 int n,h;
 cin>>h>>n;
 int a[n];
 int b[n];
 rep(i,h+1)rep(j,n+1)dp[i][j]=INF;
 rep(i,n)cin>>a[i]>>b[i];
 //rep(i,n)dp[0][i]=0;
 dp[0][0]=0;
 rep(i,n)rep(j,h+1){
   dp[j][i+1]=min(dp[j][i+1],dp[j][i]);
   dp[min(j+a[i],h)][i+1]=min(dp[min(j+a[i],h)][i+1],dp[j][i+1]+b[i]);
 }
 cout<<dp[h][n]<<endl;


}

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

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

    if(a<=c&&c<=b)cout<<"Yes"<<endl;
    else if(a>=c&&c>=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

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

struct segtree {
    int size;
    vector<ll> dat;
    ll init = 0LL;

    segtree(int N)
    {
        size = 1;
        while (size < N)
            size *= 2;
        dat = vector<ll>(2 * size - 1, init);
    }

    ll op(ll a, ll b)
    {
        return a | b;
    }

    void update(int i, ll x)
    {
        i += size - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] = op(dat[2 * i + 1], dat[2 * i + 2]);
        }
        return;
    }

    ll value(int i)
    {
        return dat[i + size - 1];
    }

    ll query(int a, int b)
    {
        return query(a, b, 0, 0, size);
    }

    ll query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
            return init;
        if (a <= l && r <= b)
            return dat[k];
        ll lv, rv;
        lv = query(a, b, 2 * k + 1, l, (l + r) / 2);
        rv = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return op(lv, rv);
    }
};

int main()
{
    int n, q;
    string s;
    cin >> n >> s >> q;
    segtree st(n);
    REP(i, n)
    {
        st.update(i, (1 << (s[i] - 'a')));
    }
    REP(i, q)
    {
        int c;
        cin >> c;
        if (c == 1) {
            int idx;
            char d;
            cin >> idx >> d;
            idx--;
            st.update(idx, (1 << (d - 'a')));
        }
        if (c == 2) {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            ll ret = st.query(l, r+1);
            int ans = 0;
            REP(j, 26)
            if ((ret >> j) & 1)
                ans++;
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 12216
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std ;
#define INF 1300500100

int table[520][20010] ;

main()
{
	int n , m ;
	int c[20] , p[20010] ;
	
	while( cin >> n >> m , n  )
	{
		for( int i=0 ; i<m ; i++ ) cin >> c[i] ;
		for( int i=1 ; i<=n ; i++ ) cin >> p[i] ;
		
		for( int i=0 ; i<520 ; i++ )
			for( int j=0 ; j<20010 ; j++ )
				table[i][j] = INF ;
		
		table[255+128][0] = 0 ;
		
		for( int i=1 ; i<=n ; i++ )
		{
			for( int j=0 ; j<=510 ; j++ )
			{
				if( table[j][i-1] != INF )
				{
					for( int k=0 ; k<m ; k++ ){
						int y = j-255+c[k] ;
						if( y > 255 ) y = 255 ;
						else if( y < 0 ) y = 0 ;
						
						table[y+255][i] = min( table[y+255][i] , table[j][i-1]+(p[i]-y)*(p[i]-y) ) ;
					}
				}
			}
		}
		
		int ans = INF ;
		for( int i=0 ; i<=510 ; i++ ) ans = min( ans , table[i][n] ) ;
		cout << ans << endl ;
	}
}

Measured memory_bytes: 41880
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b = map(int, input().split())
if a <= b:
    print(a)
else:
    print(a-1)


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

void explode(int bomb[14][14],int x,int y){
	bomb[x][y]=0;
	for(int m=-3;m<=3;m++){
		if(bomb[x+m][y]==1){
			explode(bomb,x+m,y);
		}else if(bomb[x][y+m]==1){
			explode(bomb,x,y+m);
		}
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int bomb[14][14]={0};
		string str;
		int x,y;
		for(int j=0;j<8;j++){
			cin>>str;
			for(int k=0;k<8;k++){
				bomb[j+3][k+3]=str[k]-48;
			}
		}
		cin>>x;
		cin>>y;
		explode(bomb,y+2,x+2);
		cout<<"Data "<<i<<":"<<endl;
		for(int j=3;j<=10;j++){
			for(int k=3;k<=10;k++){
				cout<<bomb[j][k];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               string a,b,c;
               cin>>a>>b>>c;
               char ch = a[0];
               int i=0;
               a.erase(i,1);
               char ans;
               while(true)
               {
                    if(ch=='a')
                    {
                         if(a.size()==0)
                         {
                              ans = 'A';
                              break;
                         }
                         ch = a[0];
                         a.erase(i,1);
                    }
                    else if(ch=='b')
                    {
                         if(b.size()==0)
                         {
                              ans = 'B';
                              break;
                         }
                         ch = b[0];
                         b.erase(i,1);
                    }
                    else
                    {
                         if(c.size()==0)
                         {
                              ans = 'C';
                              break;
                         }
                         ch = c[0];
                         c.erase(i,1);
                    }
               }
               cout<<ans;
       }
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cstring>
//#include<algorirhm>
using namespace std;
int main()
{
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k) cout<<k;
	else if((a+b)>=k) cout<<a;
	else cout<<a-(k-a-b);
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	set<ll>arr;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		arr.insert(x);
	}
	
	if(arr.size()%2!=0)
		cout<<arr.size()<<"\n";
	else
		cout<<arr.size()-1<<"\n";
}

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

const int MAX_N = 2e5 + 5;
int N, K;
lint bit[MAX_N], A[MAX_N];

lint sum(int i){
    lint res = 0;
    while(i){
        res += bit[i];
        i -= i & -i;
    }
    return res;
}

void add(int i, lint x){
    while(i<MAX_N){
        bit[i] += x;
        i += i & -i;
    }
}

int main(){
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> K;
    for(int i=1;i<=N;i++) {cin >> A[i], A[i] -= K;}
    
    vector<lint> S(N+1); S[0] = A[0];
    for(int i=1;i<=N;i++) {A[i] += A[i-1], S[i] = A[i];}

    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());

    lint ans = 0;
    for(int i=0;i<=N;i++){
        int idx = distance(S.begin(), lower_bound(S.begin(), S.end(), A[i])) + 1;
        ans += sum(idx); add(idx, 1);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define pii pair < int , int >
#define one first
#define two second
#define rint read<int>
#define int long long
#define pb push_back
#define db double
#define ull unsigned long long
#define lowbit(x) ( x & ( - x ) )
#define mp std::make_pair

using std::queue ;
using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::swap ;
using std::sort ;
using std::unique ;
using std::greater ;

template < class T >
    inline T read () {
        T x = 0 , f = 1 ; char ch = getchar () ;
        while ( ch < '0' || ch > '9' ) {
            if ( ch == '-' ) f = - 1 ;
            ch = getchar () ;
        }
       while ( ch >= '0' && ch <= '9' ) {
            x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
            ch = getchar () ;
       }
       return f * x ;
    }

const int N = 1e2 + 7 ;

int x , n , ans ;
bool mk[N] ;

signed main () {
	int now = 0x7f7f7f7f ;
	x = rint () ; n = rint () ;
	rep ( i , 1 , n ) mk[rint ()] = true ;
	rep ( i , 0 , 200 )
		if ( ! mk[i] )
			if ( labs ( x - i ) < now ) { now = x - i ; ans = i ; }
	printf ("%lld\n" , ans ) ;
    return 0 ;
}

Measured memory_bytes: 3764
#include<stdio.h>

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    int ans = 0;
    if(a == 3){
        ans += 100000;
    }else if(a == 2){
        ans += 200000;
    }else if( a== 1){
        ans += 300000;
    }
    if(b == 3){
        ans += 100000;
    }else if(b == 2){
        ans += 200000;
    }else if( b== 1){
        ans += 300000;
    }
    if( a == 1 && b == 1){
        ans += 400000;
    }
    printf("%d", ans);

    return 0;
}

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

using namespace std;



int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
  string s;
  string t;
  cin>>s>>t;
  int i,cnt=0;
  for(i=0;i<s.length();++i)
   {
       if(s[i]!=t[i])
         cnt++;
   }
   
   cout<<cnt;
     return 0;
}

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

counter=0
for i in range(N):
    a=A[i]+A[i+1]
    b=B[i]
    if a<=b:
        counter +=a
        A[i+1]=0
    elif b>A[i]:
        counter +=b
        A[i+1]=a-b
    else:
        counter +=b
print(counter)

Measured memory_bytes: 18476
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))



        

def main():
    mod=10**9+7
    K=I()
    if K<=pow(10,16):
        N=2
        if K%2==0:
            ans=[K//2+1,K//2+1]
        else:
            ans=[K//2,K//2+3]
    else:
        N=50
        a=N-1+K//N
        b=K%N
        if b!=0:
            a-=b
        ans=[a]*N
        for i in range(b):
            ans[i]+=N+1
    
        
    print(N)
    print(' '.join(map(str, ans)))
    

        

main()


Measured memory_bytes: 38352
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

#a!をmodしつつ求める
def fact(a,M=mod):
    ans = 1
    for i in range(2,a+1):
        ans = ans*i
        ans = ans%M
    return ans


#互いに素なa,bについて、a*x+b*y=1の一つの解[x,y]を出力
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]


#aの逆元(mod M)を求める（aとMは互いに素であることが前提）
def mod_inv(a,M=mod):
    x = extgcd(a,M)[0]
    return (M+x%M)%M

N,K = II()

inv = [0]*(N+1)
for i in range(N+1):
    inv[i] = mod_inv(fact(i))

kfact = fact(K-1)
nfact = fact(N-K+1)

for i in range(1,K+1):
    if N-K+1-i < 0:
        print(0)
    else:
        ans = kfact*inv[i-1]*inv[K-i]*nfact*inv[i]*inv[N-K+1-i]
        ans = ans%mod
        print(ans)

Measured memory_bytes: 42864
#include <iostream>
#include <string>

using namespace std;

int main() {
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    if(s == "AC") {
        ac++;
    } else if (s == "WA") {
        wa++;
    } else if (s == "TLE") {
        tle++;
    } else if (s == "RE") {
		re++;
    }
  }
    
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
    
  return 0;
}

Measured memory_bytes: 3232
#include <stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d",&a,&b,&c);
    if (a < b) {
        if(b < c) {
            printf("%d %d %d\n",a,b,c);
        } else if (a < c && c < b) {
            printf("%d %d %d\n",a,c,b); 
        } else {
            printf("%d %d %d\n",c,a,b);
        }
    } else {
        if (a < c) {
            printf("%d %d %d\n",b,a,c);
        } else if (b < c && c < a) {
            printf("%d %d %d\n",b,c,a);
        } else {
            printf("%d %d %d\n",c,b,a);
        }
    }
    return 0;
}


Measured memory_bytes: 2708
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int a,b; cin>>a>>b;
  if(a==b)
  puts("Draw");
  else if(a==1||(a>b)&&b!=1)
  puts("Alice");
  else
  puts("Bob");

  return 0;
}


Measured memory_bytes: 256
//Volume5-0582
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int a,b,c,x=0,y=0,h=0,triangle=0,right=0,acute=0,obtuse=0;

		while(true){
			a=sc.nextInt(); b=sc.nextInt(); c=sc.nextInt();
			if(a >= b+c || b >= a+c || c >= a+b){break;}
			triangle++;
			if     (a >= b && a >= c){h=a;x=b;y=c;}
			else if(b >= c && b >= a){h=b;x=c;y=a;}
			else if(c >= a && c >= b){h=c;x=a;y=b;}
			if(Math.pow(h,2) == Math.pow(x, 2)+Math.pow(y, 2)){
				right++;
			} else if (Math.pow(h,2) < Math.pow(x, 2)+Math.pow(y, 2)){
				acute++;
			} else {
				obtuse++;
			}
		}
		System.out.println(triangle+" "+right+" "+acute+" "+obtuse);
	}
}

Measured memory_bytes: 20204
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,K;
    cin>>N>>K;
    int answer=1;
    rep(i,N) {
        if(answer*2<answer+K) answer*=2;
        else answer+=K;
    }
    cout<<answer<<endl;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N;
int dp[5][101010];
int x[5][101010];

int rec(int day, int pre) {
  if (day > N) return 0;
  if (dp[pre][day] >= 0) return dp[pre][day];
  int res = 0;
  for (int i = 1; i <= 3; i++) {
    if (pre == i) continue;
    res = max(res, rec(day + 1, i) + x[i][day]);
  }
  return dp[pre][day] = res;
}

signed main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= 3; j++) {
      cin >> x[j][i];
    }
  }

  mm(dp);

  cout << rec(1, 0) << endl;
  return 0;
}


Measured memory_bytes: 13568
from sys import stderr, setrecursionlimit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

x, y = getInts()
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
print("Yes" if (x in g1 and y in g1) or (x in g2 and y in g2) or (x == y == 2) else "No")

Measured memory_bytes: 3572