akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

int rand16() {
    return rand() & (TWO(16) - 1);
}
int my_rand() {
    return rand16() << 15 | rand16();
}

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

const int MN = 2011;

int m, n;
int a[MN][MN], b[MN][MN];
int f[MN][MN], inc[MN][MN];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9) << boolalpha;
    int q;
    while (cin >> m >> n >> q) {
        memset(b, 0, sizeof b);
        FOR(i,1,m) {
            string s; cin >> s;
            FOR(j,1,n) a[i][j] = s[j-1] - '0';

            FOR(j,1,n) {
                b[i][j] = b[i-1][j] + b[i][j-1] - b[i-1][j-1];

                if (a[i-1][j] && a[i][j]) b[i][j] += 1;
            }
        }

        memset(f, 0, sizeof f);
        memset(inc, 0, sizeof inc);
        FOR(i,1,m) {
            FOR(j,1,n) {
                if (a[i][j] && !a[i][j-1]) f[i][j] = f[i][j-1] + 1;
                else f[i][j] = f[i][j-1];
            }

            FOR(j,1,n) f[i][j] += f[i-1][j];

            FOR(j,2,n) {
                if (a[i][j-1] && a[i][j]) inc[i][j] = 1;
                inc[i][j] += inc[i-1][j];
            }
        }

        while (q--) {
            int i1, j1, i2, j2; cin >> i1 >> j1 >> i2 >> j2;
            int res = 0;
            res += f[i2][j2] - f[i1-1][j2] - f[i2][j1-1] + f[i1-1][j1-1];
            res += inc[i2][j1] - inc[i1-1][j1];

            res -= b[i2][j2] - b[i1][j2] - b[i2][j1-1] + b[i1][j1-1];
            cout << res << '\n';
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 128000
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

ll f(ll a) {
    if (a % 2 == 0) {
        return ((a + 2) / 2 % 2) ^ (a + 1);
    } else {
        return (a + 1) / 2 % 2;
    }
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif

        ll a, b;
        cin >> a >> b;
        cout << (f(a - 1) ^ f(b)) << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main(){
    ll n,a,b,k,p,ans;
    cin >>n>>a>>b;
    k=n/(a+b);
    p=n%(a+b);
    if(p<a){
        ans=p;
    }else{
        ans=a;
    }
  ans+=k*a;
    cout <<ans;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
const int MX=2e2+7;
const int mod=1e9+7;
const double eps=1e-6;
const double pi=3.14159265358979;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}
ll __gcm(ll a,ll b){return a*b/__gcd(a,b);}
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  int t;
  int k;
  cin>>k;
  int ans=0;
  for(int i=1;i<=k;i++)
  {
      for(int j=1;j<=k;j++)
      {
          int m=__gcd(i,j);
          for(int a=1;a<=k;a++)
          {
            ans+=__gcd(m,a);
          }
      }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string six(int x){
    string res;
    res = to_string(x);
    while(res.size()<6){
        res='0'+res;
    }
    return res;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<P>tw(m);
    vector<vector<ll>>so(m);
    rep(i,m){
        int p;
        ll y;
        cin >> p >> y;
        tw[i]=make_pair(p,y);
        so[i]={p,y,i};
    }
    
    sort(so.begin(),so.end());
    vector<int>ken(m,0);
    int order = 1;
    ken[so[0][2]]=1;
    rep(i,m-1){
        if(so[i][0]==so[i+1][0]){
            order++;
            ken[so[i+1][2]]=order;
        }
        else{
            order=1;
            ken[so[i+1][2]]=order;
        }
    }
    rep(i,m){
        cout<<six(tw[i].first)+six(ken[i])<<endl;
    }


    return 0;
}

Measured memory_bytes: 8960
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[6] = { 1,-1,0,0,0,0 };
int dy[6] = { 0,0,1,-1,0,0 };
int dz[6] = { 0,0,0,0,1,-1 };
int main() {
	map<pair<int,P>, int> mp;
	ll a, b, c; cin >> a >> b >> c;
	ll res = 2 * (a*b + b * c + c * a);
	int n; cin >> n;
	int x, y, z;
	rep(i, n) {
		cin >> x >> y >> z;
		int cnt = 0;
		rep(k, 6) {
			int nx = x + dx[k]; int ny = y + dy[k]; int nz = z + dz[k];
			if (nx < 0 || ny < 0 || nz < 0 || nx == a || ny == b || nz == c|| mp[{nx, { ny, nz }}] == 1)cnt++;
		}
		res += (ll)2 * (ll)(3 - cnt);
		mp[{x, { y, z }}] = 1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3524
import itertools, math

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
route = list(range(N))

dist = 0
for r in list(itertools.permutations(route)):
    for i in range(1,N):
        dist += ((xy[r[i]][0] - xy[r[i-1]][0])**2 + (xy[r[i]][1] - xy[r[i-1]][1])**2)**0.5

print(dist/math.factorial(N))

Measured memory_bytes: 8100
s = int(input())

a = [s]
idx = 1
n = s
while True:
    if n % 2 == 0:
        n = n // 2
    else:
        n = (3*n) + 1
    idx += 1
    
    if n in a: break
    a.append(n)
    
print(idx)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int n;
    cin >> n;
    vector<pii> ab(n), cd(n);
    REP(i, n){
        cin >> ab[i].fi >> ab[i].se;
    }
    REP(i, n){
        cin >> cd[i].fi >> cd[i].se;
    }

    vector<int> is_use(n, 0);
    int ans = 0;
    SORT(cd);
    REP(i, n){
        vector<pii> y_id;
        REP(j, n){
            if(is_use[j] == 1) continue;
            if(ab[j].fi < cd[i].fi && ab[j].se < cd[i].se){
                y_id.pb(pii(ab[j].se, j));
            }
        }

        if(!y_id.empty()){
            RSORT(y_id);
            ans++;
            is_use[y_id[0].se] = 1;
        }
    }
    pr(ans);
}  

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int vis[N];
vector<vector<int>>adj;
void dfs(int node){
    vis[node]=1;
    for(int i=0;i<adj[node].size();i++){
        int child = adj[node][i];
        if(!vis[child])
            dfs(child);
    }
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    int n,m;
    scanf("%d%d",&n,&m);
    adj=vector<vector<int>>(n+10);
    
    for(int i=0;i<m;i++){
        int from,to,w;
        scanf("%d%d%d",&from,&to,&w);
        from--;
        to--;
        adj[from].push_back(to);
        adj[to].push_back(from);
    }
    ll cnt=0;
    for(int i=0;i<n;i++){
        if(!vis[i]){
            cnt++;
            dfs(i);
        }
    }
    printf("%lld",cnt);
    return 0;
}

Measured memory_bytes: 9216
import sys
sys.setrecursionlimit(10**7)

N = int(input())
S = str(input())
#a, b = map(int, input().split())
#array = [int(s) for s in input().split()]

if N % 2 == 0 and S[0:int(N/2)] == S[int(N/2):]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N;
    ll ans = 0;
    cin >> N;
    vecl L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(all(L));
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N;j++)
        {
            for (int k = j + 1; k < N;k++)
            {
                if(L[i] != L[j] && L[k] != L[i] && L[j] != L[k] &&L[i] < L[k] + L[j] && L[k] < L[j] + L[i] && L[j] < L[i] + L[k]){
                    ans++;
                    //cout << L[i] << " " << L[j] << " " << L[k] << endl;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int A,B,C;cin>>A>>B>>C;
  if(A+B>=C)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
void solve2(string& s) {
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == '#' && (i == s.size() - 1 || s[i + 1] != 'A') && (i == 0 || s[i - 1] != 'A')) {
			s[i] = 'B'; return;
		}
	}
	s[s.find('#')] = 'B';
}
void solve3(string &s) {
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '#') {
			if (i < s.size() - 1 && s[i + 1] == '#') {
				s[i + 1] = 'C'; return;
			}
			if (i > 0 && s[i - 1] == '#') {
				s[i - 1] = 'C'; return;
			}
		}
	}
	s[s.size() / 2] = 'C';
}
void solve4(string &s) {
	vector<int> ret(s.size(), 999999999);
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '#') {
			for (int j = 0; j < s.size(); j++) {
				ret[j] = min(ret[j], abs(i - j));
			}
		}
	}
	s[max_element(ret.begin(), ret.end()) - ret.begin()] = 'D';
}
int N, Q;
int main() {
	while (cin >> N >> Q, N) {
		string s(N, '#'), t;
		while (Q--) {
			cin >> t;
			if (t == "A") s[s.find('#')] = 'A';
			if (t == "B") solve2(s);
			if (t == "C") solve3(s);
			if (t == "D") solve4(s);
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int);
int pop(void);

int n[100],top=0;

int main(){
  int x,ans1=0,ans2=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      ans1=pop();
      ans2=pop();
      push(ans1+ans2);
    }
    else if ( s[0] == '-' ){
      ans1=pop();
      ans2=pop();
      push(ans2-ans1);
    }
    else if ( s[0] == '*' ){
      ans1=pop();
      ans2=pop();
      push(ans1*ans2);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",n[1]);

  return 0;
}

void push (int x){

  top++;
  n[top]=x;
  
}

int pop(void){

  top--;
  return n[top+1];

}



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

inline int read(){
    int a = 0;
    bool f = 0;
    char c = getchar();
    while(c != EOF && !isdigit(c)){
        if(c == '-')
            f = 1;
        c = getchar();
    }
    while(c != EOF && isdigit(c)){
        a = (a << 3) + (a << 1) + (c ^ '0');
        c = getchar();
    }
    return f ? -a : a;
}

const int MOD = 1e9 + 7 , MAXN = 4000 , MAXM = 200000;
int f[MAXN + 10][MAXN + 10] , jc[MAXN + 10 << 1] = {1 , 1} , ny[MAXN + 10 << 1] = {1} , a[MAXM + 10] , b[MAXM + 10];

inline long long poww(long long a , int b){
    int times = 1;
    while(b){
        if(b & 1)
            times = times * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return times;
}

int main(){
    for(long long i = 2 ; i <= MAXN << 1 ; i++)
        jc[i] = jc[i - 1] * i % MOD;
    ny[MAXN << 1] = poww(jc[MAXN << 1] , MOD - 2);
    for(long long i = (MAXN << 1) - 1 ; i ; i--)
        ny[i] = ny[i + 1] * (i + 1) % MOD;
    int N = read() , ans = 0;
    for(int i = 1 ; i <= N ; i++){
        a[i] = read();
        b[i] = read();
        f[-a[i] + 2000][-b[i] + 2000]++;
        ans = (ans + MOD - jc[a[i] + b[i] << 1] * (long long)ny[a[i] << 1] % MOD * ny[b[i] << 1] % MOD) % MOD;
    }
    for(int i = 1 ; i <= MAXN ; i++){
        f[i][0] += f[i - 1][0];
        f[0][i] += f[0][i - 1];
    }
    for(int i = 1 ; i <= MAXN ; i++)
        for(int j = 1 ; j <= MAXN ; j++)
            f[i][j] = ((f[i][j] + f[i - 1][j]) % MOD + f[i][j - 1]) % MOD;
    for(int i = 1 ; i <= N ; i++)
        ans = (ans + f[a[i] + 2000][b[i] + 2000]) % MOD;
    cout << ans * poww(2 , MOD - 2) % MOD;
    return 0;
}


Measured memory_bytes: 64512
w = input()
c = 1

if w=="RRR":
  print(3)
elif w=="RRS":
  print(2)
elif w=="RSR":
  print(1)
elif w=="RSS":
  print(1)
elif w=="SRR":
  print(2)
elif w=="SRS":
  print(1)
elif w=="SSR":
  print(1)
else:
  print(0)


Measured memory_bytes: 9068
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <numeric>
#include <limits>
#include <queue>
#include <cstdint>
#include<iomanip>
#define ll long long int
#define rep(i,rept) for (int (i) = 0; (i) < rept; (i)++)
#define rept(i,n,rept) for (int (i) = n; (i) < rept; (i)++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
#define fr first
#define se second
#define lolo 92233720368547757
#define susu 1000000007
typedef std::pair<int, int> pp;
typedef std::pair<ll, ll> llpp;
using namespace std;
int main() {
	bool b = false;
	int n, m;
	string s[50],str[50];
	cin >> n >> m;
	rep(i, n) {
			cin >> s[i];
	}
	rep(i, m) {
		cin >> str[i];
	}
	rep(i, n - m + 1) {
		rep(j, n - m + 1) {
			b = true;
			rep(k, m) {
				rep(l, m) {
					if (s[i + k][j + l] != str[k][l]) {
						b = false;
						break;
					}
					if (k == m - 1 && l == m - 1) {
						Yes(true);
						return 0;
					}
				}
				if (!b) {
					break;
				}
			}
		}
	}
	Yes(false);
	return 0;
}

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

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

const int MAXW = 25, MAXH = 25;
const char B = '.', R = '#';
char tile[MAXW][MAXH];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

int solve(int x, int y)
{
    int ans = 1;

    REP(4)if(tile[x + dx[i]][y + dy[i]] == B)
    {
        tile[x + dx[i]][y + dy[i]] = R;
        ans += solve(x + dx[i], y + dy[i]);
    }

    return ans;
}

int main()
{
    int w, h;
    while(cin >> w >> h && ( w || h))
    {
        memset(tile, R, sizeof(tile));

        int x, y; char t;
        rep(j, h)rep(i, w)
        {
            cin >> tile[i + 1][j + 1];
            if(tile[i + 1][j + 1] == '@'){ x = i + 1; y = j + 1; tile[i + 1][j + 1] = R;}
        }
            cout << solve(x, y) << endl;
    }

    return 0;
}

Measured memory_bytes: 1168
from itertools import groupby
from operator import itemgetter
import sys
input = sys.stdin.readline
read = sys.stdin.read

N = int(input())
geta = 10**9
A = [int(round(float(input())*geta)) for _ in range(N)]
geta2 = geta * geta

B = []
for a in A:
    twoes = (a & -a).bit_length() - 1
    a >>= twoes
    fives = 0
    while a % 5 == 0:
        a //= 5
        fives += 1
    B.append((twoes, fives))

B.sort()
#print(B)
idx_r = N-1
Five = [0] * 19
ans = 0
for l2, group in groupby(B, key=itemgetter(0)):
    while idx_r >= 0:
        r2, r5 = B[idx_r]
        if r2 + l2 < 18:
            break
        Five[r5 if r5<=18 else 18] += 1
        idx_r -= 1
    #print(Five)
    for _, l5 in group:
        #print((18-l5) if l5<=18 else 0)
        ans += sum(Five[(18-l5) if l5<=18 else 0:])
        if l2>=9 and l5>=9:
            ans -= 1
print(ans//2)


Measured memory_bytes: 96704
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using namespace std;
typedef pair<long long,long long> ii;
typedef long long lint;

int arr[10000000];
vector<string> S;

void add(int i, int j, int to){
	S.push_back("+ " + to_string(i) + " " + to_string(j) + " " + to_string(to));
}

void comp(int i, int j, int to){
	S.push_back("< " + to_string(i) + " " + to_string(j) + " " + to_string(to));
}

const int ONE = 4;
const int TARGET = 2;
const int C = 90;
const int MAXBIT = 30;

int A(int i){ ///10 to 40
	return i+10;
}

int B(int i){ ///50 to 80
	return i+50;
}


signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	add(0,1,3);
	add(3,3,3);
	comp(2,3,ONE);
	
	add(ONE,0,0);
	add(ONE,1,1);
	
	for(int i = MAXBIT;i >= 0;i--){
		int a = A(i);
		add(ONE,a,a);
		for(int j = 0;j < i;j++){
			add(a,a,a);
		}
		
		add(a,a+1,a);
		
		comp(a,0,a);
		for(int j = 0;j < i;j++){
			add(a,a,a);
		}
		
		add(a,a+1,a);
	}
	
	for(int i = 0;i <= MAXBIT;i++){
		int a = A(i);
		comp(a+1,a,a);
	}
	
	
	for(int i = MAXBIT;i >= 0;i--){
		int b = B(i);
		add(ONE,b,b);
		for(int j = 0;j < i;j++){
			add(b,b,b);
		}
		
		add(b,b+1,b);
		
		comp(b,1,b);
		for(int j = 0;j < i;j++){
			add(b,b,b);
		}
		
		add(b,b+1,b);
	}
	
	for(int i = 0;i <= MAXBIT;i++){
		int b = B(i);
		comp(b+1,b,b);
	}
	
	
	for(int i = 0;i <= MAXBIT;i++){
		for(int j = 0;j <= MAXBIT;j++){
			add(A(i),B(j),C);
			comp(ONE,C,C);
			
			for(int k = 0;k < i+j;k++){
				add(C,C,C);
			}
			
			add(TARGET,C,TARGET);
		}
	}
	
	cout << S.size() << "\n";
	for(string s : S) cout << s << "\n";
}



Measured memory_bytes: 5264
x,y=map(int,input().split())
a1=-1
b1=-1
c1=-1
for a in range(0,x+1):
    for b in range(0,x+1-a):
        c=x-a-b
        if 10000*a+5000*b+1000*c==y:
            a1=a
            b1=b
            c1=c
print(a1,b1,c1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=2e5+9;
int n,c[N],ans[N],sz[N];
map <int,int> mp[N];
vector <int> g[N];
void dfs(int v,int p){
    int hv=-1,mx=0;
    for(auto u:g[v]){
        if(u==p)continue;
        dfs(u,v);
        sz[v]+=sz[u];
        int x=sz[u]-mp[u][c[v]];
        ans[c[v]]+=x*(x-1)/2+x;
        if(mp[u].size()>mx)mx=mp[u].size(),hv=u;
    }
    swap(mp[hv],mp[v]);
    for(auto u:g[v]){
        if(u==p or u==hv)continue;
        for(auto i:mp[u])
            mp[v][i.f]+=i.s;
    }
    sz[v]++;
    mp[v][c[v]]=sz[v];
}
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> c[i];
    for(int i=1;i<n;i++){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++){
        int x=n-mp[1][i];
        ans[i]+=x*(x-1)/2+x;
    }
    int k=n*(n-1)/2+n;
    for(int i=1;i<=n;i++)
        cout << k-ans[i] << '\n';
}

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

if S[A] != "-":
    print("No")
    exit()

if S[:A].count("-") != 0:
    print("No")
    exit()

if S[A + 1:].count("-") != 0:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 2940
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

class BIT {
public:
  vector <ll> bit;
  int N;

  BIT(int n) {
    N = n;

    for (int i = 0; i <= N; ++i) {
      bit.push_back(0);
    }
  }

  ll sum(int i) {
    ll ret = 0;

    while (i > 0) {
      ret += bit[i];
      i -= i & -i;
    }

    return ret;
  }

  void add(int i, ll x) {
    while (i <= N) {
      bit[i] += x;
      i += i & -i;
    }
  }
};

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

  BIT bit(N);

  int a, t, x;
  for (int i = 1; i <= N; ++i) {
    cin >> a;
    bit.add(i, a);
  }

  for (int i = 0; i < Q; ++i) {
    cin >> t >> a >> x;

    if (t == 0) {
      bit.add(a + 1, x);
    } else {
      cout << bit.sum(x) - bit.sum(a) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 8368
N,M = map(int,(input().split()))
K = [[] for _ in range(N)]
for i in range(N):
    K[i] = list(map(int,(input().split())))

like = [0]*M
for i in range(N):
    for j in range(1,len(K[i])):
        like[K[i][j]-1] += 1

c = 0
for i in range(M):
    like[i] -= N


for i in range(M):
    if like[i] == 0:
        c += 1

print(c)

Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10**8)

S = int(input())
MOD = 10**9+7

from functools import lru_cache
@lru_cache(maxsize=10**8)
def rec(n):
    if n < 3: return 0
    ret = 1
    for i in range(3, n-3+1):
        ret += rec(i)
    return ret%MOD

print(rec(S))

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

int main(){
    int n,k;
    cin >> n >> k;
    int mx = (n-1)*(n-2)/2;
    if(mx < k){
        puts("-1");
        return 0;
    }
    vector<P> ans;
    rep(i,n-1) ans.push_back(P(i+1,n));
    int add = mx-k; //列挙数を指定する
    vector<P> edge;
    //へんの列挙をして、必要数だけansに加える
    rep(i,n-1) rep(j,i) edge.push_back(P(i+1,j+1));
    rep(i,add) ans.push_back(edge[i]);
    cout << ans.size() << endl;
    rep(i , ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    maxA = max(A)
    if maxA == 1:
        print('pairwise coprime')
        return
    prime = [i % 2 != 0 for i in range(maxA+1)]
    prime[2] = True
    f = [False] * (maxA+1)
    for i in range(3, int(maxA**.5)+1):
        if prime[i] == False:
            continue
        p = i * 2
        while p <= maxA:
            prime[p] = False
            p += i

    def gcd(x, y):
        if y == 0:
            return x
        return gcd(y, x % y)

    pairwise_coprime = A[0]
    setwise_coprime = A[0]
    for An in A[1:]:
        setwise_coprime = gcd(setwise_coprime, An)
        if setwise_coprime == 1:
            break
    
    for An in A:
        if An == 1:
            continue
        # print('An = {}'.format(An))
        if f[An]:
            if setwise_coprime == 1:
                print('setwise coprime')
                return
            else:
                print('not coprime')
                return
        elif prime[An]:
            f[An] = True
        else:
            for i in range(2, An // 2 + 1):
                if prime[An]:
                    if f[An]:
                        if setwise_coprime == 1:
                            print('setwise coprime')
                            return
                        else:
                            print('not coprime')
                            return
                    else:
                        f[An] = True
                        break
                if f[An]:
                    if setwise_coprime == 1:
                        print('setwise coprime')
                        return
                    else:
                        print('not coprime')
                        return
                elif An % i == 0:
                    # print('i={}'.format(i))
                    if f[i]:
                        if setwise_coprime == 1:
                            print('setwise coprime')
                            return
                        else:
                            print('not coprime')
                            return
                    f[i] = True
                    while An % i == 0:
                        An //= i
                    if An == 1:
                        break
        # print(f)
    print('pairwise coprime')

if __name__ == '__main__':
    main()

Measured memory_bytes: 209420
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for i := 1.0; i <= 10000.0; i++ {
		if int(i*0.08) == a && int(i*0.1) == b {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


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

struct point {
  int c;
  int x, y;
};

bool operator < (const point &lhs, const point &rhs) {
  if (lhs.x != rhs.x) return lhs.x < rhs.x;
  else return lhs.y < rhs.y;
}

int n;
vector<point> whlpt;
set<point> cndst;

int ans;

int main(void){
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    point tmppoint;
    int tmpx, tmpy;
    scanf("%d %d", &tmpx, &tmpy);
    tmppoint.x = tmpx;
    tmppoint.y = tmpy;
    tmppoint.c = 0;
    whlpt.push_back(tmppoint);
  }

  for (int i = 0; i < n; ++i) {
    point tmppoint;
    int tmpx, tmpy;
    scanf("%d %d", &tmpx, &tmpy);
    tmppoint.x = tmpx;
    tmppoint.y = tmpy;
    tmppoint.c = 1;
    whlpt.push_back(tmppoint);
  }

  sort(whlpt.begin(), whlpt.end(), [](const point &a, const point &b){return a.x < b.x;});

  for (auto cpt: whlpt) {
    if (cpt.c == 0) cndst.insert(cpt);
    else {
      point mxpt; mxpt.y = -1;
      for (auto itr = cndst.begin(); itr != cndst.end(); ++itr) {
        point tpt = *itr;
        if (tpt.y < cpt.y && mxpt.y < tpt.y) {
          mxpt = tpt;
        }
      }
      if (mxpt.y != -1) {
        cndst.erase(mxpt);
        ans += 1;
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
using Primes: factor
using DataStructures: SortedDict
function main()
    n = parse(Int,readline())
    sa = factor(SortedDict, n)
    ret = 0
    for p in sa
        ni = p |> last
        for del in 1:10
            if ni >= del
                ni -= del
                ret += 1
            end
        end
    end
    println(ret)
end
main()

Measured memory_bytes: 223188
fun main() {
    val builder = StringBuilder()

    val mod = 998244353L

    val (n, m, k) = readInputLine().split(" ").map { it.toInt() }

    val factorial = LongArray(n + 1)
    val inverse = LongArray(n + 1)
    val factorialInverse = LongArray(n + 1)
    factorial[0] = 1L
    factorial[1] = 1L
    inverse[0] = 1L
    inverse[1] = 1L
    factorialInverse[0] = 1L
    factorialInverse[1] = 1L
    for (i in 2..n) {
        factorial[i] = (factorial[i - 1] * i.toLong() % mod)
        inverse[i] = (mod - inverse[mod.toInt() % i] * (mod / i.toLong()) % mod)
        factorialInverse[i] = (factorialInverse[i - 1] * inverse[i] % mod)
    }

    fun nCm(n: Int, m: Int): Long {
        return factorial[n] * (factorialInverse[m] * factorialInverse[n - m] % mod) % mod
    }

    val color = LongArray(n + 1)

    color[1] = m.toLong()

    for (i in 2..n) {
        color[i] = (color[i - 1] * (m - 1).toLong()) % mod
    }

    var ans = 0L

    for (i in 0..k) {
        ans = (ans + color[n - i] * nCm(n - 1, i)) % mod
    }

    builder.appendln(ans)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 43480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
	return x*f;
}
const int maxn=2e5+10;
int n,k;
int main(){
	n=read(),k=read();
	int d=n/k,f=k/2;ll ans=1ll*d*d*d;
	if(!(k&1)){
		d=0;
		while(f<=n)++d,f+=k;
		ans+=1ll*d*d*d;
	}printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string S;
int main(){
    cin >> S;
    int ct = 0;
    rep(i,3) if(S[i] == '1') ct++;
    cout << ct << '\n';
}

Measured memory_bytes: 256
n, k = map(int, input().split())
d = list(map(int, input().split()))
digit = [str(i) for i in range(10) if not i in d]
ans = []
stack = [i for i in digit]
while stack:
  s = stack.pop()
  if int(s) >= n:
    ans.append(int(s))
  else:
    for i in digit:
      if len(i+s) <= len(str(n))+1:
        stack.append(i+s)

print(min(ans))

      


Measured memory_bytes: 5436
import collections
N = int(input())
A = list(map(int, input().split()))


C = collections.Counter(A)

d = {}

total = 0
for k, v in C.items():
    d[k] = (v*(v-1)//2, (v-1)*(v-2)//2)
    total += d[k][0]


for i in range(N):
    minus = d[A[i]][0]
    plus = d[A[i]][1]
    print(total - minus + plus)

Measured memory_bytes: 38940
N = int(input())

connections = [[] for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    connections[u].append((v, w))
    connections[v].append((u, w))

COLOR_WHITE = 0
COLOR_BLACK = 1
COLOR_NONE = 2

colors = [COLOR_NONE for _ in range(N)]
colors[0] = COLOR_WHITE

stack = [(0, 0)]

while stack:
    root, abs_distance = stack.pop()
    for node, distance in connections[root]:
        if colors[node] == COLOR_NONE:
            new_distance = abs_distance+distance
            colors[node] = COLOR_WHITE if (new_distance) % 2 == 0 else COLOR_BLACK
            stack += [(node, new_distance)]

for c in colors:
    print(c)


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

using namespace std;
int main(){
  double a,b;
  cin >> a >> b;
  if(a>b){
    cout << "GREATER" << endl;
  }
  else if(a<b){
    cout << "LESS" << endl;
  }
  else if(a==b){
    cout << "EQUAL" << endl;
  }
}


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

int main(){
    int z;
    while(cin >> z, z){
        z *= z*z;
        int ans = z;
        for(int i = 1; i*i*i <= z; i++){
            for(int j = i; j*j*j <= z-i*i*i; j++){
                ans = min(ans, z-i*i*i-j*j*j);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);


    int n, m;
    cin >> n >> m;
    long ans = (long) n * m + 1;
    cout << (n == 1 || m == 1 ? 1 : ans / 2);

    return 0;


}


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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i = 0; i < n; i++){
		cin>>d[i];
	}
	sort(all(d));
	cout<<d[n/2] - d[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int a1,a2,a3,b1,b2,b3;
	cin >> a1 >> b1;
	cin >> a2 >> b2;
	cin >> a3 >> b3;
	int c1= 0;
	int c2= 0;
	int c3= 0;
	int c4= 0;
	vector<int> va, vb,vc;
	va.push_back(a1);
	va.push_back(a2);
	va.push_back(a3);
	vb.push_back(b1);
	vb.push_back(b2);
	vb.push_back(b3);
	// for (auto x: va) {
	// 	cout << x << ",";
	// }
	// cout << endl;
	// for (auto x: vb) {
	// 	cout << x << ",";
	// }
	// cout << endl;
	
	for (auto x: va) {
                if( x == 1){
					c1 += 1;
				}else if(x == 2){
					c2 += 1;
				}else if(x == 3){
					c3 += 1;
				}else{
					c4 += 1;
				}
        }
	for (auto x: vb) {
                if( x == 1){
					c1 += 1;
				}else if(x == 2){
					c2 += 1;
				}else if(x == 3){
					c3 += 1;
				}else{
					c4 += 1;
				}
        }
	// cout << c1 << endl;
	// cout << c2 << endl;
	// cout << c3 << endl;
	// cout << c4 << endl;
	vc.push_back(c1);
	vc.push_back(c2);
	vc.push_back(c3);
	vc.push_back(c4);
	// 	for (auto x: vc) {
	// 	cout << x << ",";
	// }
	// cout << endl;
	std::sort(vc.begin(),vc.end());
	// 	for (auto x: vc) {
	// 	cout << x << ",";
	// }
	// cout << endl;
	vector<int> vd{1,1,2,2};

	if (vc == vd){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	// cout << (n+1)  / 2  << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n,m,c;cin>>n>>m>>c;
    int b[m];
    for(int i = 0;i<m;i++) cin>>b[i];
    int ko = 0;
    for(int i = 0;i<n;i++){
      int a[m];
      int g = 0;
      for(int j = 0;j<m;j++) cin>>a[j];
      for(int k = 0;k<m;k++){
         g+=b[k]*a[k];
      }
      if(g+c > 0) ko++;
    }
    cout<<ko;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[40000],a[200000],b[200000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<LL>vec;
vector<edge>ed;
vector<Pll>v;
map<LL,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		LL x;
		cin >> x;
		if (x % 2 == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll mod=998244353;

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

struct perm{
private:
    int sz;
    vector<ll> p,invp;
public:
    perm(int n){
        sz=n+1;
        p.resize(sz),invp.resize(sz);
        p[0]=1;
        for(int i=1;i<=sz-1;i++){
            p[i]=p[i-1]*i%mod;
        }
        invp[sz-1]=mod_pow(p[sz-1],mod-2);
        for(int i=sz-2;i>=0;i--){
            invp[i]=invp[i+1]*(i+1)%mod;
        }
    }
    ll comb(ll x,ll y){
        if(x<y||y<0)return 0;
        return (p[x]*invp[x-y]%mod)*invp[y]%mod;
    }
};
perm p(1<<24);
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans=mod_pow(3,n);
    vector<ll> p2(n+1,1);
    for(int i=0;i<n;i++){
        p2[i+1]=p2[i]*2%mod;
    }
    for(int i=n/2+1;i<=n;i++){
        ans-=p.comb(n,i)*p2[n-i]*2;
        ans+=mod;
        ans%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 340480
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s[5] == '0' && s[6] <= '4')
    {
        cout << "Heisei";
    }
    else
    {
        cout << "TBD";
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
c = []
s = 0
for i in range(N):
  c.append(min(a[i]//400, 8))
import collections
colors = collections.Counter(c)
for i in range(8):
  if colors.get(i, 0) != 0:
    s += 1
ss = colors.get(8, 0)

print(max(s, 1), s+ss)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll dp[100001];

void solve_abc099_c() {
	ll N;
	ll ans = 0;
	cin >> N;

	dp[0] = 0;

	ll val;
	rep2(i, 1, N+1) {
		dp[i] = INF;
		val = 1;
		while (val <= i) {
			dp[i] = min(dp[i], dp[i - val] + 1);
			val *= 6;
		}
		val = 1;
		while (val <= i) {
			dp[i] = min(dp[i], dp[i - val] + 1);
			val *= 9;
		}
	}

	cout << dp[N] << "\n";
}

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

	solve_abc099_c();

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
string s[10000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
int main() {
	cin>>N>>H>>W;
	cout<<(N-H+1)*(N-W+1)<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

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

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += a[i] - 1;
  }
    
  cout << ans << endl;
}


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

int main(int argc, char const *argv[])
{
  string s;
  cin>>s;
  for(int i = 0;i<s.length();i++){
    if(s[i]=='1') s[i]='9';
    else if(s[i]=='9') s[i] = '1';
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
<?php
  
$N = fgets(STDIN);
$N = explode(" ", $N);

$k = $N[0];
$s = $N[1];

$count = 0;
for ($x = 0; $x <= $k; $x++) {
  for ($y = 0; $y <= $k; $y++) {
    $z = $s - ($x + $y);
      if ($z >= 0 && $z <= $k) {
        $count++;
      }
  }
}
echo $count;
?>


Measured memory_bytes: 3956
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  for j in range(i+1, n):
    l = j+1
    a = l - k
    b = abs(k - x) + abs(l - y) + 1
    if b < a:
      ans[b-1] += 1
    else:
      ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

Measured memory_bytes: 3444
#include <iostream>
#include <string>

int main()
{
	std::string S = "";
	std::cin >> S;

	if (S == "Sunny")
	{
		std::cout << "Cloudy\n";
	}
	else if (S == "Cloudy")
	{
		std::cout << "Rainy\n";
	}
	else
	{
		std::cout << "Sunny\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int c1=0,c2=0,c4=0;
    REP(i,N){
        int a; cin>>a;
        if(a%4==0) c4++;
        else if(a%2==0) c2++;
        else c1++;
    }
    if(c2>0) c1++;

    cout<<(c1<=c4+1? "Yes":"No")<<endl;
}


Measured memory_bytes: 256