akhauriyash/Code-Regression huggingface dataset:
def game(t, s)
  cnt = 0
  s.each_cons(2).reduce(0){ |c, (l, r)|
    l, r = r, l if t == 1
    if r % 3 == 1 && l % 3 != 1 || r % 3 == 2 && l % 3 == 0
      c + 1
    else
      t = 1 - t
      c
    end
  }
end

while s = gets.chomp
  break if s == '#'
  s = s.split('').map(&:to_i)
  p [game(0, s), game(1, s)].min
end

Measured memory_bytes: 23336
n, m, c = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []


count = 0

for i in range(n):
    A.append(list(map(int, input().split())))
    sum = 0

    for j in range(m):
        sum = sum + A[i][j] * B[j]

    sum = sum + c
    if 0 < sum:
        count = count + 1


print(count)


Measured memory_bytes: 3060
a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
    dum = str(i)
    dum_len = len(dum)
    flag = "on"
    for i in range(dum_len//2):
        if dum[i] != dum[-(i+1)]:
            flag = "off"
    if flag == "on":
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {
    
    int n;
    cin>>n;
    set<string> m;
    rep(i,n){
        string q,s;
        cin>>q>>s;
        if(q=="insert")m.insert(s);
        else yn(m.count(s));
    }
    
}


Measured memory_bytes: 32164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define x1 jfkljfewlkjfwekl
#define x2 jkfwejklfwej
#define y1 kfewfe
#define y2 jfwekj3w3e
 
int bomb[50][50];
 
 
int a[4][4] = {
	{0,0,0,0},
	{0,0,0,0},
	{1,1,0,0},
	{1,1,0,0},
};
int myquery(int x1,int x2,int y1,int y2){
	int sum = 0;
	for(int i = y1 ; i <= y2 ; i++)
		for(int j = x1 ; j <= x2 ; j++)
			sum += a[i][j];
	return sum;
}
int query(int x1,int x2,int y1,int y2){
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	//return myquery(x1,x2,y1,y2);
	int sum;
	cin >> sum;
	return sum;
}
int dfs(int x1,int x2,int y1,int y2,int prv){
	if( x1 > x2 or y1 > y2 ) return 0;
	
	int ask = prv == -1 ? query(x1,x2,y1,y2) : prv;
	//cout << ask << endl;
	if( ask == (x2-x1+1) * (y2-y1+1) ){
		int ans = 0;
		for(int i = y1 ; i <= y2 ; i++)
			for(int j = x1 ; j <= x2 ; j++)
				bomb[i][j] = 1;
		return ask;
		
	}else if( ask == 0 ){
		 return 0;
	}
	int X = (x1+x2) / 2;
	int Y = (y1+y2) / 2;
	int a = dfs(x1,X,y1,Y,-1);
	int b = dfs(X+1,x2,y1,Y,-1);
	int c = dfs(x1,X,Y+1,y2,-1);
	int d = dfs(X+1,x2,Y+1,y2,ask-a-b-c);
	return ask;
	
}
signed main(){
	int H,W,N,K;
	cin >> H >> W >> N >> K;
	//dfs(0,W-1,0,H-1,-1);
	long long ans = 0;
	long long w = 1;
	for(int i = 0 ; i < H ; i+=2){
		for(int j = 0 ; j < W ; j += 2 ){
			dfs(i,i+1,j,j+1,-1);
		}
	}
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			ans += w * bomb[i][j];
			ans %= K;
			w *= 2;
			w %= K;
		}
	}
	cout << "!" << " " << ans << endl;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	sort(A,A+N);
	int M=A[N-1]-A[0];
	for(int i=1;i<N-1;i++){
		M+=abs(A[i]);
	}
	cout<<M<<endl;
	int X=A[0],Y=A[N-1];
	for(int i=1;i<N-1;i++){
		if(A[i]<0){
			cout<<Y<<" "<<A[i]<<endl;
			Y-=A[i];
		}
		else{
			cout<<X<<" "<<A[i]<<endl;
			X-=A[i];
		}
	}
	cout<<Y<<" "<<X<<endl;
	return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
