akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

// vector vの中のn以下の数で最大のものを返す
int bs(vector<int> &v, int x){
    int ok = -1; //これがx以下 
    int ng = v.size(); //x以上 
    // 問題によってokとngを入れ替える
    while(abs(ok - ng) > 1){
        int mid = (ok + ng)/2;
        if(v[mid] <= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    
    string s;
    string t;
    cin>>s>>t;
    map<int,vector<int> > m;
    rep(i,s.size())m[s[i]].pb(i);
    rep(i,s.size())m[s[i]].pb(i+s.size());
    irep(i,m)Sort(i->second);
    ll ans=0;
    int b=0;
    rep(i,t.size()){
        if(m.find(t[i])==m.end()){
            fin(-1);
            return 0;
        }
        b=*lower_bound(m[t[i]].begin(),m[t[i]].end(),b)+1;
        if(b>=(int)s.size()){
            b-=(int)s.size();
            ans+=(int)s.size();
        }
    }
    ans+=b;
    fin(ans);

}


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

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }

	constexpr ModInt getOne() const
	{
		return ModInt(1ll);
	}
	constexpr ModInt getZero() const
	{
		return ModInt(0ll);
	}
};

////////////////
// 組み合わせ //
///////////////

template<int64_t mod_ = 1'000'000'007, int max_ = 200'000>
class Combination {
public:
	std::array<ModInt<mod_>, max_ + 1> inv, fact, finv;

	Combination()
	{
		inv[0] = inv[1] = fact[0] = fact[1] = finv[0] = finv[1] = 1;
		for (int num{2}; num <= max_; num++)
		{
			inv[num] = (mod_ - (int64_t)inv[mod_ % num] * (mod_ / num) % mod_) % mod_;
			fact[num] = num * fact[num - 1] % mod_;
			finv[num] = inv[num] * finv[num - 1] % mod_;
		}
	}

	ModInt<mod_> getCombi(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[r] * finv[n - r];
	}

	ModInt<mod_> getPerm(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[n - r];
	}
};
constexpr int64_t mod{998'244'353};
Combination<mod, 3'000'000> combi;
using Mint = ModInt<mod>;

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	// 3*M+N-1 C N-1 - (M+N-1 C N-1 - M+N-2 C N-2) * N
	Mint ans;
	for (int i{M & 1}; i <= N && i <= M; i += 2)
		ans += combi.getCombi(N, i) * combi.getCombi((3 * M - i) / 2 + N - 1, N - 1);
	ans -= (combi.getCombi(M + N - 1, N - 1) - combi.getCombi(M + N - 2, N - 2)) * Mint(N);
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 70656
n=gets.to_i
p=gets.chomp.split(" ").map(&:to_i)

ans=0
min=p[0]
(n-1).times do|i|
  if min>=p[i]
    ans+=1
  end
  min=(min>p[i]) ? p[i] : min
end
puts ans+((min>=p[n-1]) ? 1 : 0)


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

// http://tsutaj.hatenablog.com/entry/2017/03/30/224339
constexpr int INF = INT_MAX;
struct LazySegmentTree {
 private:
  int n;
  vector<int> node, lazy;
  vector<bool> lazyFlag;

 public:
  LazySegmentTree(vector<int> v) {
    int sz = (int)v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1);
    lazy.resize(2 * n - 1, INF);
    lazyFlag.resize(2 * n - 1, false);

    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
  }

  void lazyEvaluate(int k, int l, int r) {
    if (lazyFlag[k]) {
      node[k] = lazy[k];
      if (r - l > 1) {
        lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
        lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
      }
      lazyFlag[k] = false;
    }
  }

  void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    lazyEvaluate(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = x;
      lazyFlag[k] = true;
      lazyEvaluate(k, l, r);
    } else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
  }

  int find(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    lazyEvaluate(k, l, r);
    if (b <= l || r <= a) return INF;
    if (a <= l && r <= b) return node[k];
    int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
};

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

  vector<LazySegmentTree> st(2, LazySegmentTree(vector<int>(n, n - 2)));

  ll r = ll(n - 2) * ll(n - 2);
  while (q--) {
    int k, x;
    cin >> k >> x;
    k -= 1;
    x -= 2;
    int y = st[k].find(x, x + 1);
    r -= y;
    if (x < st[1 - k].find(0, y)) st[1 - k].update(0, y, x);

    // cerr << k << " " << x << ": " << y << endl;
  }
  cout << r << endl;
}


