akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>

using namespace std;
using lint = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)
#define rep_inv(i, n) for (lint i = (n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n")

//constexpr lint mod = 998'244'353LL;
constexpr lint Mod = 1000'000'007LL;
constexpr lint Inf = 3'000'000'000'000'000'007LL; //3e18+7
constexpr double Pi = 3.141592653589793;

template<class T> using prique     = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << rhs.first << " " << rhs.second; }
template<class InputIterator> void arrin(InputIterator first, InputIterator last) { for (; first != last; ++first) cin >> (*first); }
template<class InputIterator> void arrout(InputIterator first, InputIterator last) {
	for (; first != last; ++first) {
		cout << (*first) << ((first + 1) != last ? " " : "\n");
	}
}

bool pri(lint x) { 
	for (lint i = 2; i * i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return 1 < x; 
}

lint fact[3000000];
void fact_init(lint n, lint m = Mod) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1] % m;
	}
}

lint modpow(lint x, lint n, lint m = Mod) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r, lint m = Mod) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], m - 2, m) % m * modpow(fact[r], m - 2, m) % m;
	return res < 0 ? res + m : res;
}

map<lint, lint> factring(lint n) {
	map<lint, lint> res;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++res[i];
		}
	}
	if (n != 1) ++res[n];
	return res;
}

int n;
lint k, ans;
lint a[2 * 100010], s[2 * 100010];
map<lint, vector<lint>>mp;
map<lint, lint>cnt;

inline lint f(lint x) { return (x % k + k) % k;}

int main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		s[i + 1] += s[i] + a[i];
		mp[f(s[i] - i)].push_back(i);
	}
	mp[f(s[n] - n)].push_back(n);

	rep(i, n + 1) {
		lint x = f(s[i] - i);
		const vector<lint>& v = mp[x];
		auto itr = v.begin() + cnt[x];
		lint add = lower_bound(itr, v.end(), i + k) - itr;
		ans += add - 1;
		++cnt[x];
	}

	cout << ans << endl;
}

