akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{char a[100005];int n,i;
scanf("%s",a);
n=strlen(a);
if(n%2==1)
  {cout<<"No"<<endl;
  return 0;
  }
for(i=0;i<n;i++)
  if((a[i]==a[n-i-1])||(a[i]=='q'&&a[n-i-1]=='d')||(a[i]=='q'&&a[n-i-1]=='b')||(a[i]=='p'&&a[n-i-1]=='d')||(a[i]=='p'&&a[n-i-1]=='b'))
    {cout<<"No"<<endl;
    return 0;
	}
cout<<"Yes"<<endl;
return 0;
}

Measured memory_bytes: 384
//眠い
#include <iostream>
#include <algorithm>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;

int h, w, K;
char s[30][31];

//シミュレーション用
char tmp[30][30];
int height[30];
bool mark[30][30];

int erase() {
	int r, c;
	char nTmp[30][30];
	int nHeight[30] = {0};
	
	rep(r, h) rep(c, w) nTmp[r][c] = '@';
	
	int score = 0;
	for (c = 0; c < w; c++) {
		for (r = 0; r < height[c]; r++) {
			if (mark[r][c]) { score += (int)(tmp[r][c] - '0'); continue; }
			nTmp[nHeight[c]][c] = tmp[r][c];
			nHeight[c]++;
		}
	}
	
	for (c = 0; c < w; c++) { height[c] = nHeight[c]; }
	rep (r, h) rep(c, w) tmp[r][c] = nTmp[r][c];
	return score;
}

int drop(int r, int c) {
	
	int i, j, k;
	int score = 0;
	
	rep(i, h) rep(j, w) tmp[i][j] = s[i][j];
	rep(j, w) height[j] = h;
	rep(i, h) rep(j, w) mark[i][j] = false;
	
	mark[r][c] = true; erase(); mark[r][c] = false;
	
	for (i = 0; ; i++) {
		bool flag = false;
		
		//マーク
		rep(j, h) rep(k, w) mark[j][k] = false;
		for (j = 0; j < h; j++) {
			int pos = 0;
			int cnt = 0;
			for (k = 0; k < w; k++) {
				if (height[k] <= j || tmp[j][pos] != tmp[j][k]) {
					pos = k;
					cnt = 0;
				}
				cnt++;
				
				if (cnt >= K) {
					for (int l = pos; l <= k; l++) {
						mark[j][l] = true;
					}
					flag = true;
				}
			}
		}
		
		//消す
		if (!flag) return score;
		score += (1 << i) * erase();
	}
	return score;
}

void input() {
	cin >> h >> w >> K;
	int i; for (i = h - 1; i >= 0; i--) cin >> s[i];	//s[0]の方が下にある
}

int main() {
	input();
	
	int ans = 0;
	int i, j;
	
	rep(i, h) rep(j, w) ans = max(ans, drop(i, j));
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <numeric>
using namespace std;
string str;
int main() {
    cin >> str;
    if(str[0]=='Y'&&str[1]=='A'&&str[2]=='K'&&str[3]=='I') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n)     for (ll i = 0; i < (n); ++i)
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)  (x).begin(), (x).end()    //昇順
#define rall(x) (x).rbegin(), (x).rend()  //降順
#define yes     out("Yes");
#define no      out("No");

int main() {
    in(n);
    vector<ll> f0(n);
    vector<ll> f1(n);
    rep(i, n) {
        in(x);
        in(y);
        f0[i] = x - y;
        f1[i] = x + y;
    }
    out(max(*max_element(all(f0)) - *min_element(all(f0)), *max_element(all(f1)) - *min_element(all(f1))));
}

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

int a[100005]={0},maxv=0,ans,n,x,i;