#define ll long long
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
int main(){
    ll a,b,ans=0;
    scanf("%lld%lld",&a,&b);
    ll g=gcd(a,b);
    for(ll i=2;i*i<=g;i++){
        if(g%i==0) ans++;
        while(g%i==0) g/=i;
    }
    if(g>1) ans++;
    printf("%lld\n",ans+1);
    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
S = [read_str() for _ in range(N)]

def solve():
    _a = 0
    b_ = 0
    ba = 0
    in_ab = 0

    # search
    for i in range(N):
        if S[i][0] == 'B' and S[i][-1:] == 'A':
            ba += 1
        elif S[i][0] == 'B':
            b_ += 1
        elif S[i][-1:] == 'A':
            _a += 1
        for j in range(len(S[i]) - 1):
            if S[i][j: j + 2] == 'AB':
                in_ab += 1

    ans = 0
    if ba == 0:
        ans += in_ab + min(_a, b_)
        return ans
    ans += in_ab + max(ba - 1,0) + max(0, min(_a - 1, b_ - 1))
    # print(in_ab, ba, ans)
    if _a > 0: ans += 1
    if b_ > 0: ans += 1
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 4336
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  string S,T;
  cin >> S;
  cin >> T;
  int count = 0;

  rep(i,S.length()){
    if(S[i] != T[i]) count++;
  }

  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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

int main()
{
    ll N, M, C;
    cin >> N >> M >> C;
    vector<ll> B(M);
    rep(i, M) cin >> B[i];
    ll count = 0;
    rep(i, N)
    {
        ll sum = 0;
        rep(j, M)
        {
            ll A;
            cin >> A;
            sum += A * B[j];
        }
        if (sum > -C)
            count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
//#include<algorithm>//for sort,lower_bound,upper_bound...
//#include<map>//for map and multimap
//#include<vector>//for vector and bvector
#include<string>//for string,wstring,u16string and u32string
//#include<queue>//for queue,priority_queue and deque
#include<iostream>//for cin,cout,cerr and clog
//#include<cstring>//for memset,memcpy,strlen,strcmp...
//#include<ctime>//for clock
//#include<cstdlib>//for rand,exit,free and malloc
//#include<cmath>//for abs,sqrt,floor,log...
using namespace std;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) do{typeof(a) t=a;a=b;b=t;}while(false);
#define fe(v,bg) for(v=head[bg];v;v=e[v].next)
#define INF 0x7fffffff
#define re register
#define us unsigned
//#define RW_FILE 1
typedef long long ll;
template<typename T>inline T read(){T res=0;bool f=true;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=false;ch=getchar();}while(ch>='0'&&ch<='9')res=(res<<1)+(res<<3)+(ch^48),ch=getchar();return f?res:-res;}
inline int readi(){return read<int>();}inline ll readll(){return read<ll>();}
template<typename T>inline void write(T x,char ed=32){int p=0,num[20];if(!x)putchar('0');else{if(x<0)putchar('-'),x=-x;for(;x;x/=10)num[p++]=x%10;for(;p;)putchar(num[--p]+48);}putchar(ed);}
template<typename T>inline void writeln(T x){write(x,'\n');}
const int MAXN=1e5+15;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();++i)
		if(s[i]=='C'){
			for(int j=i+1;j<s.size();++j)
				if(s[j]=='F'){
					cout<<"Yes\n";
					return 0;
				}
		}
	cout<<"No\n";
	return 0;
}



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

using namespace std;

struct duy{
    long long x, y;
} den[100005];
long long h, w, n, res[12];
long long c[] = {0, 0, 1, 1, 1, -1, -1, -1, 0};
long long d[] = {1, -1, 0, -1, 1, 0, -1, 1, 0};
map <long long, long long> m;

