akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivess
ll n, dist[MAXN];
vector <pi> v[MAXN];
int main()
{
	cin >> n;
	for(ll i = 0; i < n; i++) v[i].pb(pi((i+1)%n, 1));
	for(ll i = 0+1; i <= n; i++) v[i].pb(pi((i*10)%n, 0));
	mmst(dist, -1);
	dist[1] = 1;
	deque <ll> dq;
	dq.pb(1);
	while(!dq.empty())
	{
		ll x = dq.front();
		dq.pop_front();
		for(auto i : v[x])
		{
			ll to = i.f;
			if(dist[to] == -1||dist[to]>dist[x]+i.s)
			{
				dist[to] = dist[x] + i.s;
				if(i.s) dq.pb(i.f);
				else dq.push_front(i.f);
			}
		}
	}
	cout << dist[0] << "\n";
}

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




signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;cin>>n;
    if(n%2) cout<<0;
    else
    {
        int ans=0;
        n/=2;
        for (int i = 5; n / i >= 1; i *= 5) 
            ans += n / i;
        cout<<ans<<endl;
    }
    return 0;
}


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

struct Point { 
	int x, y; 
	Point() {};
	Point(int _x, int _y) : x(_x), y(_y) {}
};

const int op[2][4] = {{1, -1, 0, 0}, {0, 0, 1, -1}};

void dfs(int x, int y, std::vector<std::vector<bool> > &vis) {
	if(vis[x][y]) return;
	vis[x][y] = true;
	for(int i = 0; i < 4; ++i) {
		int nx = x + op[0][i];
		int ny = y + op[1][i];
		if(nx < 1 || nx >= vis.size() || ny < 1 || ny >= vis[nx].size()) continue;
		dfs(nx, ny, vis);
	}
}

void compress(std::vector<Point> &p) {
	std::vector<int> v1, v2;
	
	for(int i = 0; i < p.size(); ++i) 
		for(int j = -1; j <= 1; ++j) {
			v1.emplace_back(p[i].x + j);
			v2.emplace_back(p[i].y + j);
		}

	std::sort(v1.begin(), v1.end());
	std::sort(v2.begin(), v2.end());
	v1.erase(std::unique(v1.begin(), v1.end()), v1.end());
	v2.erase(std::unique(v2.begin(), v2.end()), v2.end());
	
	for(int i = 0; i < p.size(); ++i) {
		p[i].x = lower_bound(v1.begin(), v1.end(), p[i].x) - v1.begin();
		p[i].y = lower_bound(v2.begin(), v2.end(), p[i].y) - v2.begin();
	}
}

typedef long long LL;