Measured memory_bytes: 16408
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
#define pb(v,e) v.push_back(e)
#define ms(a,v) memset(a,v,sizeof(a))
#define cp(a,b,n) rep(i,n)a[i] = b[i]

string sint(int i){
   stringstream buf;
   buf<<i;
   return buf.str();
}

/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/
int r,c;

int main(){
   while(scanf("%d %d",&r,&c) != EOF , r && c){
      if ( r%2 == 0 || c%2 == 0){
         printf("yes\n");
      }else{
         printf("no\n");
      }
   }
   return 0;
}

Measured memory_bytes: 1172
N = int(input())
def d(n):
  if n % 2 == 1:
    return 0
  elif n % 4 == 0:
    return 2
  elif n % 2 == 0:
    return 1
  else:
    return 0
  
dic = {0:0, 1:0, 2:0}
for a in [int(x) for x in input().split()]:
  dic[d(a)] += 1
ret = 'No'
c = 1
if dic[1]:
  c = 0
if dic[0] <= dic[2] + c:
  ret = 'Yes'
print(ret)

Measured memory_bytes: 14252
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var first=Arr.shift().split(":");
   first=first[1].slice(0,-1).split(",");
   var F={};
   first.forEach(function(v){F[v]=true;});
   var obj={};
   for(var i=0;i<n-1;i++){
      var arr=Arr.shift().split(":");
      obj[arr[0]]=arr[1].slice(0,-1).split(",");
   }
   var L=0;
   while(true){
      if(L==Object.keys(F).length)break;
      L=Object.keys(F).length;
      for(var k in F){
         if(obj.hasOwnProperty(k) && F[k]){
            obj[k].forEach(function(v){F[v]=true;});
            F[k]=false;
         }
      }
   }
   var cnt=0;
   for(var k in F)if(obj.hasOwnProperty(k)==false)cnt++;
   console.log(cnt);
}

Measured memory_bytes: 11636
// AOJ 2353 Four Arithmetic Operations
// 2017.11.27 bal4u@uu

#include <stdio.h>
#define LIM 2147483648LL
#define P   4294967311LL		// ???= 0x???10000000F??¬??¬, prime number??¬
#define P2  4294967309LL		// = P-2
#define M1	20					// 2^20 = 0x100000 = 1048576
#define M2  0xfffff				// = 2^20 -1

#define multi(x,y)	(((((x)*((y)>>M1)%P)<<M1)+(x)*((y)&M2))%P)

char buf[15], *p;
int getint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

#if 0
long long multi(long long x, long long y)
{
	return (((x*(y>>M1)%P)<<M1) + x*(y&M2)) % P;
}
#endif

long long power(long long y, long long m)
{
   long long s = 1;
   long long d = y % P;

   while (m > 0) {
      if (m & 1) s = multi(s, d);
      m >>= 1;
      d = multi(d, d);
   }
   return s;
}

