akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
char s[N], t[N];
int sum1[N], sum2[N];

int main() {
  scanf("%s%s", s, t);
  int len1 = strlen(s), len2 = strlen(t);
  for (int i = 0; i < len1; ++i) sum1[i + 1] = sum1[i] + (s[i] == 'A' ? 1 : 2);
  for (int i = 0; i < len2; ++i) sum2[i + 1] = sum2[i] + (t[i] == 'A' ? 1 : 2);
  int m;
  scanf("%d", &m);
  while (m--) {
    int L1, R1, L2, R2;
    scanf("%d%d%d%d", &L1, &R1, &L2, &R2);
    --L1; --L2;
    if ((sum1[R1] - sum1[L1]) % 3 == (sum2[R2] - sum2[L2]) % 3) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}


Measured memory_bytes: 1536
mod = 10 ** 9 + 7
def solve():
    N, M = map(int, input().split())
    if abs(N-M) >= 2:
        print("0")
    elif N == M:
        print(factorial(N) % mod * factorial(M) % mod * 2 % mod)
    else:
        print(factorial(N) % mod * factorial(M) % mod)


def factorial(n):
    res = 1
    for i in range(1,n+1):
        res *= i
        res %= mod
    
    return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38512
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
	double x1,x2,y1,y2,r1,r2,d;
	int n,i;
	
	cin >> n ;
	
	for(i=0;i<n;i++)
	{
		cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2 ;
		
		d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
		
		if(d-r1-r2>0.0)
			cout << "0" << endl;
		else if(r1-d-r2>0.0)
			cout << "2" << endl;
		else if(r2-d-r1>0.0)
			cout << "-2" << endl;
		else
			cout << "1" << endl;
	}
}
	

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

vector<int> divisor(int n){
  vector<int> rtn;
  for(int i=1;i*i<=n;i++) if(!(n%i)){
    rtn.push_back(i);
    if(i!=n/i) rtn.push_back(n/i);
  }
  sort(rtn.begin(),rtn.end());
  return rtn;
}

int main(){
  int n,ans=0;cin>>n;
  vector<int> a(1000001,0),b(n,0);
  REP(i,n){
    int tmp;
    cin>>tmp;
    a.at(tmp)++;
    b.at(i)=tmp;
  }

  REP(i,n){    
    vector<int> Divisor=divisor(b.at(i));
    bool f=1;
    for(auto p:Divisor){
      if(p==b.at(i)){
        if(a.at(p)>1){
          f=0;
          break;
        }
      }else if(a.at(p)>0){
        f=0;
        break;
      }
    }
    if(f) ans++;
  }
  
  //REP(i,100) cout<<a.at(i)<<" ";
  cout<<ans<<endl;
}

Measured memory_bytes: 7884
#include<stdio.h>
int main(){
  int n,k,w[100000],l,m,r,i,j,flag,count=0;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
  }
  l=0;
  r=100000*10000;
  while(l+1<r){
    m=(l+r)/2;
    j=0;
    for(i=0;i<k;i++){    
      count=0;
      flag=0;
      for(;j<n;j++){
	count+=w[j];
	if(count>m && i==k-1){flag=1;break;}
	if(count>m){break;}
      }
      if(flag==1 || j==n)break;
    }
    if(flag==1)l=m;
    else r=m;
  }
  printf("%d\n",r);
  return 0;
}
    
      
    



Measured memory_bytes: 2128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

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

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> cnt(n_max,0);
    rep(i,n){
        rep(j,3){
            cnt[a[i] + j]++;
        }
    }
    Pll max_ = {0,-2};
    rep(i,n_max)chmax(max_, {cnt[i], i});
    cout << max_.first << endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
B = LIST()

good = []
bad = []
for i in range(N):
    need = A[i] - B[i]
    if need >= 0:
        good.append(need)
    else:
        bad.append(need)

if sum(good) + sum(bad) < 0:
    print(-1)
    exit()

good.sort(reverse=True)

goodsm = 0
badsm = -sum(bad)
cnt = 0
for i in range(len(good)):
    if goodsm >= badsm:
        break
    goodsm += good[i]
    cnt += 1

print(cnt + len(bad))


Measured memory_bytes: 20516
s=input()

if (s=='SAT'):
    print(1)
elif (s=='FRI'):
    print(2)
elif (s=='THU'):
    print(3)
elif (s=='WED'):
    print(4)
elif (s=='TUE'):
    print(5)
elif (s=='MON'):
    print(6)
elif (s=='SUN'):
    print(7)


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = l[0], b = l[1];

            Console.WriteLine(a <= b ? a : a - 1);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
