akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    while (k--)
    {
        if (y<=x)
            y*=2;
        else if (z<=y)
            z*=2;

    }
    if (x<y&&y<z)
        cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    return 0;
}


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

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

    vector<int> v(M + 1, 0);
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int a;
            cin >> a;
            v[a]++;
        }
    }

    int res = 0;
    for (int i = 1; i <= M; i++) {
        if (v[i] == N) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    s = input()
    for i in s:
        a = ord(i) - ord('A')
        a = (a + n) % 26
        print(chr(a + ord('A')), end='')
    print()

main()


Measured memory_bytes: 4716
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
string s;
int main()
{
	int i,j,k,n,m,x,y,z,t;
	cin>>s;
	n=0;
	for(i=0;i<s.size();i++)
	{
		n+=s[i]-'0';
	}
	if(n%9==0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}


Measured memory_bytes: 3888
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

#define size_t int

int _u[4] = {0, 1, -1, 0};
int _v[4] = {1, 0, 0, -1};
long H, W;

void myfind(long c, long _i, long _j, vector<vector<bool> > &f , vector<vector<char> > &S, long *b, long *w) {
  char color = c ? '#' : '.';
  for (size_t k = 0; k < 4; k++) {
    long u = _i + _u[k];
    long v = _j + _v[k];
    if (u >= 0 && u < H && v >= 0 && v < W) {
      if (S[u][v] == color && !f[u][v]) {
        // printf("_i=%ld _j=%ld u=%ld v=%ld\n", _i, _j, u, v);
        f[u][v] = 1;
        // ff[v][v] = 1;
        (c ? *b : *w)++;
        myfind(!c, u, v, f, S,  b, w);
      }
    }
  }
}


int main(int argc, char const *argv[]) {
  scanf("%ld %ld", &H, &W);
  char _S[H][W];
  vector<vector<char> > S(H, vector<char>(W));
  vector<vector<bool> > f(H, vector<bool>(W));
  long r = 0;
  for (size_t i = 0; i < H; i++) {
    scanf("%s", _S[i]);
    for (size_t j = 0; j < W; j++) {
      S[i][j] = _S[i][j];
    }
  }
  for (size_t i = 0; i < H; i++) {
    for (size_t j = 0; j < W; j++) {
      if (!f[i][j]) {
        long b = S[i][j] == '#' ? 1 : 0;
        long w = S[i][j] == '.' ? 1 : 0;
        long _i = i;
        long _j = j;
        long c = S[i][j] == '#' ? 1 : 0;
        f[_i][_j] = 1;
        myfind(!c, _i, _j, f, S, &b, &w);
        // printf("%ld %ld\n", b, w);
        r += b*w;
      }
    }
  }
  printf("%ld\n", r);
  return 0;
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

int dfs(const vector<string> &s, int i, int j) {
    if (isdigit(s[i][j])) {
        return s[i][j] - '0';
    }

    int ret = (s[i][j] == '+' ? 0 : 1);
    int nj = j + 1;
    rep2(ni, i + 1, s.size()) {
        if (nj >= s[ni].size()) break;
        if (s[ni][nj] == '.') continue;
        if (s[i][j] == '+') ret += dfs(s, ni, nj);
        if (s[i][j] == '*') ret *= dfs(s, ni, nj);
    }
    return ret;
}

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

    int n;
    while (cin >> n, n) {
        vector<string> s(n);
        rep(i, n) cin >> s[i];
        cout << dfs(s, 0, 0) << endl;
    }
}

Measured memory_bytes: 3156
#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<functional>
#include<algorithm>
#include<math.h>
#include<unordered_map>
#include<string.h>
#include<limits.h>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<unordered_set>
#include<deque>
#define int long long
using namespace std;

int ans[500][500];
signed main() {
	int X, Y, x, y; cin >> X >> Y >> x >> y;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			ans[i][j] = 1;
		}
	}
	for (int i = 0; i < X; i += x) {
		for (int j = 0; j < Y; j += y) {
			ans[i][j] = pow(10, 9) - x*y + 1;
		}
	}
	for (int i = x - 1; i < X; i += x) {
		for (int j = y - 1; j < Y; j += y) {
			ans[i][j] = -pow(10, 9);
		}
	}
	int sum = 0;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			sum += ans[i][j];
		}
	}
	if (sum > 0) {
		puts("Yes");
		for (int i = 0; i < X; i++) {
			for (int j = 0; j < Y; j++) {
				if (j)cout << " ";
				cout << ans[i][j];
			}
			cout << endl;
		}
	}
	else {
		puts("No");
	}
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