Measured memory_bytes: 41128
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B){
    long long max = 0;
    
    long long ai = 0;
    long long bi = 0;
    long long time = 0;

    for (ai=0;ai<A.size(); ++ai) {
        if (A[ai] + time <= K) {
            time += A[ai];
        }else{
            break;
        }
    }
    for (bi=0;bi<B.size();++bi) {
        if (time <= K && max < ai + bi) max = ai + bi;

        time += B[bi];
        while (time > K && ai > 0) {
            ai--;
            time -= A[ai];
        }
    }
    if (time <= K && max < ai + bi) max = ai + bi;

    cout << max << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, M, K, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 6436
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 105

void dfs(int now,vector<vector<int> >& g,vector<bool>& used,vector<int>& ans){

    used[now] = true;
    for(auto to : g[now]){
        if(used[to] > 0){
            continue;
        }
        dfs(to,g,used,ans);
    }
    ans.push_back(now+1);
}


void Topological_Sort(int v,int e,vector<vector<int> >& g,vector<bool>& used,vector<int>& ans){

    for(int i = 0;i < v;++i){
        if(used[i] == true){
            continue;
        }
        dfs(i,g,used,ans);
    }
    reverse(ans.begin(),ans.end());
}


int main(){

    int m,n;
    cin >> m >> n;
    vector<vector<int> > g(ARRAY_MAX);
    vector<bool> used(ARRAY_MAX,false);
    vector<int> ans;

    REP(i,n){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
    }

    Topological_Sort(m,n,g,used,ans);
    REP(i,ans.size()){
        cout << ans[i] << endl;
    }  


    return 0;
}


Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;

struct query {long long V, D, C;};

vector<query> VQ;
vector<vector<long long> > V;
static long long ANS[100000][11] = {};

void DFS(long long v, long long d, long long c) {
	if (ANS[v][d] != 0) return;
	ANS[v][d] = c;
	if (d == 0) return;
	DFS(v, d - 1, c);
	for (long long p : V[v]) DFS(p, d - 1, c);
}

int main() {
	long long N, M, Q;
	cin >> N >> M;
	V.resize(N);
	for (int i = 0; i < M; i++) {
		long long A, B;
		cin >> A >> B;
		A--, B--;
		V[A].push_back(B);
		V[B].push_back(A);
	}
	cin >> Q;
	VQ.resize(Q);
	for (int i = 0; i < Q; i++) {
		cin >> VQ[i].V >> VQ[i].D >> VQ[i].C;
		VQ[i].V--;
	}
	reverse(VQ.begin(), VQ.end());
	for (int i = 0; i < Q; i++) {
		DFS(VQ[i].V, VQ[i].D, VQ[i].C);
	}
	for (int i = 0; i < N; i++) cout << ANS[i][0] << endl;
}

Measured memory_bytes: 17780
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N_,K = map(int,input().split())

A = list(map(int,input().split()))

A.sort()

ans = 0

for i in range(K-1,N_):
    ans += cmb(i,K-1,mod) * A[i]
    ans %= mod
    #print(ans)

for i in range(K-1,N_):
    ans -= cmb(i,K-1,mod) * A[N_-i-1]
    ans %= mod
    #print(ans)

print(ans)

Measured memory_bytes: 133008
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e5 + 6;

int n, k;
vector<int> adj[MAXN];
ll fac[MAXN];
ll ifac[MAXN];
ll res;

ll mypow_mod(ll x, ll exp, ll MOD) {
		if (exp == 0)
			return 1;
		
		if (x > MOD)
			x %= MOD;
		
		if (exp & 1) {
			ll half = mypow_mod(x, exp >> 1, MOD);
			return ((half * half % MOD) * x) % MOD;
		}
		else {
			ll half = mypow_mod(x, exp >> 1, MOD);
			return (half * half) % MOD;
		}
	}
	

bool input() {
	int x, y;
	
	cin >> n >> k;
	for (int i = 1; i < n; ++i) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	
	return !cin.fail();
}

void clear_input() {
	for (int i = 0; i <= n; ++i)
		adj[i].clear();
	n = 0;
}

void preprocess() {
	
	fac[0] = 1;
	ifac[0] = 1;
	for (int i = 1; i <= n || i <= k; ++i) {
		fac[i] = fac[i-1] * i % MOD;
		ifac[i] = mypow_mod(fac[i], MOD-2, MOD);
	}
	
}

void dfs(int u, int pa) {
	if (pa == -1) { // root
		if (adj[u].size()+1 > k) res = 0;
		else
			res = res * fac[k] % MOD * ifac[k-(adj[u].size()+1)] % MOD;
	}
	else {
		if (adj[u].size()-1 > k-2) res = 0;
		else
			res = res * fac[k-2] % MOD * ifac[k-2-(adj[u].size()-1)] % MOD;
	}
	
	for (auto v : adj[u]) if (v != pa)
		dfs(v, u);
}

void process(int itest) {
	
	res = 1;
	dfs(1, -1);
	cout << res << endl;
	
}

void oneTest() {
	
	while(input()) {
		preprocess();
		process(0);
		clear_input();
	}
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  K--;
  if('A' <= S[K] && S[K] <= 'Z'){
    S[K] = 'a' + (S[K]-'A');
  }

  cout << S << endl;
  
  return 0;
}


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

int main()
{
	int A, B;
	char S[12], T[12], U[12];
	
	scanf("%s %s", S, T);
	scanf("%d %d", &A, &B);
	scanf("%s", U);
	
	(strcmp(S,U)==0) ?  printf("%d %d", A, B, A--) : printf("%d %d", A, B, B--);	
	
	return 0;
} 

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

vector< vector<int> > Graph;
vector< int > value;









int main(int argc, const char * argv[]) {
    
  
    
    
    int n; cin >> n;
    vector<int> H(n); rep(i,n) cin >> H[i];
    
    int ans=0;
    int hypo=0;
    
    for (int i = 0; i < n - 1; i++) {
        if(H[i] >= H[i+1]) {
            hypo++;
            ans = max(ans,hypo);
        }else{
            hypo = 0;
        }
        
    }
    cout << ans << endl;
    
    


    
    

    
}


Measured memory_bytes: 640
/*
 * Author:  heyuhhh
 * Created Time:  2019/11/16 20:01:35
 */
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << '\n'; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
void pt() {std::cout << '\n'; }
template<typename T, typename...Args>
void pt(T a, Args...args) {std::cout << a << ' '; pt(args...); }
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 105;

int n;
char s[N];

void run(){
    cin >> n;
    cin >> (s + 1);
    if(n & 1) cout << "No";
    else {
        for(int i = 1; i <= n / 2; i++) if(s[i] != s[i + n / 2]) {
            cout << "No";
            return;
        }   
        cout << "Yes";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
	return 0;
}

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


#define ll  long long


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') cnt1++;
        if(s[i]=='G') cnt2++;
        if(s[i]=='B') cnt3++;
    }

ans = cnt1 * cnt2 * cnt3;

for(int i = 1; i <= n; i++){
  for(int j = 0; j< n; j++){
    if(j - i < 0 || j + i >= n) continue;
    if(s[j] != s[j - i] && s[j] != s[j + i] && s[j + i] != s[j - i])
    {
       // cout<<"s[j] : "<<j<<"s[j-i] : "<<j-i<<"s[j+i] : "<<j+i<<endl;
        ans--;
    }
  }
}
  cout << ans << "\n";
  return 0;
}


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  vector<int> v(4);
  rep(i,4){
    cin >> v[i];
  }

  string S;
  rep(i,4){
    S.push_back((char)(v[i]+48));
  }
  sort(S.begin(),S.end());
  if(S == "1479") cout << "YES" << endl;
  else cout << "NO" << endl;


}

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