struct BIT{
	using D = int;
	int N;
	vector<D> bit;
	BIT(int n){		//nは区間幅!!!
		N=n;
		bit.assign(n+1,0);
	}
	BIT(){}
	D sum(int i){		//i個の和a[0]+..a[i-1]
		D s=0;
		while(i>0){
			s+=bit[i];
			i-=(i&-i);
		}
		return s;
	}
	D val(int i){	//return a[i]	(0-ind)
		return sum(i+1)-sum(i);
	}
	void add(int i,D x){	//a[i]+=x (0-indexed)
		i++;
		while(i<=N){
			bit[i]+=x;
			i+=(i&-i);
		}
	}
};

bool is(V<bool> v){
	int N = v.size();
	BIT bit(2*N+1);	//[-N,N]
	int s = 0;
	ll cnt = 0;
	rep(i,N){
		bit.add(s+N,1);
		if(v[i]) s++;
		else s--;
		cnt += bit.sum(s+N+1);
	}
	return cnt >= ((ll)N*(N+1)/2+1)/2;
}
int main(){
	int N;
	cin>>N;
	V<int> a(N);
	rep(i,N) cin>>a[i];
	int lb = 1, ub = 1e9+1;
	while(ub-lb>1){
		int m = (ub+lb)/2;
		V<bool> v(N);
		rep(i,N) v[i] = a[i]>=m;
		if(is(v)) lb = m;
		else ub = m;
	}
	cout<<lb<<endl;
}

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

int main() {
  int square[105][105];
  for(int i=0; i<105; i++)
    for(int j=0; j<105; j++)
      square[i][j] = 0;
  int w, h, n;
  cin >> w >> h >> n;
  for(int i=0; i<n; i++){
    int x, y, func;
    cin >> x >> y >> func;
    switch(func) {
      case 1:
        for(int X=0; X<x; X++)
          for(int Y=0; Y<105; Y++)
            square[Y][X] = 1;
        break;
      case 2:
        for(int X=x; X<105; X++)
          for(int Y=0; Y<105; Y++)
            square[Y][X] = 1;
        break;
      case 3:
        for(int X=0; X<105; X++)
          for(int Y=0; Y<y; Y++)
            square[Y][X] = 1;
        break;
      case 4:
        for(int X=0; X<105; X++)
          for(int Y=y; Y<105; Y++)
            square[Y][X] = 1;
        break;
    }
  }
  int cnt = 0;
  for(int i=0; i<h; i++)
    for(int j=0; j<w; j++)
      if(square[i][j] == 0)
        cnt++;
  cout << cnt << endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
using ll = long long;
using ld = long double;
mt19937 rng(time(0));

ll ifloor(ll n, ll d) {
  if (d < 0) n = -n, d = -d;
  if (n >= 0) return n / d;
  return -(-n / d);
}

ll n, k;
vector<ll> pos, neg;
ll z;
bool check(ll x) {
  ll ans = 0;
  // PP
  if (x > 0) {
    for (int i = 0; i < pos.size(); i++) {
      int j = --upper_bound(pos.begin(), pos.end(), x / pos[i]) - pos.begin();
      ans += max(0, j - i);
    }
  }
  // PN
  if (x < 0) {
    for (int i = 0; i < pos.size(); i++) {
      int j = lower_bound(neg.begin(), neg.end(), (abs(x) + pos[i]-1) / pos[i]) - neg.begin();
      ans += max(0, (int)neg.size() - j);
      //cerr << neg[i] << " --> " << j+1 << nl;
    }
  } else {
    ans += pos.size() * neg.size();
  }
  // NN
  if (x > 0) {
    for (int i = 0; i < neg.size(); i++) {
      int j = --upper_bound(neg.begin(), neg.end(), x / neg[i]) - neg.begin();
      ans += max(0, j - i);
    }
  }
  // Z
  if (x >= 0) {
    ans += z * (pos.size() + neg.size()) + z*(z-1)/2;
  }
  //if (-10 <= x && x <= 10) {
    //cerr << "ANS: " << x << " -> " << ans << nl;
  //}
  return ans >= k;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (a == 0) z++;
    else (a < 0 ? neg : pos).push_back(abs(a));
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());
  ll l = -1e18, r = 1e18, ans = -1;
  while (l <= r) {
    ll m = (l+r)/2;
    if (check(m)) {
      ans = m;
      r = m-1;
    } else l = m+1;
  }
  cout << ans << nl;
}


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