int main() {
	int w, h;
	while(~scanf("%d%d", &w, &h) && (w != 0 || h != 0)) {
		int n;
		scanf("%d", &n);
		
		std::vector<Point> p(n + n + 2);
		for(int i = 1; i <= n; ++i) {
			int x1, y1, x2, y2;
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			p[i].x = x1, p[i].y = y1;
			p[i + n].x = x2, p[i + n].y = y2;
		}
		p[0] = Point(0, 0);
		p[n + n + 1] = Point(w, h);
		
		compress(p);
		
		w = p[n + n + 1].x, h = p[n + n + 1].y;
		std::vector<std::vector<bool> > vis(w, std::vector<bool>(h));

		for(int i = 1; i <= n; ++i)
			for(int j = p[i].x; j < p[i + n].x; ++j)
				for(int k = p[i].y; k < p[i + n].y; ++k)
					vis[j][k] = true;

		int ans = 0;
		int sx = p[0].x, sy = p[0].y;
		for(int i = sx; i < w; ++i)
			for(int j = sy; j < h; ++j) 
				if(!vis[i][j]) {
					++ans;
					dfs(i, j, vis);
				}
		printf("%d\n", ans);
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    string s;
    cin >> s;
    int total=0, x=1;
    ll ans=0;
    ll cnt[2019] = {};
    cnt[0] = 1;
    REPD(i,(SIZE(s))){
        total += (s[i]-'0')*x;
        total %= 2019;
        cnt[total] += 1;
        x = (x*10)%2019;
    }

    REP(i,2019){
        ans += (cnt[i]*(cnt[i]-1))/2;
    }
    cout << ans;
}

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

int main()
{
    int n, i, x, y, c, flag = 0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> x >> y;
        if(x == y)
        {
            c+=1;
            if(c == 3)
            flag = 1;
        }
        else
        c = 0;
    }
    if(flag == 1)
    cout << "Yes";
    else
    cout << "No";
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define all(a) a.begin(),a.end()
#define sz(a) (int)a.size()
#define fi first
#define se second
#define LOCAL_JUDGE 1 //remember to change
using namespace std;
int main(){
	long long n,m,ans;
	cin>>n>>m;
	if(n==2 || m==2) ans=0;
	else if(n>2 && m>2) ans=(n-2)*(m-2);
	else if(n>2) ans=n-2;
	else if(m>2) ans=m-2;
	else ans=1;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
using System;
 
class Program
{
    static void Main()
    {
        int c = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        
        for (int i=0; i<c; i++)
        {
           int v = int.Parse(s[i]);
           int j = i-1;
           
           while (j>=0 && int.Parse(s[j])>v)
           {
              s[j+1] = s[j];
              j--;   
           }
           s[j+1] = v.ToString();
           
           string ret="";
           for (int x=0; x<c; x++) { ret = ret + s[x] + " "; }
           Console.WriteLine(ret.TrimEnd());
        }
    }
}


Measured memory_bytes: 9748
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

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

  std::vector<std::string> sn(n);
  for (auto &s : sn) {
    std::cin >> s;
    std::sort(&s[0], &s[s.length()]);
  }

  std::sort(sn.begin(), sn.end());

  int64_t count = 0;
  int64_t local_count = 0;
  for (int i = 1; i < n; ++i) {
    if (sn[i - 1] == sn[i]) {
      ++local_count;
    } else {
      if (local_count > 0) {
        count += local_count * (local_count + 1) / 2;
      }
      local_count = 0;
    }
  }
  if (local_count > 0) {
    count += local_count * (local_count + 1) / 2;
  }

  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=2e5+9;
ll mark[N];
int main()
{
    FASTINOUT;
    ll x,d,a,hit=0,ans=0;
    cin>>x>>d>>a;
    d*=2;
    vector<pair<ll,ll>>v(x);
    for (int i=0;i<x;i++)
        cin>>v[i].first>>v[i].second;
        sort(v.begin(),v.end());
    for (int i=0;i<x;i++){
        v[i].second-=hit;
        if (v[i].second>0){
            ll need =(v[i].second+a-1)/a;
            ans+=need;
            hit+=need*a;
            ll l=i,r=x-1,mid;
            while (l<=r){
                mid=(l+r)/2;
                if (v[i].first+d>=v[mid].first)
                    l=mid+1;
                else
                    r=mid-1;
            }
            l--;
           // cout<<"l = "<<l<<endl;
            mark[l]+=need*a;
        }
        hit-=mark[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

  int a, b, c;

  cin >> a >> b >> c;

  int maxa = max({a, b, c});
  int mina = min({a, b, c});

  cout << maxa - mina << endl;



  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h=0,m=0,s=0,S;
  scanf("%d",&S);
  while(S>=3600){
    S-=3600;
    h++;
  }
  while(S>=60){
    S-=60;
    m++;
  }
  s+=S;
  printf("%d:%d:%d\n",h,m,s);
  return(0);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double p,q,r;
	cin>>p>>q>>r;
	if(p/q<=r)
	{
		cout<<"Yes"<<"\n";
	}
	else
	{
		cout<<"No"<<"\n";
	}
}



Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
int32_t main()
{
	fast;
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int > v[n];
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int x;
			cin >> x;
			v[x - 1].push_back(i);
		}

	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i].size() == 0) {
			ans++;
		}
	}
	cout << ans;






}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;
inline ll read()
{
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=1e5+5;
int n,m,fa[MAXN];
struct EDGE
{
	int u,v;
}e[MAXN];
ll ans[MAXN],sz[MAXN];
int get_fa(int x)
{
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		e[i].u=read(); e[i].v=read();
	}
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	ans[m]=(ll)n*(n-1)/2;
	for(int i=m;i>=1;--i)
	{
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll N;
    cin >> N;
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    ll ans = INF;
    rep(i, 0, N-1) {
        ll ans1 = a[i];
        ll ans2 = a[i+1];
        while(true) {
            ll a = max(ans1, ans2);
            ll b = min(ans1, ans2);
            ans1 = a % b;
            ans2 = b;

            if (a % b == 0) {
                ans = min(b, ans);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cstdio>
#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
int main()
{
	int e; while (cin >> e , e)
	{
		int m = 214214, x = 0;
		rep(y, 1001) rep(z, 101)
		{
			x = e - (y * y + z * z * z);
			if (e == x + (y * y) + (z * z * z) && x >= 0 ) 
			{ m = min(x + y + z, m); }
			else if (e > x + (y * y) + (z * z * z)) { break; }
		}
		printf("%d\n", m);
	}
	return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define v vector
typedef  long long int ll;
#define f first
#define s second
typedef pair<int,ll> pi;
#define N 21
#define MOD 1000000009
#define inf 1e15
typedef vector<int> vi;
//maximal suffix s.t is decreasing when length 26 

int main()
{
    string s,ans="";int len,i,flag;char ch='.',cur;
    getline(cin,s);len=s.length();
    
    set<char>al;set<char>::iterator it;
    for(i=0;i<26;i++)al.insert(97+i);
    
    for(i=0;i<len;i++)al.erase(s[i]);
    if(al.size()!=0)
    {
    it=al.begin();
    ans=s;

    
    ans+=(*it);
    cout<<ans<<endl;
    }
    
    else
    {
        for(i=25;i>0;i--)if(s[i]>s[i-1])break;
        if(i==0)return cout<<-1<<endl,0;
        ans+=s.substr(0,i);
        ch=ans[ans.length()-1];
        cur='{';
        while(i<len)
        {
            if(s[i]<cur&&s[i]>ch)cur=s[i];
            i++;
        }
        ans[ans.length()-1]=cur;
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int cntT = c / b;
        if(c % b != 0) cntT++;
        int cntA = a / d;
        if(a % d != 0) cntA++;
        System.out.println( cntT <= cntA ? "Yes" : "No");
    }
}

Measured memory_bytes: 35592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi fac,finv,inv;
void init(ll n){
    n*=3;
    fac=vi(n+5);finv=vi(n+5);inv=vi(n+5);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,n+5){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    ll n;cin>>n;
    init(n);
    ll ans=0;
    vi v(n);
    rep(i,n){
        v[i]=fac[n-1-i]*fac[i]%mod*modcom(n-3-(2*i-1)+i,i)%mod;
    }
    rep(i,n-1)v[i]=(v[i]+mod-v[i+1])%mod;
    //outv(v);
    rep(i,n)ans=(ans+(n-1-i)*v[i])%mod;
    out(ans);
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll h,w,k;
  cin >> h >> w >> k;
  char s[h][w];
  rep(i,h){
    rep(j,w){
      cin >> s[i][j];
    }
  }
  char t[h][w];
  ll m,ans=0;
  for (int bit = 0; bit < (1<<h); ++bit) {
    for (int bit2 = 0; bit2 < (1<<w); ++bit2) {
      m=0;
      rep(i,h){
        rep(j,w){
          t[i][j]=s[i][j];
        }
      }
      rep(i,h){
        if (bit & (1 << i)) {
          rep(j,w){
            t[i][j]='.';
          }
        }
      }
      rep(i,w){
        if (bit2 & (1 << i)) {
          rep(j,h){
            t[j][i]='.';
          }
        }
      }
      rep(i,h){
        rep(j,w){
          if(t[i][j]=='#')m++;
        }
      }
      if(m==k)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;
const int MAX = 2*123500;

/** Problem0243 : Filling Game **/
typedef struct {
	char field[10][10];
	bool area[10][10];
	int cost;
} S;

int w, h;
string list = "RGB";
void bond(char f[10][10], bool b[10][10])
{
	bool vis[10][10];
	queue<P> Q;
	fill(vis[0], vis[0]+10*10, false);
	Q.push(P(0, 0));
	
	while (Q.size()) {
		P p = Q.front(); Q.pop();
		if (vis[p.first][p.second]) continue;
		else vis[p.first][p.second]=true;
		
		rep(i, 4) {
			int nx=p.first+dx[i], ny=p.second+dy[i];
			if_range(nx, ny, w, h) {
				if (f[nx][ny] == f[p.first][p.second]) {
					b[nx][ny] = true;
					Q.push(P(nx, ny));
				}
			}
		}
	}
}

int main()
{
	while (cin>>w>>h, h||w) {
		
		queue<S> Q;
		S first;
		
		rep(y, h) rep(x, w) {
			cin >> first.field[x][y];
			first.area[x][y]=false;
		}
		
		first.area[0][0]=true;
		bond(first.field, first.area);
		
		rep(y, h) rep(x, w) {
			rep(i, 4) {
				int nx=x+dx[i], ny=y+dy[i];
				if (0<=nx&&nx<w&&0<=ny&&ny<h&&first.area[x][y]&&first.field[0][0]==first.field[nx][ny])
					first.area[nx][ny]=true;
			}
		}
		
		first.cost = 0;
		Q.push(first);
		
		while (Q.size()) {
			S s = Q.front();
			
			bool flg=true;
			rep(y, h) {
				rep(x, w) {
					flg &= s.area[x][y];
				}
				if (!flg) break;
			}
			if (flg) {
				cout << s.cost << endl;
				break;
			}
			rep(i, 3) {
				if (s.field[0][0]==list[i]) continue;
				rep(y, h) rep(x, w) {
					if (s.area[x][y])
						s.field[x][y] = list[i];
				}
				bond(s.field, s.area);
				s.cost++;
				Q.push(s);
				s = Q.front();
			}
			Q.pop();
		}
	}
}

Measured memory_bytes: 51204
import java.util.*;
public class Main {
	static final int team = 3;
	static final int player = 8;
	
	public void doIt() {
		Scanner stdIn = new Scanner(System.in);
		Player[][] judge = new Player[3][8];
		
		for(int r = 0; r < team; r++) {             //データ読み込み
			for(int c = 0; c < player; c++) {
				int number = stdIn.nextInt();
				String time = stdIn.next();
				judge[r][c] = new Player(number, time);
			}
		}
		for(int r = 0; r < 3; r++)
			Arrays.sort(judge[r]); 
		
		Player[] temp = new Player[18];
		int count = 0;
		for(int r = 0; r < team; r++) {
			for(int c = 2; c < player; c++) {
				temp[count++] = judge[r][c];
			}
		}
		Arrays.sort(temp);
		
		for(int r = 0; r < team; r++) {
			for(int c = 0; c < 2; c++) {
				System.out.println(judge[r][c].getNumber() + " " + judge[r][c].getTime());
			}
		}
		for(int r = 0; r < 2; r++) {
			System.out.println(temp[r].getNumber() + " " + temp[r].getTime());
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

	class Player implements Comparable<Player>{
		private int number;
		private String time;
		
		public Player(int number, String time) {
			this.number = number;
			this.time = time;
		}
		
		public int getNumber() {
			return(number);
		}
		public String getTime() {
			return(time);
		}
		
		public void setNumber(int number) {
			this.number = number;
		}
		public void setTime(String time) {
			this.time = time;
		}
		
		@Override
		public int compareTo(Player o) {
			return(time.compareTo(o.time));
		}
	}
	
}

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

int main(void){
int a,b,k;
cin >> a;
cin >> b;
cin >> k;

for(int i=0;i<k;i++){
if(i%2==0){
    if(a%2==1){
        a--;
    }
    b=b+a/2;
    a=a/2;
} else {
    if(b%2==1){
        b--;
    }
    a=a+b/2;
    b=b/2;


}
}
cout <<a<<endl;
cout<<b<<endl;
return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  cout<<a-(a>b?1:0)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,a,b;
  cin>>n>>a>>b;
  int diff=abs(a-b);
  if(diff%2==1)cout<<"Borys"<<endl;
  else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
var
	N,i:Longint;
	p,A,T:int64;
begin
	read(N,p);
	T:=1000;
	for i:=2 to N do begin
		read(A);
		if p<A then begin
			T:=T mod p+T div p*A;
		end;
		p:=A;
	end;
	writeln(T);
end.

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int T, X;
  cin >> T >> X;
  cout << fixed << setprecision(57) << (double)T / X << "\n";

  return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 48 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 02:10:47
**/

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a, b, x; cin >> a >> b >> x;
    a % x == 0 ? cout << b / x - a / x + 1 << '\n' : cout << b / x - a / x << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	int a[3];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=1;i<=a[0];i++){
		int f=1;
		for(int j=0;j<n;j++)if(a[j]%i!=0)f=0;
		if(f)cout<<i<<endl;
	}
	return 0;
}


Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
int main(){
    bool pd[100]={0};
    char a[100];
    gets(a);
    for(int i=0;i<strlen(a);i++)
    {
        if(a[i]=='C')
        {
            pd[0]=1;
        }
        if(a[i]=='F'&&pd[0]==1)
        {
            pd[1]=1;
        }
    }
    if(pd[1])
    {
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
k,n=map(int,input().split())
h=list(map(int,input().split()))
l=[]
for i in range(n-1):
  l.append(h[i+1]-h[i])
l.append(h[0]+k-h[n-1])
ll=sorted(l,key=int,reverse=True)
print(k-ll[0])


Measured memory_bytes: 32232
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> friendlies(n);
    rep(i, n) cin >> friendlies[i];
    sort(friendlies.rbegin(), friendlies.rend());

    priority_queue<ll> q;
    q.push(friendlies[1]);
    q.push(friendlies[1]);

    ll ans = friendlies[0];
    friendlies.erase(friendlies.begin());
    friendlies.erase(friendlies.begin());

    for (ll f :  friendlies) {
        ans += q.top();
        q.pop();
        q.push(f);
        q.push(f);
    }

    cout << ans << endl;

}


Measured memory_bytes: 6932
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define PI acos(-1.0)
typedef long long ll;

using namespace std;

int n,a[110];
void fun()
{
	int b,j;
	for(int i=1;i<n;i++)
	{
		b=a[i];
		j=i-1;
		while(j>=0&&a[j]>b)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=b;
		for(int i=0;i<n;i++)
		{
			if(i>0) printf(" ");
			printf("%d",a[i]);
		}
		printf("\n");
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
	{
		if(i>0) printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
	fun();
	return 0;
}

Measured memory_bytes: 3224
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let N = S.len();
    let ans = (0..N).filter(|&i| S[i] != S[N - i - 1]).count() / 2;

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

Measured memory_bytes: 4352
A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
B = [int(input()) for _ in range(n)]

bingo = [[False, False, False] for _ in range(3)]

for i in range(3):
    for j in range(3):
        for b in B:
            if (A[i][j] == b):
                bingo[i][j] = True


flag = False
for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2]:
        flag = True
    if bingo[0][i] and bingo[1][i] and bingo[2][i]:
        flag = True

if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    flag = True

if bingo[2][0] and bingo[1][1] and bingo[0][2]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int count = 0;
  bool ans = 0;
  rep(i, k) {
    if (b > a) break;
    b *= 2;
    count = i + 1;
  }
  REP(i, count, k) {
    if (c > b) break;
    c *= 2;
    count = i + 1;
  }
  if ((b > a && c > b) && count <= k) ans = 1;
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3552
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		read().stream()//
				.map(new Main()::execute)//
				.forEach(System.out::println);
	}

	private static List<Integer> read() {
		Scanner sc = new Scanner(System.in);

		int q = sc.nextInt();
		List<Integer> valueList = new ArrayList<>();
		for (int i = 0; i < q; i++) {
			valueList.add(sc.nextInt());
		}

		sc.close();
		return valueList;
	}

	public int execute(int originalValue) {
		return execute(originalValue, new HashSet<>());
	}

	public int execute(int originalValue, Set<Integer> valueSet) {
		if (originalValue < 10) {
			return valueSet.size();
		} else if (valueSet.contains(originalValue)) {
			return -1;
		} else {
			valueSet.add(originalValue);
			return execute(next(originalValue).getAsInt(), copy(valueSet));
		}
	}

	private <T> Set<T> copy(Set<T> source) {
		Set<T> dest = new HashSet<T>();
		dest.addAll(source);
		return dest;
	}

	private OptionalInt next(int value) {
		String str = String.valueOf(value);
		return IntStream.range(1, str.length())//
				.map(i -> Integer.parseInt(str.substring(0, i)) * Integer.parseInt(str.substring(i))).max();
	}
}

Measured memory_bytes: 38820
N, M = map(int, input().split())
a = [10**18] + sorted(map(int, input().split()), reverse=True)


def solve(x):
   count = 0
   j = N
   for i in range(1, N+1):
      while a[i] + a[j] < x:
         j -= 1
      count += j
   
   return count


left, right = 0, 10**18
while left < right - 1:
   mid = (left + right) // 2
   if solve(mid) >= M:
      left = mid
   else:
      right = mid

acc = a[:]
acc[0] = 0
for i in range(N):
   acc[i+1] += acc[i]

ans = 0
j = N
for i in range(1, N+1):
   while a[i] + a[j] < left+1:
      j -= 1
   ans += a[i]*j + acc[j]
   M -= j

if M:
   ans += left * M

print(ans)

Measured memory_bytes: 55356
s = input()
b = ""
f = ""
change_flag = 1
for i in range(int(input())):
    a = input().split(" ")
    if(a[0] == "1"):
        change_flag *= -1
    else:
        if((a[1] == "1" and change_flag == 1) or (a[1] == "2" and change_flag == -1)):
            b = a[2] + b
        else:
            f = f + a[2]

if(change_flag == -1):
    print(f[::-1]+s[::-1]+b[::-1])
else:
    print(b+s+f)


Measured memory_bytes: 4516
using System;
using System.Collections;
using System.Linq;

class Prog
{
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] Tstrings = Console.ReadLine().Split(' ');
        int[] Ts = new int[N];
        for(int i = 0;i < N;i++)
        {
            Ts[i] = int.Parse(Tstrings[i]);
        }
        int Ss = 0;
        for(int i = 0;i < N;i++)
        {
            Ss = Ss + Ts[i];
        }

        int M = int.Parse(Console.ReadLine());
        for(int i = 0;i < M;i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            int P = int.Parse(input[0]) - 1;
            int X = int.Parse(input[1]);

            Console.WriteLine(Ss - Ts[P] + X);
        }
    }
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2!=0){
    cout << "No" << endl;
  }else{
    for(int i=0;i<N/2;i++){
      if(S[i]!=S[N/2+i]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int p=0;
    long long t=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        a[i]=s;
        t+=s;
    }
    if(n==2){
        cout<<abs(a[0]-a[1])<<endl;
        return 0;
    }
    long long ans=1000000000;
    for(int i=0;i<n-1;i++){
        t-=2*a[i];
        if(ans>abs(t)){
            ans=abs(t);
            p=abs(t);
        }
    }
    cout<<p<<endl;
}


Measured memory_bytes: 1024
n,Y=map(int,input().split())
for i in range(n+1):
  y=(Y-1000*n-9000*i)//4000
  if (Y-1000*n-9000*i)%4000==0 and y>=0 and y<=n and n-i-y>=0 and n-i-y<=n:
    print("{} {} {}".format(i,y,n-i-y))
    exit()
print("{} {} {}".format(-1,-1,-1))

Measured memory_bytes: 3064
using System;

namespace _0362
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] tramp = new int[n];
            for (int i = 0; i < n; i++) tramp[i] = int.Parse(Console.ReadLine());
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                if (i * 10 <= max) max = Math.Max(max,i * 10 + tramp[i]);
            }
            if (max >= (n - 1) * 10)
            {
                int min = (n - 1) * 10;
                for (int i = 0; i < n; i++)
                {
                    int a = n - i - 1;
                    if (min <= a * 10) min = Math.Min(min,a * 10 - tramp[a]);
                }
                Console.WriteLine(min <= 0 ? "yes" : "no");
            }
            else Console.WriteLine("no");
        }
    }
}


Measured memory_bytes: 11408
#include <cstring>
#include <string>
#include <memory>
#include <iostream>

/**
@note prime number and less than 1,000,000
*/
constexpr int max_size()
{
    return 1000003;
}

constexpr int null_val()
{
    return -1;
}

class dictionary {
public:
    dictionary()
        : _data(std::make_unique<int[]>(max_size()))
    {
        for (int i = 0; i < max_size(); ++i) {
            _data[i] = null_val();
        }
    }

    void insert(const std::string& str) {
        return insert(str2key(str), 0);
        return;
    }

    bool find(const std::string& str) {
        return find(str2key(str), 0);
    }

private:
    int str2int(const char ch) {
        if (ch == 'A') {
            return 1;
        }
        if (ch == 'C') {
            return 2;
        }
        if (ch == 'G') {
            return 3;
        }
        if (ch == 'T') {
            return 4;
        }
        return 0;
    }

    int str2key(const std::string& str)
    {
        int sum = 0;

        for (std::size_t i = 0; i < str.size(); ++i) {
            sum += str2int(str[i]);
            sum *= 5;   //move up;
        }
        
        return sum;
    }

    int base_hash(const int key) const
    {
        return key % max_size();
    }

    int collision_hash(const int key) const
    {
        constexpr int modulo = max_size() + 1;
        return 1 + key % modulo;
    }

    int create_hash(const int key, const int r) const 
    {
        const int base = base_hash(key);
        const int collision = collision_hash(key);
        const int h = (base + r * collision) % max_size();
        return h;
    }

    void insert(const int key, const int r)
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            _data[h] = key;
            return;
        }
        if (_data[h] == key) {
            return;
        }

        insert(key, r + 1);
        return;
    }

    bool find(const int key, const int r) const
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            return false;
        }
        if (_data[h] == key) {
            return true;
        }

        return find(key, r + 1);
    }

    bool is_empty(const int idx) const {
        return _data[idx] == null_val();
    }

private:
    std::unique_ptr<int[]> _data;
};

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

    int n;
    std::cin >> n;
    std::cin.ignore();

    dictionary dict;
    std::string buf;
    for (int i = 0; i < n; ++i) {
        getline(std::cin, buf);
        if (buf.front() == 'i') {
            static const std::size_t size = strlen("insert ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            dict.insert(val);
        }
        else {
            static const std::size_t size = strlen("find ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            if (dict.find(val)) {
                std::cout << "yes" << std::endl;
            }
            else {
                std::cout << "no" << std::endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 6804
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R') {
		cout << 3 << endl;
	} else if ((S[0] == 'R' && S[1] == 'R') || (S[1] == 'R' && S[2] == 'R')) {
		cout << 2 << endl;
	} else if (S[0] == 'R'|| S[1] == 'R' || S[2] == 'R') {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
}



Measured memory_bytes: 3636
#include <iostream>

int main()
{
	int n, x;
	std::cin >> n >> x;

	int cont = 0;

	while (n + x > 0) {
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
					for (int k = j + 1; k <= n; k++) {
							if (i + j + k == x) {
								cont++;
							}
					}
			}
		}
		std::cout << cont << std::endl;
		
		std::cin >> n >> x;
		cont = 0;
	}
}

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

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

for cx in range(101):
    for cy in range(101):
        H = abs(cx - x[u]) + abs(cy - y[u]) + h[u]
        ok = True
        for i in range(n):
            ok &= max(H - abs(cx - x[i]) - abs(cy - y[i]), 0) == h[i]
        if ok:
            print(cx, cy, H)


Measured memory_bytes: 3064
X = int(input())

num_105 = X // 105
for i in range(num_105 + 1):
    remain_money_105 = (X - 105 * i)
    num_104 = remain_money_105 // 104
    for j in range(num_104 + 1):
        remain_money_104 = remain_money_105 - 104 * j
        num_103 = remain_money_104 // 103
        for k in range(num_103 + 1):
            remain_money_103 = remain_money_104 - 103 * k
            num_102 = remain_money_103 // 102
            for l in range(num_102 + 1):
                remain_money_102 = remain_money_103 - 102 * l
                num_101 = remain_money_102 // 101
                for m in range(num_101 + 1):
                    remain_money_101 = remain_money_102 - 101 * m
                    if remain_money_101 % 100 == 0:
                        print(1)
                        exit()
print(0)


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,i,j,k;
    ll arr[]={600,800,1000,1200,1400,1600,1800};
    cin>>n;
    for(i=0;i<7;i++)if(n<arr[i])break;
    cout<<8-i;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int n,x,m[1005],sum,MIN=1005,ans;
int main() {
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>m[i];
		sum+=m[i];
		MIN=min(MIN,m[i]);
	}
	ans=n+(x-sum)/MIN;
	cout<<ans<<endl;
}

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