int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x;
		
		
		if(x>100000) ans++;
		else{
			a[x]++;
			if(a[i]>maxv) maxv=a[i];
		}
	}
	
	for(i=1;i<=100000;i++){
		if(a[i]!=0&&a[i]!=i){
			if(a[i]>i) ans+=a[i]-i;
			else ans+=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

cand_str_set = set(s_list)

calced_list = [(s_list.count(str_i) - t_list.count(str_i)) for str_i in cand_str_set]
calced_list.append(0)

print(max(calced_list))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,M,X,Y;cin>>N>>M>>X>>Y;
 vector<ll> x(N);
  for(ll i=0;i<N;i++) {
cin>>x[i];
  }
  vector<ll> y(M);
  for(ll i=0;i<M;i++) {
    cin>>y[i];
  }
  
  sort(all(x));
  sort(all(y));
  
  ll xmax=x.back();
  ll ymin=y[0];
  
  if(X<=xmax&&xmax<ymin&&ymin<=Y) {
cout<<"No War"<<endl;
  }
  else {
cout<<"War"<<endl;
  }
}
  
  

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  A.push_back(K + A[0]);
  ll ans = 0;
  int m = 0;
  for (int i = 0; i < N; i++) {
    int d = A[i + 1] - A[i];
    ans += d;
    m = max(m, d);
  }
  cout << ans - m << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
 
#define ff first
#define ss second
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define mem(a) memset(a , 0 ,sizeof a)
#define rep(i,a,b) for(int i=a ; i<b ; ++i)
#define deb(x) cout << #x << " - " << x << "\n";
#define deb2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D2(x) { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define clz(x) __builtin_clzll(x)
#define bit(x) __builtin_popcount(x)
//(a / b) + ((a % b) != 0);
 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 10000000000000000;
const ll MAX_N = 1e5 + 7;

int main() {
    IOS;
    ll a,b,c,k; cin>>a>>b>>c>>k;
    if(a+b>=k){
        cout<<min(a,k);
    }
    else{
        ll res = k - (a+b);
        cout<< a - res;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int MAXX = 3e5+7;

int row[MAXX], col[MAXX];
vector< int >occ[MAXX];

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

    int h, w, m;
    cin >> h >> w >> m;

    while (m--) {
        int x, y;
        cin >> x >> y;
        row[x]++;
        col[y]++;
        occ[x].push_back(y);
    }

    multiset< int >mr, mc;
    for (int i = 1; i <= h; i++) mr.insert(row[i]);
    for (int i = 1; i <= w; i++) mc.insert(col[i]);

    int ans = max(*prev(mr.end()), *prev(mc.end()));
    ans = max(ans, *prev(mr.end())+*prev(mc.end()) - 1);

    for (int i = 1; i <= h; i++) {
        if (row[i] < *prev(mr.end())) continue;
        for (int y : occ[i]) mc.erase(mc.find(col[y]));
        if (mc.size()) ans = max(ans, row[i]+*prev(mc.end()));
        for (int y : occ[i]) mc.insert(col[y]);
    }

    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 50524
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    A = fetch_vec<ll>(N);
}

int solve(){
    bool fi=true;
    bool g=false,d=false;
    int ans=0;
    for (int i = 0; i < N-1; i++)
    {
        if(fi){
            if(A[i]<A[i+1]) { g=true; fi=false; ans++;}
            else if(A[i]>A[i+1]){ d=true; fi=false; ans++;}
            else continue;
        }
        else if(g){
            if(A[i]<=A[i+1]) continue;
            else {g=false;fi=true;}
        }
        else if(d){
            if(A[i]>=A[i+1]) continue;
            else {d=false;fi=true;}
        }        
    }
    if(fi) ans++;
    cout << ans << endl;

    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll()

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	string s,t;
    	cin>>s>>t;
    	int n=s.length(),i,j;
    	int m=t.length();
    	int ans=n+1;
    	for(i=0;i+m-1<n;i++)
    	{
    		int cnt=0;
    		for(j=0;j<m;j++)
    		{
    			if(s[i+j]!=t[j])
    			cnt++;
			}
			ans=min(ans,cnt);
		}
		cout<<ans;
    	

    }

}


Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	char table[5][5];
	while(~scanf("%s",table)){
		if(table[0][0] == '0') break;
		for(int i=1;i<=2;i++){
			scanf("%s",table+i);
		}

		int winner=0;
		for(int i=0;i<3;i++){
			int w=0,b=0;
			for(int j=0;j<3;j++){
				if(table[i][j] == 'w') w++;
				if(table[i][j] == 'b') b++;
			}
			if(w==3) winner = 1;
			if(b==3) winner = -1;
		}

		for(int i=0;i<3;i++){
			int w=0,b=0;
			for(int j=0;j<3;j++){
				if(table[j][i] == 'w') w++;
				if(table[j][i] == 'b') b++;
			}
			if(w==3) winner = 1;
			if(b==3) winner = -1;
		}

		if(table[0][0] == table[1][1]
		&& table[1][1] == table[2][2]
		&& table[2][2] =='w') winner = 1;

		if(table[0][0] == table[1][1]
		&& table[1][1] == table[2][2]
		&& table[2][2] =='b') winner = -1;

		if(table[0][2] == table[1][1]
		&& table[1][1] == table[2][0]
		&& table[2][0] =='w') winner = 1;

		if(table[0][2] == table[1][1]
		&& table[1][1] == table[2][0]
		&& table[2][0] =='b') winner = -1;

		printf("%s\n", winner == 1 ? "w" : winner == -1 ? "b" : "NA");

	}
}