int main(){
	long r, c;
	cin >> r >> c;
	//r = 2;
	//c = 2;
	vector< vector<long> > sp(r);
	for (long i = 0; i < r; i++){
		sp[i].resize(c);
	}
	for (long i = 0; i < r; i++){
		for (long j = 0; j < c; j++){
			cin >> sp[i][j];
		}
	}
	vector<long> rsum(r, 0);
	vector<long> csum(c, 0);
	for (long i = 0; i < r; i++){
		for (long j = 0; j < c; j++){
			rsum[i] += sp[i][j];
		}
	}
	for (long i = 0; i < c; i++){
		for (long j = 0; j < r; j++){
			csum[i] += sp[j][i];
		}
	}
	long sum = 0;
	for (long i = 0; i < r; i++){
		sum += rsum[i];
	}
	for (long i = 0; i < r; i++){
		for (long j = 0; j < c; j++){
			cout << sp[i][j] << " ";
		}
		cout << rsum[i] << endl;
	}
	for (long i = 0; i < c; i++){
		cout << csum[i] << " ";
	}
	cout << sum << endl;
	/*
	vector< vector<long> > newsp(r + 1);
	for (long i = 0; i < r + 1; i++){
		newsp[i].resize(c + 1);
	}
	for (long i = 0; i < r + 1; i++){
		for (long j = 0; j < c + 1; j++){
			if (i < r && j < c) newsp[i][j] = sp[i][j];
			else if (i = r && j < c) newsp[i][j] = csum[j];
			else if (j = c && i < r) newsp[i][j] = rsum[i];
			else newsp[i][j] = sum;
		}
	}
	for (long i = 0; i < r + 1; i++){
		for (long j = 0; j < c + 1; j++){
			cout << newsp[i][j];
		}
		cout << endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 1280
s = list(input())
n = len(s)
cnt1 = 0
cnt2 = 0
for i in range(n):
        if i%2 == 0:
                if s[i] == "1":
                        cnt1 += 1
                else:
                        cnt2 += 1
        else:
                if s[i] == "0":
                        cnt1 += 1
                else:
                        cnt2 += 1
print(min(cnt1,cnt2))


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
std::string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto sort_all(T& v) { return std::sort(v.begin(),v.end()); }
template<typename T>
auto sum_all(const T& v) { auto z = v[0]; z = 0;
    return std::accumulate(v.begin(),v.end(),z); }
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}

template<typename K, typename V>
class defaultmap: public std::map<K,V>
{
private:
    std::function<V(K)> defaultfunc;
public:
    defaultmap(std::function<V(K)> df) { defaultfunc = df; };
    auto& operator[](const K& key) {
        auto itr = this->find(key);
        if( itr != this->end() )
            return itr->second;
        else
            return this->std::map<K,V>::operator[](key)=defaultfunc(key);
    };
};
class CountUp
{
private:
    int index;
public:
    CountUp() { index = 0; };
    auto operator()(...) { return index++; };
    auto next() { return index; };
};
/* Usage of CountUp:
    CountUp cu;
    auto dm = defaultmap<K, int>(cu);
*/


typedef llint Int;

int main(void)
{
    int N, M;
    cin >> N >> M;
    auto A = input<int>(N);

    CountUp cu;
    auto dm = defaultmap<int, int>(cu);
    dm[0];
    vector<int> v({1});
    int s = 0;
    int L = 1;
    loop(i, N) {
        s = (s+A[i]) % M;
        auto j = dm[s];
        if(j < L) {
            v[j]++;
        } else {
            v.push_back(1);
            L++;
        }
    }
    Int ans = 0;
    for (Int n : v) {
        ans += n*(n-1)/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3836
#include <iostream> 
 
int main(){
    bool flg=false;
    int N;
    std::string S;

    std::cin >>N >>S;

    if(!(N%2)){
        int N2 = N/2;
        if(S.substr(0,N2)==S.substr(N2,N2))
            flg=true;

    }

    std::cout<<(flg?"Yes":"No")<<std::endl;
 
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int count = 0;
  while (X >= (count + 1) * (Y + Z) + Z) {
    count++;
  }
  cout << count << endl;
  return 0;
}

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

int main(){
  long long N;
  string S;  
  
  cin >> N >> S;
  
  string s = "";
  s = s + S[0];
  
  for(int i = 1; i < N; i++){
    if(S[i] != S[i-1]){
     s = s + S[i]; 
    }
  }
  cout << (int)(s.length());    
  return 0;
}

Measured memory_bytes: 696
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  if ((long long) A * B < N){
    cout << -1 << endl;
  } else if (A + B - 1 > N){
    cout << -1 << endl;
  } else {
    vector<int> cnt(B, 1);
    cnt[0] = A;
    int M = N - A - B + 1;
    for (int i = 1; i < B; i++){
      if (M % (B - 1) >= i){
        cnt[i] += M / (B - 1) + 1;
      } else {
        cnt[i] += M / (B - 1);
      }
    }
    vector<int> ans;
    for (int i = 0; i < B; i++){
      for (int j = N - cnt[i] + 1; j <= N; j++){
        ans.push_back(j);
      }
      N -= cnt[i];
    }
    N = ans.size();
    for (int i = 0; i < N; i++){
      cout << ans[i];
      if (i < N - 1){
        cout << ' ' ;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 5828
/*
████████████████████████████████████████████████████████████████
████████████████        ████████████████        ████████████████
████████████              ██████████                ████████████
████████                    ██████                    ██████████
██████                                                  ████████
██████                      ██████                      ████████
████        ██████████    ████████    ██████████          ██████
████      ████        ████████████████          ████      ██████
████        ████  ████    ██    ██████              ██      ████
████          ██████████      ██████        ████████        ████
████            ██████████  ████████    ████████            ████
████              ██    ██  ██    ██    ████████      ████  ████
████              ██████    ██  ████      ██    ██  ██    ██████
████        ████████  ████  ██  ████      ██    ██  ██    ██████
████        ██  ██████        ████        ██    ████    ████████
██████      ██████                  ██    ██    ██    ██████████
██████        ████████████████████████  ██████      ██  ██  ████
████████████      ██            ██████  ██    ██████    ██  ████
██████  ██  ██      ████████████  ██    ██      ██    ██    ████
██████  ██  ██      ████  ██    ██        ██    ██████    ██████
██████  ██  ██      ██  ██  ████            ████████████████████
██████    ██████  ████  ██  ██          ██  ████████    ████████
██████████    ████████      ██          ██      ██    ██████████
██████████    ████    ██████              ██████    ████████████
████████████████  ██  ██  ██                      ██████████████
████████████  ██    ████    ██                  ████████████████
████████████    ██  ████████  ██              ██████    ██    ██
██████████████    ██████████████            ████████          ██
████████████████████████████████████      ██████████          ██
██████████████████████████████████████  ██████████████      ████
████████████████████████████████████████████████████████  ██████
████████████████████████████████████████████████████████████████
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    string a,b,c; cin>>a>>b>>c;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&a[i]==c[i]) continue;
        if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i]){
            cnt++;
        }else{
            cnt+=2;
        }
        // cout<<cnt<<endl;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int n;
    cin >> n;
    vi data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    deque<int> deq;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            deq.push_front(data[i]);
        }
        else {
            deq.push_back(data[i]);
        }
    }
    if (n % 2 == 1) {
        for (int x : deq) {
            cout << x << " ";
        }
    }
    else {
        for (int i = n - 1; i >= 0; i--) {
            cout << deq[i] << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 4852
S = input()
T = input()
def count(string):
    Ans =[0]*len(string)
    Alpha = [0]*26
    c = 0
    for st in string:
        if(Alpha[ord(st)-97] == 0):
            Alpha[ord(st)-97] = c
            Ans[c] = c
        elif(Alpha[ord(st)-97] != 0):
            Ans[c] = Alpha[ord(st)-97]
    
        c += 1
    return Ans

if(count(T) == count(S)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

	int a = 0, b = M;
	int c = M + 1, d = 2 * M;
	for (int i = 0; i < M; ++i)
	{
		if (i % 2 == 0)
		{
			cout << a + 1 << ' ' << b + 1 << endl;
			++a, --b;
		}
		else
		{
			cout << c + 1 << ' ' << d + 1 << endl;
			++c, --d;
		}
	}
}

int main()
{
	ABC165E();
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  int N;
  cin >> N;
  int a[110000];
  FOR(i,0,N) cin >> a[i];
  int d[110000];
  FOR(i,0,N) {
    d[a[i]]++;
  }
  int ans = 0;
  int nearnum;
  FOR(i,0,100000) {
    nearnum = d[i] + d[i+1] + d[i+2];
    ans = max(ans, nearnum);
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 4364
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll H, W;
vector<string> board;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};

ll solve(ll sx, ll sy) {
    vvll values(H, vll(W, inf));
    stack<pair<ll, ll>> st; // {{x, y}, dist}
    st.push({sx, sy});
    values[sy][sx] = 0;

    while (st.size()) {
        auto point = st.top(); st.pop();
        ll x = point.first, y = point.second;

        rep(i, 4) {
            ll nx = x + dx[i], ny = y + dy[i];
            if (
                0 <= nx && nx < W &&
                0 <= ny && ny < H &&
                board[ny][nx] == '.' &&
                values[ny][nx] > values[y][x] + 1
            ) {
                values[ny][nx] = values[y][x] + 1;
                st.push({nx, ny});
            }
        }
    }

    ll maxn = 0;
    rep(i, H) rep(j, W) {
        if (board[i][j] == '.' && values[i][j] != inf) maxn = max(maxn, values[i][j]);
    }

    return maxn;
}

int main()
{
    cin >> H >> W;
    board.resize(H);
    rep(i, H) {
        cin >> board[i];
    }

    ll minn = 0;
    rep(sy, H) rep(sx, W) {
        if (board[sy][sx] == '#') continue;
        minn = max(minn, solve(sx, sy));
    }
    cout << minn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,n;
  cin >> h >> n;
  int a[n],s=0;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    s+=a[i];
  }
  if(s>=h) cout << "Yes"; else cout << "No";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

static int MOD;

// factorial(mod) n!
ll fact(ll n) {
	ll res = 1;
	while (n > 1) {
		res = res * n % MOD;
		n--;
	}
	return res;
}

// power(mod) x^n
ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

// inverse(mod) x^(-1)
ll inv(ll x) {
	return modpow(x, MOD - 2);
}

// permutation(mod) nPr
ll permu(ll n, ll r) {
	if (r < 0 || n < r) return 0;
	else {
		ll res = fact(n);
		res = res * inv(fact(n - r)) % MOD;
		return res;
	}
}

// combination(mod) nCr
ll combi(ll n, ll r) {
	ll res = permu(n, r);
	res = res * inv(fact(r)) % MOD;
	return res;	
}

ll modmul(ll x, ll y) {
	return x * y % MOD;
}

int main () {
	MOD = 1000000007;
	int N, M, K; cin >> N >> M >> K;
	ll x = (N - 1);
	x = modmul(x, N);
	x = modmul(x, N + 1);
	x = modmul(x, inv(6));
	x = modmul(x, M);
	x = modmul(x, M);
	ll y = (M - 1);
	y = modmul(y, M);
	y = modmul(y, M + 1);
	y = modmul(y, inv(6));
	y = modmul(y, N);
	y = modmul(y, N);
	ll z = combi(M * N - 2, K - 2);
	ll ans = (x + y) * z % MOD;
	// debug(x); debug(y); debug(z);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int m,f,r;
    for(int i=0;i<50;i++){
        scanf("%d %d %d",&m,&f,&r);
        if(m<0 && f<0 && r<0){
            break;
        }
        else if (m<0 || f<0){
            printf("F");
            printf("\n");
        }
        else if (m+f>=80){
            printf("A");
            printf("\n");
        }
        else if (m+f>=65){
            printf("B");
            printf("\n");
        }
        else if (m+f>=50){
            printf("C");
            printf("\n");
        }
        else if (m+f<30){
            printf("F");
            printf("\n");
        }
        else if (m+f>=30){
            if(r>=50){
                printf("C");
                printf("\n");
            }
            else{
                printf("D");
                printf("\n");
            }
        }
    }
    return 0;
}



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

int sumDigit(int n) {
    int sumD = 0;
    while(n >= 10 ) {
        sumD += n%10;
        n /= 10;
    }
    sumD += n;
    return sumD;
}

int main() {
    int n; cin >> n;
    int sumD = sumDigit(n);
    if (n%sumD == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
def r;gets.split.map &:to_i;end
def rr(n);n.times.map{r};end
N,M = r
S = rr(N)
S.sort_by! &:first

c = M
m = 0
S.each do |(a,b)|
  if b < c
    c -= b
    m += b * a
  else
    m += c * a
    p m
    exit
  end
end

Measured memory_bytes: 12664
package main

import (
	"fmt"
)

func main() {
	var a, b int

	fmt.Scanf("%d %d", &a, &b)

	fmt.Println(logic(a, b))
}

func logic(a, b int) int {
	if a <= 5 {
		return 0
	}

	if a <= 12 {
		return b / 2
	}

	return b
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;

int main(){
    ll x, diff;
    cin >> x;
    int n = 200;
    for(int a=-n; a<=n;a++){
        for(int b=-n; b<=n; b++){
            diff = pow(a,5)-pow(b,5);
            if(diff==x){
                cout << a << ' ' << b << endl;
                break;
                }
        }
        if(diff==x) break;
    }
    return 0;
}


/*
int N;
vector<vector<int>> dp;
void solve(int i, int j, ll x, vector<vector<int>> dp){
    if (i>N || j>N) return;
    if(dp.at(N+i).at(N+j) == 0) dp.at(N+i).at(N+j)=1;
    else return;
    //cout << i<<j << endl;
    ll tmp;
    tmp = (ll)pow(i,5)-(ll)pow(j,5) - x;
    if (tmp==0){
        cout << i << j << endl;
        return;
    }else{
        solve(i+1, j, x, dp);
        solve(i, j+1, x, dp);
    }
   return;
}
int main(){
    N=5;
    vector<vector<int> > dp(2*N+1, vector<int>(2*N+1, 0));
    ll x;
    cin >> x;
    solve(-N,-N,x,dp);
}

int N;
vector<vector<int>> dp;
void solve(ll x){
    ll diff;
    for(int i=-N; i<N; i++){
        for(int j=-N; j<N; j++){
            diff = pow(i,5)-pow(j,5)-x;
            //cout << i<<j << endl;
            if(diff==0){
                cout<< i << ' ' <<j<< endl;                
                break;
                }
        }
        if(diff==0) break;
    }
}

int main(){
    N=200;
    ll x;
    cin >> x;
    solve(x);
}
*/

Measured memory_bytes: 4020
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> dp(N+1, N);
  dp[N] = 0;
  for(int i=N; i>=0; i--){
    for(int j=0; j<=ceil(log(N) / log(9)); j++)
      if(i + (int)pow(9, j) <= N)
	dp[i] = min(dp[i], dp[i + (int)pow(9, j)] + 1);
    for(int j=0; j<=ceil(log(N) / log(6)); j++)
      if(i + (int)pow(6, j) <= N)
	dp[i] = min(dp[i], dp[i + (int)pow(6, j)] + 1);
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 768
divisors n = divisors' n 1

divisors' n d
    | d * d > n = []
    | n `mod` d == 0 = if d == d' then d:ds else d:d':ds
    | otherwise = divisors' n (d + 1)
    where d' = n `div` d
          ds = divisors' n (d + 1)

main = do
    n <- readLn :: IO Int
    print $ length $ filter (\a -> odd a && length (divisors a) == 8) [1..n]

Measured memory_bytes: 508
n,q = map(int, input().split())
s =input()
A = [[int(j) for j in input().split()] for i in range(q)]
ls = [0] * (n+1)
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        ls[i+1]= ls[i]+1
    else:
        ls[i+1]= ls[i]

for k in range(q):
    print(ls[A[k][1]-1]-ls[A[k][0]-1])

Measured memory_bytes: 24472
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  while(x!=0||y!=0){
    if(x<y){
      cout<<x<<' '<<y<<endl;
    }else{
      cout<<y<<' '<<x<<endl;
    }
    cin>>x>>y;
  }
  return (0);
}

Measured memory_bytes: 3076
n,t = STDIN.gets.chomp.split(/ +/).map(&:to_i)

db = []
n.times do
  c,e = STDIN.gets.chomp.split(/ +/).map(&:to_i)
  if e <= t
    db<<c
  end
end

if db.size > 0
  puts db.min
else
  puts "TLE"
end



Measured memory_bytes: 1788
import java.util.*;

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

        int n = scanner.nextInt();
        int m = scanner.nextInt();

        List<Integer> votes = new ArrayList<>();
        int total = 0;
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            votes.add(a);
            total += a;
        }
        Collections.sort(votes, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2.intValue() - o1.intValue();
            }
        });

        int target = votes.get(m - 1);
        double threshold = (total * 1.0d) / (m * 4);
        if ((target * 1.0d) >= threshold) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#define S second
using namespace std;
double ans, pi=acos(-1.0);
pair<int,int> b[200005];
vector<int> v;

int main() {
	int x1, y1, x2, y2, n, M=1e9, bc=0;
	int i, t, tx, ty, fl=0;
	scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n);
	if(x1>x2) swap(x1, x2), swap(y1, y2);
	if(y1>y2) y1 = M-y1, y2 = M-y2, fl=1;
	for(i=0; i<n; i++) {
		scanf("%d%d", &tx, &ty);
		if(fl) ty = M-ty;
		if(x1<=tx && tx<=x2 && y1<=ty && ty<=y2) b[bc++] = {tx, ty};
	}
	sort(b, b+bc);
	for(i=0; i<bc; i++) {
		t = lower_bound(v.begin(), v.end(), b[i].S) - v.begin();
		if(t==v.size()) v.push_back(b[i].S);
		else v[t] = b[i].S;
	}
	ans = (x2-x1 + y2-y1) * 100.0 + v.size() * (5*pi - 20);
	if(v.size() == min(x2-x1, y2-y1)+1) ans += 5*pi;
	printf("%.15f", ans);
	return 0;
}

Measured memory_bytes: 2936
import math
while True:
    num=int(input())
    if num==0:
        break
    lst=list(map(int,input().split()))
    m=sum(lst)/len(lst)
    var=[(i-m)**2 for i in lst]
    n_var=sum(var)/len(lst)
    print(round(math.sqrt(n_var),8))


Measured memory_bytes: 5720
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int k = s.size();
    int cnt=0;
    for(auto c : s){
        // cout << c << endl;
        if(c == 'o') cnt++;
    }

    // cout << cnt << endl;
    if(15 - k >=8-cnt) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int x,n;
    cin>>x>>n;
    vi p(n);
    VIN(p);
    sort(ALL(p));


    int mn = IINF;
    int mnval = -999;
    int nidx = 0;
    FOR(i,-200,200+1){

        if(nidx<n && i==p[nidx]){
            nidx++;
            continue;
        }
        if( chmin(mn,abs(x-i)) ){
            mnval = i;
        }
    }
    cout << mnval << endl;
    return 0;
}

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

enum {
    MALE, FEMALE
};

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

    int ok = 0, ng = N;
    int before, curr, before_i;
    string s;

    for (int i = 0; i < 20; i++) {
        if (i == 0) {
            cout << 0 << endl;
            cin >> s;
            if (s == "Male") {
                curr = MALE;
            } else {
                curr = FEMALE;
            }
            before_i = 0;
            before = curr;
            continue;
        }

        int mid = (ok + ng) / 2;
        cout << mid << endl;
        cin >> s;
        if (s == "Male") {
            curr = MALE;
        } else {
            curr = FEMALE;
        }

        if (curr == before) {
            if ((mid - before_i) % 2 == 0) {
                if ((mid - before_i) >= 0) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            } else {
                if ((mid - before_i) >= 0) {
                    ng = mid;
                } else {
                    ok = mid;
                }
            }
        } else {
            if ((mid - before_i) % 2 == 0) {
                if ((mid - before_i) >= 0) {
                    ng = mid;
                } else {
                    ok = mid;
                }
            } else {
                if ((mid - before_i) >= 0) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
        }
        before_i = mid;
        before = curr;
    }
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    int N=in();
    int left[N];
    int right[N];
    string S=in<string>();
    int count_west;count_west=0;
    REP(i,N){
        left[i]=count_west;
        if(S[i]=='W'){
            count_west++;
        }
    }
    int count_east;count_east=0;
    REP(i,N){
        right[N-i-1]=count_east;
        if(S[N-i-1]=='E'){
            count_east++;
        }
    }

    int ans;ans=N;
    REP(i,N){
        //debug(left[i]);
        //debug(right[i]);
        ans=min(ans,left[i]+right[i]);
    }
    print(ans);
}

Measured memory_bytes: 2948
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 100011;

int n, i;
ll C, x[maxN], v[maxN];
ll dpl[maxN], dpr[maxN];

ll solve() {
    int i, j;
    ll act;

    dpl[0] = act = 0;
    for (i = 1; i <= n; i++) {
        act += v[i];
        dpl[i] = max(dpl[i - 1], act - 2LL * x[i]);
    }

    dpr[n + 1] = act = 0;
    for (i = n; i >= 1; i--) {
        act += v[i];
        dpr[i] = max(dpr[i + 1], act - (C - x[i]));
    }

    ll ans = 0;
    for (i = 0; i <= n; i++) ans = max(ans, dpl[i] + dpr[i + 1]);
    return ans;
}


int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d%lld", &n, &C);
    for (i = 1; i <= n; i++) scanf("%lld%lld", &x[i], &v[i]);

    ll ans = solve();
    for (i = 1; i <= n; i++) x[i] = C - x[i];
    reverse(x + 1, x + n + 1);
    reverse(v + 1, v + n + 1);

    ans = max(ans, solve());

    printf("%lld", ans);

    return 0;
}


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