string day[] = {
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
};

ll zeller(ll y, ll m, ll d){
    if(m <= 2){
        y--;
        m += 12;
    }
    return (365 * y) + (y / 4) - (y / 100) + (y / 400) + (306 * (m + 1)) / 10 + d - 429;
}

int main(){
    int a,b;
    while(cin >> a >> b && a){
        int z = zeller(2004,a,b);
        cout << day[(z+1)%7] << endl;
    }
}

Measured memory_bytes: 1196
N,K = map(int, input().split())
lis = list(map(int, input().split()))

lis = [(ele+1)/2 for i, ele in enumerate(lis)]

ans_lis = []

ans_lis.append(sum(lis[0:K]))

for i in range(N-K):
    ele = ans_lis[-1] - lis[i] + lis[i+K]
    ans_lis.append(ele)
    
print(max(ans_lis))

Measured memory_bytes: 24812
MOD = 10 ** 9 + 7
H, W, K = map(int, input().split())

if W == 1:
    print(1)
    exit()

dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        dp[i][j] %= MOD
        here = dp[i][j]
        for d in range(2 ** (W - 1)):
            d = format(d, '0' + str(W - 1) + 'b')
            if not d.count('11'):
                if j == 0:
                    if d[j] == '1':
                        dp[i + 1][j + 1] += here
                    else:
                        dp[i + 1][j] += here
                elif j == W - 1:
                    if d[j - 1] == '1':
                        dp[i + 1][j - 1] += here
                    else:
                        dp[i + 1][j] += here
                else:
                    if d[j - 1] == '1':
                        dp[i + 1][j - 1] += here
                    elif d[j] == '1':
                        dp[i + 1][j + 1] += here
                    else:
                        dp[i + 1][j] += here

print(dp[H][K - 1] % MOD)


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>L(M);
	vector<int>R(M);
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
	}
	int min = L[0];
	int max = R[0];
	for (int i = 1; i < M; i++) {
		if (min < L[i]) {
			min = L[i];
		}
		if (max > R[i]) {
			max = R[i];
		}
	}
	int ans = max - min + 1;
	if (ans < 0) { ans = 0;}
	cout << ans << endl;
}

Measured memory_bytes: 1024
mod = 10 ** 9 + 7

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod



N, K, *A = map(int, open(0).read().split())

A.sort()

mc = ModComb(2 * 10 ** 5)

mi = 0
for i, a in enumerate(A, 1):
    mi += a * mc.nCk(N - i, K - 1)
    mi %= mod


ma = 0
for i, a in enumerate(reversed(A), 1):
    ma += a * mc.nCk(N - i, K - 1)
    ma %= mod

print((ma - mi) % mod)


Measured memory_bytes: 33388
#include <stdio.h>