int main() 
{ 
  fastio;
  file();
  int n;
  cin>>n;
  vv cnt(n+1);
  vv a(n);
  lld ans = 0;
  for (int i = 0; i < n; ++i) {
      cin >> a[i];
      ans += cnt[a[i]];
      ++cnt[a[i]];
  }
  // for(auto x:cnt){
  //   cout<<x<<" ";
  // }
  // cout<<endl;
  // for(auto x:a){
  //   cout<<x<<" ";
  // }
  // cout<<endl;
  for (int i = 0; i < n; ++i) {
      cout<<ans - cnt[a[i]] + 1 << '\n';
  }
} 


Measured memory_bytes: 4224
N = int(input())

# 1+2+3+4+...+(N-2)+(N-1)+N
# N+(N-1)+(N-2)+...+4+3+2+1
# 上と下を足し算して、２で割る

a = N+1
b = N

print(int( a * b * 0.5 ))

Measured memory_bytes: 9132
# とっかかりを掴むために、全探索で実験してみる
n = int(input())
A = list(map(int, input().split()))
boxes = [None]*(n+1)
for i in range(n, 0, -1):
    coef = 1
    tmp = 0
    while i*(coef+1) <= n:
        coef += 1
        tmp += boxes[i*coef]
    boxes[i] = A[i-1] ^ (tmp % 2)

ans = []
for idx, v in enumerate(boxes):
    if v == 1:
        ans.append(idx)

print(len(ans))
if len(ans) > 0:
    print(*ans)


Measured memory_bytes: 14140
stdin = open(0).read().rstrip().split('\n')
N = int(stdin[0])
A = []
i=1
j=-1
while i< len(stdin):
    l=[]
    index=int(stdin[i])
    l.append(index)
    i+=1
    for _ in range(index):
        l.append(list(map(int,stdin[i].split())))
        i+=1
    A.append(l)
ans = 0
for bit in range(2**N):
    s = format(bit,'b').zfill(N)
    flag = True
    for j in range(len(A)):
        if s[j] == '1':
            num = A[j][0]
            for k in range(1,num+1):
                if A[j][k][1]!=int(s[A[j][k][0]-1]):
                    flag = False
                    break
        if not flag:
            break
    if flag:
        ans = max(ans,s.count('1'))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main() {
  int n, score;
  cin >> n >> score;

  vector<vector<vector<ll>>> dp(55, vector<vector<ll>>(55, vector<ll>(2605)));

  dp[0][0][0] = 1;

  repp(i, 0, n - 1) {
    repp(j, 0, i) {
      repp(k, 0, score + 1) {
        dp[i + 1][j][k + 2 * j] += dp[i][j][k];
        dp[i + 1][j][k + 2 * j] %= MOD;
        dp[i + 1][j + 1][k + 2 * (j + 1)] += dp[i][j][k];
        dp[i + 1][j + 1][k + 2 * (j + 1)] %= MOD;
        dp[i + 1][j][k + 2 * j] += dp[i][j][k] * 2 * j;
        dp[i + 1][j][k + 2 * j] %= MOD;
        if (j > 0) {
          dp[i + 1][j - 1][k + 2 * (j - 1)] += dp[i][j][k] * j * j;
          dp[i + 1][j - 1][k + 2 * (j - 1)] %= MOD;
        }
      }
    }
  }
  cout << dp[n][0][score] << endl;
}

Measured memory_bytes: 63104
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=llint(n)
ans=0
cnt=0

for i in permutations(range(n)):
    cnt+=1
    for j in range(n-1):
        ans+=((arr[i[j]][0]-arr[i[j+1]][0])**2 + (arr[i[j]][1]-arr[i[j+1]][1])**2)**0.5

print(ans/cnt)

Measured memory_bytes: 65768
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}
ll a[55],n,k;
ll dfs(ll l,ll r){
    ll s;
	vector<ll> vec;
	for(int i=0;i<=l;i++) vec.push_back(a[i]);
	for(int i=r;i<n;i++) vec.push_back(a[i]);
	sort(vec.begin(),vec.end());
	ll maxs;
	maxs=k-vec.size();          
	if(maxs<0) return 0;
	s=0;
	for(int i=0;i<vec.size();i++){
		if(vec[i]<0&&maxs>0){
        	maxs--;
		}
		else{
			s+=vec[i];
		}
	}
	return s;
}