using namespace std;

int n,a[50];
int maxv,maxj;

int f(int x){
	if (x<0)return -x;
	else return x;
}

int main()
{
	cin>>n;
	int i,j;
	for (i=0;i<n;i++){
		cin>>a[i];
		if (f(a[i])>maxv){
			maxv=f(a[i]);
			maxj=i; 
		}
	}
	cout<<2*(n-1)<<endl;
	for (i=0;i<n;i++){
		if (i==maxj)continue;
		cout<<maxj+1<<' '<<i+1<<endl;
	}
	for (i=1;i<n;i++){
		if (a[maxj]>0){
			cout<<i<<' '<<i+1<<endl;
		}
		else{
			cout<<n-i+1<<' '<<n-i<<endl;
		}
	}
	return 0;
}


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

int main()
{
    int num,limit;
    cin >> num >> limit;
    int current, ans = 0;
    for(int i=0;i<num;i++){
        cin >> current;
        if(current >= limit){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli N, M;
  cin >> N >> M;
  lli ans=0;
  vector<pair<lli, lli>> H(N);
  
  rep(i, N){
    cin >> H.at(i).first;
     H.at(i).second= H.at(i).first;
  }
  
  rep(i, M){
  int A, B;
    cin >> A >> B;
    if(H.at(A-1).second<H.at(B-1).second)
      H.at(A-1).first=0;
    else if(H.at(A-1).second>H.at(B-1).second)
      H.at(B-1).first=0;
    else{
      H.at(A-1).first=0;
      H.at(B-1).first=0;
    }
  }
  rep(i, N){
    if(H.at(i).first!=0)
  ans++;
  }
  cout << ans << endl;
}

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

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

    string c1, c2;
    int ans1=0, ans0=0;
    for(int i=0; i<s.size(); i++){
        if(i%2 == 0){
            if(s[i] == '0'){
                ans1++;
            }else{
                ans0++;
            }
        }else{
            if(s[i] == '0'){
                ans0++;
            }else{
                ans1++;
            }
        }
    }

    cout<<min(ans0, ans1)<<endl;
    return 0;
}

Measured memory_bytes: 3672
def solve():
#    tmp_max = P[0]
    tmp_min = P[0]
    cnt = 1
    for i in range(0,N):
        if P[i] < tmp_min:
            tmp_min = P[i]
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    N = int(input())
    P = list(map(int, input().split()))
    solve()  


Measured memory_bytes: 32204
#include<bits/stdc++.h>
#define console
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define siz(x) ((int)(x).size())
#define full(v) v.begin(), v.end()
#ifndef console
ifstream fin("data.in");
ofstream fout("data.out");
#else
#define fin cin
#define fout cout
#endif
#define MAX(x, y) ((a) > (b) ? (a) : (b))
#define usain_bolt() (ios_base::sync_with_stdio(false), \
                      fin.tie(NULL), fout.tie(NULL))