int main (){
	
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);

	if(C>A && C<B || A==B && B==C && A==C){
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; ++i) {
    cin >> X[i];
  }
  
  if (M <= N) {
    cout << 0 << endl;
  } else {
    sort(X.begin(), X.end());
    vector<int> difs(M-1);
    for (int i = 0; i < M - 1; ++i) {
      int xi = X[i];
      int next_xi = X[i + 1];
      difs[i] = next_xi - xi;
    }
    sort(difs.rbegin(), difs.rend());
    int result = accumulate(difs.begin(), difs.end(), 0);
    for (int i = 0; i < N - 1; ++i) {
      result -= difs[i];
    }
    cout << result << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, x, y);
	ll min_ans = INF;
	vector<int> h = { -1, 1 };
	for (int i : h)
		for (int n : h)
			if (y*i >= x * n) {
				ll ans = (i < 0) + (n < 0) + (y*i - x * n);
				min_ans = min(min_ans, ans);
			}
	cout << min_ans << endl;
	return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    if a * b > 0 :
        if a > 0 and b > 0:
            print("Positive")
        elif a < 0 and b < 0:
            print("Positive" if abs(a - b + 1) % 2 == 0 else "Negative")
        elif a < 0 and 0 < b:
            print("Positive" if abs(a) % 2 == 0 else "Negative")
    else:
        print("Zero")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#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)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int n;
    cin >> n;
    auto par = make_vec<int>(20, n);
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int c;
            cin >> c;
            par[0][c] = i;
        }
    }

    for (int i = 1; i < 20; ++i) {
        rep(j, n) {
            par[i][j] = par[i-1][par[i-1][j]];
        }
    }

    vector<int> dep(n);
    rep(i, n) {
        if (i == 0) continue;
        int now = i;
        for (int j = 19; j >= 0; --j) {
            if (par[j][now] != 0) {
                now = par[j][now];
                dep[i] += 1 << j;
            }
        }
        dep[i]++;
    }

    auto la = [&](int v, int level) {
        rep(i, 20) {
            if (level >> i & 1) {
                v = par[i][v];
                level -= 1 << i;
            }
        }
        return v;
    };

    auto lca = [&](int u, int v) {
        if (dep[u] < dep[v]) swap(u, v);
        u = la(u, dep[u] - dep[v]);
        if (u == v) return u;
        for (int i = 19; i >= 0; --i) {
            if (par[i][u] != par[i][v]) {
                u = par[i][u];
                v = par[i][v];
            }
        }
        return par[0][u];
    };

    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        cout << lca(u, v) << '\n';
    }
}



Measured memory_bytes: 11156
# C - Traveling
N = int(input())
T = []
for n in range(N):
    T.append([int(i) for i in input().split()])
now_t = 0
now_x = 0
now_y = 0
cnt=0
for t in T:
    if t[0]%2 !=(t[1]+t[2])%2:
        print('No')
        exit()
        
    if t[0] -now_t  >= abs(t[1]-now_x)+abs(t[2]-now_y):
        now_t = t[0]
        now_x = t[1]
        now_y = t[2]
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 21108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int N;
	cin >> N;
	vector <int> as(N), bs(N), cs(N);
	rep(N, i) cin >> as[i];
	rep(N, i) cin >> bs[i];
	rep(N, i) cin >> cs[i];
	sort(all(as));
	sort(all(bs));
	sort(all(cs));
	ll ans = 0;
	rep(N, i) {
		ans += (upper_bound(all(as), bs[i]-1) - as.begin()) * (cs.end() - lower_bound(all(cs), bs[i]+1));
	}
	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1408
S = str(input())

count = 0
result = []

for i in range(len(S)):
  if (S[i] == "A") or (S[i] == "C") or (S[i] == "G") or (S[i] == "T"):
    count += 1
    if i == len(S) - 1:
      result.append(count)
  else:
    result.append(count)
    count = 0
    if i == len(S) - 1:
      result.append(count)

maxi = result[0]
    
for j in range(len(result)):
  if maxi < result[j]:
    maxi = result[j]

