akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll lft;
  cin >> lft;
  ll ans = 0;
  REP(i, n-1) {
    ll rgt;
    cin >> rgt;
    if(lft == rgt) {
      ans++;
      lft = -1;
    }
    else {
      lft = rgt;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,a[5555];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <list>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <random>
#include <queue>
#include <fstream>
#include <iterator> // std::back_inserter
#include <chrono>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <float.h>
#include <cassert>
#include <functional>

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    int count = 0;
    string ans = "APPROVED";

    cin >> N;

    int a[N];

    for(int i=0; i<N; i++) cin >> a[i];

    for(int i=0; i<N; i++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0) ans = "DENIED";
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
int a[110];
int main() {
	int n;
	int kase;
		scanf("%d", &n);
		int flag = -1;
		a[0] = 0;
		while(n) {
			a[++flag] = n%(-2);
			n /= (-2);
			if(a[flag] == -1) 
            {
				a[flag] = 1;
				n++;
			}
		}
		while(flag>0) 
            printf("%d", a[flag--]);
		printf("%d", a[0]);
	return 0;
}


Measured memory_bytes: 128
import numpy as np

n = int(input())
a = [int(input()) for _ in range(n)]
na = np.array(a)
maxI = np.argmax(na)
maxA = na[maxI]
nb = np.copy(na)
nb[maxI] = 0
maxA2 = np.max(nb)
for i in range(n):
    if i != maxI:
        print(na[maxI])
    else:
       print(maxA2)

Measured memory_bytes: 26724
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader t= new BufferedReader(new InputStreamReader(System.in));
        Vector<Integer> vector =new Vector<Integer>();
        
        for (int i=1;i<=10;i++){
            vector.add(Integer.parseInt(t.readLine()));
        }
        Collections.sort(vector);
        Collections.reverse(vector);
        for(int i=0;i<3;i++){
            System.out.println(vector.get(i));
        }
    }

}

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

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

using namespace std;
using lint=long long;

template<class T> struct edge{
	int u,v;
	T wt;
	bool operator<(const edge& e)const{ return wt<e.wt; }
};

class union_find{
	int n;
	vector<int> p;
public:
	union_find(int n):n(n),p(n,-1){}
	int find(int u){ return p[u]<0?u:p[u]=find(p[u]); }
	void unite(int u,int v){
		u=find(u); v=find(v);
		if(u!=v){
			if(p[v]<p[u]) swap(u,v);
			p[u]+=p[v]; p[v]=u; n--;
		}
	}
	bool is_same(int u,int v){ return find(u)==find(v); }
	int size()const{ return n; }
	int size(int u){ return -p[find(u)]; }
};

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	int n,m;
	lint tar; scanf("%d%d%lld",&n,&m,&tar);
	vector<edge<lint>> E(m);
	rep(i,m){
		int u,v,c; scanf("%d%d%d",&u,&v,&c); u--; v--;
		E[i]=edge<lint>{u,v,c};
	}

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

	lint mst=0;
	{
		union_find U(n);
		for(auto e:E) if(!U.is_same(e.u,e.v)) mst+=e.wt, U.unite(e.u,e.v);
	}

	int crit=0,above=0;
	for(auto e0:E){
		lint cost=e0.wt;
		union_find U(n);
		U.unite(e0.u,e0.v);
		for(auto e:E) if(!U.is_same(e.u,e.v)) cost+=e.wt, U.unite(e.u,e.v);
		if     (cost==tar) crit++;
		else if(cost>tar) above++;
	}

	if(mst==tar) cout<<(pow(mint(2),crit)-2)*pow(mint(2),above)<<'\n';
	else         cout<<(pow(mint(2),crit)-1)*pow(mint(2),above+1)<<'\n';

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
const int MAX_NR = 1e6;
int cnt[MAX_NR + 1];


