akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int a,b;cin>>a>>b;
  
  if(a<=b){
    for(int i=0;i<b;i++){
      cout<<a;
    }
    cout<<endl;
  }
  
  else if(a>b){
    for(int i=0;i<a;i++){
      cout<<b;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}


int main()
{
	int n;
	cin >> n;
	int w[100];
	int sum1 = 0;
	int sum2 = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		sum2 += w[i];
	}

	sum1 += w[0];
	sum2 -= w[0];
	int near = abs(sum1 - sum2);

	for (int t = 2; t <= n - 1; t++)
	{
		sum1 += w[t - 1];
		sum2 -= w[t - 1];
		if (abs(sum1 - sum2) < near)
		{
			near = abs(sum1 - sum2);
		}
	}
	cout << near;
}



Measured memory_bytes: 31488
import numpy as np

n=int(input())
v = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

v = np.array(v)
c= np.array(c)
hikizan = v-c

x = np.zeros((3,n))
x[1] = v
x[2] = c
x[0] = hikizan

kotae = 0

for i in range(0,n):
    if x[0,i] > 0:
        kotae += x[0,i]
        
print(int(kotae))

Measured memory_bytes: 21416
# ABC153
# C

N, K = [int(s) for s in input().split()]
H_list = [int(s) for s in input().split()]
H_list.sort(reverse=True)

if N < K:
    K = N

for i in range(int(K)):
    H_list[i] = 0

print(sum(H_list))

Measured memory_bytes: 26764
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

vector<string> split(char d, string s)
{
    istringstream iss(s); string tmp; vector<string> res;
    while(getline(iss, tmp, d)) res.push_back(tmp);
    return res;
}

unordered_map<string, vector<string>> gs;
unordered_map<string, vector<string>> memo;

vector<string> dfs(string r)
{
    if (memo.find(r) != memo.end()) return memo[r];
    unordered_set<string> ans;
    for (auto name : gs[r]) {
        if (gs.find(name) == gs.end()) ans.insert(name);
        else {
            for (auto m : dfs(name)) ans.insert(m);
        }
    }
    memo[r] = vector<string>(all(ans));
    return memo[r];
}

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        gs.clear();
        memo.clear();

        string root;
        loop (n, i) {
            string l; cin >> l;
            auto vs = split(':', l);
            auto mems = split(',', vs[1]);
            auto lst = mems.back();
            mems[mems.size()-1] = lst.substr(0, lst.length()-1);
            if (!i) root = vs[0];
            gs[vs[0]] = mems;
        }

        cout << dfs(root).size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3308
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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


//O(sqrt(n))
map<ll, int> primeFactor(ll n) {
	map<ll, int> ret;

	while (n % 2 == 0) {
		n /= 2;
		ret[2]++;
	}

	int i = 3;
	while (n > 1 && (ll)i * i <= n) {
		while (n % i == 0) {
			n /= i;
			ret[i]++;
		}
		i += 2;
	}

	if (n != 1) ret.insert({ n,1 });

	return ret;
}

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

	ll n,x,m; cin >> n >> x >> m;
	vector<ll> a(m,0), sum(m+1,0), ainv(m,-1);
	ll i = 0;
	a[0] = x; ainv[x] = 0;
	sum[1] = x;
	while (ainv[a[i] * a[i] % m] == -1) {
		i++;
	  a[i] = a[i-1]*a[i-1] % m;
		sum[i+1] = sum[i] + a[i];
		ainv[a[i]] = i;
	}

	ll l = ainv[a[i]*a[i]%m];

	ll loopL = i+1-l;

	//cerr << l << " " << loopL << endl;
	//debug(a);
	//debug(ainv);
	//debug(sum);

	if (i < n) cout << sum[l] + ((n-l) / loopL)*(sum[i+1] - sum[l]) + sum[(n-l) % loopL + l] - sum[l] << endl;
	else cout << sum[n] << endl;
}