int a,b;

int main()
{
	cin>>a>>b;
	if(b>=a)
	{
		printf("%d\n",a);
	}
	else
	{
		printf("%d\n",a-1);
	}
}

Measured memory_bytes: 256
def solve(string):
    n, *a = map(int, string.split())
    a = ("{:060b}".format(_a) for _a in a)
    m = 10**9 + 7
    ans = 0
    for s in map(lambda x: x.count("1"), zip(*a)):
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 70380
#include <bits/stdc++.h>
using namespace  std;
const int N=3e3+10;
double f[N][N],p[N];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lf",&p[i]);
	f[0][0]=1,f[1][0]=1.0-p[1];
	double ans=0.000000000;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(!j)f[i][j]=f[i-1][j]*(1-p[i]);
			f[i][j]=f[i-1][j-1]*p[i]+f[i-1][j]*(1.0-p[i]);

		}
	}
	for(int i=n/2+1;i<=n;i++)ans+=f[n][i];
	printf("%.10f",ans);
    return 0;
}


Measured memory_bytes: 49880
/// TOP-DOWN - RECURSIVA;

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

int pedras[100100];
long long dp[100100]; ///Guardo os valores da funcao frog;

int n,k;
const int inf =1e9;

int frog2(int i,int j){

    if(dp[i] != -1){
        return dp[i];
    }

    int menor = inf;

    if(i>=j) return dp[i]=0;

    ///**OUU ASSIM COM ESSE MEU FOR ,,
    /*
    for(int x=1;x<=k;x++){
        if(i+x <= j){
            long long cost = (frog2(i+x,j)+ abs(pedras[i]-pedras[i+x]));

            if(cost < menor){
                menor = cost;
            }
        }
    }*/

    ///**OUU ASSIM COM OQ VI NA NET,,

    for(int x=1;x<=k;x++){
        if(i+x <= j){
            int cost = (frog2(i+x,j)+ abs(pedras[i]-pedras[i+x]));
            menor = min(menor,cost);
        }
    }

    return dp[i] = menor;
}