int main()
{
    cin.sync_with_stdio(0);

    int N;
    cin >> N;

    vector<int> nrs(N);
    for (int &nr : nrs)
    {
        cin >> nr;
    }

    int q = *max_element(begin(nrs), end(nrs));
    for (const int &nr : nrs)
    {
        for (int multiple = nr; multiple <= q; multiple += nr)
        {
            ++cnt[multiple];
        }
    }

    int res = 0;
    for (const int &nr : nrs)
    {
        if (cnt[nr] == 1)
        {
            ++res;
        }
    }

    cout << res;
}

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

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

	if(a==b){
		cout << c << endl;
	}
	else if (b == c)
	{
		cout << a << endl;
	}
	else
	{
		cout << b << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>


using namespace std;


void white_cells()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H * W) - (h * W) - (H * w) + (h * w) << "\n";
}


void double_helix()
{
  char b;
  cin >> b;

  if (b == 'A') cout << "T\n";
  else if (b == 'T') cout << "A\n";
  else if (b == 'C') cout << "G\n";
  else  cout << "C\n";

}


void five_antennas()
{
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];
  int k;
  cin >> k;

  if (a[4] - a[0] > k)
  {
    cout << ":(\n";
    return;
  }
  cout << "Yay!\n";

}

void buttons()
{
  int a, b;
  cin >> a >> b;

  int v_max = 0;
  for (int i = 0; i < 2; ++i) {
    if (a > b) {
      v_max += a;
      --a;
    }
    else
    {
      v_max += b;
      --b;
    }
  }
  cout << v_max << "\n";
}


void biscuit_generator()
{
  int a, b, t;
  cin >> a >> b >> t;

  cout << t / a * b << "\n";
}


void changing_a_character()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k - 1] += 32;
  cout << s <<"\n";
}


int main()
{
  //white_cells();
  //double_helix();
  //five_antennas();
  //buttons();
  //biscuit_generator();
  changing_a_character();
}

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

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct Edge
{
	int s, t, cost;
	Edge(int s,int t,int cost):s(s),t(t),cost(cost){}
	Edge():Edge(-1,-1,-1){}
};

int d[100][100];
int V, E;

