akhauriyash/Code-Regression huggingface dataset:
def c(l, x):
    return [i for i, _x in enumerate(l) if _x == x]
s = list(input())
ass = 1000000
for i in range(len(s)):
    r = c(s,s[i])
    ans = 0
    for i in range(len(r)-1):
        ans = max(ans,r[i+1]-r[i]-1)
    ans = max(r[0],ans,len(s)-1-r[-1])
    
    ass = min(ass,ans)
    #print(ass,r)
if len(list(set(s))) == 0:
    print(0)
else:
    print(ass)

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

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

  int color[9] = {};
  int border[9] = {4, 8, 12, 16, 20, 24, 28, 32, 50};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 9; j++) {
      if (a[i] < border[j] * 100) {
        color[j]++;
        break;
      }
    }
  }

  int type = 0;
  for (int i = 0; i < 8; i++) {
    if (color[i] > 0) type++;
  }
  cout << max(1, type) << " ";
  cout << type + color[8] << endl;
}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
	let v: Vec<i32> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
	if v[0] < v[1] && v[1] < v[2] {
		println!("Yes");
	}else {
		println!("No");
	}
}


Measured memory_bytes: 5024
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
const int MOD=1e9+7;
int ans,sum;
signed main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		ans+=sum*a;
		sum+=a;
		ans%=MOD;
		sum%=MOD;
	}
	cout<<ans;
	re 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  ll n;
  cin >> n;

  string cmd;
  ll key;
  list<ll> dll;
  rep(i,n) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> key;
      dll.push_front(key);
    } else if (cmd == "delete") {
      cin >> key;
      auto itr = std::find(dll.begin(), dll.end(), key);
      if (itr != dll.end()) {
        dll.erase(itr);
      }
    } else if (cmd == "deleteFirst") {
      dll.pop_front();
    } else if (cmd == "deleteLast") {
      dll.pop_back();
    }
  }

  bool bFirst = true;
  for(const auto& v: dll) {
    if (!bFirst) cout << " ";
    if (bFirst) bFirst = false;
    cout << v;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 34272
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	vi d(n);
	rep(i,n) cin >> d[i];
	sort(all(d));
	cout << d[n/2]-d[n/2-1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int digits_sum(int n)
{
  int sum = 0;
  while(n){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main()
{
  int n;
  cin >> n;
  int ans = 1e9;
  FOR(i,1,n/2+1){
    int a = digits_sum(i);
    int b = digits_sum(n-i);
    ans = min(ans, a+b);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
p = 10**9 + 7


xsum = 0
for i in range(n-1):
    xsum = (xsum + (x[i+1] - x[i]) * (i+1) * (n-i-1)) % p

ysum = 0
for j in range(m-1):
    ysum = (ysum + (y[j+1] - y[j]) * (j+1) * (m-j-1)) % p


ans = (xsum * ysum) % p
print(ans)


Measured memory_bytes: 83940
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 200000 + 10;

int N, K;

void Work()
{
	scanf("%d%d", &N, &K);
	long long Ans = 0;
	for (int b = 1; b <= N; b ++)
	{
		// a % b >= K
		if (K == 0)
		{
			Ans += N;
			continue;
		}
		long long seq = N / b, rem = N % b;
		// 1 .. b - 1
		if (K > b - 1)
			continue;
		Ans += (b - 1 - K + 1) * seq;
		// 1 .. rem
		if (K > rem)
			continue;
		Ans += (rem - K + 1);
	}
	printf("%lld\n", Ans);
}

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

Measured memory_bytes: 256
from collections import deque

H, W = list(map(int, input().split()))
Ch, Cw = list(map(lambda x: int(x) - 1, input().split()))
Dh, Dw = list(map(lambda x: int(x) - 1, input().split()))
S = [input() for _ in range(H)]

def walk(i, j):
    ans = []
    for h, w in [[i+1, j], [i-1, j], [i, j+1], [i, j-1]]:
        # print(h, w)
        if h >= 0 and w >= 0 and h < H and w < W:
            # print('hoen')
            if S[h][w] == '.':
                if maze[h][w] == -1:
                    ans.append((h, w))
    return ans

def warp(i, j):
    tmp = []
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if not (dh == 0 and dw == 0):
                tmp.append([i + dh, j + dw])
    ans = []
    for h, w in tmp:
        if h >= 0 and w >= 0 and h < H and w < W:
            if S[h][w] == '.':
                if maze[h][w] == -1:
                    ans.append((h, w))
    return ans

maze = [[-1]*W for _ in range(H)]
warp_n = 0
maze[Ch][Cw] = 0
walk_stack= deque(walk(Ch, Cw))
warp_set = set(warp(Ch, Cw))
# print(walk(Ch, Cw))
# print(warp(Ch, Cw))
# print('-----')
while walk_stack or warp_set:
    while walk_stack:
        h, w = walk_stack.pop()
        if maze[h][w] == -1:
            maze[h][w] = warp_n
            walk_stack.extend(walk(h, w))
            warp_set |= set(warp(h, w))
    warp_n += 1
    # print(*maze, sep='\n')
    # print('-----')
    next_warp = set()
    for h, w in warp_set:
        if maze[h][w] == -1:
            maze[h][w] = warp_n
            walk_stack.extend(walk(h, w))
            next_warp |= set(warp(h, w))
    warp_set = next_warp
print(maze[Dh][Dw])

Measured memory_bytes: 134848
#include <stdio.h>

int main(void){
	int n, x= 0, max = 0;
	char str[101];
	int i;
	
	scanf("%d", &n);
	scanf("%s", str);
	
	for (i = 0; i < n; i++){
		if (str[i] == 'I') x++;
		else x--;
		
		if (x > max) max = x;
	}
	
	printf("%d", max);
	
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int p,s=0,i=5;
	while (i--)	fscanf(stdin, "%d", &p), s += (p < 40 ? 40 : p) / 5;
	P(d, s);
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll mod=1000000007;

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll tc = 1;

  //  cin >> tc;


    while(tc--){
		ll k, n, i, maxm = 0, x, j, fl = 0;
        
        ll N, M;
        cin >> N >> M;
        
        std::vector<ll> A(N,0);
        ll totvot = 0;
        
        for(i=0; i<N; i++) cin >> A[i], totvot += A[i];
        
        ll ans = 0; 
        for(i=0; i<N; i++){
        	if(totvot <= 4*M*A[i]) ans++;
        	
        	
        }
    	if(ans >= M) cout << "Yes" << endl;
    	else cout << "No" << endl;
    }

}






Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <regex>
#include <vector>
#include <algorithm>
#include <chrono>
#include <thread>
#include <limits>
#include <array>
#include <iterator>

using namespace std;

int main(){

	int N,tmp;
	int ans =0;
	std::vector<int> L;

	cin >> N;

	for(int i = 0; 2*N > i;i++){
		cin >> tmp;
		L.push_back(tmp);
	}

	sort(L.begin(), L.end(), std::greater<int>());

	for(int i = 0; 2*N>i;i+=2){
		ans += min(L[i],L[i+1]);
	}

	cout<<ans<<endl;

	return 0;

}


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

string s;
int sLength;

long long bitToInt(short bit)
{
	long long retval = s[sLength-1] - '0';
	long long sisuu = 0;
	for(int i = sLength-2; i >= 0; i--){
		//cout << (bit >> i) % 2 << " " << retval << "\n";
		if((bit >> i) % 2 == 0){
			sisuu = 0;
			retval += (s[i] - '0') * pow(10 , sisuu);
		}else{
			sisuu++;
			retval += (s[i] - '0') * pow(10, sisuu);
		}
	}
	return retval;
}

long long dfs(long long n, short bit)
{
	if(n == sLength){
		//cout << bit << "\n";
		return bitToInt(bit);
	}

	return dfs(n+1, (bit << 1) | 1) + dfs(n+1, bit << 1);
}

int main()
{
	cin >> s;
	sLength = s.size();

	cout << dfs(1,0) << "\n";

	//cout << bitToInt(0x4) << "\n";

	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	while (true) {
		int n; cin >> n;
		if (n == 0)return 0;

		vector<int> a(n);

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

		int ans = INF;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				ans = min(ans,abs(a[i] - a[j]));
			}
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3072
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
vector<ll> fact, fact_inv, inv;
//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
 
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

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

    int SIZE=2e+5+1;
    init_nCk(SIZE);

    ll ans=0;
    REP2(i,K,N+2){
        ans+=(((2*N+3-i)*i)/2-(((1+i)*i)/2-1));
        ans%=MOD;
    }
    cout << ans << endl;
    
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 0) {
        int ans = (A + B) / 2;
        cout << ans << endl;
    } else {
        string ans = "IMPOSSIBLE";
        cout << ans << endl;
    }
    return 0;
}

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

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

	int nums[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cout << nums[k - 1] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 50
#define NIL -1

int C[MAX];

int fibonacch(int x){
  int i;
  if(x==0 || x==1) return C[x]=1;
  if(C[x]!=NIL) return C[x];
  return C[x]=fibonacch(x-1)+fibonacch(x-2);
  
}

    

int main(){
  int n,i;
  for(i=0;i<MAX;i++) C[i]=-1;
  scanf("%d",&n);

  

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

  return 0;
}





Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

template <typename TYPE>
struct Prime_template
{
    TYPE N;
    bool isPrime;
    std::vector<TYPE> factor;
    std::map<TYPE, TYPE> factorized;
    Prime_template(TYPE n)
    :N(n), isPrime(false)
    {
        factor.push_back(1);
        if (N>1) factor.push_back(N);
        for (TYPE i = 2; i*i <= N; ++i) {
            TYPE ex = 0;
            if (N % i == 0) {
                factor.push_back(i);
                TYPE other = N / i;
                if (other != i) factor.push_back(other);
            }
        }
        std::sort(factor.begin(), factor.end());
        isPrime = factor.size() == 2U;
    
        for (TYPE i = 2; i*i <= n; ++i) {
            TYPE ex = 0;
            if (n % i == 0) {
                while (n % i == 0) {
                    ++ex;
                    n /= i;
                }
                factorized.insert(std::make_pair(i, ex));
            }
        }
        if (n != 1) factorized.insert(std::make_pair(n, 1));
    }
};
using Prime = Prime_template<long long>;

void solve() {
    vector<ll> sum = {0};
    FOR(i, 1, 100) {
        sum.push_back(sum.back() + i);
    }

    ll n; cin >> n;
    int count = 0;

    auto factorize = Prime(n).factorized;
    for (auto& f : factorize) {
        for (; n % f.first == 0; n /= f.first);
        int k = prev(upper_bound(sum.begin(), sum.end(), f.second)) - sum.begin();
        count += k;
    }
    if (n != 1) ++count;
    cout << count << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3668
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int dp[100005];
vector<int> elist[100005];

int dfs(int node) {
    if(dp[node] != -1) return dp[node];
    dp[node] = 0;
    for(int& v:elist[node]) dp[node] = max(dp[node], dfs(v)+1);
    return dp[node];
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    rep(i, m) {
        int u, v; cin >> u >> v;
        elist[u].pb(v);
    }
    int bes = 0;
    memset(dp, -1, sizeof dp);
    rep1(i, n) bes = max(bes, dfs(i));
    cout << bes << endl;
}



Measured memory_bytes: 7552
#include <stdio.h>



int main(void)
{
	int n, x;
	int ways = 0;

	while(1){
		ways = 0;
		scanf("%d%d", &n, &x);
		if(n == 0 && x == 0) break;
		for(int a = 1; a <= n; a++){
			for(int b = 1; b < a; b++){
				if(b > a) break;
				for(int c = 1; c < b; c++){
					if(c > b) break;
					int total = a + b + c;
					if(total == x && a != b && b != c){
						// printf("%d %d %d\n", a, b, c);
						 ways++;
					}
				}
			}
		}
		printf("%d\n", ways);
	}

	return 0;

}


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

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

    if (N >= 10) {
        N %= 10;
    }

    if (N == 3) {
        cout << "bon" << endl;
    }
    else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
import re
import sys
from collections import *
from functools import lru_cache
from heapq import *
from itertools import *

INF=float('inf')

sys.setrecursionlimit(2**31-1)

rfs=lambda:rl().split()
ri=lambda:int(rl())
ris=lambda:list(map(int,rfs()))
rl=lambda:next(sys.stdin)
rrs=lambda:list(map(str.strip,sys.stdin))
rs=lambda:rl().strip()
rt=lambda:sys.stdin.read()
rg=lambda:list(map(list,rrs()))

def n4(i,j):
    return [
                (i-1,j),
        (i,j+1),        (i,j-1),
                (i+1,j),
    ]

def n8(i,j):
    return [
        (i-1,j-1),(i-1,j),(i-1,j+1),
        (  i,j-1),        (  i,j+1),
        (i+1,j-1),(i+1,j),(i+1,j+1),
    ]

inb=lambda i,j,m,n:0<=i<m and 0<=j<n

###########################################

N,A=ri(),ri()
if N%500-A<=0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define int long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int mod = 1e9+7;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif


int32_t main(){
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	int n,d;
	cin>>n>>d;

	d*=d;

	int ans = 0;

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

		int dis = x*x + y*y;

		if(dis <= d)
			ans++;
	}


	cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 3596
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

#include<bits/stdc++.h>
using namespace std;

const int MAX_N=25;

int A[MAX_N],B[MAX_N],C[MAX_N],N,ans=0;

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>N;
	for(int i=1;i<=N;i++) cin>>A[i];
	for(int i=1;i<=N;i++) cin>>B[i];
	for(int i=1;i<=N-1;i++) cin>>C[i];
	for(int i=1;i<=N;i++){
		ans+=B[A[i]]; if(A[i]+1==A[i+1]) ans+=C[A[i]];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var m = cin.ReadInt;

            var list = new int[m];
            for (int i = 0; i < n; i++)
            {
                var k = cin.ReadInt;
                for (int j = 0; j < k; j++)
                {
                    var tmp = cin.ReadInt;
                    list[tmp-1]++;
                    
                }
            }
            int counter = 0;
            for (int i = 0; i < m; i++)
            {
                if(list[i] == n)
                {
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 13268
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s,t;cin>>s>>t;
  if(t.size()){
    t.pop_back();
    if(s==t){
      cout<<"Yes"<<ENDL;
      return 0;
    }
  }

  cout<<"No"<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

#pragma warning(disable : 4996)

using namespace std;

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

	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	vector<vector<long long> > dp(n, vector<long long>(n, 0)); // [i, j]

	for (int i = 0; i < n; i++)
	{
		dp[0][i] = a[i];
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i % 2)
			{
				if (a[j] > a[(j + i + 1) % n])
				{
					dp[i][j] = max(dp[i][j], dp[i - 1][(j + 1) % n]);
				}

				if (a[(j + i) % n] > a[(j + n - 1) % n])
				{
					dp[i][j] = max(dp[i][j], dp[i - 1][j]);
				}
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j] + a[(j + i) % n], dp[i - 1][(j + 1) % n] + a[j]);
			}
		}
	}

	long long ret = 0;

	for (int i = 0; i < n; i++)
	{
		ret = max(ret, dp[n - (2 - n % 2)][i]);
	}

	printf("%lld\n", ret);

	return 0;
}

Measured memory_bytes: 34308
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    a, b, c, k = map(int, input().split())
    if k < a:
        print(k)
    else:
        if k - a < b:
            print(a)
        else:
            print(a-(k-a-b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27140
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		long a=fs.nextLong();
		long b=fs.nextLong();
		long c=fs.nextLong();
		long d=fs.nextLong();
		System.out.println(Math.max(a*d,Math.max(b*c,Math.max(a*c,b*d))));
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 32824
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    s=S()
    t=S()

    yn='Yes' if s==t[:len(s)] else 'No'
    print(yn)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9056
#include <stdio.h>
 
int main(void){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a==b){
	printf("%d\n",c);
	} else if(b==c){
	printf("%d\n",a);
	} else {
	printf("%d\n",b);
	}
	return 0;
}

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

int main(){
int m1,m2,d1,d2;
cin>>m1>>d1>>m2>>d2;
if(m1!=m2){
  cout<<1<<endl;
}
else
{
  cout<<0<<endl;
}



}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int a[10];
int b[10];
bool flag;
int c[10];
void dfs(int aa,int bb,int cc)
{
    if(bb+cc==10)
    {
        flag=true;
        return ;
    }
    if(bb==0||(a[aa]>b[bb-1]&&b[bb]==0))
    {
        b[bb]=a[aa];
        dfs(aa+1,bb+1,cc);
        b[bb]=0;
    }
    if(cc==0||(a[aa]>c[cc-1]&&c[cc]==0))
    {
        c[cc]=a[aa];
        dfs(aa+1,bb,cc+1);
        c[cc]=0;
    }
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        memset(b,0,sizeof(b));
        memset(c,0,sizeof(c));
        for(int i=0;i<10;i++)
            cin>>a[i];
        flag=false;
        dfs(0,0,0);
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");


    }
    return 0;
}

Measured memory_bytes: 3040
package main

import (
    "fmt"
    "sort"
)

type Tuple struct {
    x, index int
}

type Tuple3 struct {
    i, j, cost int
}

type Tuples []Tuple
type Tuple3s []Tuple3

func (ts Tuples) Len() int {
    return len(ts)
}

func (ts Tuples) Swap(x, y int) {
    ts[x], ts[y] = ts[y], ts[x]
}

func (ts Tuples) Less(i, j int) bool {
    return ts[i].x < ts[j].x
}

func (ts Tuple3s) Len() int {
    return len(ts)
}

func (ts Tuple3s) Swap(x, y int) {
    ts[x], ts[y] = ts[y], ts[x]
}

func (ts Tuple3s) Less(i, j int) bool {
    return ts[i].cost < ts[j].cost
}

var ran, par []int

func initialize(n int) {
    par, ran = make([]int, n), make([]int, n)
    for i := 0; i < n; i++ {
        par[i] = i
        ran[i] = 1
    }
}

func find(x int) int {
    if x == par[x] {
        return x
    }
    par[x] = find(par[x])
    return par[x]
}

func unite(x, y int) bool {
    x = find(x)
    y = find(y)
    if x == y {
        return false
    }

    if ran[x] < ran[y] {
        par[x] = y
    } else {
        par[y] = x
        if ran[x] == ran[y] {
            ran[x]++
        }
    }
    return true
}

func main() {
    var n int
    fmt.Scan(&n)
    x, y := make(Tuples, n), make(Tuples, n)
    for i := 0; i < n; i++ {
        var a, b int
        fmt.Scan(&a, &b)
        x[i] = Tuple {a, i}
        y[i] = Tuple {b, i}
    }
    sort.Sort(x)
    sort.Sort(y)
    costs := make(Tuple3s, 2 * n - 2)
    for i := 1; i < n; i++ {
        costs[2 * i - 2] = Tuple3 {x[i].index, x[i - 1].index, x[i].x - x[i - 1].x}
        costs[2 * i - 1] = Tuple3 {y[i].index, y[i - 1].index, y[i].x - y[i - 1].x}
    }
    sort.Sort(costs)
    count := 0
    ans := 0
    initialize(n)
    for _, t := range costs {
        if count == n - 1 {
            break
        }
        if unite(t.i, t.j) {
            count++
            ans += t.cost
        }
    }
    fmt.Println(ans)
}


Measured memory_bytes: 12544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication32 {
    class Program {
        static void Main(string[] args) {
            string w = Console.ReadLine();

                var result = Method(w);
            if (result)
                Console.WriteLine("Yes");
            else {
                Console.WriteLine("No");
            }
        }
    
        private static bool Method(string w) {

            int[] str = new int[26];//a~z

            for (int i = 0; i < w.Length; i++) {
                int index = w[i]-'a';
                str[index]++;
            }
            for (int i = 0; i < str.Length; i++) {
                if (str[i] % 2 == 1) {
                    return false;
                } 
            }
            return true;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>

using namespace std;

template<typename T>
class Queue {
private:
    vector<T> vec;
    uint32_t head;
    uint32_t tail;

public:
    Queue(uint32_t n) {
        vec.resize(n + 1);
        head = 0;
        tail = 0;
    }

    void increment(uint32_t &x) {
        x++;
        x %= vec.size();
        return;
    }

    void enqueue(T x) {
        vec[tail] = x;
        increment(tail);
    }

    T dequeue() {
        T x = vec[head];
        increment(head);
        return x;
    }

    bool empty() {
        return head == tail;
    }
};

struct Process {
    string name;
    int32_t time;
};

int main() {
    int64_t n;
    int32_t q;

    cin >> n >> q;

    Queue<Process> queue(n);

    while (n--) {
        Process p;
        cin >> p.name >> p.time;
        queue.enqueue(p);
    }

    int64_t sum = 0;
    while (!queue.empty()) {
        Process proc = queue.dequeue();

        if (proc.time > q) {
            sum += q;
            proc.time -= q;
            queue.enqueue(proc);
        } else {
            sum += proc.time;
            cout << proc.name << " " << sum << endl;
        }
    }

    return 0;
}

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

bool dfs(string s) {
  if (s == "ABC") return true;

  string t = regex_replace(s, regex("ABC"), "A");
  if (t.size() != s.size() && regex_replace(t, regex("A"), "ABC") == s) {
    if (dfs(t)) return true;
  }
  t = regex_replace(s, regex("ABC"), "B");
  if (t.size() != s.size() && regex_replace(t, regex("B"), "ABC") == s) {
    if (dfs(t)) return true;
  }
  t = regex_replace(s, regex("ABC"), "C");
  if (t.size() != s.size() && regex_replace(t, regex("C"), "ABC") == s) {
    if (dfs(t)) return true;
  }

  // if (dfs(regex_replace(s, regex("ABC"), "A"))) return true;
  // if (dfs(regex_replace(s, regex("ABC"), "B"))) return true;
  // if (dfs(regex_replace(s, regex("ABC"), "C"))) return true;
  return false;
}

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

  cout << (dfs(s) ? "Yes" : "No") << endl;
}



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

int main() {

	string s; cin >> s;
	string ans = "No";
	if (s.size() % 2 != 0) {}
	else {
		bool ok = true;
		for (int i = 0; i < s.size(); i++) {
			if (i % 2 == 0) {
				if (s[i] != 'h') ok = false;
			}
			else {
				if (s[i] != 'i') ok = false;
			}
		}
		if (ok) ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3536
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int ret = 0;
            int maxDivide = 0;
            for (int i = 1; i <= N; i++)
            {
                int divideVal = i;
                int divideCount = 0;
                while (divideVal % 2 == 0)
                {
                    divideVal /= 2;
                    divideCount++;
                }

                if (divideCount >= maxDivide)
                {
                    maxDivide = divideCount;
                    ret = i;
                }
            }
            Console.WriteLine(ret);
        }        
        
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int n;
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int cnt = 0;
	for(int i = 1; i <= n; ++ i) {
		++ cnt;
		int j = i;
		while(s[j + 1] == s[i])
			++ j;
		i = j;
	}
	printf("%d\n", cnt - 1);
}

Measured memory_bytes: 3820
#include<iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);

	int arr[5],a=0;

	for(int i=0;i<5;i++)
	{
		cin>>arr[i];
		if(arr[i]==0)
			a=i;
	}

	cout<<a+1;




	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>

using namespace std;

typedef long long in;

int main(){
    int n;
    cin >> n;
    vector<in> a(n);
    int ct=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]%2==1){
            ct++;
        }
    }
    if(ct%2==1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int D, T, S;
	cin >> D >> T >> S;
	T *= S;
	if (D <= T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3640
from collections import Counter, defaultdict
from bisect import bisect_right

s = input()
t = input()

c = Counter(s)
for e in t:
    if c[e] == 0:
        print(-1)
        exit()

ss = s + s
d = defaultdict(list)
for i, e in enumerate(ss):
    d[e].append(i)

now = -1
ans = 0
for e in t:
    i = bisect_right(d[e], now)
    nxt = d[e][i]
    ans += nxt - now
    now = nxt % len(s)

print(ans)


Measured memory_bytes: 12276
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

int main(void){
    string S,T;
    cin>>S>>T;
    int ans=0;
    rep(i,3){
        if(S[i]==T[i]){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
using std::min;

const int MAXN=5e5+5,INF=~0U>>1;

int n,K;
int seq[MAXN],pos[MAXN];

const int rt=1;
struct SEGTN{int l,r,lc,rc;int mnv;} t[MAXN<<2];int tcnt=rt;
inline void upd(int o){t[o].mnv=min(t[t[o].lc].mnv,t[t[o].rc].mnv);}
void buildTree(int o,int l,int r)
{
	t[o].l=l,t[o].r=r;
	if(l==r) {t[o].mnv=INF;return;}
	int mid=(l+r)>>1;
	t[o].lc=++tcnt;buildTree(t[o].lc,l,mid);
	t[o].rc=++tcnt;buildTree(t[o].rc,mid+1,r);
	upd(o);
}
void ch(int o,int p,int v)
{
	if(t[o].l==t[o].r) {t[o].mnv=v;return;}
	int mid=(t[o].l+t[o].r)>>1;
	if(p<=mid) ch(t[o].lc,p,v);
	else ch(t[o].rc,p,v);
	upd(o);
}
int calMin(int o,int l,int r)
{
	if(l<=t[o].l&&t[o].r<=r) return t[o].mnv;
	int mid=(t[o].l+t[o].r)>>1;
	int res=INF;
	if(l<=mid) res=min(res,calMin(t[o].lc,l,r));
	if(r>mid) res=min(res,calMin(t[o].rc,l,r));
	return res;
}

int inDgr[MAXN];
struct E{int next,to;} e[MAXN<<1];int ecnt,G[MAXN];
void addEdge(int u,int v){e[++ecnt]=(E){G[u],v};G[u]=ecnt;inDgr[v]++;}

inline void buildGraph()
{
	buildTree(rt,1,n);
	int u,v;
	for(v=n;v;v--) 
	{
		u=calMin(rt,pos[v]-K+1,pos[v]);
		if(u<=n) addEdge(pos[u],pos[v]);
		u=calMin(rt,pos[v],pos[v]+K-1);
		if(u<=n) addEdge(pos[u],pos[v]);
		ch(rt,pos[v],v);
	}
}

std::priority_queue<int> heap;
inline void toposort()
{
	int i;
	for(i=1;i<=n;i++) if(!inDgr[i]) heap.push(i);
	for(int v=n;v;v--)
	{
		int u=pos[v]=heap.top();heap.pop();
		for(i=G[u];i;i=e[i].next)
			if(--inDgr[e[i].to]==0)
				heap.push(e[i].to);
	}
}

int main()
{
	int i;
	scanf("%d%d",&n,&K);
	for(i=1;i<=n;i++) scanf("%d",seq+i);
	for(i=1;i<=n;i++) pos[seq[i]]=i;
	buildGraph();
	toposort();
	for(i=1;i<=n;i++) seq[pos[i]]=i;
	for(i=1;i<=n;i++) printf("%d\n",seq[i]);
	return 0;
}

Measured memory_bytes: 42360
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(s.at(i) == '+'){
            ans++;
        }else{
            ans--;
        }

    }

    cout << ans << endl;
    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++)

int main() {
  int n, m;
  cin >> n;
  vector<string> sn(n);
  rep(i, n) { cin >> sn[i]; }
  cin >> m;
  vector<string> tn(m);
  rep(j, m) { cin >> tn[j]; }
  
  int cnt, maxi = 0;
  rep(i, n) {
    cnt = 0;
   	rep(k, n) {
      if (sn[k] == sn[i]) cnt++;
    }
    rep(l, m) {
      if (tn[l] == sn[i]) cnt--;
    }
    maxi = max(cnt, maxi);
  }
  
  cout << maxi << endl;
  
}


Measured memory_bytes: 256
import math

def test(a, b, h, m):
  h_x = a * math.sin(((h * math.pi) / 6) + ((m * math.pi) / 360))
  h_y = a * math.cos(((h * math.pi) / 6) + ((m * math.pi) / 360))
  m_x = b * math.sin((m * math.pi) / 30)
  m_y = b * math.cos((m * math.pi) / 30)
  
  print(math.sqrt(((h_x-m_x) ** 2) + ((h_y-m_y) ** 2)))
  
a, b, h, m = input().split()
test(float(a), float(b), float(h), float(m))

Measured memory_bytes: 62632
//file_name:ABC71_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    int x[1000] = {};

    char a = 'a';
    char z = 'z';

    rep(i,s.size()){
        x[(int)s[i]]++;
    }
    int flag = 0;
    srep(i,(int)a,(int)z+1){
        if(x[i]==0){
            cout << (char)i;
            flag = 1;
            break;
        }
    }
    if(flag==0){
        cout << "None";
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 512
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int N = ReadInt();
    char[] S = ReadCharArray();
    int[] count = S.Distinct().Select(c => S.Count(d => d == c)).ToArray();
    long ans = 1L;
    foreach (int i in count) {
      ans *= i + 1;
      ans %= 1000000007;
    }
    Console.WriteLine(ans-1);
  }

  private static List<int> _var;
  public static int cin() { if (_var == null || _var.Count() == 0) { _var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>(); } int ans = _var[0]; _var.RemoveAt(0); return ans; }
  public static void Swap<T>(ref T a, ref T b) {T temp = a;a = b;b = temp;}
  public static string ReadStr() { return Console.ReadLine(); }
  public static int ReadInt() { return int.Parse(Console.ReadLine()); }
  public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  public static long ReadLong() { return long.Parse(Console.ReadLine()); }
  public static char ReadChar() { return Console.ReadLine()[0]; }
  public static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  public static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  public static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 14432