int main()
{
	int n, c, y;
	long long x;

	fgets(p=buf, 10, stdin), n = getint();
	x = 0;
	while (n--) {
		fgets(p=buf, 15, stdin);
		c = *p, p+=2, y = getint();
		if (c == '1') {
			x += y; if (x < 0) x += P; if (x >= P) x -= P;
		} else if (c == '2') {
			x -= y; if (x < 0) x += P; if (x >= P) x -= P;
		} else if (c == '3') {
			if (y < 0) x = multi(x, (P+y));
			else       x = (x*y) % P;
		} else {  // div
			if (y < 0) x = multi(x, power(P+y, P2));
			else       x = multi(x, power(y,   P2));
		}
	}
	if (x >= LIM) x -= P;
	printf("%lld\n", x); 
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

struct Op {
    int num, val;

    bool operator<(const Op& op) const {
        return val != op.val ? val > op.val : num > op.num;
    }
};

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

    int n, m;
    cin >> n >> m;

    priority_queue<int> pq;
    rep(_, 0, n) {
        int x;
        cin >> x;
        pq.push(-x);
    }

    // O(m * log(m))
    vector<Op> op(m);
    rep(i, 0, m) { cin >> op[i].num >> op[i].val; }
    sort(all(op));

    // O(n)
    vi b(n, 0);
    int i = 0;
    rep(j, 0, m) {
        rep(_, 0, op[j].num) {
            b[i++] = op[j].val;
            if (i >= n) { break; }
        }
        if (i >= n) { break; }
    }

    // O(n * log(n))
    rrep(i, 0, n) {
        int x = -pq.top();
        pq.pop();
        pq.push(-max(x, b[i]));
    }

    // O(n * log(n))
    ll ans = 0;
    while (!pq.empty()) {
        ans -= (ll)pq.top();
        pq.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    int s;
    cin>>s;
    int n=s/100; //mae
    int m=s%100; //usiro

    if(n==0){
        if(m>0 && m<=12){
            cout<<"YYMM"<<endl;
        }
        else cout<<"NA"<<endl;
        return 0;
    }
    if(m==0){
        if(n>0 && n<=12){
            cout<<"MMYY"<<endl;
        }
        else cout<<"NA"<<endl;
        return 0;
    }


    if(n>12 && m>12){
        cout<<"NA"<<endl;
        return 0;
    }
    if(n>12 && m<=12){
        cout<<"YYMM"<<endl;
    }
    else if(m>12 && n<=12){
        cout<<"MMYY"<<endl;
    }
    else cout<<"AMBIGUOUS"<<endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,a,b,c;
	int i,j,k;
	int t=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&x);
	for(i=0;i<=a;i++)
	{
		for(j=0;j<=b;j++)
		{
			for(k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==x)
				{
					t++;
				}
			}
		}
	}
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int inf = 100000;

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	vector<vector<int>> w;
	w.resize(inf + 10);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		w[a].push_back(b);
	}


	long int r = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j < w[i].size(); j++) {
			q.push(w[i][j]);
		}

		if (!q.empty()) {
			r += q.top();
			q.pop();
			//cerr << "day: " << i << " r: " << r << endl;
		}
	}

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 5632
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n-1):
    if (p[i-1]<p[i] and p[i]<p[i+1]) or (p[i-1]>p[i] and p[i]>p[i+1]):
        count+=1
print(count)

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