const long long oo = 0x3f3f3f3f;
const double PI = acos(-1);

const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

typedef long long ll;
typedef unsigned int ui;

int main()
{
    usain_bolt();
    int n;
    fin >> n;
    int lasdigit = n % 10;
    if (lasdigit == 2 || lasdigit == 4 || lasdigit == 5 || lasdigit == 7 || lasdigit == 9)
            fout << "hon";
    else if (lasdigit == 0 || lasdigit == 1 || lasdigit == 6 || lasdigit == 8)
            fout << "pon";
    else if (lasdigit == 3)
            fout << "bon";
#ifndef console
    fin.close(), fout.close();
#else
#undef fin cin
#undef fout cout
#endif // console
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

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

    std::vector<int> L(N);
    for (int i = 0; i < N; i++) {
        std::cin >> L[i];
    }
    std::sort(L.begin(), L.end());

    if (std::accumulate(L.begin(), L.begin() + N - 1, 0) > L.back()) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

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

const int N_MAX = 200005;
int buka[N_MAX];

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

    for(int i = 1; i <= n; i++){
        buka[i] = 0;
    }

    for(int i = 2; i <= n; i++){
        int a;
        scanf("%d", &a);
        buka[a]++;
    }
    for(int i = 1; i <= n; i++){
        printf("%d\n", buka[i]);
    }
    return 0;
}