int main(){

    memset(dp,-1,sizeof(dp));

    cin >>n>>k;

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

    cout<<frog2(0,n-1)<<endl;
}
/**/


Measured memory_bytes: 12544
#include<stdio.h>
int main(){
  int m,nmi,nma,i,a[200],g[2];
  while(1){
    g[0]=0;
    scanf("%d%d%d",&m,&nmi,&nma);
    if(m==0&&nmi==0&&nma==0)break;
    for(i=0;i<m;i++){
      scanf("%d",&a[i]);
      if(i>=nmi&&nma>=i){ 
	if(a[i-1]-a[i]>=g[0]){
	  g[0]=a[i-1]-a[i];
	  g[1]=i+1;
	}
      }
    }
    printf("%d\n",g[1]-1);
  }
  return 0;
}
      

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;

#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define present(c,x) 	((c).find(x) != (c).end())
#define rep(i,n)        for(ll i=0LL; i<(n); i++)

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

//Maths functions
ll Digit(ll N){ll res=0;while(N) res++, N/=10;return res;}
ll Gcd(ll a,ll b){ return b?Gcd(b,a%b):abs(a); }


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

	ll n;
	cin>>n;
	string s;
	std::map<string, ll> mp;
	for(ll i=0; i<n;i++)
	{
		cin>>s;
		mp[s] +=1;
	}
	ll m=0;
	for(auto it=mp.begin(); it!= mp.end(); it++)
	{
		ll x= it->second;
		m =max(m,x);
	}
	for(auto it=mp.begin(); it!= mp.end(); it++)
	{
		if(it->second == m)
			cout<<it->first<<endl;
	}
	return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

