akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;

    vector<int> length(N, 0);

    for (int i = 0; i < N; ++i) {
        for (int j = (i+1); j < N; ++j) {
            int path1 = j - i;
            int path2 = abs(i - X) + abs(j - Y) + 1;

            length[min(path1, path2)]++;
        }
    }

    for (int i = 1; i < N; ++i)
        cout << length[i] << endl;

    return 0;
}


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

int main() {
  int a,b;
  char op;
  
  cin >> a >> op >> b;
  
 if (op == '+') {
  cout <<  a + b;
 }
 else if (op == '-') {
   cout << a - b;
}
  return 0;
  }


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = INT_MAX;
const int mod = 1e9 + 7;
const int maxn = 6e5 + 111;
     
using namespace std;

int q, n, m, dp[2000][2000];
char a[2000][2000];

void solve(){    
	cin >> n >> m;

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];

	dp[1][1] = 1;

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (a[i][j] == '.')
				dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod;

	cout << dp[n][m];
		
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 20608
def construct_table(n, s):
    table = [-1] * (n + 1)
    j = -1
    for i in range(n):
        while j >= 0 and s[i] != s[j]:
            j = table[j]
        j += 1
        table[i + 1] = j
    return table


s = input()
t = input()
n = len(s)
m = len(t)
s2 = s * ((max(m, n) + m) // n + 1)
tb = construct_table(m, t)
l = [False] * n
i = 0
j = 0
while i < n:
    if t[j] != s2[i + j]:
        i += j - tb[j]
        if j > 0:
            j = tb[j]
    else:
        j += 1
        if j == m:
            l[i] = True
            i += j - tb[j]
            j = tb[j]
inv = [0] * n
for i in range(n):
    if l[i]:
        t = (i + m) % n
        i = t
        inv[t] += 1
ans = 0
v = [0] * n
for i in range(n):
    if inv[i] == 0:
        v[i] = 1
        r = 0
        while l[i]:
            r += 1
            t = (i + m) % n
            v[t] = 1
            i = t
        ans = max(ans, r)
if 0 in v:
    print(-1)
else:
    print(ans)


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    fastIO;
    ll X;
    cin >> X;
    ll year = 0, amt = 100;
    while (year < 5000) {
        if (amt >= X) {
            cout << year << endl;
            return 0;
        }
        ++year;
        amt += amt / 100;
    }
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N + 1), B(M + 1);
    rep(i, N) {
        ll temp;
        cin >> temp;
        A[i + 1] = A[i] + temp;
    }
    rep(i, M) {
        ll temp;
        cin >> temp;
        B[i + 1] = B[i] + temp;
    }
    ll ans = 0;
    rep(i, N + 1) {
        if(A[i] > K) break;
        ll temp = K - A[i];
        auto iter = upper_bound(B.begin(), B.end(), temp);
        ans = max(ans, i + distance(B.begin(), iter) - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6424
/*input 
25
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3608
str1 = input()
k = int(str1.split()[0])
n = int(str1.split()[1])
stra = input().split()
a = [int(x) for x in stra]
maxlen = k - a[n - 1] + a[0]
for i in range(1, n):
    if a[i] - a[i - 1] > maxlen:
        maxlen = a[i] - a[i - 1]
print(k - maxlen)


Measured memory_bytes: 26444
#include<stdio.h>

int main(void)


{


int a,b,c;


int count=0;


int i;


scanf("%d %d %d",&a,&b,&c);


for(i=a;i<=b;i++)


{


if(c%i==0) count++;


}


printf("%d\n",count);


return 0;


}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;


int main()
{
    int n, m, c[50] = {0};
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        c[a - 1]++;
        c[b - 1]++;
    }
    rep(i, n)
    {
        cout << c[i] << endl;
    }
}

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

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

	int D = N%10;
	string ans;
	if(D == 0 || D == 1 || D == 6 || D == 8){
		ans = "pon";
	}else if(D == 3){
		ans = "bon";
	}else{
		ans = "hon";
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<vector<int>> r(n + 1,vector<int>(n + 1,0));
    pair<int,int> M[m];
    for (int i = 0; i < m; ++i){
        cin >> a >> b;
        M[i] = make_pair(a,b);
    }
    for (int i = 0; i < m; ++i) {
        r[M[i].first][M[i].second] += 1;
        r[M[i].second][M[i].first] += 1;
    }
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            sum += r[i][j];
        }
        cout << sum << endl;
        sum = 0;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,k,c;
	cin>>n>>k;
	c=k;
	if(n==1){
		cout<<k;
	}else{
		for(int i=0;i<n-1;i++){
			c*=k-1;
		}
		cout<<c;
	}
	return 0;
}

Measured memory_bytes: 256
import math
n, d = list(map(int, input().split()))
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = list(map(int, input().split()))
    
#print(x)
cnt = 0
for i in range(n):
    d1 = math.sqrt(x[i]*x[i] + y[i]*y[i])
    #print(d1)
    if d >= d1:
        #print(d1)
        cnt += 1
print(cnt)

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H+2, vector<char>(W+2));
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
    cin >> a.at(i+1).at(j+1);
    }
  }

vector<vector<int>> suu(H+2, vector<int>(W+2));
  for(int i=1;i<=H;i++){//for 
  	for(int j=1;j<=W;j++){// for j 
		  if(a.at(i).at(j)=='#'){//if ==# 
          		suu.at(i-1).at(j-1)+=1; 
          		suu.at(i-1).at(j+0)+=1; 
		        suu.at(i-1).at(j+1)+=1; 
    		    suu.at(i+0).at(j-1)+=1; 
        	    suu.at(i+0).at(j+0)+=1; 
       		    suu.at(i+0).at(j+1)+=1; 
 		        suu.at(i+1).at(j-1)+=1; 
   			    suu.at(i+1).at(j+0)+=1; 
    		    suu.at(i+1).at(j+1)+=1;        
          }//if end
   }//for j end
}//for i end

  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
     	  if(a.at(i+1).at(j+1)=='#'){
          cout << "#";
          }
      	  else{
	      cout << suu.at(i+1).at(j+1);
          }
    }
    cout << endl;
  }
}


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

//Stellar Performance of the Debunkey Family
public class Main{

	static  class UnionFind {
		final int[] tree;
		int num;
		public UnionFind(int n) {
			this.tree = new int[n];
			Arrays.fill(tree, -1);
			num=n;
		}

		// merge the set contains x and the set contains y
		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if(x != y) {
				if(tree[x] < tree[y]) {
					x ^= y; y ^= x; x^= y;
				}
				tree[x] += tree[y];
				tree[y] = x;
				num--;
			}
		}
		// decide if x and y belong to the same set
		boolean find(int x, int y) {
			return root(x) == root(y);
		}
		int root(int x) {
			return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
		}
		// return size of the set contains x
		int size(int x) {
			return -tree[root(x)];
		}
		// return the number of sets
		int getNum() {
			return num;
		}
	}
	
	static class E implements Comparable<E>{
		int s, t, cost;
		public E(int s, int t, int cost) {
			this.s = s;
			this.t = t;
			this.cost = cost;
		}
		public int compareTo(E o) {
			return cost-o.cost;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			PriorityQueue<E> q = new PriorityQueue<E>();
			while(m--!=0)q.add(new E(sc.nextInt(),sc.nextInt(),sc.nextInt()));
			UnionFind u = new UnionFind(n);
			int s = 0;
			while(u.num>1){
				E e = q.poll();
				if(!u.find(e.s, e.t)){
					u.union(e.s, e.t);
					s+=e.cost;
				}
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

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

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

Measured memory_bytes: 4772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
typedef long long LL;
int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a == b) { std::cout << c << std::endl; return 0; }
	if (a == c) { std::cout << b << std::endl; return 0; }
	if (c == b) { std::cout << a << std::endl; return 0; }
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

ll n, ans[500][500];
void dfs(ll l, ll r, ll level) {
    if(r-l==1) return;
    const ll m = (l+r)/2;
    dfs(l, m, level+1);
    dfs(m, r, level+1);
    // [l, (l+r)/2), [(l+r)/2, r) の間をつなぐ
    FOR(i, l, m) FOR(j, m, r) {
        ans[i][j] = level;
    }
}

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

    cin >> n;
    dfs(0, n, 1);

    REP(i, n) FOR(j, i+1, n) cout << ans[i][j] << (j==n-1?'\n':' ');

    return 0;
}


Measured memory_bytes: 2432
// clear time: 00:20
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define TIMES(i) while(i--)
#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

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

    TIMES(n) {
        // 入力
        double ax, ay, ar, bx, by, br;
        cin >> ax >> ay >> ar >> bx >> by >> br;

        // 距離を求める
        double dis_x = abs(ax-bx),
            dis_y = abs(ay-by),
            dist = sqrt(dis_x * dis_x + dis_y * dis_y);

        // cout << dis_x << " " << dis_y << " " << dist << endl;

        // 離れている
        if ( dist > ar + br ) {
            cout << 0;

        // aが内包されている
        } else if ( dist + ar < br ) {
            cout << -2;

        // bが内包されている
        } else if ( dist + br < ar ) {
            cout << 2;

        // 交わっている
        } else {
            cout << 1;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
using System;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力受け取ってやる
            int N  = int.Parse(Console.ReadLine());
            if (N <= 999){
                Console.WriteLine("ABC");
            }
            else{
                Console.WriteLine("ABD");
            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using P = pair<int, int>;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k)cout<<s<<endl;
    else cout<<s.substr(0,k)+"..."<<endl;
}


Measured memory_bytes: 3640
n,k=map(int,input().split())
dp=[[0]*(n+1) for _ in range(n+1)]
mod=10**9+7
dp[0][0]=1
dp[1][0]=1
dp[1][1]=1
for i in range(2,n+1):
    for j in range(n+1):
        dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%mod
for a in range(1,k+1):
    if n-k+1<a:
        print(0)
        continue
    else:
        print(dp[n-k+1][a]*dp[k-1][a-1]%mod)   

Measured memory_bytes: 104064
#include <iostream>
using namespace std;
int main()
{
    long long int c,i,j,k,l,m,n;
    cin>>n;
    long long int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    k=1;
    c=0;
    for(i=0;i<n;i++)
    {
        if(arr[i]==k)
        {
            k++;
            c++;
        }
    }
    if(c==0)
    {
        cout<<"-1";
    }
    else
    {
        cout<<(n-c);
    }

}


Measured memory_bytes: 1792
N = int(input())
S = input()

S_ans = []
#print(S_ans)

#貪欲法
for i, j in enumerate(S):
  if i == 0:
    S_ans.append(1)
  else:
    if S[i-1] == j:
      S_ans.append(0)
    else:
      S_ans.append(1)
      
print(sum(S_ans))

Measured memory_bytes: 4084
#include<iostream>
#include<cstdio>
#include <cstring>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<stack>
using namespace std;
typedef long long LL;
const int maxn = 1e5+5;
LL a[maxn], sum[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n; cin>>n;
    for(int i = 1; i <= n; i++) cin>>a[i];
    sort(a+1, a+n+1);
    for(int i = 1; i <= n; i++) sum[i] = a[i] +sum[i-1];
    int res = 1;
    for(int i = n-1; i >= 1; i--)
    {
        if(sum[i]*2 >= a[i+1]) res++;
        else break;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    cin >> n;
    bool ok = false;
    rep1(i,10){
        rep1(j,10){
            if(i * j == n)ok = true;
        }
    }
    if(ok) cout << "Yes" << endl;
    if(!ok) cout << "No" << endl;
}

Measured memory_bytes: 256
def match(x,y):
    ret = True
    for i in range(m):
        for j in range(m):
            if A[y+i][x+j] != B[i][j]:
                ret = False
    return ret


n,m = map(int,input().split())
A = []
for i in range(n):
    A.append(list(input()))
B = []
for i in range(m):
    B.append(list(input()))

flg = False
for i in range(n-m+1):
    for j in range(n-m+1):
        if match(i,j):
            flg = True
print('Yes' if flg else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]-=i+1;
    }

    sort(all(a));
    ll b=a[n/2];
    ll ans=0;
    rep(i,n){
        ans+=abs(a[i]-b);
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 1792
n, m = map(int, raw_input().split())
A = [[0 for i in range(m)] for j in range(n)]
b = [0 for i in range(m)]
ans = [0 for i in range(n)]

for i in range(n):
    temp = map(int, raw_input().split())
    for j in range(m):
        A[i][j] += temp[j]
for i in range(m):
    b[i] = int(raw_input())
    
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
        
for i in range(n):
    print ans[i]

Measured memory_bytes: 6604
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<c-a<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
void Solve() {
    int pt,px,py;
    int t,x,y;
    read(N);
    pt = 0,px = 0,py = 0;
    for(int i = 1 ; i <= N ; ++i) {
	read(t);read(x);read(y);
	int k = abs(x - px) + abs(y - py);
	if(k > t - pt) {
	    puts("No");return;
	}
	if((k ^ t) & 1) {puts("No");return;}
    }
    puts("Yes");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
   ll a,b,m;
   cin>>a>>b>>m;
   ll x[a];
   ll y[b];
   ll m1=inf,m2=inf;
   for(int i=0;i<a;i++)
    {    
        cin>>x[i];
        m1=min(m1,x[i]);
    }
     for(int i=0;i<b;i++)
    {    
        cin>>y[i];
        m2=min(m2,y[i]);
    }

    ll ans=m1+m2;
    for(int i=0;i<m;i++)
    {
        ll u,v,w;
        cin>>u>>v>>w;
        ans=min(ans,x[u-1]+y[v-1]-w);
    }
    cout<<max(ll(0),ans)<<endl;
    return 0;
}


Measured memory_bytes: 1792
a,b = map(int,input().split())
k = 50
d = [['.' if i<k else '#' for j in range(2*k)] for i in range(2*k)]
a-=1
b-=1
for i in range(0,50,2):
    for j in range(0,100,2):
        if b>0:
            d[i][j] = '#'
            b-=1

for i in range(51,100,2):
    for j in range(0,100,2):
        if a>0:
            d[i][j] = '.'
            a-=1

print(2*k, 2*k)
for s in d:
    print("".join(s))


Measured memory_bytes: 3188
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
   
}



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

int n;
long long ans;
int l[2005];
int f[2005];

int main(){

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

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l[i];
        f[l[i]]++;
    }
    for(int i=1;i<=2000;i++){
        f[i]+=f[i-1];
    }
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            ans+=f[l[i]+l[j]-1]-f[abs(l[i]-l[j])];
            if(l[i]>abs(l[i]-l[j]))ans--;
            if(l[j]>abs(l[i]-l[j]))ans--;
        }
    }
    cout<<ans/3<<endl;

    return 0;
}

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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

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

int main(){
ll A,B,C,K; cin>>A>>B>>C>>K;
if(K<=A){
    cout<<K<<endl;
}else if(K<=A+B){
    cout<<A<<endl;
}else{
    cout<<A-(K-A-B)<<endl;
}

}

Measured memory_bytes: 3524
#include<iostream>

using namespace std;

int main(){

	int x,y;
	for(;;){
		cin>>x>>y;
		if(x>y){
			swap(x,y);
		}
		if(x==0&&y==0)break;
		cout<<x<<" "<<y<<endl;
	}
	return 0;

}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	vector < pair <int,int> > v;
	for(int i = 0 ; i < n ; i++)
	{
		int t;
		cin >> t;
		v.push_back({t,i+1});
	}
	sort(v.begin(),v.end());
	for(auto i : v)cout << i.second << " ";
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

bitset<11> dig;

int main(){

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

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

    long long k;
    long long n;

    cin >> n >> k;

    for(int i = 0; i < k; ++i){
        int j;
        cin >> j;
        dig[j] = 1;
    }

    while(true){
        long long cop = n;
        bool f = false;
        while(cop != 0){
            if(dig[cop % 10]){
                f = true;
                break;
            }
            cop /= 10;
        }
        if(!f){
            cout << n;
            return 0;
        }
        ++n;
    }

    return 0;
}


Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().rstrip())
g = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = map(int, sys.stdin.readline().split())
    g[a].append((b, c))
    g[b].append((a, c))

q, k = map(int, sys.stdin.readline().split())
xy = zip(*[map(int, sys.stdin.read().split())] * 2)

def dfs(v):
    dist = [None] * (n + 1)
    stack = [(v, 0)]
    while stack:
        x, d = stack.pop()
        dist[x] = d
        for y, dd in g[x]:
            if dist[y] is None:
                stack.append((y, d + dd))
    return dist

def main():
    dist_k = dfs(k)
    
    for x, y in xy:
        yield dist_k[x] + dist_k[y]

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 59736
n = int(input())

x = []
y = []
h = []

for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])

for i in range(n):
    if h[i] >= 1:
        t = i
        break

for cy in range(101):
    for cx in range(101):
        H = h[t] + abs(x[t] - cx) + abs(y[t] - cy)
        for i in range(n):
            if h[i] != max(H - abs(cx - x[i]) - abs(cy - y[i]), 0):
                break
            if i == n - 1:
                print('{} {} {} '.format(cx, cy, H))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int arr[n+1]={0},ans[n+1],i,d;
  
  for(i=1;i<=n;i++)
    cin >> arr[i];
  
  ans[1]=0;
  
  for(i=2;i<=n;i++)
  {  ans[i]=ans[i-1]+abs(arr[i-1]-arr[i]);
     if(i>2)
    ans[i]=min(ans[i],ans[i-2]+abs(arr[i-2]-arr[i]));
  }
   cout<<ans[n];
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int input[] = new int[10];

        for (int i = 0; i < 10; i++) {
            input[i] = sc.nextInt();
        }

        Arrays.sort(input);

        for (int i = 9; i > 6; i--) {
            System.out.println(input[i]);
        }
    }
}

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

int main(){
    int n;cin >> n;
    char  str[n][10];
    for(int i=0;i<n;i++){
        cin >> str[i]; 
    }

    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;


    for(int i=0;i<n;i++){        
        if(strcmp(str[i],"AC")==0) ac++;
        if(strcmp(str[i],"WA")==0) wa++;
        if(strcmp(str[i],"TLE")==0) tle++;
        if(strcmp(str[i],"RE")==0) re++;
    }


    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);



}

Measured memory_bytes: 4712
import sys
from itertools import accumulate
input=sys.stdin.buffer.readline
def main():
    n,k=map(int,input().split())
    a=[*map(int,input().split())]
    for _ in'_'*k:
        b=[0]*n
        for i,t in enumerate(a):
            if i>t:b[i-t]+=1
            else:b[0]+=1
            j=i-~t
            if j<n:b[j]-=1
        a=[*accumulate(b)]
        if min(a)==n:break
    print(' '.join(map(str,a)))
main()

Measured memory_bytes: 35516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++)
			{
				var s = Console.ReadLine();
				if (Regex.IsMatch(s, ">'(=+)#\\1~$"))
				{
					Console.WriteLine("A");
				}
				else if (Regex.IsMatch(s, ">\\^(Q=)+~~$"))
				{
					Console.WriteLine("B");
				}
				else
				{
					Console.WriteLine("NA");
				}
			}
		}
	}
}

Measured memory_bytes: 7348
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
left = lr[0][0]
right = lr[0][-1]
cnt = 0

for i in lr:
  if i[0] > left:
    left = i[0]
  
  if i[-1] < right:
    right = i[-1]

if left <= right:
  print(right - left + 1)
else:
  print(0)

Measured memory_bytes: 27340
#include<cstdio>

long long gcd(long long a,long long b){ return b?gcd(b,a%b):a; }

int main(){
    int n;
    scanf("%d",&n);
    int a = -1, b = -1, c = -1;
    int start = n/4;
    if(start==0) start++;
    for(long long i = 1; i <= 3500; i++){
        if(a!=-1) break;
        for(long long j = i; j <= 3500; j++){
            if(a!=-1) break;
            long long up = 4, down = n;
            up = up*i-down; down = down*i;
            if(up<=0) continue;
            up = up*j-down; down = down*j;
            if(up<=0) continue;
            //printf("i = %lld, j = %lld, up = %lld, down = %lld\n",i,j,up,down);
            long long g = gcd(up,down);
            up /= g, down /= g;
            if(up==1){
                a = i, b = j, c = down;
            }
        }
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 1704
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		Long x = fs.nextLong();
		System.out.println((x / 500) * 1000 + ((x % 500) / 5) * 5);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i,n) reps(i,0,n)
int dp[2][1<<20][2]={{{1}}};
int main(){
  int h,w,next = 1,cur = 0,mod = 100000,ans = 1,mkbit,mki;
  char mas[20][20],tmp[]="JOI";
  cin >> h >> w;
  rep(i,h) rep(j,w) cin >> mas[i][j];
  rep(x,h){
    rep(y,w){
      fill_n(dp[next][0],2*(1<<20),0);
      rep(bit,1<<w) rep(i,2) if(dp[cur][bit][i]) rep(j,3){
        mkbit = bit & ~(1 << y) , mki = ( j == 0 );
        if( mas[x][y] != '?' && mas[x][y] != tmp[j] ) continue;
        if( (bit & 1 << y ) && j == 2) continue;
        if( i == 1 && j == 1 ) mkbit |= 1 << y - 1;
        dp[next][mkbit][mki] += dp[cur][bit][i];
        if(dp[next][mkbit][mki] >= mod) dp[next][mkbit][mki] -= mod;
      }
      swap(next,cur);
    }
    rep(bit,1<<w){
      dp[cur][bit][0] += dp[cur][bit][1];
      if(dp[cur][bit][0] >= mod) dp[cur][bit][0] -= mod;
      dp[cur][bit][1] = 0;
    }
  }
  rep(i,h) rep(j,w) if(mas[i][j] == '?') ans = (ans * 3) % mod;
  rep(bit,1<<w) ans = (ans - dp[cur][bit][0] + mod) % mod;
  cout << ans << endl;
}

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

using namespace std;

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

    int N;
    long long K;
    cin >> N >> K;

    vector<int> a(N+1);
    vector<vector<int> > table(64, vector<int>(N+1, -1));

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

    for(int k = 0; k < 63; ++k){
        for(int i = 1; i <= N; ++i){
            if(table[k][i] == -1){
                table[k+1][i] = -1;
            }else{
                table[k+1][i] = table[k][table[k][i]];
            }
        }
    }

    int res = 1;

    for(int i = 0; K > 0; K >>= 1, ++i){
        if(K & 1){
            res = table[i][res];
        }
    }

    cout << res << '\n';

}

Measured memory_bytes: 54944
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

list1 = [A,B,C,D,E]
min1 = min(list1)
if N % min1 != 0:
  ans = N//min1 + 5
else:
  ans = N//min1 + 4

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  pair<pair<string,int > ,int> a[111];
  cin>>n;
  for(int i=0;i<n;i++)
  {
  	int b;
   	string x;
   	cin>>x;
   	cin>>b;
   	a[i]=make_pair(make_pair(x,b),i);
  }	
    for(int i=0;i<n-1;i++)
  	  for(int j=n;j>=i+1;j--)
  	  {
  	  	if(a[j-1].first.first<a[j].first.first)
  	  	{	
  	  	    swap(a[j-1],a[j]);
		}
		if(a[j-1].first.first==a[j].first.first)
		  if(a[j-1].first.second>a[j].first.second)
		  {
		  	swap(a[j-1],a[j]);
		  }
	  }
	for(int i=0;i<n;i++)
	{
		cout<<a[n-i-1].second+1<<endl;
	}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int dp[55][55][10000];

signed main()
{
        int N,A; cin>>N>>A;
        vint x(N);
        REP(i,N) cin>>x[i];

        dp[0][0][0]=1;
        for(int i=1;i<=N;i++){
                for(int j=0;j<=i;j++){
                        for(int k=0;k<10000;k++){
                                dp[i][j][k]+=dp[i-1][j][k];
                                if(j>0 and k>=x[i-1]) dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]];
                        }
                }
        }
        int ans=0;
        for(int j=1;j<=N;j++) ans+=dp[N][j][j*A];
        cout<<ans<<endl;
}


Measured memory_bytes: 186624
from bisect import*
n,d,a,*t=map(int,open(0).read().split())
c=[0]*-~n
z=sorted(zip(*[iter(t)]*2))
s=0
for i,(x,h)in enumerate(z):c[i]+=c[i-1];h-=c[i];t=min(-h//a,0);c[i]-=t*a;c[bisect(z,(x+d+d,9e9))]+=t*a;s-=t
print(s)

Measured memory_bytes: 48852
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}



void solve()
{
 
 int n;
 cin >> n ;
 map<string,int>mp;

 forf(i,0,n)
 {
  string s;
  cin >> s;
  mp[s]++;
 }
 cout<<"AC x "<<mp["AC"]<<"\n";
 cout<<"WA x "<<mp["WA"]<<"\n";
 cout<<"TLE x "<<mp["TLE"]<<"\n";
 cout<<"RE x "<<mp["RE"]<<"\n";
}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3664
n = int(input())
hn = list(map(int, input().split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
dp[1] = abs(hn[1] - hn[0])
for i in range(2, n):
    dp[i] = min(
        dp[i],
        dp[i-1] + abs(hn[i-1] - hn[i]),
        dp[i-2] + abs(hn[i-2] - hn[i])
        )
print(dp[n-1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    int a,b,c,d;cin >>a>>b>>c>>d;
    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))
        cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;

int i, j;
string s;
int n;
ll dp[100001][13] = {0};
const ll mod = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  string s(to_string(n));
  int res = 0;
  int len = s.size();
  if (len % 2 == 1) {
    res += n - (int)pow(10, len - 1) + 1;
    len -= 2;
  } else {
    len -= 1;
  }
  while (len > 0) {
    res += 9 * (int)pow(10, len - 1);
    len -= 2;
  }
  cout << res << endl;
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 256
import math._

case class Point(x: Double, y: Double) {
  override def toString = s"$x $y"
}

object KochCurve {
  val th = 60.0.toRadians

  def koch(n: Int, p1: Point, p2: Point): List[Point] = {
    require(n >= 0)

    def go(n: Int, p1: Point, p2: Point): List[Point] = {
      if (n == 0)
        List(p2)
      else {
        // わかんないのでコピペ
        val s = Point((2.0 * p1.x + 1.0 * p2.x) / 3.0,
			          (2.0 * p1.y + 1.0 * p2.y) / 3.0)
        val t = Point((1.0 * p1.x + 2.0 * p2.x) / 3.0,
			          (1.0 * p1.y + 2.0 * p2.y) / 3.0)
        val u = Point((t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x ,
			          (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y)
        go(n - 1, p1, s) ++
        go(n - 1, s,  u) ++
        go(n - 1, u,  t) ++
        go(n - 1, t,  p2)
      }
    }

    p1::go(n, p1, p2)
  }

  def run() = {
    val sc = new java.util.Scanner(Console.in)
    val n = sc.next().toInt
    println(koch(n, Point(0.0, 0.0), Point(100.0, 0.0)) mkString "\n")
  }
}

object Main extends App {
  KochCurve.run()
}



Measured memory_bytes: 56904
// https://atcoder.jp/contests/dp/tasks/dp_e

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

ll dp[100001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w, i1, i2;
    cin >> n >> w;
    // vector<ll> dp(w + 1, 0);
    REP(i, n) {
        cin >> i1 >> i2;
        for (ll k = w; k >= i1; k--) {
            dp[k] = max(dp[k], dp[k - i1] + i2);
        }
    }
    cout << *max_element(begin(dp), end(dp)) << endl;

    return 0;
}


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

#define MAX 500000
#define INF 999999999

int l[MAX/2+2] = {};
int r[MAX/2+2] = {};
int c ;

int s[500000];

void merge(int left,int mid,int right){
  
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  
  for(i = 0;i < n1;i++) l[i] = s[left + i];
  for(i = 0;i < n2;i++) r[i] = s[mid + i];
  
  l[n1] = INF;
  r[n2] = INF;
  
  i = j = 0;
  
  for(k = left;k < right;k++){
    c++;
    if(l[i] <= r[j]){
      s[k] = l[i];
      i++;
    }
    else{
      s[k] = r[j];
      j++;
    }
  }
}

void mergesort(int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(left,mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}

int main(void){
  int n,i;
  c=0;

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

  mergesort(0,n);
  
  for(i=0;i<n;i++){
    if(i) cout << " ";
    cout << s[i];
  }
  
  cout << endl;
  cout << c << endl;
}

Measured memory_bytes: 6948
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d,luas1,luas2;
	cin >> a >> b >> c >> d;
	luas1=a*b;
	luas2=c*d;
	if (luas1>=luas2){
		cout << luas1 << endl;
	}else if(luas2>=luas1){
		cout << luas2 << endl;
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<long int> v(n);
	for(int i=0;i<n;i++){
		cin >> v.at(i);
	}
	sort(v.begin(),v.end());
	int f=0;
	for(int i=0;i<n-1;i++){
		if(v.at(i)==v.at(i+1)){
			f=1;
		}
	}
	if(f==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 1792