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

using ull = unsigned long long;
class RollingHash_Mersenne {
	const ull MASK30 = (1ULL << 30) - 1;
	const ull MASK31 = (1ULL << 31) - 1;
	const ull MASK61 = (1ULL << 61) - 1;
	const ull MOD = MASK61;
	const ull base = rand() % (ull)1e5 + 3;
	const ull POSITIVIZER = MOD << 2;
	vector<ull> hash, power;

	// a * b と mod が等しい数を返す
	// 結果は (1UL << 63) + 3 - (1UL << 31) * 3 以下
	ull Mul(ull a, ull b) const {
		ull au = a >> 31;
		ull ad = a & MASK31;
		ull bu = b >> 31;
		ull bd = b & MASK31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30;
		ull midd = mid & MASK30;
		return au * bu * 2 + midu + (midd << 31) + ad * bd;
	}

	// mod 2^61-1を計算する
	ull CalcMod(ull x) const {
		ull xu = x >> 61;
		ull xd = x & MASK61;
		ull res = xu + xd;
		if(res >= MOD) res -= MOD;
		return res;
	}

   public:
	RollingHash_Mersenne(const string &s) {
		int sz = (int)s.size();
		hash.assign(sz + 1, 0);
		power.assign(sz + 1, 0);
		power[0] = 1;
		for(int i = 0; i < sz; i++) {
			power[i + 1] = CalcMod(Mul(power[i], base));
			hash[i + 1] = CalcMod(Mul(hash[i], base) + s[i]);
		}
	}

	template <class T>
	RollingHash_Mersenne(const vector<T> &v) {
		int sz = (int)v.size();
		hash.assign(sz + 1, 0);
		power.assign(sz + 1, 0);
		power[0] = 1;
		for(int i = 0; i < sz; i++) {
			power[i + 1] = CalcMod(Mul(power[i], base));
			hash[i + 1] = CalcMod(Mul(hash[i], base) + v[i]);
		}
	}

	ull get(int l, int r) const { return CalcMod(hash[r] + POSITIVIZER - Mul(hash[l], power[r - l])); }

	ull connect(ull h1, ull h2, ull h2len) const { return CalcMod(Mul(h1, power[h2len]) + h2); }

	// Longest Common Prefix
	int LCP(int l_this, int r_this, RollingHash_Mersenne &other, int l_other, int r_other) {
		int len = min(r_this - l_this, r_other - l_other);
		int low = 0, high = len + 1;
		while(high - low > 1) {
			int mid = (low + high) / 2;
			if(get(l_this, l_this + mid) == other.get(l_other, l_other + mid))
				low = mid;
			else
				high = mid;
		}
		return low;
	}
};