print(maxi)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
VI arr[200000];
int main()
 {  fast();
	int t, n,m, k;
  cin>>n>>m;
	vector<ll> vect(n+1,0);
  fore1(i,1,n+1)cin>>vect[i];
 // print(vect); END;
    while(m--){
      int a,b;
      cin>>a>>b;
     // cout<<a<<" "<<b<<endl;
      arr[a].push_back(b);
      arr[b].push_back(a); 
	}
  int count=n;
 // print(arr[2])i)
 
  fore1(k,1,n+1){
      
      if(arr[k].size()>0)
      {
          for(ll child:arr[k]){
              if(vect[k]<=vect[child])
             { count--;
              break;}
          }
      }
    
 }
  cout<<count<<endl;}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string s;
    cin >> s;
    ll n = s.length();
    ll memo[2019] = {};
    ll hash = 0;
    memo[0]++;

    ll base = 1;
    rep(i, n) {
        ll index = n - i - 1;
        int num = s[index] - '0';
        hash += num * base;
        hash %= 2019;
        // cout << hash << endl;
        memo[hash]++;
        base *= 10;
        base %= 2019;
    }

    ll ans = 0;
    rep(i, 2019) {
        if (memo[i] <= 1) {
            continue;
        }
        ans += (memo[i] * (memo[i] - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3732
#include <stdio.h>

int main(void){
        int a, b, c;

        scanf("%d %d %d",&a,&b,&c);

        if (a == b && b == c){
                printf("1\n");
                }
        else if (a == b || b == c || a == c){
                printf("2\n");
        }
        else if (a != b && b != c && a != c){
                printf("3\n");
        }
        return 0;
}

Measured memory_bytes: 1648
#include<iostream>
#include<time.h>
using namespace std;

//?????????????´???°??¨????????°
int prime[100000];
int primeNum;
bool flag;

//??\??????
int N;

int main() {
	//?????????????´???°?????????
	//clock_t start=clock();
	primeNum=0;
	for (int i = 7; i < 300000; i += 7) {
		flag=true;
		//??¢??\????´???°??§??????????????????????´???°????????????
		for (int j = 0; j < primeNum; j++) {
			if ((i - 1)<prime[j] * prime[j])break;
			if((i-1)%prime[j]==0)flag=false;
		}
		if(flag)prime[primeNum++]=i-1;

		flag=true;
		for (int j = 0; j < primeNum; j++) {
			if ((i + 1)<prime[j] * prime[j])break;
			if((i+1)%prime[j]==0)flag=false;
		}
		if(flag)prime[primeNum++]=i+1;
	}


	//clock_t end = clock();

	//cout<<(double)(end-start)<<endl;

	//??\?????¨??????
	while (true) {
		cin>>N;
		if(N==1)break;
		cout<<N<<":";
		for (int i = 0; i < primeNum; i ++) {
			if(N%prime[i]==0)cout<<" "<<prime[i];
		}
		cout<<endl;
	}
	return 0;
}

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

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

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

  int ans = N-K;
  if(K==1) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	long long int a, b, k, c;
	cin >> a >> b >> k;
	c = b;
	b = b - (k - a);
	a -= k;
	if (b < 0)
	b = 0;
	if (a <= 0) {
		a = 0;
		cout << 0 << " " << b;
	}
	else
	cout << a << " " << c;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int n,c=0;
    string s;
    cin>>n>>s;
    vector<int> v(n,0);
    for(int i=0;i<n;i++){
        if(s[i]=='R')v[i]=1;
    }
    int l=0;
    int r=n-1;
    while(l<r){
        while(v[l]!=0){
            l++;
            if(l==n)break;
        }
        while(v[r]!=1){
            r--;
            if(r==0)break;
        }
        if(l<r)c++;
        v[l]=1;
        v[r]=0;
    }
    cout<<c;
}


Measured memory_bytes: 4296
n=int(input())
D={}
ma=1
for i in range(n):
    s=input()
    if s in D:
        D[s]+=1
        ma=max(ma,D[s])
    else:
        D[s]=1

L=[]
for i in D:
    if D[i]==ma:
        L.append(i)
L.sort()
for i in L:
    print(i)

Measured memory_bytes: 91992
import itertools,copy
h,w,k = map(int,input().split())
C = [list(input()) for i in range(h)]
ans = 0
for bith in range(2**h):
  for bitw in range(2**w):
    Ccopy = copy.deepcopy(C)
    for high in range(h):
      if (1 & bith>>high):
        for i in range(w):
          Ccopy[high][i] = "."
    for width in range(w):
      if (1 & bitw>>width):
        for i in range(h):
          Ccopy[i][width] = "."
    if list(itertools.chain.from_iterable(Ccopy)).count("#") == k:
      ans += 1
print(ans)


Measured memory_bytes: 9220
# -*- coding: utf-8 -*-
import decimal
import math
n,d = list(map(int,input().split()))
x = [list(map(lambda x:decimal.Decimal(int(x)),input().split())) for i in range(n)]

def calc_distance(arr1,arr2):
    return math.sqrt(sum(list(map(lambda x,y:(x-y)**2,arr1,arr2))))
ret = 0
for i in range(n):
    for j in range(i):
        if calc_distance(x[i],x[j])%1==0.0:
            ret+=1
print(ret)


Measured memory_bytes: 5332
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
   
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var n = Read();
        var str = Console.ReadLine().Split(' ');
        var s = str[0];
        var t = str[1];

        for (int i = 0; i < n; i++)
        {
            Console.Write("{0}{1}", s[i], t[i]);
        }


        Console.Out.Flush();

    }
}

Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()