int main(){
    cin >> h >> w >> n;
    for(long long i = 1; i <= n; i++){
        cin >> den[i].x >> den[i].y;
        for(long long j = 0; j < 9; j++){
            long long t1 = den[i].x + c[j];
            long long t2 = den[i].y + d[j];
            if(t1 > 1 && t1 < h && t2 > 1 && t2 < w){
                long long tmp = (t1 - 1) * w + t2;
                if(m[tmp] == 0){
                    res[1]++;
                    m[tmp] = 1;
                }
                else{
                    res[m[tmp]]--;
                    m[tmp]++;
                    res[m[tmp]]++;
                }
            }
        }
    }
    long long t = (h - 2) * (w - 2);
    for(long long i = 1; i <= 9; i++) t -= res[i];
    cout << t << endl;
    for(long long i = 1; i <= 9; i++) cout << res[i] << endl;
}


Measured memory_bytes: 58112
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int> 
#define N (1<<7)

int n,m,ans;
vector<int>edge[10];
bool vis[10];

bool check()
{
	REP(i,n)if(!vis[i])return false;
	return true; 
}

void dfs(int x,int l)
{
	if(l==n)
	{
		if(check())ans++;
		return;
	}
	rep(i,edge[x].size())
	{
		int y=edge[x][i];
		if(vis[y])continue;
		vis[y]=true;
		dfs(y,l+1);
		vis[y]=false;
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int u,v;
		scanf("%d%d",&u,&v); 
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	vis[1]=true;
	dfs(1,1);
	printf("%d",ans);
	return 0;
}
/*
3 3
1 2
1 3
2 3
*/

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define TMAX 1000001
#define PMAX 10001
int main(){
  char T[TMAX],P[PMAX];
  int i,l,m;
    
  scanf("%s",T);
  scanf("%s",P);
    
  l=strlen(T);
  m=strlen(P);
    
  for(i=0;i<l;i++){
    if(strncmp(&T[i],P,m)==0) printf("%d\n",i);
  }
  return 0; 
}  

Measured memory_bytes: 1548
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool find(string s, char c) {
	for (int i = 0; i < s.size(); i++)if (s[i] == c)return true; return false;
}
int main() {
	int n; string s; cin >> n >> s;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		string s1 = s.substr(0, i), s2 = s.substr(i, n);
		int cnt = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			if (find(s1, c) && find(s2, c))cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

struct Edge{
	int from, to;
	ll cost;
	Edge(int from, int to, ll cost) : from(from), to(to), cost(cost){}
};

int n, m;

int ng;

vector<Edge> es;
vector<ll> dist;
void bellman_ford(int s){
	dist[s] = 0;
	for(int i = 0; i < 2 * n; ++i){
		for(auto e : es){
			if(dist[e.from] == LINF)continue;
			if(dist[e.from] + e.cost < dist[e.to]){
				dist[e.to] = dist[e.from] + e.cost;
				if(i >= n - 1 && e.to == n - 1)ng = 1;
			}
		}
	}

}

int main(){
  int s;
  cin >> n >> m;
  for(int i = 0; i < m; ++i){
  	int a, b;
  	ll c;
  	cin >> a >> b >> c;
  	--a;
  	--b;
  	c = -c;
  	es.push_back(Edge(a, b, c));
  }

  dist.assign(n, LINF);
  bellman_ford(0);
  if(ng)cout << "inf" << endl;
  else cout << -dist[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: i32,
    }
    let mut ret = 1;
    let mut r = 1;
    while r * r <= n {
        ret = r * r;
        r += 1;
    }
    println!("{}", ret);
}


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

signed main(void)
{
	int n;
	cin >> n;
	int a[n], ans1, ans2;
	vector<int> v(n);
	rep(i, n)
	{
		cin >> a[i];
		v[i] = a[i];
	}
	sort(v.begin(), v.end());
	ans1 = v[n / 2 - 1];
	ans2 = v[n / 2];
	rep(i, n)
	{
		if (a[i] <= ans1)
			cout << ans2 << endl;
		else if (a[i] >= ans2)
			cout << ans1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3840
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: String = read();
    let mut number = 0;
    for i in 0..a.chars().count() {
        if a.chars().nth(i).unwrap() == '+' {
            number += 1;
        } else if a.chars().nth(i).unwrap() == '-' {
            number -= 1;
        } 
    }
    println!("{}", number);
}


Measured memory_bytes: 4352
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define pf psuh_front
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define eb emplace_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 2 * 1e3 + 7;
const ld pi = 3.14159265359;
const int INF = 1e20 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

string s;

set < char > st;

map < char, int > cnt;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> s;

  for(int i = 0; i < s.size(); i++){
    cnt[s[i]]++;
    st.insert(s[i]);
  }

  for(auto i : st){
    if(cnt[i] % 2 == 1){
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        for (ll j = 1; j <= n; ++j) {
            if (i * j >= n) break;
            ans++;
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> broken(n);
  rep(i,m){
    int a;
    cin >> a;
    broken[a] = 1;
  }
  
  vector<int> dp(n+2);
  const int mod = 1000000007;
  dp[n] = 1;
  for (int i=n-1; i>=0; i--){
    if (broken[i]){
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1]+dp[i+2])%mod;
  }
  
  cout << dp[0] << endl;
  return 0;
  
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<vector<int> >v(w, vector<int>(h));
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			v[i][j] = 1;
		}
	}

	int x, y, a;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> a;

		if (a == 1) {
			for (int j = 0; j < x; j++) {
				for (int k = 0; k < h; k++) {
					v[j][k] = 0;
				}
			}
		}
		else if (a == 2) {
			for (int j = x; j < w; j++) {
				for (int k = 0; k < h; k++) {
					v[j][k] = 0;
				}
			}
		}
		else if (a == 3) {
			for (int j = 0; j < w; j++) {
				for (int k = 0; k < y; k++) {
					v[j][k] = 0;
				}
			}
		}
		else if (a == 4) {
			for (int j = 0; j < w; j++) {
				for (int k = y; k < h; k++) {
					v[j][k] = 0;
				}
			}
		}
	}

	int cnt = 0;
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			cnt += v[i][j];
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

char dividing(int pm, int pe, int pj);

int main(void)
{
	int ninnzuu;
	int point[3];
	while(true) {
		scanf("%d", &ninnzuu);
		if(ninnzuu == 0) {
			break;
		}
		for(int i = 0; i < ninnzuu; i++) {
			scanf("%d %d %d", &point[0], &point[1], &point[2]);
			printf("%c\n", dividing(point[0], point[1], point[2]));
		}
	}
	return 0;
}

char dividing(int pm, int pe, int pj)
{
	if(pm == 100 || pe == 100 || pj == 100) {
		return 'A';
	}else 	if(pm + pe >= 180) {
		return 'A';
	}else 	if(pm + pe + pj >= 240) {
		return 'A';
	}else  	if(pm + pe + pj >= 210) {
		return 'B';
	}else  	if(pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) {
		return 'B';
	}else{
		return 'C';
	}
}

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

int main(){
int n; cin >> n;
vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
int ans=0;
for(int i=n-1; i>1; i--){
    for(int j=i-1; j>0; j--){
        int a,b;
        b=l[j];
        a=l[i];
        for(int h=j-1; h>=0; h--){
            if((a-b)<l[h]) ans++;
            else break;
        }
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,*w = [int(i) for i in read().split()]
#n,*t = map(int,read().split())

#n = int(input())
#s = input()
h,a = [int(i) for i in readline().split()]


print((h+a-1)//a)










Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

vector<int> solve(vector<int> pre_runrun) {
	rep(i, pre_runrun.size() - 1) {
		if (abs(pre_runrun[i] + 1 - pre_runrun[i + 1]) <= 1 && pre_runrun[i] != 9) {
			pre_runrun[i] += 1;
			rrep(j, i - 1) {
				pre_runrun[j] = max(0, pre_runrun[j + 1] - 1);
			}

			return pre_runrun;
		}
	}

	if (pre_runrun[pre_runrun.size() - 1] != 9) {
		++pre_runrun[pre_runrun.size() - 1];
		rrep(j, pre_runrun.size()-2) {
			pre_runrun[j] = max(0, pre_runrun[j + 1] - 1);
		}
	}
	else {
		rep(i, pre_runrun.size()) pre_runrun[i] = 0;
		pre_runrun.push_back(1);
	}

	return pre_runrun;
}

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

	int k;
	cin >> k;

	vector<int> runrun;
	runrun.push_back(1);
	REP(i, 1, k) {
		runrun = solve(runrun);
	}

	rrep(i, runrun.size() - 1) {
		cout << runrun[i];
	}

	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  for (ll i = 1; i * i <= n - 1; i++) {
    if ((n - 1) % i == 0) {
      ans += 2;
    }
    if (i == 1 || i * i == n - 1) {
      ans--;
    }
  }
  for (ll k = 2; k * k <= n; k++) {
    if (n % k) {
      continue;
    }
    ll tmp = n;
    while (tmp % k == 0) {
      tmp /= k;
    }
    if (tmp % k == 1) {
      ans++;
    }
    ll tmpk = n / k;
    tmp = n;
    while (tmp % tmpk == 0) {
      tmp /= tmpk;
    }
    if (k * k != n && tmp % tmpk == 1) {
      ans++;
    }
  }
  cout << (n == 2 ? 1 : ans) << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include <vector>
#include <set>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	set<int>s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout<<s.size();
}


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

struct node{
	int num;
	int sco;
}b[200005];

int main(){
	int n,i,j;
	cin>>n;
	int a[n];
	
	for(i=1;i<=n;i++)
		b[i].num=i;
	for(i=1;i<n;i++)
		cin>>a[i];
		
	for(i=1;i<n;i++)
		b[a[i]].sco++;
		
	for(i=1;i<=n;i++)
		cout<<b[i].sco<<endl;
	return 0;
}

Measured memory_bytes: 5964
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &x : a) cin >> x;

    vector<int> plus(n), minus(n);
    for (int i = 0; i < n; ++i) {
        plus[i] = i + a[i] + 1;
        minus[i] = i - a[i] + 1;
    }
    print(plus);
    print(minus);
    map<int, int> count;
    for (int i = 1; i < n; ++i) {
        count[minus[i]]++;
    }

    int ans = 0;
    for (int i = 0; i < n-1; ++i) {
        print("Checking", plus[i], "count:", count[plus[i]]);
        ans += count[plus[i]];
        count[minus[i]]--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 30592
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    max_abc= max(A,B,C)

    dif = 3*max_abc-A-B-C
    if dif%2 == 0:
        print(dif//2)
    else:
        print((3*(max_abc+1)-A-B-C)//2)
    
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	sort(V);
	if (V[0] + V[1] == V[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#define endl "\n"

int main()
{
	faster;
	
	ll a,b,d;
	cin >> a;
	char c;
	cin >> b >> c >> d;
	b *= 100;
	b += d;

	cout << (ll)((a * b)/100) << endl;

	return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

const int Nmax=2017;
int dp[Nmax][Nmax];

signed main(){
	vi fact{1};
	FOR(i,1,114514)
		fact.PB(fact.back()*i%mod);
	vi factInv;
	for(auto v:fact)
		factInv.PB(modInv(v));
	const auto comb=[&](int a,int b){
		return fact[a]*factInv[b]%mod*factInv[a-b]%mod;
	};
	int n=read(),k=read();
	dp[0][0]=1;
	FOR(i,1,Nmax){
		int sum=dp[i-1][i-1];
		FOR(j,i,Nmax){
			add(sum,dp[i-1][j]);
			dp[i][j]=sum;
		}
	}
	int ans=0;
	REP(i,n)
		add(ans,dp[k-1][i]);
	if(n-k>0)
	mult(ans,modPow(2,n-k-1));
	cout<<ans<<endl;
}


Measured memory_bytes: 25076
#include <iostream>
using namespace std;
int main(void){
    int h1,h2,k1,k2;
    int a,b,c,d;
    cin >> h1 >> h2 >> k1 >> k2;
    cin >> a >> b >> c >>d;
    int l,m;
    l = a*h1 + b*h2 + (h1/10)*c + (h2/20)*d;
    m = a*k1 + b*k2 + (k1/10)*c + (k2/20)*d;
    
    if(l > m){
        cout << "hiroshi" << endl;
    }
    else if(l < m){
        cout << "kenjiro" << endl;
    }
    else{
        cout << "even" << endl;
    }
        
 }



Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
#include<math.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define SWAPCP(a,b) (a=Add(a,b),b=Add(a,Minus(b)),a=Add(a,Minus(b)))
typedef struct complex complex;
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
struct complex{double real,imag;}A[524288]={{0},{0}};
static inline complex Add(complex x,complex y){complex z;z.real=x.real+y.real;z.imag=x.imag+y.imag;return z;}
static inline complex Minus(complex x){x.real=-x.real;x.imag=-x.imag;return x;}
static inline complex Mul(complex x,complex y)
{
  complex z;z.real=x.real*y.real-x.imag*y.imag;
  z.imag=x.real*y.imag+x.imag*y.real;return z;
}
const int MOD=200003,len=524288,bit=19;
const double pi=3.141592653589793238462643383;
int rev[524288];
static inline void FFT(int t)
{
  rep(i,len)if(rev[i]>i){SWAPCP(A[rev[i]],A[i]);}
  for(int i=1;i<len;i<<=1)
  {
    complex v;v.real=cos(pi/i),v.imag=t*sin(pi/i);
    for(int j=0;j<len;j+=i<<1)
    {
      complex w;w.real=1;w.imag=0;
      rep(k,i)
      {
        complex x=A[k+j],y=Mul(w,A[k+j+i]);
        A[k+j]=Add(x,y);A[k+j+i]=Add(x,Minus(y));
        w=Mul(v,w);
      }
    }
  }
  if(t==-1)rep(i,len){A[i].real/=len;A[i].imag/=len;}
} 
int main(void)
{
  int N,temp=1,to[200003];long sum=0;
  rep(i,MOD-2){temp=2*temp%MOD;to[temp]=i+1;}
  if(!scanf("%d",&N))return -1;
  rep(i,N)
  {
    int x;if(!scanf("%d",&x))return -1;
    sum-=1l*x*x%MOD;
    if(!x)continue;
    x=to[x];A[x].real+=1.0;A[x].imag=0;
  }
  rep(i,len){rev[i]=(rev[i>>1]>>1)|((i&1)<<(bit-1));}
  FFT(1);rep(i,len){A[i]=Mul(A[i],A[i]);}FFT(-1);
  temp=1%MOD;rep(i,400004){sum+=(long)(A[i].real+0.5)*temp;temp=2*temp%MOD;}
  return OUT(sum/2),0;
}

Measured memory_bytes: 13436
s=list(input())
t=list(input())
u=list(int(-1) for i in range(26))
ans=[]

for i in range(len(s)):
    if u[ord(s[i])-97]==-1:
        u[ord(s[i])-97]=ord(t[i])-97
        
    else:
        if u[ord(s[i])-97]!=ord(t[i])-97:
            print('No')
            exit()
  
for i in range(len(u)):
    if u[i]!=-1:
        ans.append(u[i])

if len(set(ans))<len(ans):      
    print('No')
else:
    print('Yes')



Measured memory_bytes: 6704
#include<stdio.h>

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

  char s[n][2];
  for(int i=0;i<n;i++){
    scanf("%s", s[i]);
  }

  int c[4]={0,0,0,0};
  for(int j=0;j<n;j++){
    if(s[j][0]=='A') c[0]++;
    else if(s[j][0]=='W') c[1]++;
    else if(s[j][0]=='T') c[2]++;
    else c[3]++;
  }

  printf("AC x %d\n", c[0]);
  printf("WA x %d\n", c[1]);
  printf("TLE x %d\n", c[2]);
  printf("RE x %d\n", c[3]);

  return 0;
}


Measured memory_bytes: 1924
def main():

    MAX_VALUE = 10**6 + 5

    n = int(input())
    a = list(map(int, input().split()))

    cnt = [0] * MAX_VALUE

    ans = 0

    for x in a:

        if cnt[x] != 0:
            cnt[x] = 2
            continue

        for i in range(x, MAX_VALUE, x):
            cnt[i]+=1

    for x in a:
        if cnt[x] == 1:
            ans += 1 

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const ll inf = 1LL<<60;

int main()
{
  ll k;
  cin >> k;
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll ans = inf;
  for (int i=0; i<n; i++) {
    if (i==0) {
      ans = a[n-1]-a[0];
    } else {
      ans = min(ans, a[i-1]+k-a[i]);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
struct Edge{
    int to,id;
};
const int maxn=1005;
const int maxm=2e5+7;
vc<Edge> G[maxn];
pi edge[maxm];
bool vis[maxn];
bool can[maxn][maxn];
int go[maxn][maxn][2];
void dfs(int u,int st,int tp,int fi=-1)
{
    if(vis[u]) return ;
    can[st][u]=1;
    vis[u]=1;
    go[st][u][tp]=fi;
    for(auto e:G[u])if(!vis[e.to])
    {
        int v=e.to;
        dfs(v,st,tp,fi==-1?e.id:fi);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    for(int i=0,u,v;i<m;i++)
    {
        cin>>u>>v;
        edge[i]={u,v};
        G[u].push_back(Edge{v,i});
    }
    for(int i=1;i<=n;i++)
    {
        memset(vis,0,sizeof(vis));
        dfs(i,i,0);
        memset(vis,0,sizeof(vis));
        reverse(G[i].begin(),G[i].end());
        dfs(i,i,1);
    }
    for(int i=0,u,v;i<m;i++)
    {
        u=edge[i].first,v=edge[i].second;
        //dbg(u,v,can[v][u]);
        if(can[v][u]^(go[u][v][0]!=i||go[u][v][1]!=i)) cout<<"diff\n";
        else cout<<"same\n";
    }

}

Measured memory_bytes: 14720
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 


int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string res="";
    REP(i,ty-sy)res+="U";
    REP(i,tx-sx)res+="R";
    REP(i,ty-sy)res+="D";
    REP(i,tx-sx)res+="L";
    res+="L";
    REP(i,ty-sy+1)res+="U";
    REP(i,tx-sx+1)res+="R";
    res+="D";
    res+="R";
    REP(i,ty-sy+1)res+="D";
    REP(i,tx-sx+1)res+="L";
    res+="U";
    cout<<res<<endl;
    return 0;
}


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

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

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    int N,M;
    cin>>N>>M;
    map<int,bool> m;
    m[0]=true;
    map<int,int> cnt;
    rep(i,N) cnt[i]=1;
    rep(i,M){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        if(m[x]){
            if(cnt[x]==1) {
                m[x] = false;
                m[y] = true;
            }
            else {
                m[y] = true;
            }
        }
        cnt[x]--;
        cnt[y]++;
    }
    int ans = 0;
    rep(i,N) {
        if(m[i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12804
def main(n, a):
    for i in a:
        if i % 2 == 0:
            if i % 3 != 0 and i % 5 != 0:
                print("DENIED")
                return

    print("APPROVED")


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pi pair<ll,ll>
int main(){
    ll n,i,j,k,l,sum=0;
    vector<ll>v;
    cin>>n>>j;
    for(i=0;i<n;i++){
        cin>>k;
        v.pb(k);
    }
    sort(v.begin(),v.end());
    for(i=0;i<j;i++){
        //cout<<v[i]<<" ";
        sum+=v[i];
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 3636
// #include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >>n;
    vector<int> num(n);
    vector<int> copy;
    
    for(int i=0; i<n; i++){
        cin >> num[i];
    }
    int cnt= 0;
    for(int i=0; i<n-2; i++){
        int a= num[i+1];
        copy= num;
        for(int a:copy) cerr << a <<" ";
        cerr << endl;
        sort(copy.begin()+i,copy.begin()+i+3);
        for(int a:copy) cerr << a <<" ";
        cerr << endl;
        if(a==copy[i+1]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 888
import java.util.Scanner;
class Main{
public static void main(String[] agrs){
Scanner scan=new Scanner(System.in);
String str=scan.next();
int times=Integer.parseInt(str);
int a=times/3600;
times=times%3600;
int b=times/60;
times=times%60;
int c=times;
System.out.println(a+":"+b+":"+c);
}
}

Measured memory_bytes: 26288
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> b(n-1);
  for(int i=0;i<n-1;i++){
    cin>>b[i];
  }
  int ans=0;
  ans+=(b[0]+b[n-2]);
  for(int i=0;i<n-1;i++){
    if(b[i-1]>b[i]){
      ans+=b[i];
    }else{
      ans+=b[i-1];
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#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 all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define x first
#define y second

template<typename X> inline X abs(const X& a) { return a < 0 ? -a : a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acosl(ld(-1));

mt19937 mt(time(NULL));

const int N = 100 * 1000 +13;
int n;
char s[N], t[N];

inline bool read()
{
	if (scanf ("%s", s) != 1)
		return false;
		
	n = int(strlen(s));

	return true;
}

int b[N];

inline void solve()
{
	forn (i, n)
		b[i] = (i == 0 ? 0 : b[i - 1]) + (s[i] == 'g' ? +1 : -1);
		
	cout << b[n - 1] / 2 << endl;
}

int main()
{
#ifdef SU2_PROJ
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;

	assert(read());
	solve();

#ifdef SU2_PROJ
	cerr << "TIME: " << clock() << endl;
#endif

	return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    string o, e;
    cin >> o >> e;
    rep(i, o.size() + e.size()) {
        if (i % 2 == 0) cout << o[i / 2];
        else cout << e[i / 2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
mm, dd = map(int, input().split())

count = 0
for d in range(1, dd + 1):
    d1 = d % 10
    d10 = d // 10
    m = d1 * d10
    if d1 >1 and d10 > 1 and m <= mm:
        count += 1
print(count)


Measured memory_bytes: 38384
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    AB = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x:x[1])

    res = 0
    remove = -1
    for a, b in AB:
        if remove <= a:
            res += 1
            remove = b
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 29460
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
    
  ll s, w;
  cin >> s >> w;
  if(w >= s) cout << "unsafe";
  else cout << "safe";
  return 0;
} //good night.

Measured memory_bytes: 3648
from collections import Counter

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

cnt = Counter(A)

ans = [0] * N
for i in range(N):
    ans[i] = K + cnt[i+1] - Q

print("\n".join("Yes" if val > 0 else "No" for val in ans))


Measured memory_bytes: 15864
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int N, M;
string U[257];

int main() {
  char s[14];
  scanf("%d", &N);
  for (int i=0;i<N;i++) {
    scanf("%s", s);
    U[i] = s;
  }
  scanf("%d", &M);
  bool opened = false;
  for (int i=0;i<M;i++) {
    scanf("%s", s);
    const string* p = find(U, U+N, (string)s);
    if (!p->empty()) {
      opened = !opened;
      printf("%s by %s\n", (opened ? "Opened" : "Closed"), s);
    } else {
      printf("Unknown %s\n", s);
    }
  }
  return 0;
}

Measured memory_bytes: 2832