#define rep(i, n) for(int i = 0; i < (n); i++)

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

	RollingHash_Mersenne rh(s);
	int res = 0;
	rep(i, n) {
		rep(j, n) {
			if(j <= i + res) continue;
			int a = rh.LCP(i, n, rh, j, n);
			//	cout << a << endl;
			res = max(res, min(a, j - i));
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define base 2001
#define N 200002
#define mod 1000000007
int n,dp[base*2+1][base*2+1],A[N],B[N],fac[base*4],ifac[base*4];ll ans;
int ksm(int a,int b){
	int r=1;
	for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)r=1ll*r*a%mod;
	return r;
}
int C(int a,int b){
	return 1ll*fac[a]*ifac[a-b]%mod*ifac[b]%mod;
}
void rc(){
	fac[0]=1;
	for(int i=1;i<=8000;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[8000]=ksm(fac[8000],mod-2);
	for(int i=7999;i>=0;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	for(int i=1;i<=n;i++)(ans-=C(2*(A[i]+B[i]),A[i]*2))%=mod;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&A[i],&B[i]);
		dp[-A[i]+base][-B[i]+base]++;
	}
	for(int i=-2000+base;i<=2000+base;i++)
		for(int j=-2000+base;j<=2000+base;j++)
			(dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%mod)%=mod;
	for(int i=1;i<=n;i++)(ans+=dp[A[i]+base][B[i]+base])%=mod;
	rc();
	cout<<(ans+mod)%mod*500000004ll%mod;
	return 0;
}
/*
有n个数对
求出 ∑i=1n∑j=i+1n(ai+bi+aj+bj,ai+aj)
 */


Measured memory_bytes: 64384
#include <bits/stdc++.h>
#define md 1000000007
#define fi first
#define se second
#define mp make_pair
#define	inf 1000000000
#define li 100005
#define lo long long
#define pb push_back
using namespace std;
int n,bas,flag;
char s[105];
string t="keyence";
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=7;i++){
		if(s[i]!=t[bas]){
			flag=1;
			break;
		}
		bas++;
	}
	if(flag==0){
		printf("YES\n");
		return 0;
	}
	bas=6;
	for(int i=n;i>=n-6;i--){
		if(s[i]!=t[bas]){
			flag=1;
			break;
		}
		bas--;
	}
	if(flag==0){
		printf("YES\n");
		return 0;
	}
	for(int i=1;i<=6;i++){
		int tut=0,gg=0;
		for(int j=1;j<=i;j++){
			if(s[j]!=t[tut]){
				gg=1;
				break;
			}
			tut++;
		}
		if(gg==1) continue;
		int k=7-i;
		int hop=0,gol=6;
		for(int j=n;j>=n-k+1;j--){
			if(s[j]!=t[gol]){
				hop=1;
				break;
			}
			gol--;
		} 
		if(hop==0){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}


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

int main(){
    char ch;
    int cnt[26]={};
    while(cin >> ch){
        ch=tolower(ch);
        if(isalpha(ch)) cnt[ch-'a']++;
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',cnt[i]);
    }
    return 0;
}


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

int main(){

  char c[4];
  for(int i=0;i<4;i++){
    cin >> c[i];
  }
  if((c[0]==c[1]&&c[1]==c[2])||(c[1]==c[2]&&c[2]==c[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int R, G;
  cin >> R >> G;

  cout << 2 * G - R  << endl;
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(void){

int a,b;
char op;

while(1){
	scanf("%d %c %d", &a, &op, &b);

	if(op=='+')	printf("%d\n", a+b);
	if(op=='-')	printf("%d\n", a-b);
	if(op=='*')	printf("%d\n", a*b);
	if(op=='/')	printf("%d\n", a/b);
	if(op=='?')	break;
	}

return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int N = 200000 + 10;
typedef long long LL;

int n,a[N],nex[N][60],pos[N],lef[N]; LL k;

int main() {
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=n;i>=1;i--){
        lef[a[i]]=i;
    }
    memset(pos,0,sizeof(pos));
    nex[n+1][0]=1;
    for(int i=n;i>=1;i--){
        if(!pos[a[i]]) {
            nex[i][0]=lef[a[i]]+1;
        } else {
            nex[i][0]=nex[pos[a[i]]+1][0];
        }
        pos[a[i]]=i;
        //printf("nex[%d]=%d\n", i,nex[i][0]);
    }
    
    for(int i=1;i<60;i++){
        for(int j=1;j<=n+1;j++)nex[j][i]=nex[nex[j][i-1]][i-1];
    }
    int p=1;
    for(int i=59;i>=0;i--){
        if((k-1)>>i&1) {
            p=nex[p][i];
        }
    }
    //printf("p=%d\n", p);
    int stk[N]={0},top=0,has[N]={0};
    for(int i=p;i<=n;i++){
        if(has[a[i]]==0){
            stk[++top]=a[i]; has[a[i]]=1;
        } else {
            while(top) {
                int x=stk[top];
                has[stk[top]]=0; --top;
                if(x==a[i]) break;
            }
        }
    }
    for(int i=1;i<=top;i++) printf("%d ", stk[i]);
}

Measured memory_bytes: 52224
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    for(int i=n-1; i>=0; i-=2){
        cout<<a.at(i)<<" ";
    }
    for(int i=0+n%2; i<n-1; i+=2){
        cout<<a.at(i)<<" ";
    }

}


Measured memory_bytes: 2944
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    int a, b;
    cin >> a >> b;
    if (a > 9 or a < 1 or b > 9 or b < 1) {
        cout << "-1";
    }
    else {
        cout << a * b;
    }

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = count(s.begin(), s.end(), 'R');
    if(ans == 2) {
        if(s[1] == 'S') ans = 1;
    }
    cout << ans << '\n';
}


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

namespace AOJ0000
{
    class Program
    {
        static void Main()
        {
            foreach (var line in from i in Enumerable.Range(1, 9)
                                 from j in Enumerable.Range(1, 9)
                                 let k = i*j
                                 select i + "x" + j + "=" + k)
            {
                Console.WriteLine(line);
            }

        }
    }
}

Measured memory_bytes: 5836
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int kouka[] = { 10,50,100,500 };

int main() {
	int n;
	int cnt = 0;
	while (cin >> n, n) {
		if(cnt)cout << endl;
		cnt++;
		int num[4];
		REP(i, 4)
			cin >> num[i];
		int ans[4] = { 0 };
		int mi = 100;
		REP(i, num[0] + 1)
			REP(j, num[1] + 1)
			REP(k, num[2] + 1)
			REP(l, num[3] + 1) {
			if (n <= i*kouka[0] + j*kouka[1] + k*kouka[2] + l*kouka[3]) {
				int n2 = i*kouka[0] + j*kouka[1] + k*kouka[2] + l*kouka[3] - n;
				int num2 = 0;
				REP(i, 4) {
					while (n2 >= kouka[3 - i]) {
						num2++;
						n2 -= kouka[3 - i];
					}
				}
				if (mi > num[0] - i + num[1] - j + num[2] - k + num[3] - l + num2) {
					mi = num[0] - i + num[1] - j + num[2] - k + num[3] - l + num2;
					ans[0] = i;
					ans[1] = j;
					ans[2] = k;
					ans[3] = l;
				}
			}
		}
		REP(i, 4) {
			if (ans[i] != 0) {
				cout << kouka[i] << " " << ans[i] << endl;
			}
		}
		
	}
}

Measured memory_bytes: 3016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, m, a;
vector<P> pp[1010];

int main() {
	while (cin >> n >> m >> a&&n + m + a) {
		rep(i, 1010)pp[i].clear();
		rep(i, m) {
			ll h, p, q;
			cin >> h >> p >> q;
			pp[h].push_back({ p,q });
		}
		ll now = a;
		for (int i = 1000; i >= 1; i--) {
			rep(j, pp[i].size()) {
				ll p = pp[i][j].first;
				ll q = pp[i][j].second;
				if (p == now) {
					swap(q, now);
					break;
				}
				else if (q == now) {
					swap(p, now);
					break;
				}
			}
		}
		cout << now << endl;
	}
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
void dfs(int now, int prev, vector<vector<int>> &edge, vector<int> &par) {
    for(auto next : edge[now]) {
        if(next != prev) {
            par[next] = now;
            dfs(next, now, edge, par);
        }
    }
}
struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y)
            return (false);
        if(data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }
    bool isSame(int x, int y) { return find(x) == find(y); }
    ll size(int k) { return (-data[find(k)]); }
};
int main() {
    int n;
    cin >> n;
    vector<vector<int>> edge(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> par(n, -1);
    dfs(0, -1, edge, par);
    vector<int> keiro;
    int p = n - 1;
    while(p != 0) {
        keiro.push_back(p);
        p = par[p];
    }
    keiro.push_back(0);
    reverse(all(keiro));
    int u = keiro[(keiro.size() - 1) / 2];
    int v = keiro[(keiro.size() - 1) / 2 + 1];
    UnionFind uf(n);
    for(int i = 0; i < n; i++) {
        for(auto e : edge[i]) {
            if(i == u && e == v) {
                continue;
            }
            if(i == v && e == u) {
                continue;
            }
            uf.unite(i, e);
        }
    }
    if(uf.size(0) > uf.size(n - 1)) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 13304
#include <bits/stdc++.h>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 998244353
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &x){
    x=0; 
    T f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-'){
            f=-1;
        }
        ch=getchar();
    }
    while(ch<='9' && ch>='0'){
        x=x*10+(ch-'0');
        ch=getchar();
    }
    x*=f;
}

int ans=0;
int main(){
    int a[105];
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%2==1 && i%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

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

	int n = s.size() - 1;
	uint64_t sum = 0;

	for (int i = 0; i < (1 << n); i++)
	{
		uint64_t add = 0;
		int r = 0;
		for (int j = 0; j < n; j++)
		{
			if (i & 1 << j)
			{
				add += stoll(s.substr(n - j, j - r + 1));
				r = j + 1;
			}
		}
		add += stoll(s.substr(0, n - r + 1));
		sum += add;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
prog=<<EOS
def getints
  gets.split.map(&:to_i)
end

n, m = getints
$g = Array.new(n) { [] }
m.times do
  a, b = getints
  a -= 1
  b -= 1
  $g[a] << b
  $g[b] << a
end

$vis = Array.new(n, false)

def dfs v, ans
  ans << v
  $vis[v] = true
  $g[v].each do |w|
    unless $vis[w] 
      dfs w, ans
      break
    end
  end
end

a = []
b = []
dfs 0, a
dfs 0, b
b.reverse!.pop
ans = b + a
puts ans.size
puts ans.map(&:succ).join " "
EOS

open('prog.rb', 'w') { |f| f.puts prog }
puts `export RUBY_THREAD_VM_STACK_SIZE=200000000 && ruby prog.rb`


Measured memory_bytes: 202704
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int a;
	VI A;
	int ans=1;
	REP(i,3){
		cin >> a;
		A.PB(a);
	}
	sort(A.begin(),A.end());
	REP(i,2){
		if(A[i]!=A[i+1])
			ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

s = list(input())
n = len(s)

if s != list(reversed(s)):
    print("No")
    exit()

tmp = s[0:int(((n-1)/2))]
#print(tmp)
if tmp != list(reversed(tmp)):
    print("No")
    exit()


tmp = s[int(((n+3)/2))-1:]
#print(tmp)
if tmp != list(reversed(tmp)):
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 38384
s = input()
for i in range(int(input())):
  code = input().split()
  if 'print'==code[0]:
    print(s[int(code[1]):int(code[2])+1])
  elif code[0]=="reverse":
    s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:]
  else:
    s = s[:int(code[1])] + str(code[3]) + s[int(code[2])+1:]


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    ll n,y; cin >> n >> y;
    rep(a,n+1){
        rep(b,n+1){
            if(n-a-b < 0) continue;
            if((a*10000 + b*5000 + (n-a-b)*1000) == y){
                cout << a << " " << b << " " << n-a-b << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

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


void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    for(int i = 0;i < 1e6;i++){
        string ss = to_string(i);
        if(ss.size() != N)continue;
        bool f = true;
        for(int j = 0;j < M;j++){
            if(ss[s[j]-1] != c[j] + '0'){
                f = false;
            }
        }
        if(f){
            cout<<i<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003

int dp[353][353]={0};
int bow[353][353]={0};

set<string> a;

int main(){

	int w,q;
	
	while(cin>>w>>q,w!=0||q!=0){
		string d;
		int id[110]={0};
		int u[110]={0};
		bool ss[110]={false};
		while(q>0){
			int a;
			cin>>d;
			
			if(d=="s"){
				cin>>a;
				cin>>id[a];
				//debug(id[a]);
					int h=0,b=0;
					bool f=false;
					for(int i=0;i<w;i++){
						//debug(ss[i]);
						if(!ss[i]){
							if(b==0){
								h=i;
							}
							//debug(b);
							b++;
							if(b==id[a]){
								for(int j=h;j<=i;j++){
									ss[j]=true;
								}
								f=true;
								u[a]=h;
								cout<<u[a]<<endl;
								break;
							}
							
						}
						else{
							h=0;
							b=0;
						}
						
					}
				if(!f)
					cout<<"impossible"<<endl;
				}
				
			else{
				cin>>a;
				for(int i=u[a];i-u[a]<id[a];i++){
					ss[i]=false;
				}
				
			}
			q--;
		}
		cout<<"END"<<endl;
	}
	
}

Measured memory_bytes: 1208
import java.util.*;

public class Main {
    public static void main(String...args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> men = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            men.add(sc.nextInt());
        }
        long l =
        men.stream().filter(s -> s >= k).count();
        System.out.println(l);
    }

}


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

const int MAXN = 200010;
const int mod = 1000000007;
const int inv2 = mod + 1 >> 1;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int A[MAXN], rk[MAXN], n, B[MAXN], pb[MAXN], sb[MAXN];
struct seg {
	int tree[MAXN << 2], tagmul[MAXN << 2];
	seg() { std::fill(tagmul, tagmul + (MAXN << 2), 1); }
	void mkmul(int u, int v) {
		tree[u] = mul(tree[u], v);
		tagmul[u] = mul(tagmul[u], v);
	}
	void pushdown(int u) {
		if (tagmul[u] != 1) {
			mkmul(u << 1, tagmul[u]);
			mkmul(u << 1 | 1, tagmul[u]);
			tagmul[u] = 1;
		}
	}
	void add(int u, int l, int r, int tar, int v) {
		if (l == r) return (void) (tree[u] += v);
		int mid = l + r >> 1;
		pushdown(u);
		if (tar <= mid) add(u << 1, l, mid, tar, v);
		else add(u << 1 | 1, mid + 1, r, tar, v);
		reduce(tree[u] = tree[u << 1] + tree[u << 1 | 1] - mod);
	}
	int qry(int u, int l, int r, int L, int R) {
		if (L <= l && r <= R) return tree[u];
		int mid = l + r >> 1, res = 0;
		pushdown(u);
		if (L <= mid) res = qry(u << 1, l, mid, L, R);
		if (mid < R) reduce(res += qry(u << 1 | 1, mid + 1, r, L, R) - mod);
		return res;
	}
} pre, suc;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> A[i], rk[i] = i;
	std::sort(rk + 1, rk + 1 + n, [] (int a, int b) { return A[a] < A[b]; });
	int all = 1;
	for (int i = 1; i <= n; ++i) {
		const int u = rk[i];
		all = mul(all, B[i] = A[u] - i + 1);
		if (B[i] <= 0) { std::cout << 0 << std::endl; return 0; }
	}
	pb[0] = sb[n + 1] = 1;
	for (int i = 1; i <= n; ++i) pb[i] = mul(pb[i - 1], B[i]);
	for (int i = n; i; --i) sb[i] = mul(sb[i + 1], B[i]);
	static int tree[MAXN];
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int x = rk[i]; x <= n; x += x & -x) reduce(ans += tree[x] - mod);
		for (int x = rk[i]; x; x &= x - 1) ++tree[x];
	}
	ans = mul(ans, all);
	for (int i = 1; i <= n; ++i) {
		int t = pre.qry(1, 1, n, 1, rk[i]);
		t = mul(mul(t, inv2), sb[i + 1]);
		reduce(ans += t - mod);
		t = suc.qry(1, 1, n, rk[i], n);
		t = mul(mul(t, inv2), sb[i + 1]);
		reduce(ans -= t);
		pre.mkmul(1, B[i] - 1);
		suc.mkmul(1, B[i] - 1);
		t = mul(pb[i - 1], mul(A[rk[i]] - i, A[rk[i]] - i + 1));
		pre.add(1, 1, n, rk[i], t);
		suc.add(1, 1, n, rk[i], t);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 17408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());

            char a[][] = new char[n][n];
            char b[][] = new char[m][m];

            for (int i = 0; i < n; i++) {
                a[i] = in.next().toCharArray();
            }
            for (int i = 0; i < m; i++) {
                b[i] = in.next().toCharArray();
            }

            boolean ok = false;

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if ((i + m - 1) >= n || (j + m - 1) >= n) continue;
                    boolean match = true;
                    for (int k = 0; k < m; k++) {
                        for (int l = 0; l < m; l++) {
                            if (a[i + k][j + l] != b[k][l]) match = false;
                        }
                    }
                    if (match) ok = true;
                }
            }
            if (ok) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



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

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

	int ret = 0;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == t[i]) {
			ret++;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
s = gets
result = 'NO'

s.length.times.with_index do |i|
  if s.match(/^#{'keyence'[0..i]}/) && s.match(/#{'keyence'[(i+1)..-1]}$/)
    result = 'YES'
  elsif s.match(/^keyence/) || s.match(/keyence$/)
    result = 'YES'
  end
end

puts result


Measured memory_bytes: 1916
#include <stdio.h>
#include <ctype.h>
int main(void){
    int N,K,i;
    scanf("%d %d",&N,&K);
    char S[N];
    scanf("%s",S);
    for(i=0;i<N;i++) {
        if(i+1==K) {
            S[i]=tolower(S[i]);
        }
        printf("%c",S[i]);
    }
    return 0;
}


Measured memory_bytes: 128
/*
********************
Author : Sahil Kundu
********************
*/
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define pb(i) push_back(i)
#define pp() pop_back()
#define f first
#define s second
#define mk(l,r) make_pair(l,r)
#define all(vc) vc.begin(),vc.end()
#define bg(vc) vc.begin()
#define ed(vc) vc.end()
#define ms(i,j) memset(i,j,sizeof i)
#define w(t) while(t--)
const ll MAX=1e5+5;
const ll INF=2e18;
bool isprime[MAX];
const ld pi=acos(-1);
vector<ll> vc;
void init()
{
    ms(isprime,true);
    isprime[1]=false;
    for(ll i=2;i*i<=MAX;i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i;j<=MAX;j+=i)
                isprime[j]=false;
        }
    }
    for(ll i=2;i<=MAX;i++)
        if(isprime[i])
        vc.pb(i);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    //init();
    w(t)
    {
        ld a,b,h,m;
        cin>>a>>b>>h>>m;
        ld angh=h*(pi/(ld)6)+m*(pi/(ld)360),angm=m*(pi/(ld)30);
        ld ang=max(angh,angm)-min(angh,angm);
        cout<<fixed<<setprecision(12)<<(ld)sqrt(a*a+b*b-(ld)2*a*b*cos(ang))<<endl;
    }
}
/*
ll msb(ll x)
{
	ll k=(ll)log2(x);
	return (ll)(pow(2,k));
}
#define gc getchar_unlocked
void scanint(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}*/

Measured memory_bytes: 4180
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let (mut s, mut c): (usize, usize) = input_two();

    let mut ans = min(s, c / 2);
    s -= ans;
    c -= ans * 2;

    ans += c / 4;

    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing
bool ok = false;
int n, col;
vector <string> v;
bool check (vector <string> tt) {
		vector <string> t(col);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < col; j++) {
				t[j] += tt[i][j];
			}
		}
		map <string, int> m;
		for (int i = 0; i < col; i++) {
			m[t[i]]++;
		}
		int c = 0;
		for (int i = 0; i < col; i++) {
			if(m[t[i]] == 0)	continue;
			string tmp = t[i];
			m[t[i]]--;
			reverse(all(tmp));
			if(t[i] == tmp) {
				if(m[tmp] == 0) {
					c++;
				}
				else {
					m[tmp] -= 1;
				}
			}
			else {
				if(m[tmp] == 0)
					return false;
				else
					m[tmp] -= 1;
			}
		}
		if(c == 0)
			return true;
		else if(c == 1 && col % 2 == 1)	
			return true;
		else
			return false;
}
void try_all(int id, vector<int> a) {
	if(id == n) {
		vector<string> tt(n);
		for (int i = 0; i < n; i++) 
			tt[i] = v[a[i]];
		if(check(tt))
			ok = true;
		return;
	}
	for (int i = 0; i < n / 2; i++) {
		if(a[i] == -1) {
			a[i] = id;
			try_all(id + 1, a);
			a[i] = -1;
			break;
		}
		else {
			if(a[n - i - 1] == -1) {
				a[n - i - 1] = id;
				try_all(id + 1, a);
				a[n - i - 1] = -1;
			}
		}
	}
	if(n % 2 && a[n / 2] == -1) {
		a[n / 2] = id;
		try_all(id + 1, a);
		a[n / 2] = -1;
	}
}
int main() {
	cin >> n >> col;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector <int> a(n, -1);
	try_all(0, a);
	if(ok)
		cout << "YES\n";
	else
		cout << "NO";
}