typedef long long ll;
using ll = long long;

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

    int n;cin>>n;
    priority_queue<ll,vector<ll>,greater<ll>> q;
    ll su=0;
    vector<ll> a(3*n),ma(3*n),mi(3*n);
    for(int i=0;i<3*n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        q.push(a[i]);
        su+=a[i];
        ma[i]=su;
    }
    for(int i=n;i<2*n;i++){
        q.push(a[i]);
        su+=a[i];
        su-=q.top();q.pop();
        ma[i]=su;
    }
    priority_queue<ll> q2;
    su=0;
    for(int i=3*n-1;i>=2*n;i--){
        q2.push(a[i]);
        su+=a[i];
        mi[i]=su;
    }
    for(int i=2*n-1;i>=n;i--){
        q2.push(a[i]);
        su+=a[i];
        su-=q2.top();q2.pop();
        mi[i]=su;
    }
    ll res=-1000000000000000;
    for(int i=n-1;i<2*n;i++){
        res=max(res,ma[i]-mi[i+1]);
        //cout<<i<<" "<<ma[i]<<" "<<mi[i+1]<<endl;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 9588
#include<iostream>
using namespace std;
int main(){
  int N;
  int *p;
  int ans=0,a=0;
  cin>>N;
  p=new int [N];
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  a=p[0];
  for(int i=0;i<N;i++){
    if(a<=p[i]){
      ans++;
      a=p[i];
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
//
//  ITP1_2.cpp
//  
//
//  Created by anthony on 2015/06/15.
//
//

#include <stdio.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
using namespace std;

int main(){
    int a, b;
    int sum, seki;
    cin >> a >> b;
    sum = 2 * a + 2 * b;
    seki = a * b;
    cout << seki << " "<< sum << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <algorithm>
using namespace std ;
int main(){
    int A, B, c, d ;
    cin >> A >> B ;
    if(A > B){
        c = A + B ;
        if(c%2 == 0){
            cout << c/2 << endl ;
        }
        else{
            cout << "IMPOSSIBLE" << endl ;
            }
    }
    else{
        c = B + A ;
        if(c%2 == 0){
            cout << c/2 << endl ;
        }
        else{
            cout << "IMPOSSIBLE" << endl ;
            }
    }
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);




ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(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;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}


ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}



/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //ll N=262144;
  //vll segtree(2*N-1);
  st s,t,u;
    cin>>s>>t>>u;
  cout<<s[0]<<t[0]<<u[0]<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define make_pair MP
#define MOD 1000000007
#define MAXM 100005
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;

}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

int gcd(int a, int b, int& x, int& y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d = gcd(b%a, a, x1, y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return d;
}

int arr[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll p=n-1;
    ll sum=p*(p+1);
    sum=sum/2;
    cout<<sum;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long a[n], sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i]; sum += a[i];
    }
    int mini = 1e9, ans = -1;
    for (int i = 0; i < n; i++) {
        if (mini > abs(a[i] * n - sum)) {
            mini = abs(a[i] * n - sum);
            ans = i;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main(void){
    int n, k;
    cin >> n >> k;
    
    set<int> st;
    
    for (int i = 0; i < k; i++){
        int d;
        cin >> d;
        
        for (int j = 0; j < d; j++){
            int a;
            cin >> a;
            st.insert(a);
        }
    }
    
    int number = (int)st.size();
    int ans = n - number;
    cout << ans << endl;
}

Measured memory_bytes: 3608
def main():
    N = int(input())
    numlist = list(map(int,input().split()))

    count = 0

    for i in range(len(numlist)):
        if (i+1) % 2 == 1:
            if numlist[i] % 2 == 1:
                count += 1
    
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include <stdio.h>

int A[30], n;

int judge(int i, int m) {
	if ( m == 0 ) return 1;
	if ( i > n ) return 0;
	int res = judge(i+1,m) || judge(i+1, m-A[i]);
	return res;
}

int main() {
	int q, m;
	scanf("%d", &n);
	for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
	scanf("%d", &q);
	for ( int i = 0; i < q; i++ ) {
		scanf("%d", &m);
		if ( judge(0, m) ) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2680
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;

const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,-1,0,1 };
const int LIT = 1e9 + 7;
int n, m;

void solve() {
    string x;
    cin >> x;
    int sum = 0;
    for (int i = 0; i < x.length(); i++) {
        sum += x[i] - '0';
    }
    if (sum % 9 == 0) cout << "Yes\n";
    else cout << "No\n";

}

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


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define end "\n"
#define endl "\n"
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int main() {
    io;
    cout.precision(20);

    
  
int n;
string s,t;
cin>>n;
cin>>s>>t;
// cout<<s<<"  "<<t<<endl;
 rep(i,0,n){
    //  cout<<i<<endl;
     cout<<s[i]<<t[i];
 }
 
 
    
 
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#define ll long long int
using namespace std;
const int maxn=300005;
int N,A,B;
int res[maxn];
int main()
{
	int con;
	bool flag=true,change=false;
	cin>>N>>A>>B;
	if (B>N-A+1||(ll)A*(ll)B<(ll)N)cout<<-1<<endl;
	else
	{
		for (int i=N-A+1;i<=N;i++)cout<<i<<" ";
		while (1)
		{
			N-=A;
			B--;
			if (!N&&!B)break;
			A=N%B==0?N/B:N/B+1;
			for (int i=N-A+1;i<=N;i++)cout<<i<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void start(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("input.txt","r")){
        freopen ("input.txt" , "r" , stdin);
        freopen ("output.txt" , "w" , stdout);
    }
    #endif
}
signed main(){
    start();

    string s,t;
    cin>>s>>t;
    int flag = 1;
    if(t.length()-s.length() == 1){
        for(int i=0;i<s.length();i++){
            if(s[i] != t[i]){
                flag = 0;
            }
        }
        if(flag == 1){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    else{
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 3640
def bubbleSort(A,N):
    global cnt
    flag=1
    while flag:
        flag=0
        for j in range(N-1,0,-1):
            if A[j]<A[j-1]:
                A[j],A[j-1]=A[j-1],A[j]
                flag=1
                cnt+=1
N = int(input())
A = list(map(int,input().split()))
cnt = 0
bubbleSort(A,N)
print(*A)
print(cnt)


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

struct s{
	ll index;
	ll value;
	bool operator <(const s& rhs) const{
		return value < rhs.value;
	}
};

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ll n,m;
    cin >> m >> n;
    vector <ll> arr(n);
    vector 
 diff(n);
    vector <bool> split(n,false);
    split[0] = true; 
    for (int z=0;z<n;z++) cin >> arr[z];
    sort(arr.begin(),arr.end());
    for (int z=1;z<n;z++){
    	diff[z].index = z;
    	diff[z].value = abs(arr[z]-arr[z-1]);
    }
    sort(diff.rbegin(),diff.rend());
    for (int z=0;z<m-1 && z<n;z++){
    	split[diff[z].index] = true;
    }
    ll answer = 0;
    ll current = arr[0];
    for (int z=1;z<n;z++){
    	if (split[z]) {
    		answer += arr[z-1]-current;
    		current = arr[z];
    	}
    }
    answer += arr[n-1]-current;
	cout << answer << endl;
	cin >> n;
}


Measured memory_bytes: 2560
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

def clcdis(i, j, x, y):
    return abs(i-x) + abs(j-y)

ansi = 0
ansj = 0
ansh = 0

flgBreakI = False

for i in range(rng):
    for j in range(rng):
        flg = True
        tmp = 0
        hmax = 10**10

        for k in range(n):
            if data[k][2] == 0:
                hmax = min(hmax, clcdis(i, j, data[k][0], data[k][1]))
            else:
                if tmp == 0:
                   tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
                else:
                    if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                        flg = False
                        break

        if flg and tmp <= hmax:
            ansi = i
            ansj = j
            ansh = tmp
            flgBreakI = True
            break

    if flgBreakI:
        break

print(ansi, ansj, ansh)




Measured memory_bytes: 14140
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> places;
  places.reserve(M);
  
  for (int m = 0; m < M; ++m) {
    int p;
    cin >> p;
    places.push_back(p);
  }
  sort(places.begin(), places.end());
  
  vector<int> distances;
  for (int i = 1; i < M; ++i) {
    distances.push_back(places[i] - places[i-1]);
  }
  sort(distances.begin(), distances.end());
  
  int res = 0;
  for (int i = 0; i < M-N; ++i) {
    res += distances[i];
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>

int main(){
	int a,b,c;
	int i,j=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=0; i<b-a+1; i++){
		if(c%(a+i) == 0){
			j++;
		}
	}
	printf("%d\n",j);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector <int> a(3*n);
    for(int i=0;i<3*n;i++){
        cin >> a[i];
    }
    vector <ll> pre(3*n),suf(3*n);
    multiset <ll, greater<ll>> s;
    ll sum=0;
    for(int i=0;i<3*n;i++){
        s.insert(a[i]);
        sum+=a[i];
        while(s.size()>n){
            sum-=*s.rbegin();
            s.erase(prev(s.end()));
        }
        pre[i]=sum;
    }
    sum=0;
    multiset <ll> sm;
    for(int i=3*n-1;i>=0;i--){
        sm.insert(a[i]);
        sum+=a[i];
        while(sm.size()>n){
            sum-=*sm.rbegin();
            sm.erase(prev(sm.end()));
        }
        suf[i]=sum;
    }
    long long ans=LONG_LONG_MIN;
    for(int i=n-1;i<2*n;i++){
        ans=max(ans,pre[i]-suf[i+1]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, m, sum, ans;
  string a[101], b[101];
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  cin >> m;
  for(int i=0;i<m;i++) {
    cin >> b[i];
  }
  for(int i=0;i<n;i++) {
    sum=0;
    for(int j=0;j<n;j++) {
      if(a[i]==a[j]) sum+=1;
    }
    for(int h=0;h<m;h++) {
      if(a[i]==b[h]) sum-=1;
    }
    if(sum < 0) sum=0;
    ans = max(sum,ans);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep_b(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;

int main()
{
	int K,N,now,min,i;
	cin >> K >> N;
	vector<int> A(N),B(N);
	min = K;
	rep(i, N)
	{
		cin >> A[i];
	}
		rep(i, N-1)
	{
		B[i] = A[i + 1] - A[i];
	}
	B[N-1] = A[0] + (K - A[N-1]);
	rep(i, N) {
		now = K - B[i];
		if (min > now)
			min = now;
	}
	cout << min << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <array>
#include <vector>
#include <cmath>
using namespace std;

const int D=200;
const int N=200;

struct Clothes{
    int max_t;
    int min_t;
    int c;
};

int main(){
    int d,n;
    array<array<int,N>,D> dp;
    vector<Clothes> clt;
    vector<int> tmp;

    cin>>d>>n;

    tmp.resize(d);

    for( auto &t : tmp ) cin>>t;

    clt.resize(n);

    for( auto &t : clt ) cin>>t.min_t>>t.max_t>>t.c;

    for( auto &x : dp ){
        for( auto &y : x ){
            y=0;
        }
    }

    for( int i=1 ; i<d ; i++ ){
        for( int j=0 ; j<n ; j++ ){
            if( tmp[i] >= clt[j].min_t && tmp[i] <= clt[j].max_t ){
                for( int k=0 ; k<n ; k++){
                    if( tmp[i-1] >= clt[k].min_t && tmp[i-1] <= clt[k].max_t ){
                        dp[i][j]=max(dp[i][j],abs(clt[j].c-clt[k].c)+dp[i-1][k]);
                    }
                }
            }
        }
    }

    cout << accumulate(dp[d-1].begin(),dp[d-1].end(),0,[](int a,int b){ return ( a>b ? a : b ); }) <<endl;

    return 0;
}

Measured memory_bytes: 1356
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int i,j,n,ans=0,cnt=0;
  string s;
  char a[4]={'A','T','C','G'};
  bool f;
  
  cin>>s;
  s=s+'0';
  n=s.size();
  for(i=0;i<n;i++)
  { 
    f=false;
    for(j=0;j<4;j++)
    {
      if(s[i]==a[j])f=true;
    }
    if(f==true){cnt++;}
    else 
    {
      if(ans<cnt)ans=cnt;
      cnt=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    a--;
    int cnt=1;
    int res=0;
    while(true){
        if(cnt>=b){
            cout<<res<<endl;
            return 0;
        }
        res++;
        cnt+=a;  
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int cnt;
ll w,h;
char s1[60][60],s2[60][60];
int dp[60][60][60][60];
int que[50*50*50*50+10],quecnt;
int d4[]={0,1,0,-1,0};

int f(){
	h+=2;w+=2;
	{
		int li,lj,ri,rj;
		rep(i,0,h)rep(j,0,w){
			if(s1[i][j]=='L'){
				li=i;
				lj=j;
			}
			if(s2[i][j]=='R'){
				ri=i;
				rj=j;
			}
		}
		quecnt=0;
		dp[li][lj][ri][rj]=cnt;
		que[quecnt++]=li*55*55*55+lj*55*55+ri*55+rj;
	}
	rep(qqq,0,quecnt){
		int li=que[qqq]/55/55/55;
		int lj=que[qqq]/55/55%55;
		int ri=que[qqq]/55%55;
		int rj=que[qqq]%55;
		rep(k,0,4){
			int lii=li+d4[k];
			int ljj=lj+d4[k+1];
			int rii=ri+d4[k];
			int rjj=rj+d4[k+1];
			int flag=0;
			if(s1[lii][ljj]=='#'){
				lii=li;
				ljj=lj;
				flag++;
			}
			if(s2[rii][rjj]=='#'){
				rii=ri;
				rjj=rj;
				flag++;
			}
			if(flag==2)continue;
			if(dp[lii][ljj][rii][rjj]==cnt)continue;
			if(s1[lii][ljj]=='%'&&s2[rii][rjj]=='%')return 1;
			if(s1[lii][ljj]=='%'||s2[rii][rjj]=='%')continue;
			dp[lii][ljj][rii][rjj]=cnt;
			que[quecnt++]=lii*55*55*55+ljj*55*55+rii*55+rjj;
		}
	}
	return 0;
}

int main(){
	while(scanf("%lld%lld",&w,&h),w){
		++cnt;
		rep(i,0,h)scanf(" %s %s",s1[i+1]+1,s2[i+1]+1);
		rep(i,0,w+2)s1[0][i]=s1[h+1][i]=s2[0][i]=s2[h+1][i]='#';
		rep(i,0,h+2)s1[i][0]=s1[i][w+1]=s2[i][0]=s2[i][w+1]='#';
		rep(i,0,h)rep(j,0,w/2){
			char c=s2[i+1][j+1];
			s2[i+1][j+1]=s2[i+1][w-j];
			s2[i+1][w-j]=c;
		}
//		rep(i,0,h+2)puts(s1[i]);
//		puts("");
//		rep(i,0,h+2)puts(s2[i]);
		puts(f()?"Yes":"No");		
	}
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int mx=0,mn=1e9;
	for(int i=0;i<n;++i){
		int a; cin>>a;
		mx=max(mx,a);
		mn=min(mn,a);
	}
	cout<<mx-mn<<"\n"s;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

#define ll long long
#define LLMAX 1E+9+7

int main(){
	int c5=0,c7=0;
	int a,b,c;
	cin >> a >> b >> c;
	if(a==5) c5++;
	else if(a==7) c7++;
	if(b==5) c5++;
	else if(b==7) c7++;
	if(c==5) c5++;
	else if(c==7) c7++;
	if(c5==2&&c7==1) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

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

using namespace std;

int main() {
  int n;
  long long a, b, c = 0;
  cin >> n >> a >> b;
  for (int i = 0; i < n - 2; i++) {
    long long x;
    cin >> x;
    c ^= x;
  }
  long long s = a + b;
  if (s < c || (s - c) & 1) {
    cout << -1 << '\n';
    return 0;
  }
  long long d = (s - c) / 2;
  for (int i = 60; i >= 0; i--) {
    if ((c & (1ll << i)) && ((d | (1ll << i)) <= a)) {
      d |= 1ll << i;
    }
  }
  if ((d ^ (b + a - d) ^ c) || a < d || d <= 0) {
    cout << -1 << '\n';
  } else {
    cout << a - d << '\n';
  }
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define repn(i,s,n) for (int i=int(s); i < int(n); i++)
#define rep(i,n) repn(i,0,n)
#define repd(i,n) for (int i=int(n)-1; i >= 0; i--)

typedef vector<double> VD;

#define ROT(x,y,c,s) { double u = c*x + s*y; y = -s*x + c*y; x = u; }

VD solve_givens_rot(vector<VD> A, VD b) {
  int n = A.size();
  rep(i, n) {
    repn(i2, i+1, n) {
      double r = hypot(A[i][i], A[i2][i]);
      double c = A[i][i] / r;
      double s = A[i2][i] / r;
      ROT(b[i], b[i2], c, s);
      repn(j, i, n) ROT(A[i][j], A[i2][j], c, s);
    }
  }
  repd(i, n) {
    repn(j, i+1, n) b[i] -= A[i][j] * b[j];
    b[i] /= A[i][i];
  }
  return b;
}

const double EPS = 1e-4;

bool is_ok(const VD& params, double x, double v) {
  int n = params.size();
  double ans = 0;
  rep(i, n) ans += pow(x, i) * params[i];
  return abs(ans - v) < EPS;
}

int solve(int d) {
  VD v(d+3);
  rep(i, d+3) cin >> v[i];

  vector<VD> A(d+1, VD(d+1));
  rep(remx1, d+3) {
    rep(remx2, d+3) {
      VD u, xs;
      rep(i, d+3) {
        if (i != remx1 && i != remx2) {
          u.push_back(v[i]);
          xs.push_back(i);
        }
      }
      rep(i, d+1) {
        rep(j, d+1) {
          A[i][j] = pow(xs[i], j);
        }
      }
      VD params = solve_givens_rot(A, u);
      bool ok1 = is_ok(params, remx1, v[remx1]);
      bool ok2 = is_ok(params, remx2, v[remx2]);
      if (ok1 && !ok2) return remx2;
      if (!ok1 && ok2) return remx1;
    }
  }
  return -1;
}

int main() {
  int d;
  while (cin >> d, d) cout << solve(d) << endl;
  return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define ull unsigned long long

int main(){
    int x[10]={},i;
    scanf("%d%d%d%d%d",&x[0],&x[1],&x[2],&x[3],&x[4]);
    for (i=0; i<5; i++) {
        if (x[i]==0) {
            printf("%d",i+1);
        }
    }
    return 0;
}


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

int N, M, Q;
int a[55], b[55], c[55], d[55];
int A[15];

long long dfs(int s, int n) {
  if (n == N) {
    long long score = 0;
    for (int i = 0; i < Q; i++) {
      if (A[b[i] - 1] - A[a[i] - 1] == c[i]) score += d[i];
    }
    return score;
  } else {
    long long score = 0;
    for (int i = s; i < M; i++) {
      A[n] = i + 1;
      score = max(score, dfs(i, n + 1));
    }
    return score;
  }
}

void Main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  cout << dfs(0, 0) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3656
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
a=10**9
z_max=-1*a
z_min=a
w_max=-1*a
w_min=a
for x,y in l: #点のx座標とy座標の和の最大値と最小値の差か座標の差の最大値と最小値の差が答え
  z_max=max(z_max,x+y)
  z_min=min(z_min,x+y)
  w_max=max(w_max,x-y)
  w_min=min(w_min,x-y)
print(max(z_max-z_min,w_max-w_min))

Measured memory_bytes: 45212
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
l = []
s = 0
for i,j in zip(x,x[1:]):
    l.append(j-i)
    if (j-i)*a>b:
        s+=b
    else:
        s+=(j-i)*a
print(s)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
	while(true){
		int N; SCD(N);
		int M; SCD(M);
		if ((N==0) and (M==0)) break;

		vector<int> P;
		P.PB(0);
		VSCD(P,N);

		vector<int> Ptwo;

		REP(i,N+1){
			REP(j,N+1){
				Ptwo.PB(P[i] + P[j]);
				//printf("P[%d] + P[%d] = %d\n",i,j,P[i]+P[j]);
			}
		}

		sort(Ptwo.begin(),Ptwo.end());

		int ans = 0;

		REP(i,(N+1)*(N+1)){
			int f,s;
			f = Ptwo[i];
			auto it = lower_bound(Ptwo.begin(),Ptwo.end(),M-f);
			int sind = it - Ptwo.begin();
			//printf("f = %d,sind = %d\n",f,sind);
			if (sind > (N+1)*(N+1)-1) continue;
			if (Ptwo[sind] != M-f) sind--;
			if (sind < 0) continue;
			s = Ptwo[sind];
			ans = max(ans,f+s);
		}
		PRINTD(ans);
	}
	return 0;
}


Measured memory_bytes: 10820
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b,c,d;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d);
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<Integer,List<int[]>> tree = new HashMap<>();
		for(int i=0;i<n-1;i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			int[] tmp1 = {b,c};
			int[] tmp2 = {a,c};
			if(tree.containsKey(a)) {
				tree.get(a).add(tmp1);
			}else {
				List<int[]> list = new ArrayList<>();
				list.add(tmp1);
				tree.put(a, list);
			}
			if(tree.containsKey(b)) {
				tree.get(b).add(tmp2);
			}else {
				List<int[]> list = new ArrayList<>();
				list.add(tmp2);
				tree.put(b, list);
			}
		}
		int Q = in.nextInt();
		int K = in.nextInt();
		long[] cost = new long[n+1];
		Queue<Integer> que = new ArrayDeque<>();
		que.add(K);
		while(!que.isEmpty()) {
			int node = que.poll();
			for(int[] tmp:tree.get(node)) {
				if(cost[tmp[0]]==0) {
					cost[tmp[0]] = cost[node] + tmp[1];
					que.add(tmp[0]);
				}
			}
			if(cost[K]==0) cost[K] = -1;
		}
		StringBuilder sb = new StringBuilder();
		String ls = System.lineSeparator();
		for(int i=0;i<Q;i++) {
			sb.append(cost[in.nextInt()]+cost[in.nextInt()]);
			sb.append(ls);
		}
		System.out.println(sb.toString());
		in.close();

	}

}


Measured memory_bytes: 175304
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;

  ll nr=0,ng=0,nb=0;
  for(int i=0;i<N;i++){
    if(s[i]=='R') nr++;
    else if(s[i]=='G') ng++;
    else nb++;
  }

  ll ans=nr*ng*nb;

  for(int i=0;i<N;i++){
    for(int j=1;i+2*j<N;j++){
      if((s[i]!=s[i+j]) & (s[i+j]!=s[i+2*j]) & (s[i+2*j]!=s[i])) --ans;
    }
  }

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


Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = match a {
        0 ... 5 => 0,
        6 ... 12 => b / 2,
        _ => b
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Feb  3 21:03:15 2019
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	slice := make([]int, M)
	for i := range slice {
		fmt.Scan(&slice[i])
	}
	sort.Ints(slice)

	if M <= N {
		fmt.Println(0)
		return
	}

	tmp := make([]int, M)
	for i := range slice {
		if i > 0 {
			tmp[i] = slice[i] - slice[i-1]
		}
	}

	sort.Ints(tmp)
	ans := 0
	for i := 0; i < M-N+1; i++ {
		ans += tmp[i]
	}

	fmt.Println(ans)
}


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

int main(void){
    int N;
    cin >> N;
    
    int a, b, c, d;
    a = N / 1000;
    b = N / 100 % 10;
    c = N / 10 % 10;
    d = N % 10;
    
    if (a == b && b == c) cout << "Yes" << endl;
    
    else if (b == c && c == d) cout << "Yes" << endl;
    
    else cout << "No" << endl;

}

Measured memory_bytes: 3500