void shortest_path()
{
	rep(k, 0, V)rep(i, 0, V)rep(j, 0, V)if (d[i][k] != INF&&d[k][j] != INF)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

	int start;
	cin >> V >> E;

	rep(i, 0, V)rep(j, 0, V)if (i != j)d[i][j] = INF;

	rep(i, 0, E)
	{
		int s, t, c;
		cin >> s >> t >> c;
		d[s][t] = c;
		//G[s].push_back(Edge(s, t, c));
		//G[t].push_back(Edge(t, s, c));
	}

	shortest_path();

	rep(i, 0, V)if (d[i][i] < 0)
	{
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}

	rep(i, 0, V)
	{
		rep(j, 0, V)
		{
			if (j != 0)
			{
				printf(" ");
			}
			printf(d[i][j] == INF ? "INF" : "%lld", d[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n):par(n),sizes(n,1){
    for(int i=0;i<n;i++)par[i] = i;
  }
  int find(int x){
    if(x == par[x])return x;
    return par[x] = find(par[x]);
  }
  void unite(int x,int y){
    x = find(x);y = find(y);
    if(x == y)return;
    if(sizes[x] < sizes[y])swap(x,y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
  int size(int x){
    return sizes[find(x)];
  }
};

int main(void) {
  int N, M;
  cin >> N >> M;

  vector<int> A(M), B(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b; a--; b--;
    A[i] = a;
    B[i] = b;
  }

  UnionFind uf(N);
  long long inconv = (long long)N * (N - 1) / 2;
  vector<long long> inconvs;
  for (int i = M - 1; i >= 0; i--) {
    inconvs.push_back(inconv);
    if (!uf.same(A[i], B[i])) {
      inconv = inconv - uf.size(B[i]) * uf.size(A[i]);
    }
    uf.unite(A[i], B[i]);
  }

  reverse(inconvs.begin(), inconvs.end());
  for (auto inconv : inconvs) {
    cout << inconv << endl;
  }

  return 0;
}

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

int main(){
	/*input*/
	int n, d;	cin >> n >> d; 
	int** x = new int* [n];  
	for(int i = 0; i < n; i++){
		x[i] = new int[d]; 
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			cin >> x[i][j];
		}
	}
	/*calculation*/
	int o = 0;
	for(int i = 0; i < n - 1; i++){
		for(int j = i + 1; j <= n - 1; j++){
			int m_2 = 0;
			for(int k = 0; k < d; k++){
				m_2 += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			for(int l = 0; m_2 >= l*l; l++){
				if(m_2 == l*l)o++;
			}
		}
	}
	
	/*output*/
	cout << o << endl;
	for(int i = 0; i < n; i++){
		delete[] x[i];
	}
	delete[] x;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    ll cnta=0,cntb=0;
    REP(i,n){
        if(s[i]=='a'&&cnta+cntb<a+b){
            cnta++;
            cout << "Yes" << endl;
        }else if(s[i]=='b'&&cnta+cntb<a+b&&cntb<b){
            cntb++;
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 848
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#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
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin >> n >> k;
	cout << n-k+1;
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    string s;
    int i;
    bool flag = false;
    bool result = false;

    cin >> s;

    for( i=0;s[i]!='\0';i++ ){
        if( flag == false ){
            if( s[i] == 'C' ){
                flag = true;
            }
        }else if( s[i] == 'F' ){
            result = true;
        }
    }

    if( result == true ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(all(a));
  ll sum = 0;
  REP(i, n) {
    if(sum + a[i] > x) {
      cout << i << endl;
      return 0;
    }
    sum += a[i];
  }
  if(sum == x) {
    cout << n << endl;
  }
  else {
    cout << n-1 << endl;
  }
  return 0;
}



Measured memory_bytes: 384
x=int(input())
f=x//100
d=x%100
ff=bool(1)
dd=bool(1)
if f==0 or f>12:
  ff=0
if d==0 or d>12:
  dd=0

if ff==1 and dd==1:
  print("AMBIGUOUS")
elif ff==0 and dd==0:
  print("NA")
else:
  if ff==1 and dd==0:
    print("MMYY")
  else:
    print("YYMM")

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++) {
cin>>A[i];
  }
  sort(all(A));
  vector<ll> note(A.back());
  
  for(ll i=0;i<N;i++) {
ll count=1;
    while(A[i]*count<=A.back()) {
note[A[i]*count-1]++;
    count++;
    }
  }
  
  ll ans=0;
  for(ll i=0;i<N;i++) {
if(note[A[i]-1]==1) {
ans++;
}
  }
  
  cout<<ans<<endl;
}

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

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

        while(true){
            String s = in.nextLine();
            if(s.equals("0"))break;

            char[] str = s.toCharArray();
            int sum = 0;

            for(int i = 0; i < str.length; i++){
                sum += str[i] - 48;
            }

            System.out.println(sum);
        }

    }
}


Measured memory_bytes: 26720
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
using namespace std;

int main(){
	fast_io;
	ll n;
	cin>>n;
	ll a[n];
	int i=0;
	while(i<n){
		cin>>a[i];
		i++;
	}
	ll sum1=0,sum2=0,ans=INT_MAX;
	for(i=1;i<n;i++){
		sum1=0;
		sum2=0;
		for(int j=0;j<n;j++){
			if(j<i){
				sum1+=a[j];
			}
			else{
				sum2+=a[j];
			}
		}
		ans = min(ans,abs(sum1-sum2));
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
using pis=pair<int, string > ;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,k;
  string s,w;
  lol a,b,c,x,y;
  cin >>n;
  priority_queue<pis ,vector<pis > ,greater<pis > > q;
  for(string i="1";i<="9";i[0]++){
    q.emplace(1,i);
  }
  for(int i=1;i<n;i++){
    string g;
    int u;
    u=q.top().fi;
    g=q.top().se;
    q.pop();
    u++;
    int o=g.size()-1;
    if(g[o]=='0'){
      q.emplace(u,g+"0");
      q.emplace(u,g+"1");
    }else if(g[o]=='9'){
      q.emplace(u,g+"8");
      q.emplace(u,g+"9");
    }else{
      char p=g[o]+1;
      char j=g[o];
      char l=g[o]-1;
      q.emplace(u,g+l);
      q.emplace(u,g+j);
      q.emplace(u,g+p);
    }
  }
  cout <<q.top().se<<'\n';
               
  return (0);
}


Measured memory_bytes: 15852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;
	if (1 <= a and a <= 9 and 1 <= b and b <= 9)
		cout << a * b << endl;
	else
		cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
ll H, W;
ll field[110][110];
ll dx[8] = { 0, 1, 0,-1, 1, 1,-1,-1 };
ll dy[8] = { 1, 0,-1, 0, 1,-1, 1,-1 };
void dfs(ll y, ll x) {
	field[y][x] = 0;
	for (ll i = 0; i < 8; i++) {
		ll ny = y + dy[i];
		ll nx = x + dx[i];
		if (nx >= 0 && nx < H && ny >= 0 && ny < W) {
			if (field[ny][nx] == 1)
				dfs(ny, nx);
		}
	}
}
int main() {
	while (cin >> H >> W) {
		if (H == 0 && W == 0) break;
		ll cnt = 0;
		for (ll i = 0; i < W; i++) {
			for (ll j = 0; j < H; j++) {
				cin >> field[i][j];
			}
		}
		for (ll y = 0; y < W; y++) {
			for (ll x = 0; x < H; x++) {
				if (field[y][x] == 1) {
					dfs(y, x);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}




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

#define infi            1e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(int i=0;i<n;i++)
#define pool(i,n)       for(int i=n-1;i>=0;i--)
#define loop1(i,n)      for(int i=1;i<=n;i++)
#define pool1(i,n)      for(int i=n;i>0;i--)
#define rr(n)           int n;n=rd() 

using namespace std;

inline ll rd(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
inline ll pow(ll b, ll p){ll ans=1;while(p>0)ans = ans<<b,p--;return ans;}
bool isPrime(ll n){if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}

//bool cmp(const ll &a, const ll &b)return a > b;
// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
        //freopen("in.txt", "r", stdin);
    //#endif

    rr(a);rr(b);rr(c);

    if((a<c&&b>c) || (a>c&&b<c))cout <<"Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 106
#define mo 1000000007
using namespace std;
int n,m,t,ans,v[N],w[N],g[N][4*N],f[N][N][4*N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&w[i],&v[i]);
	t=w[1]-1;
	for(int i=1;i<=n;i++)w[i]-=t;
	for(int k=1;k<=n;k++){
		if(1LL*t*k>1LL*m)break;
		for(int i=k;i<=n;i++)
			for(int j=w[i];j<=(int)min(1LL*m-1LL*t*k,4LL*n);j++)
				f[k][i][j]=max(f[k][i][j],g[i-1][j-w[i]]+v[i]),ans=max(ans,f[k][i][j]);
		memset(g,0,sizeof g);
		for(int i=k;i<=n;i++)
			for(int j=0;j<=(int)min(1LL*m-1LL*t*k,4LL*n);j++)g[i][j]=max(f[k][i][j],g[i-1][j]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 18560
X=int(input())
if X==1:
  print(1)
else:
  ans=0
  import math
  for i in range(2,int(math.sqrt(X))+1):
    val=i*i
    while val*i<=X:
      val=val*i
    ans=max(ans,val)
    if ans==X:
      break
  print(ans)


Measured memory_bytes: 3060
using System;

namespace Key20A {
    class Program {
        static void Main(string[] args) {
            var h = int.Parse(Console.ReadLine());
            var w = int.Parse(Console.ReadLine());
            var n = int.Parse(Console.ReadLine());
            var max = Math.Max(h, w);
            var x = n / max;
            if (n % max == 0) Console.WriteLine(x);
            else Console.WriteLine(x+1);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    ll k;
    cin>>s>>k;
    for(int i=0;i<k;i++){
        if(s[i]=='1') continue;
        cout<<s[i]<<endl;
        return 0;
    }
    cout<<1<<endl;
}

Measured memory_bytes: 3628
//Volume0-0024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N;
    	while(sc.hasNext()){
    		N = (int)(4.9*Math.pow(sc.nextDouble()/9.8,2)/5)+2;
    		System.out.println(N);
    	}
    }
}

Measured memory_bytes: 16784
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
ab = [inpl() for _ in range(n)]
su = sum(x[1] for x in ab)
mx = max(x[0] for x in ab)
ab.sort(key = lambda x:x[1], reverse = True)
res = 0
for i in range(n):
    if ab[i][1] > mx:
        m -= ab[i][1]
        res += 1
    else:
        break
    if m <= 0:
        print(res)
        quit()
print(res + (m + mx - 1)//mx)

Measured memory_bytes: 30964
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n =sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    System.out.println(Math.min(a*n,b));
  }
  

  
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;
int d[201][201];
vector<int> c(201, 0);

bool dfs(int n, int p, int color){
    bool flag = true;
    c[n] = color;
    rep(i, 200){
        if (i != p && d[n][i] == 1){
            if (c[i] == -color) continue;
            else if (c[i] == color) return false;
            else {
                flag = flag && dfs(i, n, -color);
            }
        }
    }
    return flag;
}

int main(){
    int N;
    cin >> N;
    rep(i, N){
        string s;
        cin >> s;
        rep(j, N){
            if (s[j] - '0' == 0 && i != j) {
                d[i][j] = 100100100;
            } else {
                d[i][j] = s[j] - '0';
            }

        }

    }

    if (!dfs(0, -1, 1)){
        cout << -1 << endl;
        return 0;
    }



    rep(k, N){
        rep(i, N){
            rep(j, N){
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, N){
        rep(j, N){
            chmax(ans, d[i][j]);
        }
    }

    cout << ans+1 << endl;


}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,c,d,g;
ll f(ll x,ll y){
    if(y==0)return x;
    return f(y,x%y);
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c>>d;
        g=f(b,d);
        if(a<b||b>d){
            cout<<"No"<<endl;
            continue;
        }
        if(c>=b+1){
            cout<<"Yes"<<endl;
            continue;
        }
        if(a%g+b-g>c){
            cout<<"No"<<endl;
        }
        else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll tmp = n;
	ll sum = 0;
	while(tmp > 0)
	{
		sum += tmp % 10;
		tmp /= 10;
	}
	cout << (n % sum ? "No" : "Yes") << endl;
	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007 
#define MOD2 998244353
#include <vector>
#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)
#define ALL(obj) (obj).begin(), (obj).end()

int main() {
	ll power[2501];
	power[0] = 1;
	REP(i, 2500) power[i + 1] = (power[i] * 26) % MOD;

	ll power2[2501];
	power2[0] = 1;
	REP(i, 2500) power2[i + 1] = (power2[i] * 26) % MOD2;

	int n;
	cin >> n;
	char s[5001];
	cin >> s;

	vll hash_list;
	ll ha=0;
	hash_list.push_back(0);
	REP(i, n) {
		ha *= 26;
		ha += s[i] - 'a';
		ha %= MOD;
		hash_list.push_back(ha);
	}

	vll hash_list2;
	ll ha2 = 0;
	hash_list2.push_back(0);
	REP(i, n) {
		ha2 *= 26;
		ha2 += s[i] - 'a';
		ha2 %= MOD2;
		hash_list2.push_back(ha2);
	}

	RFOR(j, n/2, 0) {
		unordered_map<ll, int> ma;
		REP(i, n - j + 1) {
			ll x = (hash_list[i]*power[j])%MOD;
			x = (hash_list[i + j]+MOD-x)%MOD;
			if (ma.find(x) == ma.end()) ma[x] = i;
			else if (i >= ma[x] + j) {
				ll xx = (hash_list2[i]*power2[j])%MOD2;
				xx = (hash_list2[i + j]+MOD2-xx)%MOD2;
				ll xxx = (hash_list2[ma[x]]*power2[j])%MOD2;
				xxx = (hash_list2[ma[x] + j]+MOD2-xxx)%MOD2;
				if(xx==xxx){
					cout << j;
					return 0;
				}
			}
		}
	}

	cout << "0";
	return 0;
}


Measured memory_bytes: 700
#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;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double> > vvd;
typedef vector<double> vd;

#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;

#define all(x) x.begin(), x.end()
#define INF 1000000009
#define MOD 1000000007

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

	ll n;
	cin >> n;
	ll ans = n / 500 * 1000 + (n % 500 / 5) * 5;
	cout << ans << "\n";
}

Measured memory_bytes: 256
scoret, scoreh = 0, 0
gets.to_i.times do
  taro, hanako = gets.split(" ")
  if taro == hanako
    scoret += 1
    scoreh += 1
  else
    if taro > hanako
      scoret += 3
    else
      scoreh += 3
    end
  end
end
puts [scoret, scoreh].join(" ")

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
void changeString(string &t,string p){
    if(t=="0") t=p;
    else if(t.size()<p.size()) t=p;
    else if(t.size()==p.size()){
        if(t<p) t=p;
    }
}
string dp[MAX];
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(m);
    sort(ALL(a));
    REP(i,m)IN(a[i]);
    int num[10]={0,2,5,5,4,5,6,3,7,6};
    REP(i,MAX){
        dp[i]="0";
    }
    dp[0]="";
    REP(i,n+1){
        if(dp[i]=="0")continue;
        REP(j,m){
            changeString(dp[i+num[a[j]]],dp[i]+(char)(a[j]+'0'));
        }
    }
    OUT(dp[n]);
    return 0;
}

Measured memory_bytes: 49792
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN 100100
struct hoge {
  int t, x, y;
};
hoge a[MAXN];
#define MODULO(a, b) (((a) % (b)) < 0 ? (a) % (b) + (b) : (a) % (b))
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  REP(i, N) { cin >> a[i].t >> a[i].x >> a[i].y; }
  //  bool ok = true;
  hoge now = {0, 0, 0};
  REP(i, N) {
    hoge diff = {a[i].t - now.t, a[i].x - now.x, a[i].y - now.y};
    bool flg = MODULO(diff.x + diff.y, 1 + 1) == diff.t % 2 && abs(diff.x) + abs(diff.y) <= diff.t && abs(diff.x) <= diff.t && abs(diff.y) <= diff.t;
    if (!flg) {
      //      cerr << i << " " << diff.x << " " << diff.y << " " << diff.t;
      print("No");
      return 0;
    }
    now = a[i];
  }
  print("Yes");
}

Measured memory_bytes: 2560
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc125_d

# input
n = int(input())
A = [int(s) for s in input().split()]
# get ans
isEven = len([1 for a in A if a<0]) % 2 == 0
A = [abs(a) for a in A]
if isEven:
    ans = sum(A)
else:
    ans = sum(A) - min(A)*2
# output
print(ans)



Measured memory_bytes: 14412
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	string str;
	queue<int> que[3];

	for(int i = 0;i < 3;i++){
		cin >> str;
		for(int j = 0;j < str.size();j++){
			int pushInt = 0;
			if(str[j] == 'a') pushInt = 0;
			else if(str[j] == 'b') pushInt = 1;
			else pushInt = 2;

			que[i].push(pushInt);
		}
	}

	int next = 0;
	while(true){
		int now = next;
		if(que[now].size() == 0){
			if(now == 0) cout << "A" << endl;
			else if(now == 1) cout << "B" << endl;
			else cout << "C" << endl;
			break;
		}
		next = que[now].front();
		que[now].pop();

	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

int n;
int over_red;
std::map<std::string, int> mp;
std::string color(int a) {
    std::string res;
    if      (a <  400) res = "Gray";
    else if (a <  800) res = "Brown";
    else if (a < 1200) res = "Green";
    else if (a < 1600) res = "Light Blue";
    else if (a < 2000) res = "Blue";
    else if (a < 2400) res = "Yellow";
    else if (a < 2800) res = "Orange";
    else if (a < 3200) res = "Red";
    return res;
}


int main() {
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        int a;
        std::string c;
        std::cin >> a;
        if (a < 3200) {
            c = color( a );
            if (mp.find(c) == mp.end()) {
                mp[c] = 1;
            } else {
                ++mp[c];
            }
        } else {
            ++over_red;
        }
    }
    int min = std::max((int) mp.size(), 1);
    int max = mp.size() + over_red;
    
    std::cout << min << ' ' << max << std::endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

(|>) :: a -> (a -> b) -> b
infixl 1 |>
x |> f = f x

($>) :: (Functor m) => m a -> (a -> b) -> m b
infixl 1 $>
x $> f = fmap f x

bsToInt :: BC.ByteString -> Int
bsToInt bs = bs |> BC.readInt |> fromJust |> fst

getInt :: IO Int
getInt = BC.getLine $> bsToInt

getInts :: IO [Int]
getInts = BC.getLine $> BC.words $> map bsToInt

solve [t1, x1, y1] [t2, x2, y2]
    | t < d        = False
    | even (t - d) = True
    | otherwise    = False
    where d = abs (x1 - x2) + abs (y1 - y2)
          t = t2 - t1

main = do 
    n <- getInt
    c <- replicateM n getInts
    let x = [0, 0, 0] : c 
    let ans = and $ zipWith solve x (tail x)
    putStrLn $ if ans then "Yes" else "No"
    


Measured memory_bytes: 28156
#include<bits/stdc++.h>
using namespace std;
long long a[1010];
long long b[1010];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	long long n;
	cin>>n;
	for(long long i=0;i<n;i++)cin>>a[i]>>b[i];
	long long cnt=1;
	long long ans=1;
	for(long long i=0;i<n;i++){
		long long cnt2=cnt/a[i];
		long long ans2=ans/b[i];
		if(cnt2*a[i]!=cnt)cnt2++;
		if(ans2*b[i]!=ans)ans2++;
		cnt=a[i]*max(cnt2,ans2);
		ans=b[i]*max(ans2,cnt2);
	}
	cout<<ans+cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main(){
  int a,b,c,d;
  cin >>a >>b>>c>>d;
  while(a>0 &&c>0){
    c=c-b;
    a=a-d;
  }
   if(a<=0 && c>0){
     cout <<"No"<<endl;
   }
   else {
     cout <<"Yes"<<endl;
   }
}

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

int main() {
    int a;
    cin>>a;
    cout<<(a+a*a+a*a*a)<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 2e3+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

ll dp[MAX];

int main()
{
    ll n,i,j,k,l,p,q,x,y;
    cin >> n;
    for(i=3;i<=5;i++)
        dp[i]=1;
    for(i=6;i<=n;i++)
    {
        dp[i] = 1;
        for(j=i-3;j>=3;j--)
            dp[i]=(dp[i]+dp[j])%MOD;
    }
    cout << dp[n];
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 605;

int N, M;
vector<int> al[MX_N];
double res[MX_N];

double dp(int x) {
    if (x == N) return 0;
    if (res[x] != -1) return res[x];

    res[x] = 0;
    for (int y : al[x]) res[x] += dp(y)+1;
    res[x] /= (double)SZ(al[x]);
    return res[x];
}

int main(int argc, char** argv) {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int block = -1;//stoi(argv[1]);

    cin >> N >> M;
    FOR(i,0,M-1){
        int s,t; cin >> s >> t;
        if (i == block) continue;
        al[s].push_back(t);
    }

    FOR(i,1,N) res[i] = -1;
    FOR(i,1,N) dp(i);

    double ans = dp(1);
    FOR(x,1,N) if (SZ(al[x]) > 1) {
        int i = al[x][0];
        for (int y : al[x]) {
            if (res[y] > res[i]) i = y;
        }

        al[x].erase(find(ALL(al[x]), i));

        FOR(i,1,N) res[i] = -1;
        FOR(i,1,N) dp(i);

        ans = min(ans, dp(1));
        //cout << x << " " << i << " :: " << dp(1) << endl;
        al[x].push_back(i);
    }

    cout << fixed << setprecision(7) << ans << '\n';
}



Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int x=0;

  cin >> x;
  cout << (x<1200?"ABC":"ARC") << endl;

  return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b and b!=c) cout<<c<<endl;
    if (a==c and b!=c) cout<<b<<endl;
    if (c==b and b!=a) cout<<a<<endl;   
    return 0;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(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;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
string s;
cin>>s;
if(s.length()%2==1)
{
    cout<<"No";
    return ;
}
if(s=="hi")
{
    cout<<"Yes";
    return ;
}
if(s=="hihi")
{
    cout<<"Yes";
    return ;
}
if(s=="hihihi")
{
    cout<<"Yes";
    return;
}
if(s=="hihihihi")
{
    cout<<"Yes";
    return;
}
if(s=="hihihihihi")
{
    cout<<"Yes";
    return ;
}
cout<<"No";






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	s1 = " " + s1;
	s2 = " " + s2;
	int row = s1.size();
	int col = s2.size();
	vector<vector<int>> mat(row, vector<int> (col,0));
	for(int i=0;i<row;i++)
		mat[i][0] = 1;
	for(int i=0;i<col;i++)
		mat[0][i] = 1;
	for(int i=1;i<row;i++)
	{
		for(int j=1;j<col;j++)
		{
			if(s1[i]==s2[j])
			{
				mat[i][j] = 1 + mat[i-1][j-1];
			}
			else
			{
				mat[i][j] = max(mat[i-1][j],mat[i][j-1]);
			}
		}
	}
	/*cout<<"  ";
	for(char c: s2)
		cout<<c<<' ';
	cout<<'\n';
	for(int i=0;i<row;i++)
	{
		cout<<s1[i]<<' ';
		for(int j=0;j<col;j++)
			cout<<mat[i][j]<<' ';
		cout<<'\n';
	}*/
	int i = row -1;
	int j = col -1;
	string res = "";
	while(mat[i][j]!=1)
	{
		if(mat[i][j] == mat[i-1][j])
			i--;
		else if(mat[i][j] == mat[i][j-1])
			j--;
		else if(mat[i][j] == mat[i-1][j-1] + 1)
		{
			res += s1[i];
			i--;
			j--;
		}
		else
		{
			if(mat[i-1][j] > mat[i][j-1])
				j--;
			else
				i--;
		}
	}
	reverse(res.begin(),res.end());
	cout<<res<<'\n';
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<28
using namespace std;
int main(){
  int n,c,k;
  cin>>n>>c>>k;
  int a[n];
  r(i,n)cin>>a[i];int sum=0;
  sort(a,a+n);
  r(i,n){
    int p=a[i],s=0;
    while(1){
      if(s==c)break;
      i++;
      if(abs(a[i]-p)<=k)s++;
      else break;
    }
    i--;
    sum++;
  }
  cout<<sum<<endl;
}

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

void no(){
    cout << "no" << endl;
    exit(0);
}

int main(){
    string t, p;
    cin >> t >> p;
    vector<int> v[26];
    for(int i = 0; i < t.length(); i++){
        v[t[i]-'a'].push_back(i);
    }
    int n = p.length();
    vector<int> l(n), r(n);
    int now = 0;
    for(int i = 0; now < n && i < t.length(); i++){
        if(t[i] == p[now]){
            l[now++] = i;
        }
    }
    if(now != n)    no();
    now = n-1;
    for(int i = t.length()-1; now >= 0 && i >= 0; i--){
        if(t[i] == p[now]){
            r[now--] = i;
        }
    }
    if(now != -1)   no();
    if(v[p[0]-'a'][0] != l[0] || v[p.back()-'a'].back() != r[n-1])  no();
    for(int i = 1; i+1 < n; i++){
        int cind = p[i]-'a';
        int j = *upper_bound(v[cind].begin(),v[cind].end(),l[i-1]);
        int k = *(--lower_bound(v[cind].begin(), v[cind].end(),r[i+1]));
        if(j != k)  no();
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 11136