Measured memory_bytes: 5480
<?php
	while (true) {
		$n = trim(fgets(STDIN));
		list($h, $w) = explode(" ", $n);

		if ($h == 0 && $w == 0) break;

		for ($i = 0; $i < $h; $i++) {
			for ($j = 0; $j < $w; $j++) {
				print "#";
			}
			print "\n";
		}

		print "\n";
	}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int x, y; cin >> x >> y;
	
	ll ans = 1e10;
	
	if (x <= y) chmin(ans, y - x);
	if (-x <= y) chmin(ans, y - -x + 1);
	if (x <= -y) chmin(ans, -y - x + 1);
	if (-x <= -y) chmin(ans, -y - -x + 2);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int N,K;
    int h[100000];
    int count=0;
    scanf("%d %d",&N,&K);
    for(int i=0;i<N;i++){
        scanf("%d",&h[i]);
        }
        for(int i=0;i<N;i++){
            if(K<=h[i]){
                count=count+1;
            }
        }
    printf("%d\n",count);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;

int ChangeTimesFormat(string str){
    int h = atoi(str.substr(0,2).c_str());
    int m = atoi(str.substr(3,2).c_str());
    int s = atoi(str.substr(6,2).c_str());
    int time = h*60*60+m*60+s;
    return time;
}

int main(){
    int n;
    while(cin>>n&&n!=0){
        // ðkeyÆµÄA»ÌÉ­Ë·éñÔÌ,·éñÔÌð²×é
        map<int,pair<int,int> > m;
        for(int i = 0; i < n; i++){
            string from;
            string to;
            cin>>from>>to;
            int ft=ChangeTimesFormat(from);
            int tt=ChangeTimesFormat(to);
            m[ft].first++;
            m[tt].second++;
        }
        // ñÔÌÅå
        int maxLine=0;
        // »ÝcÁÄ¢éÌñÔÌ
        int cnt=0;
        // Ì¢Ô©çµÄ¢­
        for(map<int,pair<int,int> >::iterator it = m.begin(); it!=m.end(); it++){
            // ©¦ÁÄ«½ñÔðo^
            cnt+=it->second.second;
            // o­·éñÔÌÌûª½¢ÈçÎ
            if(cnt<it->second.first){
                maxLine+=it->second.first-cnt;
                cnt=0;
            }
            else{
                cnt-=it->second.first;
            }
        }
        cout<<maxLine<<endl;
    }
    return 0;
}

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

