akhauriyash/Code-Regression huggingface dataset:
e,s=gets
h=gets.split.map(&:to_i).sort.chunk{|e|e}.map{|k,v|s||=k;[e=k,v.size]}.to_h
puts h[s]==s*2+1-e&&(s+1..e).all?{|e|h[e]&&h[e]>=2}?"Possible":"Impossible"

Measured memory_bytes: 1788
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e15;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
static int dp[65536]={0};
//vector<vector<pair<int,int>>>ko;
array<int,16>use;
/*void solve(int ter,int oya,int uex){
	//返す方向のxor
	
	for(auto it:ko[ter]){
		if(it.fir==oya){continue;}
		solve(it.fir,ter,uex^it.sec);
	}
	if(oya!=-1){use[uex]++;cerr<<uex<<endl;}
}*/
int main(void){
	int n,ans,i,j;
	//i 各bitを持ってるか
	for(i=1;i<65536;i++){//xorが0になるような組み合わせをうまいこと見つける
		int bi=0;
		for(j=1;j<16;j++){
			if(((1<<j)&i)!=0){bi^=j;}
		}
		if(bi==0){maxeq(dp[i],1);}
		
		for(j=1;j<65536;){
			if(((65535-i)&j)!=0){j+=(65535-i)&j;continue;}
			maxeq(dp[i],dp[j]+dp[i-j]);
			j++;
		}
	}
	cin>>n;ans=n;
	//ko.res(n);
	vector<int>hzi(n);
	for(i=0;i<n-1;i++){
		int x,y,a;cin>>x>>y>>a;
		hzi[x]^=a;
		hzi[y]^=a;
		//ko[x].pub(mp(y,a));
		//ko[y].pub(mp(x,a));
	}
	for(i=0;i<n;i++){use[hzi[i]]++;}
	//solve(0,-1,0);
	ans-=use[0];use[0]=0;
	for(i=1;i<16;i++){ans-=use[i]/2;use[i]%=2;}
	int bi=0;for(i=0;i<16;i++){if(use[i]==1){bi+=(1<<i);}}
	//cout<<bi<<" "<<dp[bi]<<endl;
	ans-=dp[bi];
	cout<<ans<<endl;
}

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

pair<int,int> next(pair<int,int> p, int w){
    if(p.first % 2 == 0){
        if(p.second == w - 1){
            p.first++;
        }else{
            p.second++;
        }
    }else{
        if(p.second == 0){
            p.first++;
        }else{
            p.second--;
        }
    }
    return p;
}