Measured memory_bytes: 0
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

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

	int a, b, m;
	cin >> a >> b >> m;
	vector<int> A(a), B(b);
	for (int i = 0; i < a; ++i) cin >> A[i];
	for (int i = 0; i < b; ++i) cin >> B[i];
	int min_a = *min_element(A.begin(), A.end());
	int min_b = *min_element(B.begin(), B.end());
	int min_sum = min_a + min_b;

	int x, y, c;
	int min_w = 2e9;
	for (int i = 0; i < m; ++i) {
		cin >> x >> y >> c;
		--x, --y;
		min_w = min(min_w, A[x] + B[y] - c);
	}
	cout << min(min_sum, min_w) << endl;
	return 0;
}

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

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int waterA, waterB, sugarC, sugarD;
  int dissolveRatio;
  int limit;

  cin >> waterA >> waterB >> sugarC >> sugarD >> dissolveRatio >> limit;

  vector<int> waterAmount;
  int wlpInd = max(limit/100/waterA,limit/100/waterB);

  REP(i,wlpInd+1){
    REP(k,wlpInd+1){
      int wam = 100*waterA*i+100*waterB*k;
      if (wam <= limit) waterAmount.push_back(wam);
    }
  }
  sort(waterAmount.begin(), waterAmount.end());
  waterAmount.erase(unique(waterAmount.begin(),waterAmount.end()),waterAmount.end());
  
  vector<int> sugarAmount;
  int slpInd = max(limit/sugarC+1,limit/sugarD+1);

  REP(i,slpInd+1){
    REP(k,slpInd+1){
      int sam = sugarC*i+sugarD*k;
      if (sam <= limit) sugarAmount.push_back(sam);
    }
  }

  sort(sugarAmount.begin(), sugarAmount.end());
  sugarAmount.erase(unique(sugarAmount.begin(),sugarAmount.end()),sugarAmount.end());
  
  int ans1 = 0;
  int ans2 = 0;
  double maxCons = -1.;

  REP(i,(int)waterAmount.size()){
    REP(k,(int)sugarAmount.size()){
      int wam = waterAmount[i];
      int sam = sugarAmount[k];
      int wsSum = wam + sam;
      if(wsSum <= limit && ((wam / 100 * dissolveRatio) >= sam)){
        double consentration = 100.0 * sam / wsSum;
        if(maxCons <= consentration){
          maxCons = consentration;
          ans1 = wsSum;
          ans2 = sam;
        }
      }
    }
  }

  cout << ans1 <<" "<< ans2 << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