Measured memory_bytes: 2508
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    print(ceil(n/2))
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5584
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n,k; cin >> n >> k;
  vector<double> p(n);
  rep(i, n) cin >> p[i];
  
  rep(i,n) p[i] = (p[i]+1.0)/2.0;

  double ans = 0.0;
  vector<double> s(n+1);
  rep(i,n) s[i+1] = s[i] + p[i];

  for(int i = 0; i+k <= n; i++) {
    double tmp = s[i+k] - s[i];
    //printf("tmp:%f\n", tmp);
    chmax(ans,tmp);
  }

  cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 3328
def main():
    N = int(input())
    a = list(map(int, input().split()))

    if a.count(1) == 0:
        print(-1)
        return
    index = 1
    cnt = 0
    for i in range(N):
        if index == a[i]:
            index+=1
        else:
            cnt+=1

    print(cnt)






if __name__ == '__main__':
    main()

Measured memory_bytes: 100672
void main(){
	int n = _scan();
	double oddnum=0.0;
	foreach(i; 1..n+1){
		if(i&1)oddnum+=1;
	}	
	( oddnum/(n.to!double) ).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;

//Uradi: https://codeforces.com/problemset/problem/1345/B
//I ovaj je zanimljiv: https://codeforces.com/contest/214/problem/B

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int a[5],r;
forn(i,5) {
  cin>>a[i];
  if(a[i]==0) r=i+1;
}
cout<<r<<endl;
return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define st string
#define bl bool
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define time cerr << "\nInamika vakt-da kor kad: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
void Urvatullo_Atoev()
{
    ll a,b,c,d,e=0;
    st s;
    cin>>a>>b;
    cout<<a*b;
}
int main()
{
    speed;
    Urvatullo_Atoev();
    time;
}


Measured memory_bytes: 3816