bool red[100001];
vector<ll> vec(100001,1);

void solve(long long N, long long M, vector<long long> x, vector<long long> y){
	red[0] = true;
	rep(i,M) {
		if (red[x[i]]) red[y[i]] = true;
		vec[x[i]]--;
		if (vec[x[i]] == 0) red[x[i]] = false;
		vec[y[i]]++;
	}
	ll res = 0;
	rep(i,N) {
		if (red[i]) res++;
	}
	cout << res << endl;
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> y(M-1+1);
	vector<long long> x(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
		x[i]--;
		y[i]--;
	}
	solve(N, M, x, y);
	return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using Double = long double;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
int main() {
    int n;
    cin >> n;
    auto P = vector<vector<Double>>(n, vector<Double>(n + 1));
    rep(i, n) {
        Double p;
        cin >> p;
        if (i == 0) {
            P[0][0] = 1 - p;
            P[0][1] = p;
        } else {
            for (int j = 0; j <= i + 1; j++) {
                if (j == 0) {
                    P[i][0] = (1 - p) * P[i - 1][0];
                } else {
                    P[i][j] = (1 - p) * P[i - 1][j] + p * P[i - 1][j - 1];
                }
            }
        }
    }
    Double sum = 0;
    for (int j = n / 2 + 1; j <= n; j++) {
        sum += P[n - 1][j];
    };
    cout << fixed << setprecision(10);
    cout << sum << endl;
}


Measured memory_bytes: 141056
#include "stdio.h"
#include "iostream"
#include "vector"
#include "algorithm"
#include "iomanip"
#include "map"
#include "set"
#include "bitset"
#include "queue"
#include "string.h"
#include "math.h"
#include "numeric"

using namespace std;
using LL = long long;


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

    string z = "keyence";
    int a = 0, b = 6, aa = 0, bb = s.size() - 1;
    int x = 0, c = 0;

    while (a <= b) {
        if (a < 7 and bb < (int) s.size() and z[a] == s[aa]) a++, aa++, c++;
        if (b >= 0 and bb >= 0 and z[b] == s[bb]) b--, bb--, c++;
        x ++;
        if (c >= 7) break;
        if (x >= 10) return !printf("NO");
    }

    puts("YES");
}

Measured memory_bytes: 256