akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

vll op(ll N, vll A) {
	vector<ll> ch(N + 2, 0);
	repn(i, N) {
		ll x = max(1, i-A[i]);
		ll y = min(N, i + A[i]);
		ch[x]++;
		ch[y + 1]--;
		//cout << x << " " << y << endl;
	}

	vector<ll> ret(N + 1, 0);
	repn(i, N) ret[i] = ret[i - 1] + ch[i];

	return ret;
}


int main() {
	ll N, K;
	cin >> N >> K;

	vll A(N + 1);
	repn(i, N) cin >> A[i];

	repn(i, K) {
		A = op(N, A);

		bool b = 1;
		repn(i, N)if (A[i] != N) { b = 0; }

		if (b) { break; }
	}

	repn(i, N) cout << A[i] << " ";
	cout << endl;
}

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

using namespace std;

int main() {
	int mval = 0;
	string s, buf, a, b;
	map<string, int> m;
	getline(cin, s);
	stringstream ss(s);
	while(ss >> buf) {
		m[buf] += 1;
		if(mval < m[buf]) mval = m[buf];
	}
	for(auto &v: m) {
		if(v.first.length() > b.length()) b = v.first;
		if(v.second == mval) a = v.first;
	}
	cout << a << " " << b << endl;
	return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> C(N);
    int i;
    for(i=0;i<N;i++){
        cin >> A[i];
        C[A[i]-1] = i+1;
    }
    for(i=0;i<N;i++){
        cout << C[i] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	int n;
	cin >> n;
	vector<int> o, e;
	int mo, me;
	int mno, mne;
	int mno2, mne2;
	int x;
	rep(i, n) {
		cin >> x;
		if (i%2 == 0) o.push_back(x);
		else e.push_back(x);
	}

	int ans;
	vector<int> counto = count(o);
	vector<int> counte = count(e);
	mno = maxelem(counto);
	mne = maxelem(counte);
	mo = find(counto, mno);
	me = find(counte, mne);
	mno2 = secondelem(counto);
	mne2 = secondelem(counte);

	int keep;
	if (mo != me) keep = mno + mne;
	else keep = max(mno2 + mne, mno + mne2);

	ans = n - keep;

	cout << ans;

	return 0;
}



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

int p=1000000007;
ll f(ll x){
  if(x==0){return 1;}
  if(x==1){return 1;}
  ll a=1, b=1, c=0;
  rep(i,x-1){
    c=(a+b)%p;
    a=b;b=c;
  }
  return c;
}
int main() {
  ll n,m,ans=1; cin>>n>>m;
  vector<ll> v(m);
  rep(i,m){
    cin>>v[i];
    if(i!=0){if(v[i]==v[i-1]+1){ans=0;break;}}
  }
  if(m==0){cout<<f(n);}
  else if(ans==0){cout<<0<<endl;}
  else{
    if(v[0]!=1){ans*=f(v[0]-1)%p;ans%=p;}
    for(int i=0; i<m-1;  i++){ans*=f(v[i+1]-v[i]-2)%p;ans%=p;}
    ans*=f(n-1-v[m-1])%p;ans%=p;
    cout<<ans<<endl;
  } 
  
}



Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    n %= 10;
    if (n == 3) cout << "bon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

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

int main(void){
  string s;
  cin >> s;
  
  //serach A from forward;
  
  int front = 0;
  
  int N = s.size();
  
  for (int i = 0; i < N; i++) {
    if (s.at(i) == 'A') {
      front = i;
      break;
    }
  }

  int back = N + 1;
  
  for (int i = N -1; i >= 0; i--) {
    if (s.at(i) == 'Z') {
      back = i + 1;
      break;
    }
  }
 
  cout << back - front << endl; 
}

Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

bool comp(const P& a, const P& b) {
	if (a.first != b.first) return (a.first > b.first);
	return (a.second < b.second);
}

int main() {
	vector<P> seq;
	int n;
	while (cin >> n) {
		bool inserted = false;
		for (int i = 0; i < seq.size(); i++) {
			if (seq[i].second == n) {
				seq[i].first++;
				inserted = true;
			}
		}
		if (!inserted)
			seq.push_back(P(1, n));
	}

	sort(seq.begin(), seq.end(), comp);

	int m = seq[0].first;
	for (int i = 0; seq[i].first == m; i++)
		cout << seq[i].second << endl;
	
	return 0;
}

Measured memory_bytes: 0
A,B = map(int,input().split())

#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#[[素因数,数]]を出力
def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

g = gcd(A,B)

print(len(fctr1(g))+1)


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int m, n_min, n_max;
	while (1) {
		cin >> m >> n_min >> n_max;
		if (m == 0) break;
		
		vector< int > p(m);
		for_(i,0,m) cin >> p[i];
		
		int ans = 0, max_diff = 0;
		for_(i,n_min,n_max+1) {
			int diff = p[i-1] - p[i];
			if (max_diff <= diff) {
				max_diff = diff;
				ans = i;
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> d(10, vector<int>(10, 0));
    rep(i, 10) rep(j, 10) cin >> d[i][j];
    for (int k = 0; k < 10; k++)
    { // 経由する頂点
        for (int i = 0; i < 10; i++)
        { // 始点
            for (int j = 0; j < 10; j++)
            { // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    long long ans = 0;
    rep(i, H * W)
    {
        int num;
        cin >> num;
        if (num < 0)
            continue;
        ans += d[num][1];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> H(N);
	rep(i,N) cin >> H[i];
	vector<vector<int>> G(N);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	int ans=0;
	rep(i,N){
		if(G[i].size()==0) ans++;
		rep(j,G[i].size()){
			if(H[i]<=H[G[i][j]]) break;
			if(j==G[i].size()-1) ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8800
#include <bits/stdc++.h>
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	cin>>k;
	cout<<a[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
n,h=map(int,input().split())
A=[0]*n
B=[0]*(n+1)
for i in range(n):
  A[i], B[i] = map(int, input().split())
a=max(A)
B.sort(reverse=True)
cnt=0
while h > 0:
  if a > B[0]:
    cnt+=math.ceil(h/a)
    h-=math.ceil(math.ceil(h/a)*a)
  else:
    cnt+=1
    h-=B[0]
    B.pop(0)
print(cnt)

Measured memory_bytes: 11312
#include<iostream>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s==t){cout<<"Yes"<<endl;return 0;}
    s=s.back()+s;
    s.pop_back();
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

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

	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		q.push(x);
	}
	while(m){
		if(!q.empty()){
			int x = q.top();
			q.pop();
			if(x == 0){
				break;
			}
			else{
				x = x / 2;
				m--;
				q.push(x);
			}
		}
	}
	ll money = 0;
	while(!q.empty()){
		money = money + q.top();
		q.pop();
	}
	cout << money << endl;
	return 0;
}	


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using std::cin;
using std::cout;
using std::endl;

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

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef struct{
    int p, l, r;
} node;
node t[25];
void Preoder(int root){
    printf(" %d", root);
    if(t[root].l != -1) Preoder(t[root].l);
    if(t[root].r != -1) Preoder(t[root].r);
}
void Inorder(int root){
    if(t[root].l != -1) Inorder(t[root].l);
    printf(" %d", root);
    if(t[root].r != -1) Inorder(t[root].r);
}
void Postorder(int root){
    if(t[root].l != -1) Postorder(t[root].l);
    if(t[root].r != -1) Postorder(t[root].r);
    printf(" %d", root);}
int main(){
    int i, n, id;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        t[i].p = -1;
        t[i].l = -1;
        t[i].r = -1;
    }
    for(i = 0; i < n; i++){
        scanf("%d", &id);
        scanf("%d%d", &t[id].l, &t[id].r);
        if(t[id].l != -1) t[t[id].l].p = id;
        if(t[id].r != -1) t[t[id].r].p = id;
    }
    printf("Preorder\n");
    for(i = 0; i < n; i++){
        if(t[i].p == -1){
            Preoder(i);
            printf("\nInorder\n");
            Inorder(i);
            printf("\nPostorder\n");
            Postorder(i);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 616
#include<iostream>
using namespace std;
int main(){
char a,b;
  cin>>b;
  if(b=='A')cout<<'T'<<endl;
  else if(b=='T')cout<<'A'<<endl;
  else if(b=='C')cout<<'G'<<endl;
  else if(b=='G')cout<<'C'<<endl;
}

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

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string s;
    cin>>s;
    ll a=0, bc=0, flag=0;
    ll index=0;
    ll count=0;
    while(index<s.size()){
        if(flag==0){
            if(s[index]=='A') a++;
            else{
                if(index+1<s.size()){
                    if(s[index]=='B' && s[index+1]=='C') flag=1;
                        else a=0;
                }
                else a=0;
            }
        }
        if(flag==1){
            if(index+1<s.size()){
                if(s[index]=='B' && s[index+1]=='C') bc++;
                else{count+=a*bc; bc=0; flag=0;}
            }
            else{count+=a*bc; bc=0; flag=0;}
            if(s[index]=='A') continue;
         }
        index++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;


int main() {
	LL N;
	cin >> N;
	vector<LL> v(N);


	REP(i, N) {
		LL a;
		cin >> a;
		if (a == i + 1) {
			v[i] = 1;
		}
		else {
			v[i] = 0;
		}
	}

	LL sum = 0;

	if (v[0] == 1) {
		v[0] = 0;
		v[1] = 0;
		sum++;
	}

	if (v[N-1] == 1) {
		v[N-1] = 0;
		v[N-2] = 0;
		sum++;
	}

	REP(i, N - 2) {
		if (v[i + 1] == 1) {
			v[i + 1] = 0;
			v[i + 2] = 0;
			sum++;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int n;
int arr[100][100];
int time_saver[100][2];
int now_time;

void search(int fi){
    if(!time_saver[fi][0]){
        now_time++;
        time_saver[fi][0] = now_time;
    }
    for(int i=0; i<100; i++){
        if(arr[fi][i] && !time_saver[arr[fi][i]-1][0])search(arr[fi][i]-1);
    }
    if(!time_saver[fi][1]){
        now_time++;
        time_saver[fi][1] = now_time;
    }
}

int main(int argc, const char * argv[]) {
    
    
    /////////
    //write//
    /////////
    
    cin >> n;
    now_time = 0;
    for(int i=0; i<100; i++){
        for(int j=0; j<100; j++){
            arr[i][j] = 0;
        }
        for(int j=0; j<2; j++){
            time_saver[i][j] = 0;
        }
    }
    
    for(int i=0; i<n; i++){
        int node, degree; cin >> node >> degree;
        for(int j=0; j<degree; j++){
            int tmp; cin >> tmp;
            arr[node-1][tmp-1] = tmp;
        }
    }
    
    for(int i=0; i<n; i++){
        if(time_saver[i][0])continue;
        search(i);
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<2; j++){
            if(j)cout << " ";
            else cout << i+1 << " ";
            cout << time_saver[i][j];
        }
        cout << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3144
#include <stdio.h>

int main()
{
    int s,h,min,sec;
    
    scanf("%d",&s);
    
    h = s / 3600;
    min = (s % 3600) / 60;
    sec = (s % 3600) % 60;
    
    printf("%d:%d:%d\n",h,min,sec);
    
    return 0;
    
}


Measured memory_bytes: 2120
import Data.STRef
import Control.Monad
import Control.Monad.ST
 
main :: IO()
main = getLine >> getContents >>= print.(\(x:y:xs) -> solve (y - x) (min x y) xs).map read.lines
 
solve :: Int -> Int -> [Int] -> Int
solve a b xs = runST $ do
                a' <- newSTRef a
                b' <- newSTRef b
                forM_ xs $ \z -> do
                    x <- readSTRef a'
                    y <- readSTRef b'
                    if (z - y > x) then writeSTRef a' (z - y) else return ()
                    if (z < y)     then writeSTRef b' z       else return ()
                readSTRef a'

Measured memory_bytes: 5496
#include <iostream>
using namespace std;
int main(void){
    int n=0;
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    for(int i=a;i<=b;i++){
        if(c % i == 0){
            n=n+1;
        }
        else{
            
        }
    }
    cout << n << endl;
}



Measured memory_bytes: 3088
n,p = map(int,input().split())
A = [int(i)%2 for i in input().split()]
from collections import Counter
from math import factorial 
D = Counter(A)
one = 0
for i in range(p%2,D[1]+1,2):
    one += factorial(D[1])//(factorial(i)*factorial(D[1]-i))
print((2**D[0])*one)

Measured memory_bytes: 3316
n = int(input())
txy = [[0, 0, 0]]
for i in range(n):
    txy.append(list(map(int, input().split())))

ans = 'Yes'
for i in range(n):
    time = txy[i + 1][0] - txy[i][0]
    dist = abs(txy[i][1] - txy[i + 1][1]) + abs(txy[i][2] - txy[i + 1][2])
    if time - dist == 0:
        pass
    elif time - dist > 0 and (time - dist) % 2 == 0:
        pass
    else:
        ans = 'No'
        
print(ans)

Measured memory_bytes: 27300
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], nxts[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < maxbit; i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	for (int i = 0; i < maxbits; i++)
	{
		nxts[i] = (bits[i] << 1) & (maxbit - 1);
	}

	for (int i = 0; i < H * W - 1; i++)
	{
		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			dp[t][j][0][0] = 0;
			dp[t][j][0][1] = 0;
			dp[t][j][1][0] = 0;
			dp[t][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int sum0 = dp[s][j][0][0] + dp[s][j][1][0];
			int sum1 = dp[s][j][0][1] + dp[s][j][1][1];

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][conv[nxts[j]]][0][0] += sum0;
				dp[t][conv[nxts[j]]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][conv[nxts[j] + 1]][1][0] += dp[s][j][0][0];
					dp[t][conv[nxts[j] + 1]][1][1] += dp[s][j][0][1];

					dp[t][conv[nxts[j] + 1]][1][0] %= 100000;
					dp[t][conv[nxts[j] + 1]][1][1] %= 100000;

					dp[t][conv[nxts[j]]][1][0] += dp[s][j][1][0];
					dp[t][conv[nxts[j]]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][conv[nxts[j]]][1][0] += sum0;
					dp[t][conv[nxts[j]]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][conv[nxts[j]]][1][1] += sum0;
				}
				else
				{
					dp[t][conv[nxts[j]]][1][0] += sum0;
				}

				dp[t][conv[nxts[j]]][1][1] += sum1;
			}

			dp[t][conv[nxts[j]]][0][0] %= 100000;
			dp[t][conv[nxts[j]]][0][1] %= 100000;
			dp[t][conv[nxts[j]]][1][0] %= 100000;
			dp[t][conv[nxts[j]]][1][1] %= 100000;
		}
	}

	int ret = 0;

	int last = (H * W + 1) % 2;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[last][i][0][1];
		ret += dp[last][i][1][1];

		ret %= 100000;
	}

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

	return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ull=unsigned long;
int main(){
    unsigned x,y,z,K;
    scanf("%u %u %u %u",&x,&y,&z,&K);
    ull a[x],b[y],c[z];
    for(unsigned i=0;i<x;i++)scanf("%lu",&a[i]);
    for(unsigned i=0;i<y;i++)scanf("%lu",&b[i]);
    for(unsigned i=0;i<z;i++)scanf("%lu",&c[i]);
    priority_queue<ull,vector<ull>,greater<ull>>q;
    for(unsigned i=0;i<x;i++)for(unsigned j=0;j<y;j++)for(unsigned k=0;k<z;k++){
        if(q.size()<K)q.push(a[i]+b[j]+c[k]);
        else if(q.top()<a[i]+b[j]+c[k]){
            q.pop();
            q.push(a[i]+b[j]+c[k]);
        }
    }
    ull ans[K];
    for(unsigned i=K;i--;){
        ans[i]=q.top();
        q.pop();
    }
    for(unsigned i=0;i<K;i++)printf("%lu\n",ans[i]);
}


Measured memory_bytes: 384
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let m: usize = s.next().unwrap().parse().unwrap();
	const C: [usize; 9] = [2, 5, 5, 4, 5, 6, 3, 7, 6];
	let mut a: Vec<usize> = s.take(m).map(|a| a.parse().unwrap()).collect();
	a.sort();
	let a: Vec<_> = a
		.into_iter()
		.map(|a| (std::char::from_digit(a as u32, 10).unwrap(), C[a - 1]))
		.collect();
	let mut dp = vec![std::i32::MIN; n + 1];
	dp[0] = 0;
	for i in 1..=n {
		for &(_, c) in a.iter() {
			dp[i] = std::cmp::max(
				dp[i],
				i.checked_sub(c)
					.and_then(|i| Some(dp[i]))
					.unwrap_or(std::i32::MIN)
					.saturating_add(1),
			);
		}
	}
	let mut ans = String::new();
	let mut left = n;

	while left > 0 {
		for &(digit, cnt) in a.iter().rev().filter(|&a| left >= a.1) {
			if dp[left - cnt] == dp[left] - 1 {
				ans.push(digit);
				left -= cnt;
				break;
			}
		}
	}

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


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

int main(){
    ll x,k,d;
    cin>>x>>k>>d;

    x=abs(x);
    if(x/d>k){
        cout<<abs(x-d*k)<<endl;
    }
    else{
        ll now=x-(x/d)*d;
        k-=x/d;
        if(k%2==1) cout<<abs(now-d)<<endl;
        else cout<<now<<endl;
    }
}


Measured memory_bytes: 3600
# AGC003C - BBuBBBlesort!
def main():
    N, *A = map(int, open(0).read().split())
    S = sorted(A)
    dif = set(A[::2]) ^ set(S[::2])
    ans = len(dif) // 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 20964
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int find(int x){
	string s=to_string(x);
	int dp[(int)s.size()][10][2];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=s[0]-'0';i++){
		if(s[0]==i+'0'){dp[0][i][0]=1;break;}
		dp[0][i][1]=1;
	}
	for(int i=1;i<s.size();i++){
		for(int j=0;j<10;j++){
			if(j-1>=0){
				dp[i][j-1][1]+=dp[i-1][j][1];
				if(j-1==s[i]-'0') dp[i][j-1][0]+=dp[i-1][j][0];
				if(j-1<s[i]-'0') dp[i][j-1][1]+=dp[i-1][j][0];
			}
			if(j+1<=9){
				dp[i][j+1][1]+=dp[i-1][j][1];
				if(j+1==s[i]-'0') dp[i][j+1][0]+=dp[i-1][j][0];
				if(j+1<s[i]-'0') dp[i][j+1][1]+=dp[i-1][j][0];
			}
			dp[i][j][1]+=dp[i-1][j][1];
			if(j==s[i]-'0') dp[i][j][0]+=dp[i-1][j][0];
			if(j<s[i]-'0') dp[i][j][1]+=dp[i-1][j][0];
			if(j!=0) dp[i][j][1]++;
		}
	}
	int ans=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<2;j++){
			ans+=dp[s.size()-1][i][j];
		}
	}
	return(ans);
}

int32_t main(){
    IOS;
    int k;
    cin>>k;
    int l=0,h=1e18;
    int ans=1e18;
    while(l<=h){
    	int mid=(l+h)/2;
    	int x=find(mid);
    	if(x<k) l=mid+1;
    	else{
    		if(x==k){
    			ans=min(mid,ans);
    		}
    		h=mid-1;
    	} 
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限

K = int(input())

l = [1,2,3,4,5,6,7,8,9] #１桁のルンルン数
ln = [1,2,3,4,5,6,7,8,9] #既にわかっている分をセット。重複がいやなのでset

def dfs(i):
    n = int(str(i)[-1]) #1桁目を取る
    a,b,c = n-1, n, n+1 #差の絶対値が１未満、-1/+0/+1
    if a != -1:
        ln.append(i*10+a)
    ln.append(i*10+b)
    if c != 10:
        ln.append(i*10+c)
    
    if len(str(i)) <= 10:
        if a != -1:
            dfs(i*10 + a)
        dfs(i*10 + b)
        
        if c != 10:
            dfs(i*10 + c)

for i in l: #１桁のルンルン数を順番に再帰
    dfs(i)

print(sorted(ln)[K-1]) #0-indexを意識してリストのK-1番目を出す

Measured memory_bytes: 99860
#include <bits/stdc++.h>
using namespace std;
int dp[1 << 12];
int main()
{
    int n, m;
    scanf("%d%d",&n,&m);
    for (int i = (1 << n) - 1; ~i; i--) dp[i] = 1e9;
    dp[0] = 0;
    for (int i = 1; i <= m; i++)
    {
        int a,b,k;
        scanf("%d%d",&a,&b);
        int c = 0;
        for (int j = 0; j < b; j++)
        {
            scanf("%d",&k);
            c |= (1 << k-1);
        }
        for (int j = (1 << n) - 1; ~j; j--)
        {
            dp[j | c] = min(dp[j | c], dp[j] + a);//背包
        }
    }
    int ans = dp[(1<<n) - 1];
    if (ans == 1e9) cout << -1;
    else cout << ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	const int v[6] = {1, 5, 10, 50, 100, 500};
	int ans, c;

	while (1) {
		ans = 0;

		cin >> c;
		if (c == 0) break;

		c = 1000 - c;
		for (int i = 5; i >= 0; --i) {
			int tmp = c / v[i];
			c -= v[i] * tmp;
			ans += tmp;
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	string s;
	cin >> s;
	int c = 0, l = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '(')
			c++;
		else
			c--;

		if (c < 0)
		{
			l += -c;
			c = 0;
		}
	}

	for (int i = 0; i < l; i++)
		printf("(");
	cout << s;
	for (int i = 0; i < c; i++)
		printf(")");
	printf("\n");


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define int ll
//#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.141592653589
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
using pld = pair <ld, ld>;

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

signed main()
{
    Start();
    int n, m;
    cin >> n >> m;
    vector <pii> b(n);
    cin >> b;
    sort(all(b));
    int ans = 0;
    for (auto &a : b)
    {
        if (m > a.second)
        {
            m -= a.second;
            ans += a.second * a.first;
        }
        else
        {
            ans += m * a.first;
            m = 0;
            break;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    cout << fixed << setprecision(6) << dist << endl;
}


Measured memory_bytes: 3228
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int[] A = nints(N);
        int diff = 0;
        int current = 0;
        for (int i = 0; i < N; i++) { 
            diff = A[i] - current;
            current = diff;
        }
        
        int x2 = diff;
        for (int i = 0; i < N; i++) {
            so.println(x2);
            x2 = (A[i] - x2/2)*2;
        }
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 59912
# 2019/04/13
# AtCoder Beginner Contest 124 - B

# Input
n = int(input())
h = list(map(int,input().split()))

max = h[0]
cnt = 1
# Calc
for i in range(1, n):
    if h[i] >= max:
        max = h[i]
        cnt += 1

# Output
print(cnt)

Measured memory_bytes: 2940
#include <stdio.h>
#define B 5
#define F 4
#define R 11
#define L 20

int main(void){
    int n,i,j,k,l;
    int b,f,r,v;
    int x[B][F][R];
    for(i=0;i<B;i++){
        for(j=0;j<F;j++){
            for(k=0;k<R;k++){
                x[i][j][k]=0;
            }
        }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d%d",&b,&f,&r,&v);
        if(v < 0)x[b][f][r] += v;
        else x[b][f][r] += v;
    }
    for(i=1;i<B;i++){
        for(j=1;j<F;j++){
            for(k=1;k<R;k++){
                if(k != R)printf(" ");
                printf("%d",x[i][j][k]);
            }
            printf("\n");
        }
        if(i != B -1){
            for(l=0;l<L;l++){
                printf("#");
            }
            printf("\n");
        }
        else ;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <deque>
#include <tuple>

using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl


//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n,tmp1,tmp2;
    scanf("%lld", &n);
    deque<tuple<long long int,long long int,long long int>> d(n);
    REP(i,n){
        scanf("%lld%lld", &tmp1, &tmp2);
        d.push_back(make_tuple(tmp1+tmp2,tmp1,tmp2));
    }
    long long int taka = 0,ao=0;
    sort(d.begin(), d.end());
    REP(i,n){
        if(1&i){
            ao += get<2>(d.back());
            d.pop_back();
        }else{  
            taka += get<1>(d.back());
            d.pop_back();
        }
    }
    cout << taka - ao << endl;
    return 0;
}


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

int main() {
	int N;
	int M;
	int K;
	int k_max;
	int p_max;
	int ai;
	int bi;

	cin >> N >> M >>K;

	vector<int> A(N); // N個のデータ
	vector<int> B(M); // M個のデータ

	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	for (int i = 0; i < M; i++) {
		cin >> B.at(i);
	}
	k_max=0;
	for (int i = 0; i < N; i++) {
		k_max+=A.at(i);
		ai=i+1;
		if(k_max>K) {
			ai--;
			k_max-=A.at(i);
			break;
		}
	}
	p_max=ai;
	for (int i = 0; i < M; i++) {
		k_max+=B.at(i);
		bi=i+1;
		if(k_max>K) {
			while (k_max > K) {
				if(ai==0){
					bi--;
					if(bi>p_max) p_max=bi;
					break;
				}
				ai--;
				k_max-=A.at(ai);
			}
			if(k_max > K)break;
		}
		if(k_max<=K){
			if(ai+bi>p_max){
				p_max=ai+bi;
			}
			continue;
		}
	}
	if((k_max<=K)&&(ai==N)) {
		cout << N+M << endl;
		return 0;
	}
	cout << p_max << endl;
	return 0;
}


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

int count = 0;

int main()
{
  int n;
  cin >> n;
  multiset<int> s;
  int m = 1 << n;
  rep(i, m)
  {
    int t;
    cin >> t;
    s.insert(-t);
  }
  vector<int> created;
  created.push_back(*s.begin());
  s.erase(s.begin());
  rep(i, n)
  {
    int sz = created.size();
    rep(j, sz)
    {
      auto itr = s.upper_bound(created[j]);
      if (itr == s.end())
      {
        puts("No");
        return 0;
      }
      created.push_back(*itr);
      s.erase(itr);
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    int a[n], b[n+1];
    //vector<int> a(n+1), b(n);
    for(int i=1;i<=n+1;i++) cin >> a[i];
    for(int i=1;i<=n;i++) cin >> b[i];
    ll sum=0;
    for(int i=1;i<=n;i++) {
        int left = min(a[i], b[i]);
        sum += left;
        a[i] -= left;
        b[i] -= left;
        
        int right = min(a[i+1], b[i]);
        sum += right;
        a[i+1] -= right;
        b[i] -= right;
    }
    
    cout << sum << endl;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct UnionFind
{
private:
  vi data;
  int cnt;

public:
  UnionFind(const int size) : data(size, -1), cnt(size) {}
  bool unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x != y){
      if(data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
      cnt -= 1;
    }
    return x != y;
  }
  bool same(int x, int y){ return root(x) == root(y); }
  int root(int x){ return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x){ return -data[root(x)]; }
  int group(){ return cnt; }
};


typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;


// ????????°?????????????°????????????????
pair<Weight, Edges> Kruskal(const Graph &g)
{
  int n = g.size();
  UnionFind uf(n);
  priority_queue<Edge> Q;
  rep(u, n) vrep(e, g[u]) if (u < e->dst) Q.push(*e);

  Weight total = 0;
  Edges F;
  while (F.size() < n-1 && !Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (uf.unite(e.src, e.dst)) {
      F.push_back(e);
      total += e.weight;
    }
  }
  return pair<Weight, Edges>(total, F);
}

int n, m;
int s, t;
Weight w;

int main()
{
  while((cin >> n) && n){
    cin >> m;
    Graph g(n);
    rep(i, m){
      scanf("%d,%d,%d", &s, &t, &w);
      g[s].pb(Edge(s, t, w / 100 - 1));
      g[t].pb(Edge(t, s, w / 100 - 1));
    }
    cout << Kruskal(g).first << endl;
  }

  return 0;
}

Measured memory_bytes: 1532
#include <stdio.h>

int main(){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(W >= (x + r) && (x + r) > x && x > (x - r) && (x - r) >= 0 && H >= (y + r)  && (y + r) > y && y > (y - r) && (y - r) >= 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}



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

int n;
// vector<int> x;
// vector<pair<int,int>> y;
// vector<int> b;
int x[200000];
pair<int,int> y[200000];
int b[200000];

int main() {
    cin >> n;
    // x.resize(n);
    // y.resize(n);
    // b.resize(n);
    rep(i, n) {
        cin >> x[i];
        y[i] = make_pair(x[i], i);
    }
    // sort(y.begin(), y.end());
    sort(y, y+n);
    rep(i, n) {
        if (i < n/2) {
            b[y[i].second] = y[n/2].first ;
        } else {
            b[y[i].second] = y[n/2-1].first;
        }
    }
    rep(i, n) {
        cout << b[i] << endl;
    }
}

Measured memory_bytes: 6640
#include<stdio.h>

int main(){
    int n, a[100], i, j, v, k;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for (i = 0; i < n; i++){
        v = a[i];
        j = i -1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        printf("%d", a[0]);
        for(k = 1; k < n; k++){
            printf(" %d", a[k]);
        }
        printf("\n");
    }

   return 0;

}


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

static const int MAX = 100;
bool mat[MAX][MAX];
int col[MAX], row[MAX];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            cin >> c;
            mat[i][j] = (c == '#');
            if(c == '#'){
                row[i]++;
                col[j]++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        if(!row[i]) continue;
        for(int j = 0; j < w; j++){
            if(!col[j]) continue;
            cout << (mat[i][j] ? '#' : '.');
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (final Scanner sc = new Scanner(System.in)) {
            final String[] value = sc.nextLine().split(" ");
            final int count = Integer.parseInt(value[0]);
            final int border = Integer.parseInt(value[1]);
            final String[] heights = sc.nextLine().split(" ");
            int numberOfPerson = 0;
            for (int i = 0; i < count; i++) {
                final int height = Integer.parseInt(heights[i]);
                if (border <= height) {
                    numberOfPerson++;
                }
            }
            System.out.println(numberOfPerson);
        }
    }
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int n;
    cin >> n;
    vector<ll> vll(n);
    REP(i, n)
    {
        cin >> vll[i];
    }
    vector<ll> add=vll;
    FOR(i,1,n){
        add[i]+=add[i-1];
        add[i]%=MOD;
    }
    ll ans=0;
    REP(i,n-1){
        ll a=(add[n-1]-add[i]+MOD)%MOD;
        ans+=vll[i]*a;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6424
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String b = sc.next();

        if (b.equals("A")) {
        System.out.println("T");
        sc.close();
            return;
        }
        if (b.equals("C")) {
        System.out.println("G");
        sc.close();
            return;
        }
        if (b.equals("G")) {
        System.out.println("C");
        sc.close();
            return;
        }
        if (b.equals("T")) {
        System.out.println("A");
        sc.close();
            return;
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, x;
    scanf("%d %d %d", &a, &b, &x);
    if(x<=a+b && x>=a)
    {
        printf("YES");
    }

    else
    {
        printf("NO");
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
using namespace std;
using ll =long long;
int main() {
	int N,R;
	cin >> N >> R;

	10 - N > 0 ? cout << R + 100 * (10 - N) : cout<<R;


}

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

int main() 
{
    int N;
    cin >> N;
    
    vector<long long> A(N);
    set<long long> st;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        st.insert(A.at(i));
    }
    
    if (A.size() == st.size()) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

typedef long long ll;

struct LN {
    ll k, b;

    ll f(ll x) {
        return k * x + b;
    }
};

const int N = 1e6 + 10;
const ll INF = 1e18;
LN t[4 * N];
ll dp[N], h[N];

void addLine(int v, int tl, int tr, LN nw) {
    if (t[v].f(tl) <= nw.f(tl) && t[v].f(tr) <= nw.f(tr)) {
        return;
    }
    if (nw.f(tl) <= t[v].f(tl) && nw.f(tr) <= t[v].f(tr)) {
        t[v] = nw; return;
    }
    if (tl + 1 == tr)
        return;
    int tm = (tl + tr) >> 1;
    bool lef = nw.f(tl) < t[v].f(tl);
    bool mid = nw.f(tm) < t[v].f(tm);
    if (mid)
        swap(t[v], nw);
    if (lef != mid)
        addLine(v * 2, tl, tm, nw);
    else
        addLine(v * 2 + 1, tm, tr, nw);
}

ll get(int v, int tl, int tr, int x) {
    if (tr - tl == 1)
        return t[v].f(x);
    int tm = (tl + tr) >> 1;
    if (x < tm)
        return min(t[v].f(x), get(2 * v, tl, tm, x));
    else
        return min(t[v].f(x), get(2 * v + 1, tm, tr, x));
}

void solve() {
    for (int i = 0; i < 4 * N; i++) {
        t[i] = {0, INF};
    }
    int n;
    ll C;
    cin >> n >> C;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (i != 0) {
            dp[i] = C + h[i] * h[i] + get(1, 1, 1e6, h[i]);
        }
        LN l = {-2 * h[i], dp[i] + h[i] * h[i]};
        addLine(1, 1, 1e6, l);
    }
    cout << dp[n - 1];
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 69308
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int N, W, dummy;
	dummy = scanf("%d %d", &N, &W);

	vector<pair<int, int>> shinaWV;

	vector<int> dpNV[101];

	int tmp1, tmp2;
	int vMax = 0;
	shinaWV.reserve(N);
	shinaWV.push_back(make_pair(0, 0));
	for (int i = 1; i <= N; i++) {
		dummy = scanf("%d %d", &tmp1, &tmp2);
		vMax += tmp2;
		shinaWV.push_back(make_pair(tmp1, tmp2));
	}

	int n, tmpW, tmpV;
	n = 1;
	tmpW = shinaWV[n].first;
	tmpV = shinaWV[n].second;
	dpNV[n].reserve(vMax + 1);
	for (int v = 0; v <= vMax; v++) {
		if (tmpV < v)
			dpNV[n].push_back(INT_MAX);
		else
			dpNV[n].push_back(tmpW);
	}
	for (n = 2; n <= N; n++) {
		tmpW = shinaWV[n].first;
		tmpV = shinaWV[n].second;
		dpNV[n].reserve(vMax + 1);
		for (int v = 0; v <= vMax; v++) {
			// 1～n番までの品の中で、価値v以上での最小重量を求める
			int kouho1 = dpNV[n-1][v];
			int kouho2 = (v - tmpV >= 0) ? dpNV[n-1][v-tmpV] + tmpW : INT_MAX;
			kouho2 = (kouho2 < 0) ? INT_MAX : kouho2;
			int kouho3 = (tmpV >= v) ? tmpW : INT_MAX;

			dpNV[n].push_back(min(min(kouho1, kouho2), kouho3));
		}
	}

	int v;
	for (v = 0; v <= vMax; v++) {
		if (dpNV[N][v] > W) break;
	}

	printf("%d\n", v - 1);
	
	return 0;
}


Measured memory_bytes: 39424