int main()
{
	char input[100];
	int yy, mm, dd;

	scanf("%s", input);
	sscanf(input, "%d/%d/%d", &yy, &mm, &dd);

	if (yy <= 2018) {
		cout << "Heisei" << endl;
	}
	else if (mm <= 4) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int long long
#define REP(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define mp(x,y) make_pair((x),(y))
using namespace std;


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

	int N;
	cin >> N;
	vector<int>A(N + 1);
	rep(i, N)cin >> A[i];
	int answer = 0;
	rep(i, N){
		answer += A[i] / 2;
		A[i] = A[i] % 2;
		if (A[i] && A[i + 1]){
			answer++;
			A[i]--;
			A[i + 1]--;
		}
	}
	cout << answer << endl;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int a, b, c, x;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  int ret = 0;
  for(int i = 0; i <= a; i++) {
    for(int j = 0; j <= b; j++) {
      for(int k = 0; k <= c; k++) {
        if(500*i+100*j+50*k == x) ret++;
      }
    }
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  char c[n];
  int f(0);
  for(int i(0);i<n;i++){
    cin>>c[i];
    if(c[i]=='Y')f=1;
  }
  if(f==1)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    string a, b; cin >> a >> b;
    int n, m; cin >> n >> m;
    string c; cin >> c;
    if(a == c) n--;
    else m--;
    cout << n << " " << m << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

    int n;
    cin >> n;
    vector<Pll> tasks(n);

    for(int i=0;i<n;++i) {
        cin >> tasks[i].second >> tasks[i].first;
    }
    sort(tasks.begin(), tasks.end());

    ll duration = 0;
    for(int i=0;i<n;++i) {
        duration += tasks[i].second;
        if(duration > tasks[i].first) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3328
r, g, b, n = map(int, input().split())

ans = 0

for ri in range(0,n//r+1):

    t = n - ri*r
    if t<0:
        break
    
    for gi in range(0,t//g+1):
        tt = t -gi*g
#        print((ri,gi,tt))
        if tt<0:
            break
        if tt%b == 0:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#define waru 1000000000+7

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
    }
    // showa(p)

int che  = 0;
        rep(i,n){
            // che = false;
            if(p[i] != i+1){
                che ++;
            }
        }
        if(che == 0 || che == 2){
            cout <<"YES";
        }
        else{
            cout << "NO";
        }

    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

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

    cout << (N - K + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
A = input()
A = list(A[0]+"F"+A[1]+"G"+A[2]+"H"+A[3])
B=["+", "-"]

for i in range(2):
    for j in range(2):
        for k in range(2):
            A[1] = B[i]
            A[3] = B[j]
            A[5] = B[k]
            C = "".join(A)
            if 7 == eval(C):
                print(C+"=7")
                sys.exit()

Measured memory_bytes: 3064
#include <cstdio>

int n,m;
int c[501],d[501];
int cnt[1001];
int main(void){
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d %d",&c[i],&d[i]);
		for(int j=c[i];j<d[i];j++){
			cnt[j]=1;
		}
	}
	int res=n+1;
	for(int i=0;i<=n;i++){
		res+=cnt[i]*2;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code

    int N;
    cin >> N;

    if(N>100000||N<1)return 0;

    int i = 0;
    int A[N];
    int count = 0;
    int res[N];

    for(i=0;i<N;i++){
        cin >> A[i];
        if(A[i]>N || A[i]<1)return 0;
        //cout << a[i];
        res[A[i]-1] = i+1;
    }

    for(i=0;i<N;i++){
        cout << res[i] <<" ";
    }

    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 



int main()
{ 
    long long int a, b, n, x, y, ans, i, j;
    cin >> a >> b >> n;

    if (n < b)
    {
        x = n;
        cout << (a*x)/b;
    }
    if (n == b)
    {
        x = n-1;
        cout << (a*x)/b;
    }
    if (n > b)
    {
        x = b-1;
        y = b+1;
        i = (a*x)/b - a*(x/b);
        j = (a*y)/b - a*(y/b);
        if (i > j)
        {
            cout << i;
        }
        else {
            cout << j;
        }
    }

    return 0;
    
}




Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n,m,vis[100005],s=0;
vector<int>g[100005];
void dfs(int x,int nw)
{
	vis[x]=nw;
	s+=nw;
	for(int i=0;i<g[x].size();i++)
	{
		if(vis[g[x][i]]==nw)
		{
			long long t=n;
			t=t*(n-1)/2;
			printf("%lld\n",t-m);
			exit(0);
		}
		else if(vis[g[x][i]]==-1)dfs(g[x][i],nw^1);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1;i<=n;i++)vis[i]=-1;
	dfs(1,0);
	printf("%lld\n",s*(n-s)-m);
	return 0;
} 


Measured memory_bytes: 6528
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int A, B, K;  cin >> A >> B >> K;
    int former = A, latter = B-K+1;

    while(former <= min(B,A+K-1)){
      cout << former << endl;
      former++;
    }
    // cout << "sec" << endl;
    latter = max(former, latter);
    while(latter <= B){
      cout << latter << endl;
      latter++;
    }


    return 0;
}


Measured memory_bytes: 256
/*
	最近点対：蟻本 第2版 p 326
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1e100

using namespace std;

typedef long long ll;
typedef pair<double, double> P;

const int MAX_N = (int)1e5 + 5;

int N;
P A[MAX_N];

// y 座標の昇順でマージをするための比較関数
bool compare_y(P a, P b){
	return a.second < b.second;
}

// a は x 座標の昇順で渡される
double closest_pair(P *a, int n){
	if (n <= 1) return INF;
	int m = n / 2;
	double x = a[m].first;
	double d = min(closest_pair(a, m), closest_pair(a + m, n - m));	// (1)
	inplace_merge(a, a + m, a + n, compare_y);	// 2 つのソートされた列をマージ
	// この時点で a は y 座標の昇順になっている

	// (2')
	vector<P> b; // 直線から距離 d 未満の頂点を入れていく
	for (int i = 0; i < n; ++i){
		if (fabs(a[i].first - x) >= d) continue;
		
		// b に入っている頂点を、末尾から、y 座標の差が d 以上になるまで見ていく
		for (int j = 0; j < (int)b.size(); ++j){
			double dx = a[i].first - b[b.size() - j - 1].first;
			double dy = a[i].second - b[b.size() - j - 1].second;
			if (dy >= d) break;
			d = min(d, sqrt(dx * dx + dy * dy));
		} // end for
		b.push_back(a[i]);
	} // end for

	return d;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	rep (i, N){
		double x, y; cin >> x >> y;
		A[i].first = x; A[i].second = y;
	} // end rep

	sort(A, A + N);	// x 座標でソート
	double res = closest_pair(A, N);

	printf("%.08lf\n", res);

	return 0;
}


Measured memory_bytes: 7776
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 1e18;
vector<int> g[N];

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
       int n;
       cin>>n;
       vi a(n+1);
       FF(i,1,n+1)
       {
           cin>>a[i];
       }
       vi b(n+1),c(n+1);
       MAP mp;
       FF(i,1,n+1)
       {
           b[i]=i+a[i];
           c[i]=i-a[i];
           mp[c[i]]++;
       }
       int cnt =0;
       FF(i,1,n+1)
       {
           cnt+=mp[b[i]];
       }
       cout<<cnt<<"\n";

       
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



Measured memory_bytes: 35328
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ss <- replicateM n getLine
    print $ length $ group $ sort ss

Measured memory_bytes: 165388
#include <stdio.h>

int main(){
  int n, q, i, j, k, x=0, z;
  int b[500];
  scanf("%d", &n);
  int s[n];
  for(i=0;i<n;i++)scanf("%d", &s[i]);
  scanf("%d", &q);
  int t[q];
  for(j=0;j<q;j++)scanf("%d", &t[j]);
  for(i=0;i<n;i++){
    for(j=0;j<q;j++){
          if(s[i]==t[j]){
            for(k=0,z=0;k<x;k++){
              if(s[i]==b[k])z=1;
            }
            if(z==0){
                b[x]=s[i];
                x++;
            }
          }
    }
  }
  printf("%d\n", x);
  return 0;
}


Measured memory_bytes: 2108
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	}
}


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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const int inf = 12e8;
const int mod = 1e9 + 7,
N = 2e6 + 11;

string s, t;
int n, m, q, cnt[2][N];
int sum(int l, int r, int tp) {
    return cnt[tp][r] - cnt[tp][l - 1];
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    reads(s);
    reads(t);
    n = s.size();
    s = '#' + s;
    m = t.size();
    t = '#' + t;
    for (int i = 1; i <= n; i++)
        cnt[0][i] = cnt[0][i - 1] + (s[i] == 'A' ? 1 : -1);
    for (int i = 1; i <= m; i++)
        cnt[1][i] = cnt[1][i - 1] + (t[i] == 'A' ? 1 : -1);
    read(q);
    while (q--) {
        int l, r, u, v;
        read(l);
        read(r);
        read(u);
        read(v);
        if ((sum(l, r, 0) - sum(u, v, 1)) % 3)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
}


Measured memory_bytes: 5348
#include <iostream>

using namespace std;
int main(void)
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt;
  char mem = ' ';
  for (int i = 0 ;i < S.length();i++)
  {
    if(mem != S[i])cnt++;
    mem = S[i];
  }
  cout << cnt << endl;	
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> A(n, 0);
  for(ll i=0; i<n; i++) {
    cin >> A[i];
  }
  ll xor_sum = 0;
  for(ll i=0; i<n; i++) {
    xor_sum ^= A[i];
  }

  vector<ll> B(n, 0);
  for(ll i=0; i<n; i++) {
    B[i] = xor_sum^A[i];
  }

  for(ll i=0; i<n; i++) {
    cout << B[i] << " ";
  }
  cout << endl;

  ll xor_all = 0;
  for(ll i=0; i<n; i++) {
    xor_all ^= B[i];
  }
  //cerr << "xor_all=" << xor_all << endl;
  for(ll i=0; i<n; i++) {
    //cerr << "B[i]=" << B[i] << " B[i]^xor_all=" << (B[i]^xor_all) << " A[i]=" << A[i] << endl;
    assert(A[i] == (B[i]^xor_all));
  }
}


Measured memory_bytes: 6420
#include "stdio.h"
#include "iostream"
#include <vector>

using namespace std;
int main() {
	int a,b,c;
	int w[3];
	cin >> a>>b>>c;
	if (a > b) {
		if (a > c) 
			cout << a * 10 + b + c;
		else
			cout << c * 10 + a + b;
	}
	else {
		if (b > c)
			cout << b * 10 + a + c;
		else
			cout << c * 10 + a + b;
	}
}

Measured memory_bytes: 256
from collections import deque
n,m = map(int, input().split())
ikisaki=[[] for _ in range(n+1)]

for _ in range(m):
    a,b = map(int, input().split())
    ikisaki[a].append(b)
    ikisaki[b].append(a)
ans=[0]+[1]+[0]*(n-1)
tansakuheya=deque([1])
tmp=deque()

for _ in range(1000009):

    for bangou in tansakuheya:

        for heya in ikisaki[bangou]:
            if ans[heya]==0:
                ans[heya]=bangou
                tmp.append(heya)

    tansakuheya=tmp.copy()
    tmp=deque()


    if not tansakuheya:
        break

print("Yes")
for i in range(2,n+1):
	print(ans[i])

Measured memory_bytes: 98996
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        ans+=(s[i]-'0');
    }
    if((ans%9)==0) {
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }

    return 0;
}

Measured memory_bytes: 3780
fun main(args: Array<String>) {
    abc121a()
}

fun abc121a() {
    val (h1, w1) = readLine()!!.split(" ").map { it.toInt() }
    val (h2, w2) = readLine()!!.split(" ").map { it.toInt() }

    val totalArea = h1 * w1

    val verticalBlackArea = h2 * w1
    val horizontalBlackArea = w2 * h1
    val totalBlackArea = verticalBlackArea + horizontalBlackArea - (h2 * w2)

    val totalWhiteArea = totalArea - totalBlackArea
    println(totalWhiteArea)
}


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

int main(void) {
    string S;
    int e;
    int cnt = 0;
    bool judge = true;
    cin >> S;
    e = S.size() -1;
    if(S[0] != 'A') judge = false;
    if(S[1] < 'a' || S[1] > 'z') judge = false;
    if(S[e] < 'a' || S[e] > 'z') judge = false;
    for(int i=2;i<e;i++) {
       if(S[i] < 'a' || S[i] > 'z'){
            cnt++;
            if(S[i] != 'C') judge = false;
        }
    }

    if(cnt == 1 && judge) {
        cout << "AC\n";   
    } else {
        cout << "WA\n";   
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> v[N];
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v>w)
    {
        ll d1=v*t;
        ll d2=w*t;
        ll df=abs(b-a);
        if(d1>=df+d2)
        {
            cout<<"YES";
        }
        else
        {
            cout<<"NO";
        }
    }
    else
    {
        cout<<"NO";
    }
}

Measured memory_bytes: 5980
/*---> 22 December 2019 <--- > 17:45:46 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n;
	cin>>n;
	if(n&1){
		cout<<0<<"\n";
	}
	else{
		n/=2;
		// int ans=5;
		int cur=0;
		for(int i=5;n/i>=1;i*=5)
			cur+=(n/i);
		cout<<cur<<"\n";
	}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll a[100010];
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    ll sum[100010] = {};
    ll ans = 0;
    rep(i,0,N){
        sum[i+1] = sum[i] + a[i];
        if(i % 2 == 0){
            if(sum[i+1] <= 0){
                ans += -sum[i+1] + 1;
                sum[i+1] += -sum[i+1] + 1;
            }
        }else{
            if(sum[i+1] >= 0){
                ans += sum[i+1] + 1;
                sum[i+1] -= sum[i+1] + 1;
            }
        }
    }
    rep(i,0,N+1){
        sum[i] = 0;
    }
    ll ans2 = 0;
    rep(i,0,N){
        sum[i+1] = sum[i] + a[i];
        if(i % 2 == 0){
            if(sum[i+1] >= 0){
                ans2 += sum[i+1] + 1;
                sum[i+1] -= sum[i+1] + 1;
            }
        }else{
            if(sum[i+1] <= 0){
                ans2 += -sum[i+1] + 1;
                sum[i+1] += -sum[i+1] + 1;
            }
        }
    }
    print(min(ans, ans2));








}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int x[2],y;
	scanf("%d %d",&x[0],&x[1]);
	if(x[0]>x[1]) y=x[0]-x[1];
	else y=x[1]-x[0];
	printf("%d\n",y);
	return 0;
}


Measured memory_bytes: 2120
require 'matrix'

def get_integers
    gets.split(" ").map(&:to_i)
end

loop {
    n, k = get_integers
    break if n == 0
    residue = (0..n).map{Vector[*get_integers]}.inject(&:-)
    puts residue.all?{|x| x >= 0} ? 'Yes' : 'No'
}   

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

const int MAX = 1000100;

vector<int> tetras;
vector<int> oddTetras;

int dp[MAX];
int oddDp[MAX];

int main() {
	for (int i = 1; i < 200; i++) {
		int n = i * (i + 1) * (i + 2) / 6;
		tetras.push_back(n);
		if (n % 2 == 1)
			oddTetras.push_back(n);
	}

	for (int i = 0; i < MAX; i++) {
		dp[i] = oddDp[i] = i;
	}
	for (int i = 1; i < MAX; i++) {
		for (int j = 0; tetras[j] <= i; j++) {
			dp[i] = min(dp[i], dp[i - tetras[j]] + 1);
		}
		for (int j = 0; oddTetras[j] <= i; j++) {
			oddDp[i] = min(oddDp[i], oddDp[i - oddTetras[j]] + 1);
		}
	}

	int n;
	while (cin >> n , n != 0) {
		cout << dp[n] << " " << oddDp[n] << endl;
	}
}

Measured memory_bytes: 9028
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const ll MOD = (ll)1e9 + 7 ; 
map<ll,ll> mp ;
void factors(ll x){
	for(ll i=2;i*i<=x;i++){
		while(x%i==0){
			mp[i]++;
			x /= i ; 
		}
	}
	if ( x > 1 ) mp[x]++ ; 
}
int main(){
    fastio
    ll n ; 
    cin >> n ; 
    ll ans = 1 ; 
    for(ll i=1;i<=n;i++){
    	factors(i) ; 
    }
    for(auto &p : mp){
    	ans = (ans % MOD * (p.second+1) % MOD) % MOD ; 
    }
    debug() << imie(mp) ; 
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int main(){
	long long x,t=0;
	cin >> x;
	
	for(long long i=1;;i++){
		t+=i;
		if(t>=x){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())

tmp = [0]*N
check = [0]*N
for _ in range(M):
  a, b = map(int,input().split())
  if(a == 1):
    tmp[b] += 1
  elif(b == N):
    check[a] += 1

for i in range(len(tmp)):
  if(check[i] == 1 and tmp[i] == 1):
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

"""
tmp = [0]*N
for _ in range(M):
  a, b = map(int,input().split())
  if(a == 1):
    tmp[b] += 1
  elif(b == N):
    tmp[a] += 1

if(2 in tmp):
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
"""

Measured memory_bytes: 6132
#include <iostream>
#include <cfloat>
#include <algorithm>
#include <cmath>
#include <tuple>
using namespace std;
using llong = long long;

llong n;
tuple<double, llong, llong> p[128];

double f(tuple<double, llong, llong>a, tuple<double, llong, llong> b) {
    double arg1 = get<0>(a);
    double arg2 = get<0>(b);
    double ang = fabs(arg1 - arg2);
    return min(ang, fabs(2 * M_PI - ang));
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        llong x, y;
        cin >> x >> y;
        p[i] = make_tuple(atan2(y, x), y, x);
    }
    sort(p, p + n);

    double ans = 0;
    for (int k = 1; k <= n; k++) {
        for (int i = 0; i < n; i++) {
            llong x = 0, y = 0;
            for (int j = 0; j < k; j++) {
                x += get<2>(p[(i + j) % n]);
                y += get<1>(p[(i + j) % n]);
            }
            ans = max(ans, sqrt(x * x + y * y));
        }
    }


    printf("%.*lf\n", 15, ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string t;
int a[4005],s[5][4005],u[5];
 int main(){
 	int n;
 	cin>>n>>t;
 	for(int i=1;i<=n;i++)
 	{
 		if(t[i-1]=='R') a[i]=0;
 		if(t[i-1]=='G') a[i]=1;
 		if(t[i-1]=='B') a[i]=2;
	 }
	 for(int i=1;i<=n;i++)
	   {
	   	 for(int j=0;j<3;j++)s[j][i]=s[j][i-1];
	   	 s[a[i]][i]=s[a[i]][i-1]+1;
	   }
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(a[i]==a[j])continue;
			memset(u,0,sizeof(u));
			u[a[i]]=1;u[a[j]]=1;
			int x;
			for(int k=0;k<3;k++)
			   if(u[k]==0)x=k;
			ans+=s[x][n]-s[x][j];
			if(j-i+j<=n&&a[j-i+j]==x)ans--;
		}
	}
 cout<<ans;
return 0;
}


Measured memory_bytes: 3680