Measured memory_bytes: 256
r=lambda x:p[x]>=0and r(p[x])or x
(n,m,k),*t=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
s=[-1]*-~n
i=-1
for a,b in t:
 x,y=sorted((r(a),r(b)));i+=1
 if(x!=y)*m>i:p[x]+=p[y];p[y]=x
 if(x!=y)*i<m:s[a]-=1;s[b]-=1
print(*[s[i+1]-p[r(i+1)]for i in range(n)])

Measured memory_bytes: 96856
#!/usr/bin/env python
import itertools
from operator import mul
from functools import reduce


N = int(input())
F = 1
for i in range(1,N+1):
    F = F*i

pns = []
for n in range(2, N+1):
    for pn in pns:
        if n % pn == 0:
            break
    else:
        pns.append(n)
c = 0
for num in pns:
    if F % num**74 == 0:
        c += 1
for nums in itertools.combinations(pns, 2):
    y1 = nums[0]**14 * nums[1]**4
    y2 = nums[1]**14 * nums[0]**4
    z1 = nums[0]**24 * nums[1]**2
    z2 = nums[1]**24 * nums[0]**2
    if F % y1 == 0:
        c += 1
    if F % y2 == 0:
        c += 1
    if F % z1 == 0:
        c += 1
    if F % z2 == 0:
        c += 1