using namespace std;

int a[25][25];
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, d;
    cin >> n >> d;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= d; j++) {
            cin >> a[i][j];
        }
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int x = 0;
            for (int k = 1; k <= d; k++) {
                x += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            }
            int sq = sqrt(x);
            if (sq * sq == x) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String a = scanner.next();
        String b = scanner.next();

        if((a.length() + 1 == b.length()) && b.startsWith(a)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;


    LL ans = LINF;

    REP(i,1e5+1)
    {
        LL base = 2 * C * i;
        LL kouho = base + 1LL * A * max(0, X - i) + 1LL * B * max(0, Y - i);
        if(kouho < ans) ans = kouho;
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

vll primes;
vector<bool> composite;

void prime_sieve(ll lim) {
	composite = vector<bool>(lim+1);
	for (int num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) break;
		}
	}
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	prime_sieve(min(1e3+100, ceil(sqrt(maxx)) + 100));
	umap<int, int> prime_freq = umap<int, int>();
	for (const int& a : A) {
		int b = a;
		for (int i = 0; primes[i]*primes[i] <= b; i++) {
			if (b % primes[i] == 0) prime_freq[primes[i]]++;
			while(b % primes[i] == 0) b /= primes[i];
		}
		if (b != 1) prime_freq[b]++;
	}
	int max_freq = 0;
	for (const auto& [p, freq] : prime_freq) {
		max_freq = max(max_freq, freq);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

Measured memory_bytes: 10412
//#include"bits/stdc++.h"
#include<iostream>
#include<ostream>
#include<vector>
#include<string>
#include<algorithm>

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)



using namespace std;
using ll = long long;



void solve();

int main() {

   solve();
   return 0;

}

void solve() {

	ll w, h, l;
	vector<pair<ll, pair<ll, ll>>> v;

	FOR(h_, 1, 200) {
		FOR(w_, h_ + 1, 200) {
			v.push_back(make_pair(h_*h_ + w_*w_, make_pair(h_, w_)));
		}
	}
	sort(v.begin(), v.end());

	while (cin >> h>>w,h) {
		l = h*h + w*w;
		for (vector<pair<ll, pair<ll, ll>>>::iterator it = v.begin(); it < v.end(); it++) {
			if (it->first == l && it->second.first == h) {
				cout << (it+1)->second.first << ' ' << (it+1)->second.second << endl;
				break;
			}
		}

	}
}

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

using ll=long long;
const ll MOD=1e9+7;
int main(){
    int n,t;
    cin>>n>>t;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin>>d[i];
    sort(d.begin(),d.end());
    ll res=1;
    for(int i=0;i<n;i++){
        int j=lower_bound(d.begin(),d.end(),d[i]-t)-d.begin();
        res=(res*(i+1-j))%MOD;
    }
    cout<<res<<endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    //ll a[n];
    set <ll> s;
    rep(i,n){
        ll x;
        cin >> x;
        s.insert(x);
    }

    if(n==s.size()){
        printf("YES\n");
        return 0;
    }
    else{
        printf("NO\n");
        return 0;
    }

}

Measured memory_bytes: 9600
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


int main() {
	int N;
	cin >> N;
	VI d(N);
	REP(i, N) cin >> d[i];
	SORT(d);
	int c = 1;
	REP(i, N - 1) {
		if (d[i] != d[i + 1]) c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
# 最大公約数，最小公倍数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


dp = [[0 for _ in range(205)] for _ in range(205)]

k = int(input())
ans = 0
for a in range(1, k + 1):
    for b in range(a, k + 1):
        for c in range(b, k + 1):
            if len(set([a, b, c])) == 1:
                ans += a
            elif len(set([a, b, c])) == 2:
                ans += gcd(a, gcd(b, c)) * 3
            else:
                ans += gcd(a, gcd(b, c)) * 6
print(ans)


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

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

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size()<=k) cout << s << endl;
    else{
        for(int i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3576
#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 k;
    string s, NEW;
    fin >> k >> s;
    if (s.size() > k)
    {
         for (int i = 0; i < k; ++i)
                  NEW += s[i];
      NEW += "...";
       fout << NEW;
    }
    else fout << s;
#ifndef console
    fin.close(), fout.close();
#else
#undef fin cin
#undef fout cout
#endif // console
    return 0;
}


Measured memory_bytes: 3648
(setq a (read))
(setq b (read))
(setq c (+ a b))
(setq d (- a b))
(setq e (* a b))
(if (< c d)
    (if (< d e)
        (format t "~D~%" e)
        (format t "~D~%" d)
    )
    (if (< c e)
        (format t "~D~%" e)
        (format t "~D~%" c)
    )
)

Measured memory_bytes: 11488
#include <bits/stdc++.h>
using namespace std;
int64_t MAXN = pow(10, 5) + 10;
int64_t N, first = 0;
vector<int64_t> A(MAXN);

int main()
{
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
    if (A[i] % 2)
      first = 1;
  }
  cout << (first ? "first" : "second") << endl;
}


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

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

int gcd(int a, int b){
    return (a % b == 0)? b:gcd(b ,a%b);
}
void solve(){


}
int main(){
    int N,X;
    vector<int>v;
    vector<int>v2;

    cin >> N >> X;

    int x;
    v.push_back(X);
    for (int i = 0; i < N; i++){
        cin >> x;
        v.push_back(x);
    }
    sort(all(v));

    for (int i = 0; i < v.size()-1; i++){
        v2.push_back(v[i+1] - v[i]);
    }

    int num = v2[0];
    for (int i = 0; i < v2.size()-1; i++){
        if (num > gcd(v2[i], v2[i+1])){
            num = gcd(v2[i], v2[i+1]);
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
int op2(string s){
	int ans=0;
	if(s.size()<2)
		return 0;
	ans+=(((s.size()-1)*(s.size()-2))/2)*81;
	ans+=((s[0]-'0'-1)*(s.size()-1))*9;
	int j=1;
	if(s[j]!='0'){
		ans+=s[j]-'0';
		ans+=(s.size()-2)*9;
	}
	else{
		while(j<s.size()&&s[j]=='0')
			j++;
		if(j!=s.size()){
			ans+=s[j]-'0';
			ans+=(s.size()-1-j)*9;
		}
	}
	return ans;
}


int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		string s;
		cin>>s;
		int k;
		cin>>k;
		if(s.size()<k){
			cout<<0;
			return 0;
		}
		if(k==1){
			ll ha=9*(s.size()-1);
			ha+=s[0]-'0';
			cout<<ha;
			return 0;
		}
		if(k==2){
			cout<<op2(s);
		}
		else{
			int ans=0;
			ans+=(((s.size()-1)*(s.size()-2)*(s.size()-3))/6)*9*9*9;
			string q=s;
			q.erase(q.begin());
			ans+=(s[0]-'0'-1)*(((s.size()-1)*(s.size()-2))/2)*9*9;
			s.erase(s.begin());
			
			while(s.size()!=0&&s[0]=='0')
				s.erase(s.begin());
			ans+=op2(s);
			cout<<ans;
		}

	}
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc166/tasks/abc166_b
//2020-05-03
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num, kind;
    cin >> num >> kind;
    vector<bool> v;
    for(int i=0;i<num;i++){
        v.push_back(false);
    }
    for(int i=0;i<kind;i++){
        int p;
        cin >> p;
        int tmp;
        for(int j=0;j<p;j++){
            cin >> tmp;
            v[tmp-1] = true;
        }
    }
    int ans = 0;
    for(int i=0;i<num;i++){
        if(v[i]==false){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>

using namespace std;

int main() {
	int A,B;
	cin >> A >> B;
	
	if ( A <= 8 && B <= 8) {
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  double t;
  if (n % 2 == 0){
    t=1.0/2;
  }else{
    t = (n/2+1.0)/n;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
from heapq import heapify, heappush, heappop
n, m = [int(it) for it in input().split(' ')]
items = [ - int(it) for it in input().split(' ')]
heapify(items)
for i in range(m):
    heappush(items, - (- heappop(items) // 2))

print(- sum(items))


Measured memory_bytes: 14184