int main(){
   int64_t x,y,a,b,c; cin >> x >> y >> a >> b >> c;
   vector<int64_t> p(a),q(b),r(c);
   rep(i,a){
       cin >> p[i];
   }
   rep(i,b){
       cin >> q[i];
   }
   rep(i,c){
       cin >> r[i];
   }
   sort(p.begin(),p.end());
   sort(q.begin(),q.end());
   sort(r.begin(),r.end());
   
   vector<int> S(x+y+c);
   for(int i =0; i < x; i++){
       S[i] = p[a-1-i];
   }
   for(int i =x;i < x+y; i++){
       S[i] = q[b-1+x-i];
   }
   for(int i = x+y;i < x+y+c; i++){
       S[i] = r[c-1+x+y-i];
   }

   sort(S.begin(),S.end());
   int64_t sum = 0;

   rep(i,x+y){
       sum += S[x+y+c-1-i];
   }

   cout << sum << endl;




   
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+9, INF = 0x3f3f3f3f;
int head, tail;

struct node{
    string s;
    int num;
}que[N], pp;

void Push( node p ) {
    que[tail] = p;
    tail = ( tail + 1 ) % N;
}

node popFront() {
    node p = que[head];
    head = ( head + 1 ) % N;
    return p;
}


int main( void ) {
    ios::sync_with_stdio( false );
    int n, m, ans = 0;
    cin >> n >> m;
    for( int i = 1; i <= n; ++i ) {
        cin >> que[i].s >> que[i].num;
    }
    head = 1, tail = n + 1;
    while( head != tail ) {
        pp = popFront();
        if( pp.num > m ) {
            pp.num -= m;
            ans += m;
            Push( pp );
        }
        else {
            ans += pp.num;
            cout << pp.s << ' ' << ans << '\n';
        }
    }
    return 0;
}



Measured memory_bytes: 7160
#include<bits/stdc++.h>
#define N 1001
using namespace std;
struct Node{int x,y;};
deque<Node>q;
int sx,sy,tx,ty,n,m,dis[N][N],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
char str[N][N],vis[N][N];
int main(void){
	int i,dir,j;Node x,y;memset(dis,0x3f,sizeof dis);
	scanf("%d%d%d%d%d%d",&n,&m,&sx,&sy,&tx,&ty);
	for(i=1;i<=n;++i)scanf("%s",str[i]+1);
	q.push_back({sx,sy}),dis[sx][sy]=0;
	while(!q.empty()){
		x=q.front(),q.pop_front();
		if(vis[x.x][x.y])continue;vis[x.x][x.y]=1;
		for(dir=0;dir<4;++dir){
			y={x.x+dx[dir],x.y+dy[dir]};
			if(y.x&&y.x<=n&&y.y&&y.y<=m&&str[y.x][y.y]^'#'&&dis[y.x][y.y]>dis[x.x][x.y])dis[y.x][y.y]=dis[x.x][x.y],q.push_front(y);
		}
		for(i=-2;i<=2;++i){
			for(j=-2;j<=2;++j){
				y={x.x+i,x.y+j};
				if(y.x>=1&&y.x<=n&&y.y>=1&&y.y<=m&&str[y.x][y.y]^'#'&&dis[y.x][y.y]>dis[x.x][x.y]+1)dis[y.x][y.y]=dis[x.x][x.y]+1,q.push_back(y);
			}
		}
	}
	printf("%d\n",dis[tx][ty]^0x3f3f3f3f?dis[tx][ty]:-1);
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
  int N;
  cin>>N;
  int MAX_N = N*(N-1)/2;
  vector<vector<int>> A(N,vector<int>(N-1,0));
  REP(i,N){
    REP(j,N-1){
      cin>>A[i][j];
      A[i][j]--;
    }
  }
  int num[N][N];
  int val = 0;
  REP(i,N){
    for (int j=i+1;j<N;++j){
      num[i][j] = val;
      num[j][i] = val;
      val++;
    }
  }
  vector<int> graph[MAX_N+1];
  vector<int> hight(MAX_N+1,0);
  vector<int> ans;
  REP(i,N){
    int vn = num[i][A[i][0]];
    REP(j,N-2){
      int nxt = num[i][A[i][j+1]];
      graph[vn].push_back(nxt);
      hight[nxt]++;
      vn = nxt;
    }
  }
  int days = 0;
  stack<int> st;
  REP(i,MAX_N+1){
    if (hight[i]==0) st.push(i);
  }
  while(st.size()){

    days++;
    stack<int> nxt_st;
    while(st.size()){
      int vv = st.top();st.pop();
      ans.push_back(vv);
      for (int vtmp:graph[vv]){
        hight[vtmp]--;
        if (hight[vtmp]==0) nxt_st.push(vtmp);
      }
    }
    st = nxt_st;
  }
  if (ans.size() == MAX_N+1){
    cout<<days<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}

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

using namespace std;

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

    cin >> a >> b >> c >> d;

    while(true) {
        c -= b;
        if(c <= 0) {
            printf("Yes\n");
            return 0;
        }
        a -= d;
        if(a <= 0) {
            printf("No\n");
            return 0;
        }
    }

    return 0;
}

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

using namespace std;
#define N 200200

long long a, b, ans;

int main(){
    cin >> a >> b;
    if (a % 2 != b % 2){
        cout << "IMPOSSIBLE";
    }
    else{
        ans = (a + b) / 2;
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 3484
require 'prime'
include Math
define_method :max, 			-> (a,b) { a > b ? a : b }
define_method :min, 			-> (a,b) { a < b ?  a : b }
define_method :swap, 			-> (a,b) { a, b = b, a }
define_method :gi, 				-> () { gets.split.map(&:to_i) }
define_method :gs, 				-> () { gets.chomp }
define_method :gc,				-> () { gets.chomp.split('') }
define_method :gif, 			-> () { gets.to_i }
define_method :pr,				-> (num) { num.prime_division }
define_method :darray,		-> (size1, size2, init = nil) { Array.new(size1){Array.new(size2){init}} }
define_method :array,			-> (size,init = nil) { Array.new(size){init} }
define_method :putall, 		-> (obj) { obj.each { |o| puts o } }
define_method :repl, 			-> (st,en, &block) { st.upto en do |i| block.call(i) end }
	define_method :rep, 			-> (num, &block) { num.times do |i| block.call(i) end }


		n = gi
		count = 0
		rep n[0]+1 do |x|
			rep n[0]+1 do |y|
				count += 1 if n[1] - x - y >= 0 && n[1] - x - y <= n[0]
			end
		end

		puts count

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

int main(){

int N;
cin>>N;

int i=0;
int n;
int A=1;

while(i<N){

cin>>n;

if(n%2==1){A=A*1;}
else if(n%2==0&&(n%3==0||n%5==0)){A=A*1;}
else {A=A*0;}

i++;

}

if(A==1){cout<<"APPROVED"<<endl;}
else{cout<<"DENIED"<<endl;}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;	

signed main(){IOS;
	int n,w ; cin>>n>>w;
	vector<int>dp(100001,0);
	dp[0]=0;
	for(int i=0;i<n;i++){
		int value,weight;
		cin>>weight>>value;
		for(int j=w-weight;j>=0;j--){
			dp[j+weight]=max(dp[j+weight],dp[j]+value);
		}
	}
	cout<<dp[w]<<endl;
	return 0;
}


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

using namespace std;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define ll long long
const double pi=acos(-1);
const int maxn=1e6+10;
const int mod=1e9+7;

char c[105];
int hw(int l,int r)
{
    while(l<r)
        if(c[l]!=c[r])
            return 0;
        else
        {
            l++,r--;
        }
    return 1;
}

int main()
{
    cin>>c+1;
    c[0]='#';
    int n=strlen(c);
    n--;
    if(hw(1,n)&&hw(1,(n-1)/2)&&hw((n+3)/2,n))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
vector<int> dp(100001);
int n,k,MAX,ans,g;
int gcd(int a,int b){
  if(a>b){
    int tmp=a;a=b;b=tmp;
  }
  if(a==0)return b;
  return gcd(b%a,a);
}
int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>dp[i];MAX=max(MAX,dp[i]);
    if(dp[i]==k)ans=1;
  }
  if(MAX<k){cout<<"IMPOSSIBLE"<<endl;return 0;}
  if(ans==1){cout<<"POSSIBLE"<<endl;return 0;}
  g=dp[0];
  for(int i=0;i<n;i++)g=gcd(g,dp[i]);
  if(k%g==0)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

bool compare_s(pair<ll, ll> a, pair<ll, ll> b){
	return a.second < b.second;
}

signed main()
{
	int N;
	cin >> N;
	vector<pair<ll, ll>> time;
	REP(i, N){
		ll A, B;
		cin >> A >> B;
		time.PB(pair<ll, ll>(A, B));
	}
	sort(ALL(time), compare_s);
	ll now = 0;
	REP(i, N){
		now += time[i].F;
		if(now > time[i].S){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 6384
program ABC062B
    implicit none
    integer(8)::H,W,i
    character(100),dimension(100)::A
    read(5,*)H,W
    read(5,*)(A(i),i=1,H)

    do i=1,W+2
        write(*,'(A)',advance='no')"#"
    end do
    print'(A)',""

    do i=1,H
        write(*,'(A)',advance='no')"#"
        write(*,'(A)',advance='no')A(i)(1:W)
        write(*,'(A)',advance='no')"#"
        print'(A)',""
    end do

    do i=1,W+2
        write(*,'(A)',advance='no')"#"
    end do
    print'(A)',""
end program ABC062B

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,i,a,b,c;
  cin>>n;
  int dp[n][3];
  cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
  for(i=1;i<n;i++){
    cin>>a>>b>>c;
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
  }
  cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
# define int long long
int dp[100005][3];
int a[100005][3];
int fun(int n)
{
  dp[1][0]=a[0][0];
  dp[1][1]=a[0][1];
  dp[1][2]=a[0][2];
  for(int i=2;i<=n;i++)
  {
     dp[i][0]=a[i-1][0]+max(dp[i-1][1],dp[i-1][2]);
     dp[i][1]=a[i-1][1]+max(dp[i-1][0],dp[i-1][2]);
     dp[i][2]=a[i-1][2]+max(dp[i-1][0],dp[i-1][1]);
  }
  return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int32_t main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
        cin>>a[i][j];
    }
  }
  cout<<fun(n)<<endl;
    return 0;
}

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

int main(){
  string N;
  cin>>N;
  bool flag=false;
  for(int i=0;i<3;++i){
    if(N[i]=='7') flag=true;
  }

  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3596
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    for Cx in range(101):
        for Cy in range(101):
            H = INF
            for i in range(N):
                if h[i] > 0:
                    H = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)

            flg = True
            for i in range(N):
                if max(H - abs(x[i]-Cx) - abs(y[i]-Cy), 0) != h[i]:
                    flg = False
                    break
            if flg:
                print(" ".join([str(Cx), str(Cy), str(H)]))
                return


if __name__ == '__main__':
    main()

Measured memory_bytes: 67948
weight_num = int(input())
weights = [int(i) for i in input().split()]
sum_1_list = []
sum_2_list = []
sum_1 = 0
sum_2 = 0

for i in range(weight_num):
    sum_1 += weights[i]
    sum_2 += weights[len(weights) - (i + 1)]
    sum_1_list.append(sum_1)
    sum_2_list.append(sum_2)

ans = max(sum_1_list)

for i in range(weight_num - 1):
    if ans > abs(sum_1_list[i] - sum_2_list[weight_num - (i + 2)]):
        ans = abs(sum_1_list[i] - sum_2_list[weight_num - (i + 2)])

print(ans)


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

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

  int maxi = 0, ans = 0;

  for (int i = 0; i < N; i++) {
    int H;
    cin >> H;
    if (H >= maxi) maxi = H, ans++;
  }

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

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let xx: i32 = input();
    let mut x: Vec<i32> = (0..n).map(|_| input()).collect();
    x.push(xx);
    x.sort();

    let diff: Vec<i32> = x.windows(2).map(|x| x[1] - x[0]).collect();
    let ans = diff[1..].iter().fold(diff[0], |acc, &d| gcd(acc, d));
    println!("{}", ans);
}

fn gcd(x: i32, y: i32) -> i32 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}


Measured memory_bytes: 4352
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
import functools
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()
    A = LI()

    C0, C1 = [0] * 60, [0] * 60

    for d in range(60):
        for ai in A:
            C0[d] += (ai >> d & 1) == 0
            C1[d] += (ai >> d & 1) == 1

    ans = 0
    for (d, (a, b)) in enumerate(zip(C0, C1)):
        ans = (ans + a * b * (1 << d % MOD)) % MOD
    print(ans % MOD)



if __name__ == '__main__':
    main()

Measured memory_bytes: 123944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll n, k;
ll x[100][100000];
ll sum[100000];
ll t[100000];

int main() {
    cin >> n >> k;
    int cnt = 0;
    ll i;
    for (i = 1; i*i <= n; i++) {
        if (n/i == n/(i+1)) continue;
        if (cnt == 0) x[0][cnt] = i;
        else x[0][cnt] = i - t[cnt-1];
        t[cnt] = i;
        cnt++;
    }
    i--;
    if (i*i == n) i--;
    for (; i >= 1; i--) {
        if (n/i == n/(i+1)) continue;
        else x[0][cnt] = n/i - t[cnt-1];
        t[cnt] = n/i;
        cnt++;
    }
    /*
    rep(i,cnt) cerr << t[i] << " ";
    cerr << endl;
    */
    rep(i,k-1) {
        rep(j,cnt) {
            sum[j] = ((j==0?0:sum[j-1]) + x[i][j]) % MOD;
        }
        rep(j,cnt) {
            x[i+1][j] = sum[cnt-1-j] * (t[j]-(j==0?0:t[j-1])) % MOD;
        }
    }
    ll ans = 0;
    rep(i,cnt) (ans += x[k-1][i]) %= MOD;
    cout << ans << endl;
}

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

#define int long long 

using namespace std;

void solve()
{
	int n,cnt=0;cin >> n;
	bool ok= false;
	for(int i =0;i<n;i++)
	{
		int a,b;
		cin >> a>> b;
		if(a==b)
			cnt++;
		else
			cnt=0;
		if(cnt==3){
			ok = true;
			cout << "Yes" << endl;
			break;
		}
	}
	if(!ok)
		cout << "No" << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //int t;cin >> t;while(t--)
    	solve();

    return 0;
}

Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
    ll n,m,d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(20);
    if(d!=0){
        cout << (ld)(n-d)*2*(m-1)/(n*n) << endl;
    }
    else{
        cout << (ld)(n-d)*(m-1)/(n*n) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

#define chmin(x, y) x = min(x, y)

const i64 INF = 1e8;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  i64 C;
  cin >> n >> C;
  vector<i64> H(n);
  REP(i, n) cin >> H[i];

  vector<i64> dp(n);
  vector<tuple<i64, i64, int>> lines;

  auto is_ok = [&](int i, i64 x) -> bool {
    auto [a1, b1, _1] = lines[i];
    auto [a2, b2, _2] = lines[i - 1];
    i64 y1 = a1 * x + b1;
    i64 y2 = a2 * x + b2;
    if (y1 > y2) return false;
    return true;
  };

  auto jumpto = [&](int i) -> int {
    i64 x = H[i];
    int ok = 0, ng = int(lines.size());
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      if (is_ok(mid, x)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    return get<2>(lines[ok]);
  };

  auto add_line = [&](int i) -> void {
    i64 a = -2 * H[i];
    i64 b = H[i] * H[i] + dp[i];
    while (lines.size() > 1) {
      int m = lines.size();
      auto [a1, b1, _1] = lines[m - 1];
      auto [a2, b2, _2] = lines[m - 2];
      if ((a2 - a1) * (b - b2) + (b1 - b2) * (a - a2) < 0) {
        break;
      }
      lines.pop_back();
    }
    lines.emplace_back(a, b, i);
  };

  dp[n - 1] = 0;
  add_line(n - 1);

  for (int i = n - 2; i >= 0; --i) {
    int j = jumpto(i);
    assert(j < n);
    assert(j >= 0);
    assert(H[j] > H[i]);
    i64 hd = H[j] - H[i];
    dp[i] = hd * hd + C + dp[j];
    add_line(i);
  }
  cout << dp[0] << endl;
}


Measured memory_bytes: 12640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	

	void solve(){
		

		ins(x);
		int tmp = 0;
		int tmp1 = 0;
		FOR(i,0,3){
			if(x[i] == 'R'){
				tmp++;
				tmp1 = max(tmp1,tmp);
			}
			else{
				tmp = 0;
			}
		};
		out(tmp1);
		
			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;
static const long long mod = 1000000007;

int main() {
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  const ll amax = 1000005;
  vll mk(amax, 1), unq(amax, 0);
  vll as(n);
  ll ans = 0;
  rep(i, n) cin >> as[i];
  Sort(as);
  rep(i, n){
    if(mk[as[i]]) {
      unq[as[i]] = 1;
      ans++;
      for (ll j = as[i]; j < amax; j += as[i])
        mk[j] = 0;
    } else if(unq[as[i]] == 1) {
      ans--;
      unq[as[i]] = 0;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 20396
import math

w = input()
total = 0
x = 0
y = 0


i = w.index(' ')
n = w[0:i]
d = w[(i+1):]
n = int(n)
d = float(d)


for x in range(n):
    w = input()

    i = w.index(' ')
    y = w[0:i]
    x = w[(i+1):]

    x = int(x)
    y = int(y)

    if math.sqrt((x*x)+(y*y)) <= d:
        total = total+1

print (total)

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

int main(){
    int N, M;  cin >> N >> M;
    vector<pair<int, int>> P;
    for(int i=0; i<M; i++){
        int a, b;  cin >> a >> b;
        P.push_back(make_pair(a,b));
    }
    sort(P.begin(), P.end(), [](const pair<int, int>& a, const pair<int, int>& b){
        return a.second < b.second;
    });

    int ans = 0;
    int rb = 0;
    for(int i=0; i<M; i++){
        int a = P[i].first, b = P[i].second;
        if(rb < a){
            ans++;
            rb = b-1;
        }
    }
    cout << ans << endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  int n,m; cin >> n >> m;
  out((n-1)*(m-1));
}


Measured memory_bytes: 256
/*
    /\ In The Name Of ALLAH /\
    Author : Jawahiir Nabhan
*/
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;

int a[N];
int main()
{
    int n; cin>>n;
    ll cnt = 0;
    for(int i = 0;i < n;i++)
    {
        cin>>a[i];
        if(i){
            if(a[i] < a[i-1]) cnt += a[i-1] - a[i],a[i] = a[i-1];
        }
    }
    cout<<cnt<<endl;
}


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

int main() {
  string s;
  cin >> s;
  
  if( s.at(0)==s.at(1) && s.at(2)==s.at(3) && s.at(1)!=s.at(2) ) cout << "Yes" << endl;
  else if( s.at(0)==s.at(2) && s.at(1)==s.at(3) && s.at(1)!=s.at(2) ) cout << "Yes" << endl;
  else if( s.at(0)==s.at(3) && s.at(1)==s.at(2) && s.at(3)!=s.at(2) ) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int n;
  while(true){
	cin >> n;
	if(!n) break;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];

	int max = a[0];
	for(int i=0;i<n;i++){
	  int sum = 0;
	  for(int j=i;j<n;j++){
		sum += a[j];
		if(max < sum) max = sum;
	  }
	}
	
	cout << max << endl;
  }
  return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d)
    cout << "Left" << endl;
  else if (a + b == c + d)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,k;
ll ans,f[2005][2005];
const int Mod=1000000007;
int main(){
	f[0][0]=1;
	in(n);in(k);
	for(int i=0;i<=2000;i++){
		for(int j=0;j<=2000;j++){
			f[i][j]%=Mod;
			f[i+1][j]=(f[i+1][j]+f[i][j])%Mod;
			f[i+1][j+1]=(f[i+1][j+1]+f[i][j])%Mod;
		}
	}
	for(int i=1;i<=k;i++){
		ans=f[k-1][i-1]*f[n-k+1][n-k-i+1]%Mod;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 31616
#include<stdio.h>
int main(){
    int x, y,tmp;
    for(;;){
        scanf("%d%d",&x,&y);
        if( x==0 && y==0 ){
            break;
        }
        if( x > y ){
            tmp = y;
            y = x;
            x = tmp;
        }
        printf("%d %d\n",x,y);
        
    }
    return 0;
}

Measured memory_bytes: 600
//“Failure is unimportant. It takes courage to make a fool of yourself.”
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
#define int long long int
#define P 1000000007
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define b(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 1000
#define PI 3.14159265359
#define inf LLONG_MAX
using namespace __gnu_pbds;
using namespace std;


signed main() {
    teevra_gati
    
    ll n;
    cin>>n;
    vl a(n+1), cost(n+1,0);
    f(i,1,n+1) cin>>a[i];
    cost[1] = 0;
    cost[2] = abs(a[2]-a[1]);
    f(i,3,n+1){
        cost[i] = min(cost[i-1] + abs(a[i]-a[i-1]), cost[i-2] + abs(a[i]-a[i-2]));
    }
    cout<<cost[n];
    
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000003;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  return factorials;
}

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  auto factorials = MakeFactorialTable(P - 1);

  auto solve_fn = [&]() -> FiniteField {
    int x, d, n;
    cin >> x >> d >> n;
    if (d == 0) {
      return Power(FiniteField(x), n);
    }
    if (x == 0) {
      return 0;
    }

    FiniteField k = FiniteField(x) / d;
    if (k.Value() + n - 1 >= P) {
      return 0;
    }

    return factorials[k.Value() + n - 1] / factorials[k.Value() - 1] * Power(d, n);
  };

  int q_count;
  cin >> q_count;
  for (int q_id = 0; q_id < q_count; q_id++) {
    cout << solve_fn() << "\n";
  }
}

Measured memory_bytes: 8704
import java.util.*;
import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int A[];
        A=new int[M];
        for(int i=0;i<M;i++) A[i]=sc.nextInt();
        int sum=0;
        for(int i=0;i<M;i++) sum+=A[i];
        System.out.println(Math.max(-1,N-sum));
    }
}

Measured memory_bytes: 46348
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll K;
    sll(K);
    ll now_mod = 7 % K;
    ll base10_mod = 1;
    ll n = 1;
    bool is_found = false;
    while(now_mod != 0 && n < K*2){
        base10_mod *= 10;
        base10_mod %= K;
        now_mod += (base10_mod * 7);
        now_mod %= K;
        ++ n;
    }
    if(now_mod != 0){
        n = -1;
    }

    cout << n <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3252
#include<stdio.h>
int main()
{
	int a, b, d;
	scanf("%d%d%d", &a, &b, &d);
	for (int i = 0; i < a; i++)
	{
		for (int j = 0; j < b; j++)
		{
			int s = i + j, t = i + b - j;
			if (s % (2 * d) < d)
			{
				if (t % (2 * d) < d)printf("R");
				else printf("G");
			}
			else
			{
				if (t % (2 * d) < d)printf("Y");
				else printf("B");
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()

 {
      int a,b,n,c,d;
				cin>>a>>b;
				n=a%b;
				c=a/b;
				d=c+1;
				if(n==0) cout<<c<<endl;
				else if(n!=0) cout<<d<<endl;
				
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    string S;
    bool check = false;
    cin >> S;
    if(S[0] == S[1]){
      if(S[2] == S[3] && S[0] != S[2]){
        check = true;
      }
    }else{
      if(S[0] == S[2]){
        if(S[1] == S[3]){
          check = true;
        }
      }else{
        if(S[0]==S[3]){
          if(S[1]==S[2]){
            check = true;
          }
        }
      }
    }
    // 出力
    if(check){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
    string S, N;
    cin >> S >> N;
    int x=0;
    while (x<S.length()){
        string A;
        A+=S.at(S.length()-1);
        A+=S.substr(0, S.length()-1);
        if (S==N){
            cout << "Yes" << endl;
            return 0;
        }
        S=A;
        x++;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
#define rep2(i, N, s) for(int (i) = (s); (i) < (N) + (s); (i) ++)
#define rrep(i, N) for(int (i) = (N) - 1; (i) >= (0); (i) --)
#define rrep2(i, N, s) for(int (i) = (s); (i) >= (s) - (N) + 1; (i) --)
#define INF 1e9

#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

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

int main() {
    int A, B;
    cin  >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
    return 0;
}


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

int main(){
  ll q,h,s,d,n;
  cin >> q >> h >> s >> d >> n;
  s=min(s,min(q*4,h*2));
  
  ll ans=s*(n%2);
  
  ans+=min(d,s*2)*(n/2);
  
  cout << ans << endl;
}

Measured memory_bytes: 256