int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>k;
  rep(i,n){
    cin>>a[i];
  }
  ll ans=0;
  for(int i=-1;i<n;i++){
		for(int j=i+1;j<=n;j++){
        	ans=max(ans,dfs(i,j));
		}
	}
	cout<<ans<<endl;
	return 0;
}
  
  


Measured memory_bytes: 256
// E - Colorful Hats 2
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<long long> dp(n), c(n);
	for (int i = 0; i < n; i++) {
		int x = a[i];
		long long m = (x == 0 ? 3LL : c[x - 1]) - c[x];
		dp[i] = (i == 0 ? 1LL : dp[i - 1]) * m % MOD;
		c[x]++;
	}

	cout << dp[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 2176
#-*- using:utf-8 -*-

A, B, C = map(int, input().split())
K = int(input())

for _ in range(K):
    if A >= B:
        B = B*2
    elif B >= C:
        C = C*2
    else:
        C = C*2

if A < B and B < C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9116
use strict;
use warnings;

my @a;
for my $i (0..2){
  chomp(my $aaa = <>);
  my @aaa = split(" ", $aaa);
  $a[$i]=\@aaa;
}

chomp(my $n = <>);

my @hitpos= ([0, 0, 0], [0, 0, 0], [0, 0, 0]);
for my $i (0..$n-1){
  chomp(my $b = <>);
  for my $j (0..2){
    for my $k (0..2){
      if ($a[$j][$k] == $b){$hitpos[$j][$k] = 1;}
    }
  }
}

for my $i (0..2){
  if ($hitpos[$i][0] + $hitpos[$i][1] + $hitpos[$i][2] == 3
    || $hitpos[0][$i] + $hitpos[1][$i] + $hitpos[2][$i] == 3){
    print "Yes\n";
    exit;
  }
}

if ($hitpos[0][0] + $hitpos[1][1] + $hitpos[2][2] ==3
  || $hitpos[0][2] + $hitpos[1][1] + $hitpos[2][0] == 3){
  print "Yes\n";
  exit;
}

print "No\n";

Measured memory_bytes: 640
import math

S = list(map(int, open(0).read().split()))
N = S[0]
X = S[1:1+N]
Y = S[N+1:]

def calc(p):
    s = 0
    xy = [abs(X[i] - Y[i]) for i in range(N)]
    if p == 1:
        return sum(xy)
    elif p == 2:
        return sum([x ** 2 for x in xy]) ** 0.5
    elif p == 3:
        return sum([x ** 3 for x in xy]) ** (1/3)
    elif p == -1:
        return max(xy)

def show(x):
    print("{:.6f}".format(x))

show(calc(1))
show(calc(2))
show(calc(3))
show(calc(-1))



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

int main()
{
    int x, y;
    cin >> x >> y;
    if((x+y) % 2 == 0) cout << (x+y) / 2 << endl;
    else cout << (x+y) / 2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define endl "\n"

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

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N;cin >> N;
    VI T(N);
    REP(i,N) cin >> T.at(i);
    int M; cin >> M;

    ll ans = accumulate(T.begin(), T.end(), 0);

    VI P(M), X(M);

    REP(i,M)
    {
        cin >> P[i] >> X[i];
    }
    REP(i,M)
    {   
        cout << ans - T.at(P[i]-1) + X[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
   
    int n,i,t;cin>>n;
    set<int>s;
    fo(i,0,n)cin>>t,s.insert(t);
    
    if(sz(s)==n)cout<<"YES\n";
    else cout<<"NO\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 9600
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int now[202020];
int dat[202020];
int ans[202020];
int num, ret;
void add(int a)
{
	if (a + dat[a] < num)
	{
		if (ans[a + dat[a]] == 0)ret--;
		ans[a + dat[a]]++;
	}
	dat[a]++;
}
void sub(int a)
{
	dat[a]--;
	if (a + dat[a] < num)
	{
		ans[a + dat[a]]--;
		if (ans[a + dat[a]] == 0)ret++;
	}
}
int main()
{
	int query;
	scanf("%d%d", &num, &query);
	ret = num;
	for (int i = 0; i < num; i++)
	{
		scanf("%d", &now[i]);
		add(num - now[i]);
	}
	for (int i = 0; i < query; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--;
		sub(num - now[za]);
		now[za] = zb;
		add(num - now[za]);
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 3712
from bisect import bisect_left

A,B,Q=map(int,input().split())
S=[int(input()) for i in range(A)]
T=[int(input()) for i in range(B)]
for i in range(Q):
    x=int(input())
    si=bisect_left(S,x)
    ti=bisect_left(T,x)
    if 0<si<A and 0<ti<B:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sr,tr),max(sl,tl),sl+tr+min(sl,tr),sr+tl+min(sr,tl)))
    elif si==0 and ti==0:
        sr=abs(x-S[si])
        tr=abs(x-T[ti])
        print(max(sr,tr))
    elif si==A and ti==B:
        sl=abs(x-S[si-1])
        tl=abs(x-T[ti-1])
        print(max(sl,tl))
    elif si==0 and ti==B:
        sr=abs(x-S[si])
        tl=abs(x-T[ti-1])
        print(sr+tl+min(sr,tl))
    elif si==A and ti==0:
        sl=abs(x-S[si-1])
        tr=abs(x-T[ti])
        print(sl+tr+min(sl,tr))
    elif si==0:
        sr=abs(x-S[si])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sr,tr),sr+tl+min(sr,tl)))
    elif si==A:
        sl=abs(x-S[si-1])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sl,tl),sl+tr+min(sl,tr)))
    elif ti==0:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tr=abs(x-T[ti])
        print(min(max(sr,tr),sl+tr+min(sl,tr)))
    elif ti==B:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tl=abs(x-T[ti-1])
        print(min(max(sl,tl),sr+tl+min(sr,tl)))

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