for nums in itertools.combinations(pns, 3):
    for num in nums:
        num_except = [n for n in nums if n != num]
        x = num**2 * (num_except[0]*num_except[1])**4
        if F % x == 0:
            c += 1
print(c)


Measured memory_bytes: 3560
#include <stdio.h>
int main(){
	int i,score[5],sum,ave;
	for(i = 0;i < 5;i++){
		scanf("%d",&score[i]);
		if(score[i] < 40){
			sum += 40;
		}else{
		sum += score[i];
		}
	}
	ave = sum / 5;
	printf("%d\n",ave);
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  
  cin >> a >> b;
  
  if(a == 1){
    a += 13;
  }
  if(b == 1){
    b += 13;
  }
  
  if(a > b){
    cout << "Alice" << endl;
  }
  else if(a < b){
	cout << "Bob" << endl;
  }
  else{
	cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0521

"""
import sys
from sys import stdin
input = stdin.readline


def count_coint(change):
    ans = 0
    coins = (500, 100, 50, 10, 5, 1)
    for c in coins:
        t = change // c
        ans += t
        change -= t * c
    return ans


def main(args):
    while True:
        payment = int(input())
        if payment == 0:
            break

        change = 1000 - payment
        result = count_coint(change)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7700
import sys
import math
# from collections import Counter
input = sys.stdin.readline
# import numpy as np

def inp():
    return(int(input()))

def inps():
    return str(input())
    
def inlt():
    return(list(map(int,input().split())))
    
def inlst():
    return(list(map(str,input().split())))
    
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split())) 

def ans(x,k,d):
    if abs(x)<d:
        if k%2: return  d - abs(x)
        else: return abs(x)
    else:
        div = abs(x)//d
        if div>k: return abs(x) - d*k
        else:
            if (k-div)%2: return d - abs(x)%d
            else: return abs(x)%d 

x, k, d = inlt()
print(ans(x, k, d))

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

vector<bool> f(string &a, string &b) {
    int la = a.size(), lb = b.size();
    vector<bool> ret(la+1, true);
    for (int i = 0; i < la; i++) {
        for (int j = i, k = 0; j < la && k < lb; j++, k++) {
            if (a[j] != '?' && b[k] != '?' && a[j] != b[k]) {
                ret[i] = false;
                break;
            }
        }
    }
    return ret;
}

int calc(string &a, string &b, string &c) {
    vector<bool> ab = f(a, b), bc = f(b, c), ac = f(a, c);
    int la = a.size(), lb = b.size(), lc = c.size(), ans = la+lb+lc;
    for (int i = 0; i <= la; i++) {
        for (int j = 0; j <= max(la, lb); j++) {
            if (ab[i] && (j >= lb || bc[j]) && (i + j >= la || ac[i+j])) {
                ans = min(ans, max({la, i + lb, i + j + lc}));
            }
        }
    }
    return ans;
}


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


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

int main()
{
    int n,d;
    int dist=0;
    int ans=0;
    int x[10][10];

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

    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            dist=0;
            for(int k=0;k<d;k++)
            {
                dist+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            for(int l=0;l<500;l++)
            {
                if(dist==l*l)
                {
                    ans++;
                    break;
                }
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 888
#include<stdio.h>
#define N 8
#define NOT_FREE 1
#define FREE 0

int queen[N][N],col[N],dpos[N+N-1],dneg[N+N-1],row[N];

void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
    if(row[i]!=j) printf(".");
    else printf("Q");
  }
    printf("\n");
  }
}

void putQueen(int i){
  int j;
  if(i==N){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
	if(queen[i][j]==NOT_FREE){
	  if(row[i]!=j) return;
	}
      }
    }
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE) continue;

      row[i]=j;
      col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
      putQueen(i+1);
      col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j,k,r,c;

  scanf("%d",&k);

  for(i=0;i<N;i++) for(j=0;j<N;j++) queen[i][j]=FREE;

  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    queen[r][c]=NOT_FREE;
  }

  putQueen(0);

  return 0;

}
  



Measured memory_bytes: 2056
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

def max_profit(rs, n)
  r0 = rs.shift
  r1 = rs.shift
  min_r = [r0, r1].min
  max_p = r1 - r0
  rs.each do |r|
    cur_p = r - min_r
    max_p = [max_p, cur_p].max
    min_r = [min_r, r].min
  end
  max_p
end

if __FILE__ == $0
  n, *rs = ARGF.readlines.map { |r| r.to_i }
  # assert(n == rs.size)
  # assert(n >= 2)
  max_p = max_profit(rs, n)
  puts max_p
end

# end

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

int main() {   
    ios::sync_with_stdio(0);   
    cin.tie(0);   
   
    #ifndef ONLINE_JUDGE   
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);   
    #endif   
    
	int t;cin>>t;
	if(t%1000 == 0){
		cout<<"0";
	}
	else{cout<<1000-(t%1000);}
	 



}   
        

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

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

  int opt_i = 0;
  int opt_j = 0;
  int opt_k = 0;
  int opt_l = 0;
  double opt_nodo = 0;
  
  for(int i=0;f - 100*a*i >= 0;i++){
    for(int j=0;f - 100*a*i - 100*b*j >= 0;j++){
      for(int k = 0;f - 100*a*i - 100*b*j - c*k >= 0;k++){
	for(int l = 0;f - 100*a*i - 100*b*j - c*k - d*l >= 0;l++){
	  if(i == 0 && j == 0){
	    continue;
	  }
	  if(((double)(c*k+d*l))/((double)(100*a*i+100*b*j+c*k+d*l)) >= opt_nodo
	     && (a*i+b*j)*e >= c*k+d*l){
	    opt_i = i;
	    opt_j = j;
	    opt_k = k;
	    opt_l = l;
	    opt_nodo = ((double)(c*k+d*l))/((double)(100*a*i+100*b*j+c*k+d*l));
	  }
	}
      }
    }
  }
  cout << 100*a*opt_i + 100*b*opt_j + c*opt_k + d*opt_l<< " " << c*opt_k + d*opt_l << endl;
}


Measured memory_bytes: 256
#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;
    ll ans = 0;
    cin >> N;
    rep(i, N) {
        ll l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a > 8 || b > 8)
        cout << ":(";
    else
        cout << "Yay!";
    return 0;
}

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

public class Main {
    void run() {
        try {
            char[] init = {0, 1, 2, 3, 4, 5, 6, 7};
            Map<Integer, Integer> d = new TreeMap<Integer, Integer>();
            d.put(hash(init), 0);
            Queue<char[]> que = new ArrayDeque<char[]>();
            que.add(init);
            char[][] swap = {{1, 4}, {0, 2, 5}, {1, 3, 6}, {2, 7}, {0, 5}, {1, 4, 6}, {2, 5, 7}, {3, 6}};
            while (!que.isEmpty()) {
                int zeroPos = -1;
                char[] cur = que.poll();

                for (int i = 0; i < 8; i++) {
                    if (cur[i] == 0) {
                        zeroPos = i;
                    }
                }

                for (int i = 0; i < swap[zeroPos].length; i++) {
                    int swapPos = swap[zeroPos][i];
                    char[] next = cur.clone();
                    char t = next[zeroPos];
                    next[zeroPos] = next[swapPos];
                    next[swapPos] = t;

                    if (!d.containsKey(hash(next))) {
                        d.put(hash(next), d.get(hash(cur)) + 1);
                        que.add(next);
                    }
                }
            }

            for (String line; (line = in.readLine()) != null; ) {
                StringTokenizer tokenizer = new StringTokenizer(line);
                char[] target = new char[8];
                for (int i = 0; i < 8; i++) {
                    target[i] = (char)Integer.parseInt(tokenizer.nextToken());
                }

                sysout.println(d.get(hash(target)));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    int hash(char[] ary) {
        int ret = 0;
        for(int i = 0; i < ary.length; i++) {
            ret *= 10;
            ret += ary[i];
        }
        return ret;
    }

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

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Measured memory_bytes: 30132
N, M, X = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')
for i in range(2**N):
  bag = []
  und = [0]*M
  for j in range(N):
    if (i>>j)&1:
      bag += [j]
  tmp = 0
  for j in bag:
    tmp += ca[j][0]
    for k in range(1, M+1):
      und[k-1] += ca[j][k]
  flag = True
  for k in range(M):
    if und[k] < X:
      flag = False
      break
  if flag:
    ans = min(ans, tmp)

if ans == float('inf'):
  print(-1)
else:
  print(ans)

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

int main() {
  long long h,w;
  cin>>h>>w;
  
  long long ans;
  if(h == 1 || w == 1) ans = 1;
  else if(h % 2 == 0) ans = h * w / 2;
  else ans = w * ( h - 1 ) / 2 + w / 2 + w % 2;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

x1, y1, x2, y2 = list(map(int, input().split()))

dx1 = x2 - x1
dy1 = y2 - y1

x3 = x2 - dy1
y3 = y2 + dx1
x4 = x3 - dx1
y4 = y3 - dy1

print(x3, y3, x4, y4, sep = ' ')


Measured memory_bytes: 2940