int main(void){
    int h, w, n;
    cin >> h >> w >> n;
    vector<vector<int>> grid(h, vector<int>(w));
    pair<int,int> p = {0,0};

    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        for(int j=0; j<a; j++){
            grid[p.first][p.second] = i + 1;
            p = next(p, w);
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
MAXN = 2**15
MAXRT = int(MAXN**0.5)
MAXTERM = 4

dp = [[0 for n in range(MAXN+1)] for t in range(MAXTERM+1)]
dp[0][0] = 1
for r in range(MAXRT,0,-1):
    for t in range(MAXTERM):
        for n in range(MAXN+1 - r*r):
            if dp[t][n] == 0: continue
            dp[t+1][n + r*r] += dp[t][n]

while True:
    N = int(input())
    if N == 0: break
    print(sum(map(lambda x:x[N],dp)))

Measured memory_bytes: 7504
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pair pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

void solve()
{
    int n;
    cin >> n;
    string s[4] = { "AC","WA","TLE","RE" };
    int count[4] = { 0,0,0,0 };
    while(n--)
    {
        string si;
        cin >> si;
        if(s[0]==si)
        {
            count[0]++;
        }
        else if (s[1] == si)
        {
            count[1]++;
        }
        else if (s[2] == si)
        {
            count[2]++;
        }
        else if (s[3] == si)
        {
            count[3]++;
        }
        
    }
    for (int i = 0; i < 4; i++)
    {
        cout << s[i] <<  " x " << count[i] << "\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 1; i <= N; ++i)
  {
    if(i % 2 == 1)
    {
      // Nまでの数値で奇数のみ処理
      int yakCnt = 0;
      for(int j = 1; j <= i; ++j)
      {
        if(i % j == 0)
        {
          // 現在の奇数値までに約数があればカウント
          ++yakCnt;
        }
      }
      if(yakCnt == 8)
      {
        // 約数合計が8なら出力数値カウント
        ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

 vector<int> vec(N);
 for(int i=0; i<N; i++) cin >> vec.at(i);

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

 int ans=1;

 for(int i=0; i<N; i++){
     if(i!=0 && vec.at(i)!=vec.at(i-1)) ans++;
 }

 cout <<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int j=0;
  vector<int> ans;
  for(int i=k-1;i<n;i++){
    ans.push_back(h[i]-h[j]);
    j++;
  }
  cout<<*(min_element(ans.begin(),ans.end()));
}

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

myans = []

if A - K >= 0:
    myans += [A - K]
    myans += [B]
else:
    myans += [0]
    if (A +B) - K >= 0:
        myans += [(A +B) - K]
    else:
        myans += [0]

print(' '.join(map(str,myans)))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n;
	cin >> n;
	vi v(n, 0);
	double total = 0;
	REP(i, 0, n){
		cin >> v[i];
		total += v[i];
	}
	double avg = round(total/n);
	ll ans = 0;
	//cout << avg << endl;
	REP(i, 0, n) ans += pow(v[i]-avg, 2);
	cout << ans;

}


Measured memory_bytes: 256
while True:
    n = int(raw_input())
    if n == 0:
        break
    a=[]
    for i in range(n):
        a.append(int(raw_input()))
    max = -1e10
    for i in range(len(a)):
        sum = 0
        for j in range(i,len(a)):
            sum += a[j]
            if sum > max:
                max = sum
    print max

Measured memory_bytes: 4488
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a,b = ma()
c=d=e=-1
for i in range(a+1):
    for j in range(a-i+1):
        if b == i*10000 + j*5000 + (a-i-j)*1000: 
            c,d,e=i,j,a-i-j
            break
print(c,d,e)

Measured memory_bytes: 3064
import sys
from collections import deque
n, m=map(int,input().split())
"""
頂点1~nを1~3nに3倍加する
"""
edges=[[] for i in range(3*n)]
for i in range(m):
    """
    uからvへの枝を
    uからv+n, u+nからv+2n, u+2nからv+3n
    とする
    (枝を3倍加)
    """
    u, v=map(int, input().split())
    u, v=u-1, v-1
    edges[u].append(v+n)
    edges[u+n].append(v+2*n)
    edges[u+2*n].append(v)
s, t=map(int, input().split())
s, t=s-1, t-1
q=deque()
q.append(s)
dist=[-1]*(3*n)
dist[s]=0
"""
結局求めるものは，s~tへの最短距離を3で割ったもの
"""
while len(q)!=0:
    fr=q.popleft()
    for to in edges[fr]:
        #もし行ったことがなければ
        if dist[to]==-1:
            dist[to]=dist[fr]+1
            q.append(to)
print(dist[t]//3)


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

using namespace std;

const int NMAX = 1e5+5;

struct al
{
    int to,cg;
};

vector<al> g[NMAX];
int colour[NMAX];
bool viz[NMAX];

inline void DFS(int node, int col)
{
    viz[node] = 1;
    colour[node] = col;
    int gnode,sch;
    for(auto val : g[node])
    {
        gnode = val.to;
        sch = val.cg;
        if(!viz[gnode])
        {
            if(sch == 1)
                DFS(gnode , (col%2 + 1));
            else
                DFS(gnode , col);
        }
    }
}

int main()
{
    int N,i,j;
    cin>>N;
    for(i = 1 ; i < N ; ++i)
    {
        al p;
        int x,y,c;
        cin>>x>>y>>c;
        c &= 1;
        p.to = y;
        p.cg = c;
        g[x].push_back(p);
        p.to = x;
        g[y].push_back(p);
    }

    DFS(1 , 1);

    for(i = 1 ; i <= N ; ++i)
        cout<<(colour[i] == 1)<<"\n";

    return 0;
}


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

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

  string A_ = to_string(a);
  string B_ = to_string(b);
  
  string A = "";
  for (int i = 0; i < b; i++) {
    A += A_;
  }

  string B = "";
  for (int i = 0; i < a; i++) {
    B += B_;
  }

  if (A < B) {
    cout << A << endl;
  } else {
    cout << B << endl;
  }

}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Contest
{


    class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            int ans = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}

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

int n;
char s[6003];
std::string parts[3003];
int main()
{
	scanf("%d %s",&n,s);
	int i = 0, j = 0;
	while(i < 2 * n) {
		std::string max;
		int sum = 0;
		int type = s[i] - 'a';
		std::vector<int> va, vb;
		do {
			if(s[i] == 'a') {
				++sum;
				va.push_back(i);
			} else {
				--sum;
				vb.push_back(i);
			}
			++i;
		} while(sum != 0);
		if(type == 0) {
			while(!va.empty()) {
				assert(va[0] < vb[0]);
				max += "ab";
				int j = vb[0];
				while(!va.empty() && va[0] < j) {
					va.erase(va.begin());
					vb.erase(vb.begin());
				}
			}
		} else {
			int s = va.size();
			for(int k = 0;k < s;++k) {
				std::string cur;
				int a = k, b = k;
				while(a < s || b < s) {
					if(b == s || (a != s && va[a] < vb[b])) {
						cur.push_back('a');
						++a;
					} else {
						cur.push_back('b');
						++b;
					}
				}
				if(cur > max) max = cur;
			}
		}
		parts[j++] = max;
	}
	std::string max, ans;
	for(int k = j-1;k >= 0;--k) {
		if(parts[k] >= max) {
			max = parts[k];
		}
		if(parts[k] + max >= max) {
			ans = parts[k] + ans;
		}
	}
	printf("%s\n", ans.c_str());
		
}


Measured memory_bytes: 384
/**
 * author:    Ziel
 * created:   11.04.2020 22:17:38
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
inline void cmin(T &a, T b) { a = min(a, b); }
template <class T>
inline void cmax(T &a, T b) { a = max(a, b); }

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
//	fre("");
//	ACCELERATE;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	char s[100100];
//	cin >> s;
	scanf("%s", s);
	int n = strlen(s);
	
	int q;
	scanf("%d", &q);
	
	bool rev = 0;
	vector<char> b, e;
	while (q--) {
		int type;
		scanf("%d", &type);
		
		if (type == 1) {
			rev ^= 1;
		}
		else {
			int f;
			char c;
			scanf("%d %c", &f, &c);
			
			if ((f == 1 && !rev) || (f == 2 && rev)) b.pb(c);
			else e.pb(c);
		}
	}
	
	if (rev) reverse(s, s + n);
	
	if (!rev) {
		reverse(all(b));
		for (char c: b) printf("%c", c);
		printf("%s", s);
		for (char c: e) printf("%c", c);
	} else {
		reverse(all(e));
		for (char c: e) printf("%c", c);
		printf("%s", s);
		for (char c: b) printf("%c", c);
	}
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<vector<int>> G(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> d(n);
  vector<int> ans(n);
  vector<vector<int>> cnt(2);
  int i=0, j=0, k=1;
  auto dfs = [&](auto dfs, int cur, int par) -> void {
    if(par != -1) d[cur] = d[par]+1;
    cnt[d[cur]%2].push_back(cur);
    for(int ne: G[cur]) {
      if(ne != par) dfs(dfs, ne, cur);
    }
  };
  dfs(dfs, 0, -1);
  if((int)min(cnt[0].size(), cnt[1].size()) <= n/3) {
    set<int> st; rep(i, n) st.insert(i+1);
    int flag = (cnt[0].size() < cnt[1].size());
    for(int ii: cnt[1-flag]) {
      ans[ii] = 3*k;
      k++;
      st.erase(ans[ii]);
    }
    auto itr = st.begin();
    for(int jj: cnt[flag]) {
      ans[jj] = *itr;
      itr++;
    }
  } else {
    for(int ii: cnt[0]) {
      if(3*i+1 <= n) {
        ans[ii] = 3*i+1;
        i++;
      } else {
        ans[ii] = 3*k;
        k++;
      }
    }
    for(int jj: cnt[1]) {
      if(3*j+2 <= n) {
        ans[jj] = 3*j+2;
        j++;
      } else {
        ans[jj] = 3*k;
        k++;
      }
    }
  }
  rep(i, n) cout << ans[i] << ' ';
  cout << endk;
  return 0;
}


Measured memory_bytes: 25400
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    S = collections.Counter(S)
    print('Yes' if all([v == 2 for v in S.values()]) else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

int main(void)
{
	int i;
	int j;
	
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		char[] C = S.ToCharArray();
		int N = S.Length;
		for(int i=0;i<N;i++){
			if(C[i] == 'a')continue;
			if(K>= (26 - (C[i] - 'a'))){
				K -= (26 - (C[i] - 'a'));
				C[i] = 'a';
			}
		}
		//Console.WriteLine(new String(C) + " "+ K.ToString());
		
		K %= 26;
		C[N-1] = (C[N-1] + K <='z') ? ((char)(C[N-1] + K)) : (char) (C[N-1] + K - 26);
		Console.WriteLine(new String(C));
		
		
		
		
	}
	String S;
	int K;
	public Sol(){
		S = rs();
		K = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main()
{
	string s;
	cin >> s;
	bool res = true;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == 'L')res = false;
		}
		else {
			if (s[i] == 'R')res = false;
		}
	}
	cout << (res ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
a,v1=iia()
b,v2=iia()
t=ii1()
if a<b:
    if a+t*v1>=b+t*v2:
        print('YES')
    else:
        print('NO')
else:
    if b-t*v2>=a-t*v1:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9568
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

x, y = input_a

#if x == 1 && y == 2 || x == 1 && y == 2
#  puts "Yes"
#  exit
#end
(0..(x + 1)).each do |i|
  (0..(x + 1)).each do |j|
    if i * 2 + j * 4 == y && (i + j == x)
      puts "Yes"
      exit
    end
  end
end
puts "No"


Measured memory_bytes: 14372
/**
 *   created: 12 April 2019  00:37:24
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

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

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
int main(){
	int tc=1;
	// cin>>tc;
	while(tc--){
		string s;
		cin>>s;
		int n=s.size();
		int res=0;
		int m1=0,m2=0;
		for(int i=0;i<n;i++){
			if(i%2==0 && s[i]!='0')
				m1++;
			else if(i%2==1 && s[i]!='1')
				m1++;
			// trace3(m1,s[i],i);
		}
		for(int i=0;i<n;i++){
			if(i%2==0 && s[i]!='1')
				m2++;
			else if(i%2==1 && s[i]!='0')
				m2++;
		}
		// cout<<m1<<m2<<endl;
		cout<<min(m1,m2);
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n, a, b, c, x;
    while (cin >> n >> a >> b >> c >> x, n|a|b|c|x) {
        vector<int> vi;
        for (int i = 0; i < n; i++) {
            int y;
            cin >> y;
            vi.push_back(y);
        }
        int frame = 0;
        for (int i = 0; i < vi.size(); frame++) {
            if (frame > 10000) {
                frame = -1;
                break;
            }
            if (x == vi[i])
                i++;
            if (i >= vi.size())
                break;
            x = (a*x+b) % c;
        }
        cout << frame << endl;
    }
    return 0;
}

Measured memory_bytes: 2996
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps -1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long int

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int n,t;
int a[5000],b[5000];

int dp[3001][3001];

int DP[3001][3001];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>n>>t;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	for(int i=0;i<3001;i++){
		for(int j=0;j<3001;j++){ 
			dp[i][j] = eps;
			DP[i][j] = eps;
		}
	}
	if(a[0]<=t)
    	dp[0][a[0]] = b[0];
    dp[0][0] = 0;
    for(int i=1;i<n;i++){
    	for(int j=0;j<=t;j++){
    		dp[i][j] = max(dp[i][j],dp[i-1][j]);
    		if(j-a[i]>=0){
    			dp[i][j] = max(dp[i][j],dp[i-1][j-a[i]] + b[i]);
    		}
    	}
    }
    if(a[n-1]<=t)
       DP[n-1][a[n-1]] = b[n-1];
   DP[n-1][0] = 0;
   for(int i=n-2;i>=0;i--){
   	for(int j=0;j<=t;j++){
   		DP[i][j] = max(DP[i][j],DP[i+1][j]);
   		  if(j-a[i]>=0){
    			DP[i][j] = max(DP[i][j],DP[i+1][j-a[i]] + b[i]);
    		}
   	   }
   } 
   int output =0;
   	  for(int j=0;j<=t;j++)
   	  	output = max(output,dp[n-1][j]);
   	for(int i=0;i<n;i++){
   		if(i==0||i==n-1){
   			set<int> S;
   			for(int j=t-1;j>=0;j--){
   				if(i==0){
   					S.insert(DP[i+1][t - j - 1]);
   					int maxa = *(S.rbegin());
   					int kit = maxa + b[i];
   					output = max(output,kit);		
   				}
   				else{
   				    int kit = dp[i-1][j] + b[i];
   					output = max(output,kit);	
   				}
   			}
   		}
   		else{
   		set<int> S;
   		for(int j=t-1;j>=0;j--){
   			//cout<<"j = "<<j<<" ";
   			S.insert(DP[i+1][t - j - 1]);
   			int maxa = *(S.rbegin());
   			int kit = dp[i-1][j] + maxa + b[i];
   			output = max(output,kit);
   		}
   	}
   	}
   	cout<<output;
	return 0;
}


Measured memory_bytes: 141312
#include <stdio.h>
//#include <stdbool.h>
int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    int ans[n];
    for (int i = 0; i < n; i++){
        int count = 0;
        while (1){
            if (a[i] % 2 != 0){
                ans[i] = count;
                break;
            }
            else {
                a[i] /= 2;
                count ++;
            }
        }
    }
    long int min = 1000000000;
    for (int i = 0; i < n; i++){
        if (ans[i] <= min){
            min = ans[i];
        }
    }

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

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 1046527

char dict[MAX][13];

int h1(int seed) { return seed % MAX; }
int h2(int seed) { return 1 + (seed % (MAX - 1)); }

int hash(int seed) {
  return seed % MAX;
}

long long getKey(char *data) {
  long long sum = 0, p = 1, i;
  for(i = 0;i < strlen(data);i++) {
    sum += p * data[i];
    p *= 5;
  }

  return sum;
}

void insert(char *data) {
  long long h, i, key;
  key = getKey(data);

  for(i = 0;;i++) {
    h = (h1(key) + i * h2(key)) % MAX;

    if(strcmp(dict[h], data) == 0) {
      return;
     } else if(strlen(dict[h]) == 0) {
      strcpy(dict[h], data);
      return;
    }
  }
}

int find(char *data) {
  long long h, i, key;
  key = getKey(data);

  for(i = 0;;i++) {
    h = (h1(key) + i * h2(key)) % MAX;

    if(strcmp(dict[h], data) == 0)
      return 1;
    else if(strlen(dict[h]) == 0)
      return 0;
  }
}

int main() {
  int i, n;
  char operation[7], data[13];

  for(i = 0;i < MAX;i++){
    dict[i][0] = '\0';
  }

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%s %s", operation, data);
    switch(operation[0]) {
      case 'i':
        insert(data);
        break;
      case 'f':
        if(find(data))
          printf("yes\n");
        else
          printf("no\n");
        break;
    }
  }

  return 0;
}



Measured memory_bytes: 15024
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();

int main(){
    string s;
    cin >> s;
    if( s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

void process(){
    
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  std::vector<bool> isprime(1010,true);
  std::vector<ll> prime;
  isprime[0]=false;
  isprime[1]=false;

  for(int i=2;i*i<1010;i++){
    if(isprime[i]){
      for(int j=2;i*j<1010;j++){
        isprime[i*j]=false;
      }
    }
  }

  rep(i,0,1010){
    if(isprime[i])prime.push_back(i);
  }


  ll n,ans=1;
  std::cin>>n;

  for(ll pri:prime){
    if(pri>n)break;

    ll temp=pri,v=1;
    while(temp<=n){
      v+=(n/temp);
      temp*=pri;
    }

    ans=(ans*v)%MOD;
  }

  std::cout<<ans;

  return 0;
}

Measured memory_bytes: 256
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 1e6+10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int N; 
vi a(MX);
vi vec;
bool vis[MX];
int spf[MX];

void f(int x){
	while(x>1){
		vec.pb(spf[x]);
		int b=spf[x];
		while(x%b==0) x/=b;
	}
}

void sieve(){
	for(int i=2; i<1000001; i++) if(spf[i]==-1){
		for(int j=i; j<1000001; j+=i) spf[j]=i;
	}
}


int32_t main() {
	boost; IO();
	FOR(i,0,MX) spf[i]=-1;	
	FOR(i,0,MX) vis[i]=false;

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

	int GCD=a[0]; FOR(i,1,N) GCD=__gcd(GCD,a[i]);
	
	bool sw=true;
	for(int i=N-1; i>=0 && sw; i--){
		vec.clear();
		f(a[i]);
		bool y=false;
		for(auto x: vec) if(vis[x]) y=true;
		if(y) sw=false;

		for(auto x: vec) vis[x]=true;
	}

	if(sw) cout << "pairwise coprime" << endl;
	else if(GCD==1) cout << "setwise coprime" << endl;
	else cout <<"not coprime" << endl;



	set <int> p;
	



	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


Measured memory_bytes: 19816
from collections import Counter

N = int(input())
A = [int(_) // 400 if int(_) <= 3199 else 8 for _ in input().split()]

min_counter = Counter(A).copy()
if 8 in min_counter.keys():
    min_counter.pop(8)
    if not min_counter:
        minimum = 1
    else:
        minimum = len(min_counter)
else:
    minimum = len(min_counter)

maximum = 0
max_counter = Counter(A).copy()

if 8 in max_counter.keys():
    maximum = max_counter[8]
    max_counter.pop(8)
    maximum += len(max_counter)
else:
    maximum += len(max_counter)

print(minimum, maximum)

Measured memory_bytes: 3316
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int inverse(int x){
    return binpow(x, MOD - 2, MOD);
}

void solve()
{
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for(auto & i : a)   cin >> i.F >> i.S;
    //sort(all(a));
    int a1 = INT_MIN, b1 = INT_MIN, c1 = INT_MAX, d1 = INT_MAX;
    for(int i = 0; i < n; i++){
        a1 = max(a1, a[i].F + a[i].S);
        b1 = max(b1, a[i].F - a[i].S);
        c1 = min(c1, a[i].F + a[i].S);
        d1 = min(a[i].F - a[i].S, d1);
    }
    cout << max(a1 - c1, b1 - d1) << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 6360
#include <stdio.h>
#define N 10000

int n, m, data[N], tmp[N];

void MergeSort(int data[], int left, int right){
  int mid, i, j, k;
  if(left >= right) return;
  mid = (left + right) / 2;
  MergeSort(data, left, mid);
  MergeSort(data, mid+1, right);
  for(i=left;i<=mid;i++) tmp[i] = data[i];
  for(i=mid+1, j=right;i<=right;i++, j--) tmp[i] = data[j];
  i = left;
  j = right;
  for(k=left;k<=right;k++){
    if(tmp[i] <= tmp[j]) data[k] = tmp[i++];
    else data[k] = tmp[j--];
  }
}

char find(int x){
  int l = 0, r = n;
  while(r - l >= 1){
    int i = (l + r) / 2;
    if(data[i] == x) return 1;
    else if(data[i] < x) l = i + 1;
    else r = i;
  }
  return 0;
}

main(){
  int i, in, ans = 0;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &data[i]);
  }
  MergeSort(data, 0, n-1);
  scanf("%d", &m);
  for(i=0;i<m;i++){
    scanf("%d", &in);
    if(find(in)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;  //これで"std::cout"が"cout"と書ける

//MACRO
typedef long long ll;                  //64bit以上を表現可能な型
#define INF 100000000                  //ほぼ無限
#define itn int                        //タイポ対策
#define all(x) (x).begin(), (x).end()  //sort(all(x))などとする
#define SZ(x) ((int)(x).size())        //size()簡略化
//repetition
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define repR(i, n) for (int i = n; i >= 0; i--)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;
template <class T>
bool chMAX(T &a, const T &b) {  //aよりbが大きければaに代入
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chMIN(T &a, const T &b) {  //aよりbが小さければaに代入
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

//
//
//

int main() {
    int n;
    cin >> n;
    vector<int> v;  //可変長配列

    rep(i, n) {
        int a;
        cin >> a;
        a--;             //"a"を0から始めるためマイナス
        v.push_back(a);  //末尾に"z"を追加
    }

    int now = 0;//最初は１番目が光っている
    int cnt = 0;
    while (true) {
        if (now == 1) {
            cout << cnt << endl;
            break;
        }
        if (cnt >= n) {
            cout << "-1" << endl;
            break;
        }
        cnt++;
        now = v[now];
    }

}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int MOD = (int) 998244353;
//const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;
LL a[maxn];
LL inv[maxm];

LL f[maxm], g[maxm];

void work()
{
    cin >>n;
    for(int i = 1; i <= n; i++) cin >>a[i];

    inv[0] = inv[1] = 1;
    for(int i = 2; i < maxm; i++) inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;


    for(int i = 1; i <= n; i++) f[a[i]] += a[i];
    for(int i = 1; i < maxm; i++) f[i] %= MOD;

    for(int i = 1; i < maxm; i++)
    {
        for(int j = i; j < maxm; j+= i)
            g[i] += f[j];
        g[i] %= MOD;
    }

    LL ans = 0;
    for(int i = maxm - 1; i; i--)
    {
        g[i] = g[i] * g[i] % MOD;

        for(int j = i * 2; j < maxm; j += i)
            g[i] -= g[j];
        g[i] = (g[i] % MOD + MOD) % MOD;

        ans += g[i] * inv[i] % MOD;

//        if(g[i]) cout <<i <<" " <<g[i] <<endl;
    }

    ans %= MOD;

    for(int i = 1; i <= n; i++) ans -= a[i];

    ans = (ans % MOD + MOD) % MOD;

    ans = ans * inv[2] % MOD;

    cout <<ans <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 25216
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("in.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
 
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 1e3 + 7;
typedef vector < vector < ll > > matrix;

int main()
{
    speed;
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    s += '.';
    forn( i, n ) {
    	if ( s[i] != s[i + 1] ) {
    		ans++;
    	}
    }
    cout << ans;
    time;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	string A;
	cin >> A;

	int S = 0;

	if (A[0] == '1') {
		S++;
	}
	if (A[1] == '1') {
		S++;
	}
	if (A[2] == '1') {
		S++;
	}
	cout << S << endl;
}

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

int main(){
  string str;
  cin >> str;
  
  int x = str.size();
  
  int n = 0;
  int m = 0;
  
  rep(i, x){
    if ((i + 1) % 2 == 0){
      if (str.at(i) == 'R') n++;
    }
    else {
      if (str.at(i) == 'L') m++;
    }
  }
  if (n == 0 && m == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int a, b, c;
    int f_cnt = 0, s_cnt = 0;
    vector <int> array;
    cin >> a;
    cin >> b;
    cin >> c;
    array.push_back(a);
    array.push_back(b);
    array.push_back(c);
    
    for(int i = 0; i < 3; i++){
        if(array[i] == 5)   f_cnt++;
        if(array[i] == 7)   s_cnt++;
    }
    
    if(f_cnt == 2 && s_cnt == 1)        cout << "YES\n" << endl;
    else                                cout << "NO\n" << endl;
    
    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let x: i32 = sc.read();
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    if (x - a).abs() < (x - b).abs() {
        println!("A");
    } else {
        println!("B");
    }
}

Measured memory_bytes: 4352
#include <cstdio>
using namespace std;

int num_of(char ch){return ch-'0';}
int main(){
  char buf[100];
  scanf("%s", buf);
  int y = num_of(buf[0])*1000 + num_of(buf[1])*100 + num_of(buf[2])*10 + num_of(buf[3]);
  int m = num_of(buf[5])*10 + num_of(buf[6]);
  int d = num_of(buf[8])*10 + num_of(buf[9]);
  bool flag;
  if(y>2019){
    flag = true;
  }else if(y<2019){
    flag = false;
  }else if(m>4){
    flag = true;
  }else if(m<4){
    flag = false;
  }else if(d>30){
    flag = true;
  }else if(d<=30){
    flag = false;
  }
  printf("%s", flag ? "TBD" : "Heisei");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// Prioridade
typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (int)(b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)
#define W(x) cerr << "\033[31m"<<  #x << " = " << x << "\033[0m" << endl;
// fim da Prioridade

double dp[302][302][302];
	
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); 	
	int n;
	cin >> n;
	vi count(4,0);
	for (int i = 0; i < n; i++){
		int x; 
		cin >> x;
		count[x]++;
	}

	for(int three = 0; three <= count[3]; three++){
		for(int two = 0; two <= count[3] + count[2]; two++){
			for(int one = 0; one <= n; one++){
				if(three == 0 and two == 0 and one == 0) {dp[three][two][one] = 0; continue;};
				double answer = n;
				
				if(three) answer += three * dp[three - 1][two + 1][one];
			
				if(two)   answer += two   * dp[three][two - 1][one + 1];
				
				if(one)   answer += one   * dp[three][two][one - 1];
				
				answer /= (three + two + one)*1.0;
				dp[three][two][one] = answer;
			}
		}
	}
	
	cout << setprecision(9) << fixed << dp[count[3]][count[2]][count[1]] << endl;
	return 0;
}
 


Measured memory_bytes: 215296
#include<stdio.h>
#include<string.h>

int main(void){


    char str_input[255];
    scanf("%s", str_input);

    size_t strlength = strlen(str_input);
    char* str_out = new char[strlength];
    
    for(int i = 0; i < strlength ; i++){
    
    if(i == 3 && str_input[3] == '7'){
        str_out[3] = '8';
    }else{
        str_out[i] = str_input[i];
    }
    }

    for(int i = 0; i < strlength; i++){
        printf("%c", str_out[i]);
    }
    return 0;
    
}

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

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    bool ok = true;
    rep(i, n){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                ok = false;
                break;
            }
        }
    }
    if(ok){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<int> ma(n, 0);
	int limit = 1e9;;
	bool able=false;
	REP(i, n) {
		limit--;
		if (a[i] < 0) {
			limit = min(limit, abs(a[i]) );
		}
		if (a[i] == 0) {
			limit = 1e9;
			able = true;
		}
		if (a[i] > 0&&able) {
			ma[i] = max(ma[i], min(limit, a[i]));
		}
	}
	limit = 1e9;;
	able = false;
	for (int i = n - 1; i >= 0;i--) {
		limit--;
		if (a[i] < 0) {
			limit = min(limit, abs(a[i]));
		}
		if (a[i] == 0) {
			limit = 1e9;
			able = true;
		}
		if (a[i] > 0&&able) {
			ma[i] = max(ma[i], min(limit, a[i]));
		}
	}
	int ans=0;
	REP(i, n)
		ans += ma[i];
	cout << ans << endl;
}

Measured memory_bytes: 3632