int main() {
  int A;
  cin >> A;
  int C;
  vector<int> vec(A), vec2(A);
  for (int i = 0; i < A; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < A; i++) {
    cin >> vec2.at(i);
  }
  
  for(int i=0;i<A;i++){
    if(vec.at(i)>vec2.at(i)){
      C += vec.at(i)-vec2.at(i);
    }
  }
  cout << C << endl;
}


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

using namespace std;

int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;

  vector<long long> trees(N);
  for (int i = 0; i < N; ++i)
    cin >> trees[i];

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

  long long ret = 1000000000;
  for (int i = 0; i <= N - K; ++i) {
    ret = min(ret, trees[i + K - 1] - trees[i]);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 1024
def nCr(n, r):
    import math
    # nCrのr>nは組み合わせが存在しないので0を返す
    # raiseすべきのこともあるかも
    if r > n:
        return 0
    return math.factorial(n) // ((math.factorial(n - r) * math.factorial(r)))

n, m = map(int, input().split())
res = 0
if n > 1:
    res += nCr(n, 2)
if m > 1:
    res += nCr(m, 2)
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	int a,b,k,i;
	cin>>k>>a>>b;
	for( i=a;i<=b;i++)
	{
		if(i%k==0) break;
	}
	if(i==b+1) cout<<"NG\n";
	else cout<<"OK";
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void print(int n, int *a) {
    int i;
    for(i=0;i<n;i++){
        if(i)printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}

void selectionSort(int n, int *a){
    int i,j;
    int cou = 0;
    for(i=0;i<n;i++) {
        int minj=i;
        for(j=i;j<n;j++) {
            if(a[j] < a[minj])minj = j;
        }
        if(i != minj){
            swap(&a[i],&a[minj]);
            cou++;
        }
    }
    print(n,a);
    printf("%d\n",cou);
}


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

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



Measured memory_bytes: 2084
#include<stdio.h>
//#include<math.h>
int ifcl(int p0[2],int p1[2],int p2[2],int p3[2]){
  long long x0=p1[0]-p0[0],x1=p2[0]-p0[0],x2=p3[0]-p0[0],x3=x2-x1,x4=x0-x1,x5=-x1;
  long long y0=p1[1]-p0[1],y1=p2[1]-p0[1],y2=p3[1]-p0[1],y3=y2-y1,y4=y0-y1,y5=-y1;
  //long long x3=p3[0]-p2[0],x4=p1[0]-p2[0],x5=p0[0]-p2[0];
  //long long y3=p3[1]-p2[1],y4=p1[1]-p2[1],y5=p0[1]-p2[1];
  long long x6=p2[0]-p1[0],x7=p3[0]-p1[0]/*,x3=x2-x1,x4=x0-x1,x5=-x1*/;
  long long y6=p2[1]-p1[1],y7=p3[1]-p1[1]/*,y3=y2-y1,y4=y0-y1,y5=-y1*/;
  
  long long c1=(x0*y1-y0*x1)*(x0*y2-y0*x2),c2=(x3*y4-y3*x4)*(x3*y5-y3*x5);
  long long d1=x1*x6+y1*y6,d2=x2*x7+y2*y7,d3=x1*x2+y1*y2,d4=x6*x7+y6*y7;
  if(c1==0&&c2==0)return (d1>0&&d2>0&&d3>0&&d4)?0:1;
  return (c1<=0&&c2<=0)?1:0;
}
/*double dMIN(double a,double b){return a<b?a:b;}
double drpl(int p0[2],int p1[2],int p2[2]){
  int a=p0[1]-p1[1],b=p0[0]-p1[0],c=p0[0]*p1[1]-p1[0]*p0[1];
  int d=p2[1]-p1[1],e=p2[0]-p1[0];
  int f=p2[1]-p0[1],g=p2[0]-p0[0];
  if(a*d+b*e<0||a*f+b*g>0)return dMIN(hypot(d,e),hypot(f,g));
  return abs(p2[0]*a-p2[1]*b+c)/hypot(a,b);
}
double drll(int *p0,int *p1,int *p2,int *p3){
  double l=drpl(p2,p3,p0);
  l=dMIN(l,drpl(p2,p3,p1));
  l=dMIN(l,drpl(p0,p1,p2));
  l=dMIN(l,drpl(p0,p1,p3));
  if(ifcl(p0,p1,p2,p3))l=0;
  return l;
  }*/
int main(){
  int p[4][2],n,i;
  scanf("%d",&n);
  while(n--){
    for(i=0;i<8;i++)scanf(" %d",&p[i/2][i%2]);
    printf("%d\n",ifcl(p[0],p[1],p[2],p[3]));
  }
  return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;
	cin>>n;
	map<string, int> m;
	rep(i,n){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<m.size()<<endl;
	return 0;
}


Measured memory_bytes: 19100
#include <bits/stdc++.h>
using namespace std;
 
vector<int> list_of_possible_primes() {
  // 1381 is the 55th number which satisfies the requirements of this problem.
  const int SEIVE_SIZE = 1381; // 55555;
  vector<bool> seive(SEIVE_SIZE + 1, true);
  seive[0] = false;
  seive[1] = false;
  for (int i = 2; i * i <= SEIVE_SIZE; ++i) {
    for (int j = i + i; j <= SEIVE_SIZE; j += i) {
      seive[j] = false;
    }
  }
  vector<int> list;
  for (int i = 0; i <= SEIVE_SIZE; ++i) {
    if (seive[i] && i % 5 == 1) {
      list.push_back(i);
    }
  }
  return list;
}
 
int main() {
  int n;
  cin >> n;
 
  vector<int> ps = list_of_possible_primes();
 
  for (int i = 0; i < n; ++i) {
    if (i > 0) {
      cout << " ";
    }
    cout << ps[i];
  }
  cout << endl;
}

Measured memory_bytes: 3604
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap as M
import Data.Maybe (fromJust)
import Data.List

main = do
  n <- readLn :: IO Int
  input <- getInt2DListBC
  let ans = map (solve input) [1..n-1]
  putStr . unlines . map show $ ans ++ [0]

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

toNext :: Int -> [Int] -> Int
toNext now [c, s, f]
  | now < s = s + c
  | otherwise = let n = if (now - s) `mod` f == 0
                          then (now - s) `div` f
                          else (+1) $ (now - s) `div` f
                in (s + n * f + c)

solve :: [[Int]] -> Int -> Int
solve t i = let [c,s,f] = t !! (i - 1)
            in foldl toNext s $ drop (i-1) t


Measured memory_bytes: 1148
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
SS(ll,n);
SV(ll,a,n);
auto b=a;
sort(all(a));
vector<bool>ok(a[n-1]+1,true);
rep(i,n-1)if(a[i]==a[i+1])ok[a[i]]=false;
rep(i,n){
    ll point=a[i];
    while(point+a[i]<=a[n-1]){
        point+=a[i];
        ok[point]=false;
        //p(point);
    }
}
ll ans=0;
rep(i,n)if(ok[b[i]]==true)ans++;
p(ans);
}

Measured memory_bytes: 6664
n=int(input())
lists=list(map(int,input().split()))
ans =0
SUMS=0
index=0
for l in range(n):
    while index < l or index< n and SUMS ^ lists[index] == SUMS + lists[index]:
        SUMS ^= lists[index]
        index+= 1
    ans += index-l
    SUMS ^= lists[l]
print(ans)

Measured memory_bytes: 77772
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
graph = []
for i in range(1, n):
    for j in range(i + 1, n + 1):
        graph.append([i, j])
if n % 2 == 0:
    for i in range(n // 2):
        graph.remove([i + 1, n - i])
else:
    for i in range(n // 2):
        graph.remove([i + 1, n - i - 1])
print(len(graph))
for ans in graph:
    print(*ans)


Measured memory_bytes: 4124
(function(stdin) {
  var lines = stdin.trim().split('\n');
  var n = parseInt(lines.shift(), 10);
  var nodes = [];
  var color = [];
  var d = [];
  lines.forEach(function(node) {
    var adjs = node.split(' ').map(Number).slice(2);
    nodes.push(adjs);
    color.push('WHITE');
    d.push(-1);
  });
  var queue = [];
  color[0] = 'GRAY';
  d[0] = 0;
  queue.push(1);
  while (queue.length > 0) {
    var i = queue.shift();
    nodes[i - 1].forEach(function(j) {
      if (color[j - 1] == 'WHITE') {
        color[j - 1] = 'GRAY';
        d[j - 1] = d[i - 1] + 1;
        queue.push(j);
      }
    });
  }
  d.forEach(function(dist, i) {
    console.log([i + 1, dist].join(' '));
  });
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 15664
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if (Character.isUpperCase(a.charAt(0))) {
      System.out.println("A");
    } else {
      System.out.println("a");
    }
    sc.close();
  }
}

Measured memory_bytes: 35688
import math

N = int(raw_input())
S = [raw_input() for _ in range(N)]
D = {}
for s in S:
    k = "".join(sorted(s))
    if k not in D:
        D[k] = []
    D[k].append(s)

ans = 0
for k,v in D.items():
    n = len(v)
    if n > 1:
        ans += math.factorial(n) / (2 * math.factorial(n-2))
print ans

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

void bubbleSort(vector<pair<char, int> > &a, int n){
	for(int i = 0; i < n; i++) {
		for(int j = n - 1; j >= i + 1; j--) {
			if(a[j].second < a[j-1].second)
				swap(a[j], a[j-1]);
		}
	}
	for(int i = 0; i < n - 1; i++)
		cout << a[i].first << a[i].second << " ";
	cout << a[n-1].first << a[n-1].second << endl;
}

void selectionSort(vector<pair<char, int> > &a, int n){
	for(int i = 0; i < n; i++) {
		int minv = i;
		for(int j = i; j < n; j++) {
			if(a[j].second < a[minv].second)
				minv = j;
		}
		swap(a[i], a[minv]);
	}
	for(int i = 0; i < n - 1; i++)
		cout << a[i].first << a[i].second << " ";
	cout << a[n-1].first << a[n-1].second << endl;
}

int main(){
	int n;
	scanf("%d", &n);
	int q;
	char s;
	vector<pair<char, int> > a, b;
	for(int i = 0; i < n; i++) {
		cin >> s >> q;
		a.emplace_back(s, q);
	}
	b = a;
	bubbleSort(a, n);
	printf("Stable\n");
	selectionSort(b, n);
	if(a == b) printf("Stable\n");
	else printf("Not stable\n");
}



Measured memory_bytes: 3160
n = int(input())
t = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
result = 1
for i in range(n):
    h_max, h_min = min(t[i], a[i])+1, 1
    if i != 0:
        if t[i-1] < t[i]:
            h_min = t[i]
    else:
        h_min = t[0]

    if i != n-1:
        if a[i] > a[i+1]:
            h_min = max(a[i], h_min)
    else:
        h_min = max(a[i], h_min)
    result = result * max(h_max - h_min, 0) % (10**9+7)
print(result)

Measured memory_bytes: 19136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;

int d[11][11];

int main(){
    int h,w;
    cin >> h >> w;
    rep(i,10){
        rep(j,10){
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < 10;i++){
        for (int j = 0; j < 10;j++){
            for (int k = 0;k < 10;k++){
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
    int ans = 0;
    for (int i= 0;i < h;i++){
        for (int j = 0;j < w;j++){
            int tmp;
            cin >> tmp;
            if (tmp == -1) continue;
            else ans +=d[tmp][1];
        }
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
from collections import Counter


N = int(input())
a = Counter(map(lambda x: min(8, int(x) // 400), input().split()))
super_coders = a.pop(8, 0)
mn = len(a)
if mn == 0 and super_coders:
    mn = 1
mx = len(a) + super_coders
print(mn, mx)


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

const ll mod = 998244353;

vector<ll> fac(300001); //n!(mod mod)
vector<ll> ifac(300001); //k!^{M-2} (mod mod)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod mod) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

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

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % mod; // n!(mod mod)
        ifac[i+1] = ifac[i]*mpow(i+1, mod-2) % mod; // k!^{mod-2} (mod mod) ←累乗にmpowを採用
    }

    ll ans = 0;
    for (int i = 0; i <= K; i++){
        ll c = M * mpow(M-1, N-1-i);
        c %= mod;
        c *= comb(N-1, i);
        c %= mod;
        ans += c;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7904
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second


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

const ll MOD = 1e9+7;
const int INF = numeric_limits<int>::max();

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

	int n; cin >> n;
	vector<vi> dp(n+1, vi(3, 0));
	for(int i = 1; i <= n; i++){
		cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
		if(i == 1) continue;
		for(int k = 0; k < 3; k++){
			int maxi = 0, idx;
			for(int j = 0; j < 3; j++){
				if(k == j) continue;
				if(dp[i-1][j] > maxi){
					maxi = dp[i-1][j];
					idx = j;
				}
			}
			dp[i][k] += dp[i-1][idx];
		}
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';

	return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
int n;
int tot;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int a;
		scanf("%d", &a);
		if(a % 2 == 1)tot++;
	}
	if(tot % 2 == 0)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

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

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll N, K;
ll h[100000];

void init()
{
}

void solve()
{
    ll ret = LINF;
    sort(h, h+N);
    REP(i, N-K+1){
        ret = min(ret, h[i+K-1]-h[i]);
    }
    cout << ret << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i, N){
        cin >> h[i];
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int gcd(int a, int b) {
  while (b) {
    int x = a;
    a = b;
    b = x % b;
  }
  return a;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ans += gcd(i, gcd(j , k));
      }
    }
  }
  cout << ans;
  return 0;
}

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

ll N , M ;
cin >> N >> M ;
int ans = 0 ;
  while( N <= M ){
    ans++;
    N = N*2 ;
  }
  cout << ans << endl; 
}

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

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

	int N; cin >> N;
	ll a[210000];
	bool d[210000];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	ll sum = 0;
	ll ans = 0;
	ll cnt, cnt2;
	fill(d, d + 210000, false);

	for (int i = 0; i < N; i++) {
		cnt = 1;
		cnt2 = 0;
		int p = i-1;
		sum = a[i];
		d[i] = true;
		while (p >= 0 && (sum + a[p]) == (sum ^ a[p])) {
			if (d[p] == false)d[p] = true;
			else cnt2++;
			cnt++;
			sum += a[p];
			p--;
		}
		while (i + 1 < N && (sum + a[i + 1]) == (sum ^ a[i + 1])) {
			i++;
			d[i] = true;
			cnt++;
			sum += a[i];
		}
		ans += cnt * (cnt + 1) / 2 - cnt2 * (cnt2 + 1) / 2;
	}
	cout << ans;
}

Measured memory_bytes: 2048
def decoder(s):
    ret = [0] * 26
    for c in s:
        ret[ord(c) - ord('a')] += 1
    return str(ret)
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    count = decoder(s)
    if count in dic:
        dic[count] += 1
    else:
        dic[count] = 1
ans = 0
for i, c in dic.items():
    ans += c * (c-1) // 2
print(ans)

Measured memory_bytes: 23652
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, K;
  vector<int> neg, pos;

  scanf("%d%d", &N, &K);

  for (int i = 0; i < N; i++) {
    int A;
    scanf("%d", &A);
    if (A < 0)
      neg.push_back(A);
    else
      pos.push_back(A);
  }

  sort(neg.begin(), neg.end());
  sort(pos.rbegin(), pos.rend());

  if (pos.size() == 0) {
    ll ans = 1;
    if (K % 2 == 1) {
      reverse(neg.begin(), neg.end());
    }
    for (int i = 0; i < K; i++)
      ans = ans * (mod + neg[i]) % mod;

    cout << ans << endl;
    return 0;
  }

  ll ans = 1;
  int s = 0, t = 0;

  if (K % 2) {
    ans = pos[s++];
    K--;
  }

  for (int i = 0; i < K / 2; i++) {
    ll A = s + 1 < pos.size() ? (ll)pos[s] * pos[s + 1] : 0;
    ll B = t + 1 < neg.size() ? (ll)neg[t] * neg[t + 1] : 0;

    if (s + 1 == pos.size() && t + 1 == neg.size()) {
      ans = ans * pos[s] % mod * (mod + neg[t]) % mod;
    } else if (A > B) {
      ans = ans * (A % mod) % mod;
      s += 2;
    } else {
      ans = ans * (B % mod) % mod;
      t += 2;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4264
from scipy.special import comb
N,M = input().split()
N = int(N)
M = int(M)

A = 0
B = 0
if N >= 2 :
  A = comb(N, 2, exact=True)

if M >= 2 :
  B = comb(M, 2, exact=True)
 
print(A + B)

Measured memory_bytes: 42248
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int gcd(int a, int b){
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}

int main(){
    int N; cin >> N;
    vector<pair<int, PII>> V(N);
    for(int i=0; i<N; i++){
        int a, b; cin >> a >> b;
        V[i] = pair<int, PII>(a+b, PII(a, b));
    }
    
    sort(V.begin(), V.end(), greater<pair<int, PII>>());
    ll s1 = 0;
    ll s2 = 0;
    int c = 0;
    
    while (1) {
        s1 += V[c].second.first;
        c++;
        if(c==N) break;
        s2 += V[c].second.second;
        c++;
        if(c==N) break;
    }
    cout << s1 - s2 << endl;
    return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if (a < b)
            {
                Console.WriteLine("a < b");
            } else if(a > b){
                Console.WriteLine("a > b");
            }else{
                Console.WriteLine("a == b");
            }

            
           
         

        }
    }
}

Measured memory_bytes: 13428
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
//#define mod   1000000000
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p, int mod)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}



//=============================================ASIFAZAD==============================================//


int32_t main()
{
    io;
    string s;
    int n, p;
    cin>>n>>p>>s;
    if(p == 2 || p == 5)
    {
        ll ans = 0;
        for(int i =0 ; i< n;i++)
            if((s[i] - '0')%p == 0)
                ans += i+1;
        cout<<ans;
        return 0;
    }
    vi cnt(p), modul;
    int am = 0;
    for(int i =0 ; i< n; i++)
    {
        am = (am * 10%p + (s[i] - '0')%p)%p;
        modul.pb(am);
    }

    for(int i = 0; i< n; i++)
        cnt[modul[i]*bigmod(10, n-1-i, p)%p]++;

    cnt[0]++;
    ll ans = 0;
    for(auto x: cnt)
        if(x >= 2)
            ans += 1LL*x*(x-1)/2;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 4496
#include <stdio.h>

int main(){
    int x;
    scanf("%d", &x);
    if(x>=400&&x<600){
        printf("%d", 8);
    }else if(x>=600&&x<800){
        printf("%d", 7);
    }else if(x>=800&&x<1000){
        printf("%d", 6);
    }else if(x>=1000&&x<1200){
        printf("%d", 5);
    }else if(x>=1200&&x<1400){
        printf("%d", 4);
    }else if(x>=1400&&x<1600){
        printf("%d", 3);
    }else if(x>=1600&&x<1800){
        printf("%d", 2);
    }else if(x>=1800&&x<2000){
        printf("%d", 1);
    }
    return 0;
}

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

using namespace std;



int main(){

	int i=0,n,k;
	double tot=0;
	vector<long long int>pot2;
	pot2.push_back(1);

	while(pot2[i]<5000000){
		pot2.push_back(pot2[i++]*2);
	}

	cin >> n >> k;
	double val;
	for(i=1;i<=n;i++){
		int cont=0;
		val = i; 
		while(val*pot2[cont]<k){
			cont++;
		}
		val = (1.0/n) * pow(0.5,cont);
		tot+=val;
	}
		printf("%.09lf\n", tot); 
	return 0;
}

Measured memory_bytes: 256