akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

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

// ----------------------------------------------------------

int main() {
    string s,t;
    cin >> s >> t;
    vector<set<ll>> alfa_set(26);

    const ll A = ctoi('a');
    rep(i, s.length()) {
        ll key = ctoi(t[i]) - A;
        ll val = ctoi(s[i]) - A;
        alfa_set[key].insert(val);
    }

    vector<bool> is_used(26, false);
    ll count = 0;
    for (const auto& v : alfa_set) {
        if (v.size() > 1) {
            cout << "No" << endl;
            return 0;
        }
        for (const auto& s : v) {
            //cout << count << ", " << s << endl;
            if (is_used[s]) {
                cout << "No" << endl;
                return 0;
            }
            is_used[s] = true;
        }
        ++count;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
package main

import (
	"fmt"
)

const (
	mod = int64(1000000007)
)

func modpow(x int64, y int64) int64 {
	if y == 0 {
		return 1
	} else if y == 1 {
		return x
	} else if y%2 != 0 {
		return x * modpow(x, y-1) % mod
	}
	t := modpow(x, y/2)
	return t * t % mod
}

func calc(l string) int64 {
	length := int64(len(l))

	if l == "0" {
		return int64(1)
	} else if l == "1" {
		return int64(3)
	}

	var sum int64

	// length-1 桁まで
	sum += modpow(3, length-1) % mod

	var found bool
	for i := int64(1); i < length; i++ {
		if l[i] == '1' {
			found = true
			sum += 2 * calc(l[i:]) % mod
			break
		}
	}
	if !found {
		sum += 2
	}

	return sum % mod
}

func main() {
	var l string
	fmt.Scan(&l)

	fmt.Println(calc(l))
}


Measured memory_bytes: 28800
#include <stdio.h>
#include <math.h>
int main(void){
    int n,m,i,k=0;
    int s[100];
    scanf("%d",&n);
    do{
      m = abs(n)%2;
      s[k] = m;
      n = (n-m)/(-2);
      k++;
    }while(n!=0);
    for(i=k-1;i>=0;i--){
      printf("%d",s[i]);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n,k;
   cin>>n>>k;

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

   for(long int i = k; i < n; i++){
      if(v[i] > v[i - k])
        cout<<"Yes\n";
      else
        cout<<"No\n";
   }
   return 0;
}

Measured memory_bytes: 4764
#include <stdio.h>

int abs(int a);

int main(void)
{
	int n, t, x, y, tt, xx, yy;
	int i;

	scanf("%d%*c", &n);

	t = 0; x = 0; y = 0;

	for(i=0;i<n;i++) {
		int dist, dt;

		scanf("%d %d %d%*c", &tt, &xx, &yy);
		dist = abs(xx-x) + abs(yy-y);
		dt = tt - t;

		if(dist > dt) {
			printf("No\n");
			return 0;
		} else if((dt - dist) % 2) {
			printf("No\n");
			return 0;
		}

		t = tt; x = xx; y = yy;
	}

	printf("Yes\n");
	
	return 0;
}

int abs(int a)
{
	if(a) return a;
	return -a;
}


Measured memory_bytes: 128
// ARC095A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 200;

typedef pair<int, int> pii;

int n, ans[MAX_N];
pii seq[MAX_N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &seq[i].first), seq[i].second = i;
    sort(seq + 1, seq + 1 + n);
    for (int i = 1; i <= n; i++)
    {
        int idx = n >> 1;
        if (i <= idx)
            ans[seq[i].second] = seq[idx + 1].first;
        else
            ans[seq[i].second] = seq[idx].first;
    }
    for (int i = 1; i <= n; i++)
        printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 4480
#include<stdio.h>
int main(void)
{
  int a,b,c,num;
  int x[]={a,b,c};
  for(int i=0;i<sizeof(x)/sizeof(x[0]);i++){
    scanf(" %d ",&x[i]);
  }
  if((x[0]<=x[1])&&(x[1]<=x[2])){
    printf("%d %d %d\n",x[0],x[1],x[2]);
  }else if((x[0]>x[1])&&(x[1]<=x[2])){
    if(x[0]>x[2]){
      num=x[0];
      x[0]=x[1];
      x[1]=x[2];
      x[2]=num;
      printf("%d %d %d\n",x[0],x[1],x[2]);
    }
  }else if((x[0]>x[1])&&(x[1]>=x[2])){
    num=x[0];
    x[0]=x[2];
    x[2]=num;
    printf("%d %d %d\n",x[0],x[1],x[2]);
  }else if((x[0]<x[1])&&(x[1]>x[2])){
    if(x[0]>=x[2]){
      num=x[0];
      x[0]=x[2];
      x[2]=x[1];
      x[1]=num;
      printf("%d %d %d\n",x[0],x[1],x[2]);
    }
  }
  return 0;
}   
 
  


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

#define Need_For_Speed ios_base::sync_with_stdio;cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair

#define sz size
#define bg begin
#define en end

#define fe first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e6 + 17, maxN = 4 * N, darr = 1e3 + 17, mod = 1e9 + 7;

ll q, h, s, d, n;

int main () {
	Need_For_Speed;
	cin >> q >> h >> s >> d >> n;
	cout << (n / 2) * 1ll * min(min(q * 1ll * 8, h * 1ll * 4), min(s + s, d)) + (n % 2) * 1ll * min(min(q * 1ll * 4, h + h), s);
	return 0;
}

Measured memory_bytes: 256
H, W, A, B=map(int, input().split())
mat=[[0 for j in range(W)] for i in range(H)]
for i in range(B):
  for j in range(A):
    mat[i][j]=1
for i in range(B, H):
  for j in range(A, W):
    mat[i][j]=1
for i in range(H):
  print("".join(str(e) for e in mat[i]))

Measured memory_bytes: 13812
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 

 
const long double pi = 3.14159265358979323846;

using lld = long double;

lld rad(lld x) {
  return pi * x / 180;
}

void solve() {
  lld x, y; cin >> x >> y;
  lld n, m; cin >> n >> m;

  lld hrot = (n * 60 + m) / 720;
  lld mrot = m / 60;

  lld ha = 450 - hrot * 360, ma = 450 - mrot * 360;
  // cout << ha << " " << ma << endl;

  // cout << cos(ha) * x << " " << cos(ma) * y << " " << sin(ha) * x << " " <<  sin(ma) * y << endl;

  lld a = hypot(cos(rad(ha)) * x - cos(rad(ma)) * y, sin(rad(ha)) * x - sin(rad(ma)) * y);

  cout << setprecision(15) << fixed << a << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
////////////////////////////////////////////////
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    long long ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] < a[i - 1])
        {
            ans += a[i - 1] - a[i];
            a[i] += (a[i - 1] - a[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4016
#!/usr/bin/python
#-- coding=utf8



def exchangeData(A, it1, it2):
    tmp = A[it1]
    A[it1] = A[it2]
    A[it2] = tmp


def partition(A, p, r):
    x=A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i = i+1
            exchangeData(A, i, j)

    exchangeData(A, i+1, r)
    return i+1


def print_partitionData(A, part_index):
    for i, s in enumerate(A):
        if i !=0:
            print(" ", end= "")

        if i==part_index :
            print ("[{}]".format( s), end="")
        else:
            print (s, end="")
    print("")

        
def inputData():
    data = map(int, input().split())
    return list(data)

if __name__ == "__main__" :
    input()
    A = inputData()
    part_index = partition(A, 0, len(A)-1)
    print_partitionData(A, part_index)




Measured memory_bytes: 16392
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (10005)

using namespace std;

struct edge{ int nt,to; }g[N];

int head[N],p[N],f[N],t[N],tmp[N],fg,n,num;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}

il void insert(RG int from,RG int to){
  g[++num]=(edge){head[from],to},head[from]=num; return;
}

il void dfs(RG int x){
  RG int sum=0,res=1<<30;
  for (RG int i=head[x];i;i=g[i].nt){
    dfs(g[i].to),sum+=f[g[i].to]; if (!fg) return;
  }
  for (RG int j=1;j<=p[x];++j) tmp[j]=0; tmp[0]=1;
  for (RG int i=head[x],v;i;i=g[i].nt){
    v=g[i].to;
    for (RG int j=0;j<=p[x];++j) t[j]=tmp[j],tmp[j]=0;
    for (RG int j=0;j<=p[x];++j){
      if (!t[j]) continue;
      if (j+p[v]<=p[x]) tmp[j+p[v]]=1;
      if (j+f[v]-p[v]<=p[x]) tmp[j+f[v]-p[v]]=1;
    }
  }
  for (RG int j=p[x];j>=0;--j) if (tmp[j]){ res=j; break; }
  if (res>p[x]) fg=0; else f[x]=p[x]+sum-res; return;
}

int main(){
  n=gi(),fg=1;
  for (RG int i=2;i<=n;++i) insert(gi(),i);
  for (RG int i=1;i<=n;++i) p[i]=gi(); dfs(1);
  puts(fg?"POSSIBLE":"IMPOSSIBLE"); return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll dp[13];
ll ndp[13];
string s;

int main()
{
    ios_base::sync_with_stdio(0);
    for (int i = 0; i < 13; i++)
        dp[i] = 0;
    dp[0] = 1;

    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 0; j < 13; j++)
            ndp[j] = 0;

        for (int j = 0; j <= 9; j++)
        {
            if (s[i] != '?' && j != (s[i] - '0')) continue;
            for (int k = 0; k < 13; k++)
            {
                int nk = (k * 10 + j) % 13;
                ndp[nk] = (ndp[nk] + dp[k]) % MOD;
            }
        }

        for (int j = 0; j < 13; j++)
            dp[j] = ndp[j];
    }
    cout << dp[5] << "\n";
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
  int K, S;
  cin >> K >> S;
  
  int cnt = 0;
  
  for (int x=0; x<=K; ++x)
  {
    for (int y=0; y<=K; ++y)
    {
      const int z = S - (x + y);
      if ((0 <= z) && (z <= K))
      {
        ++cnt;
      }
    }
  }
  
  cout << cnt << endl;
}


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

using namespace std;

struct edge {
    int to;
    int cost;
    edge(int a, int b) : to(a), cost(b) {}
};

vector<vector<edge>> e;
int N;

pair<int, int> dfs(int p, int par = -1)
{
    if (e[p].size() == 1 && par >= 0) return make_pair(0, p);
    pair<int, int> res = make_pair(0, -1);
    for (auto x : e[p]) {
        if (x.to == par) continue;
        auto t = dfs(x.to, p);
        t.first += x.cost;
        res = max(res, t);
    }
    return res;
}

int main()
{
    cin >> N;
    e.resize(N);
    for (int i = 0; i < N-1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        e[s].emplace_back(t, w);
        e[t].emplace_back(s, w);
    }
    auto res = dfs(0);
    res = dfs(res.second);
    cout << res.first << endl;
}


Measured memory_bytes: 15924
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

typedef double R;
typedef complex<R> P;
R const eps = 1e-8;
R const pi = acos(-1);

int main(){
    int n;
    while(cin>>n && n){
        vector<P> ps(n);
        rep(i,n){
            R x,y; cin >> x >> y;
            ps[i] = P(x,y);
        }
        int ans = 1;
        rep(i,n)rep(j,i){
            P & p = ps[i];
            P & q = ps[j];
            R d = abs(p-q)/2;
            if(d+eps > 1.0) continue;
            P m = (p+q)/R(2);
            R l = sqrt(1-d*d);
            P c = m + (p-m)/d*l*P(0,1);
            int cnt = 0;
            rep(k,n){
                if(abs(c-ps[k]) < 1.0+eps) cnt++;
                if(n-k+cnt+1 < ans) break;
            }
            ans = max(ans,cnt);
            if(ans==n) goto END;
        }
    END:;
        cout << ans << endl;
    }
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=1<<17;
int n,m,a[17],f[N],fac[N],inv[N],sum[N];
int C(int a,int b){if(a<b)return 0;return 1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	fac[0]=1;for(int i=1;i<=(1<<n);i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;for(int i=2;i<=(1<<n);i++)inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for(int i=2;i<=(1<<n);i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
	sort(a+1,a+m+1);
	f[0]=1;
	for(int i=m;i;i--)
	for(int S=(1<<n)-1;~S;S--)
	for(int j=0;j<n;j++)
	if(S&(1<<j))
	f[S]=(f[S]+1ll*f[S^(1<<j)]*C((1<<n)-a[i]-S+(1<<j),(1<<j)-1)%mod*fac[1<<j])%mod;
	int ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		int cur=1ll*f[i]*fac[(1<<n)-i-1]%mod;
		if(__builtin_popcount(i)&1)ans=(ans-cur+mod)%mod;
		else ans=(ans+cur)%mod;
	}
	ans=1ll*ans*(1<<n)%mod;
	printf("%d",ans);
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <limits.h>
int n;
long long mmin = LLONG_MAX;
long long su[220000], ar[220000];
long long abs(long long a)
{
	return a > 0 ? a : -a;
}
long long min(long long a, long long b)
{
	return a > b ? b : a;
}
int main()
{
	scanf("%d", &n);
	scanf("%lld", &ar[0]);
	su[0] = ar[0];
	for (int i = 1; i < n; i++)
	{
		scanf("%lld", &ar[i]);
		su[i] = ar[i] + su[i - 1];
	}
	for (int i = 0; i < n-1; i++)
	{
		//printf(">%d: %lld %lld\n", i, su[n - 1] - su[i], su[i]);
		mmin = min(abs(su[n - 1] - su[i]-su[i]), mmin);
	}
	printf("%lld\n", mmin);
}

Measured memory_bytes: 3328
n=int(input())
dic={}
d=[list(map(int,input().split())) for i in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        if (d[i][0]-d[j][0],d[i][1]-d[j][1]) in dic:
            dic[(d[i][0]-d[j][0],d[i][1]-d[j][1])]+=1
            dic[(d[j][0]-d[i][0],d[j][1]-d[i][1])]+=1
        else:
            dic[(d[i][0]-d[j][0],d[i][1]-d[j][1])]=1
            dic[(d[j][0]-d[i][0],d[j][1]-d[i][1])]=1
ans=0
for i in dic.values():
    ans=max(ans,i)
print(n-ans)

Measured memory_bytes: 3444
//By UditDesai
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define trav(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define nl cout<<'\n'
#define sp <<' '<<
#define sz(a) (int)(a.size())
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int N=1e5+5,MOD=1e9+7;
const ld EPS = 1e-9;
 
 
int main()
{
	fastio;
	ll i,j,n;
	cin>>n;
	ll h[n+1];
	forsn(i,1,n+1) cin>>h[i];
	ll dp[n+1][3];
	dp[1][1] = dp[1][2] = 0;
	dp[2][1] = dp[2][2] = abs(h[1]-h[2]);
	forsn(i,3,n+1)
	{
		forsn(j,1,3)
		{
			dp[i][j] = min(dp[i-j][1],dp[i-j][2]) + abs(h[i-j]-h[i]);
		}
	}
	cout<<min(dp[n][1],dp[n][2]);
	return 0;
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = 1; i <= 3; i++)
  {
    if (i != A && i != B)
      ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int a[200010];
bool can[1000010];
bool used[1000010];
int n;
int main()
{
	memset(can,false,sizeof(can));
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
	}
	zero(used);
	rep(i,n)
	{
		if(used[a[i]]==1) can[a[i]]=1;
		used[a[i]]=1;
		if(can[a[i]]==0)
		{
			for(int j=2*a[i];j<=1000000;j+=a[i])
			{
				can[j]=1;
			}
		}
	}
	int ans=0;
	rep(i,n)
	{
		if(!can[a[i]]) ans++; 
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6364
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,k,*a = map(int,read().split())

from itertools import accumulate

if k >= 100:
    print(*[n]*n)

else:
    for _ in range(k):
        na = [0]*n
        for i,ai in enumerate(a):
            na[max(0,i-ai)] += 1
            if i+ai+1 < n:
                na[i+ai+1] -= 1
        a = accumulate(na)

    print(*list(a))





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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 52

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[MAXN] ;

int main() {
    int n , hi = -100000000 , lo = 10000000, id1 , id2;
    scanf("%d" ,&n) ;
    vector <pii> ans ;
    for(int i = 0 ;i<n ;i++){
        scanf("%d" ,&a[i]) ;
        if(a[i] > hi){
            hi= a[i] ;
            id1 = i+1 ;
        }
        if(a[i]<lo){
            lo =a[i] ;
            id2 = i+1 ;
        }
    }

    if(abs(hi)>=abs(lo)) {
        for(int i = 1 ;i<=n ;i++) ans.pb(mp(id1 , i)) ;
        for(int i = 1 ; i<=n-1 ; i++) ans.pb(mp(i, i+1)) ;

    }
    else {
        for(int i = 1 ;i<=n ;i++) ans.pb(mp(id2 , i)) ;
        for(int i =n-1 ; i>=1 ;i--)ans.pb(mp(i+1 , i)) ;
    }

    id1 = 2*n - 1 ;
    printf("%d\n" , id1) ;
    for(int i =0 ; i<id1 ; i++)
        printf("%d %d\n" , ans[i].first , ans[i].second) ;

    return 0 ;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N;
  char c;
  cin >> N;
  int ans = 0;
  for(int i = 0; i < N; i++){
  	if(i == 0){
  		cin >> c;
  		ans++;
  	}
  	else{
  		char newc;
  		cin >> newc;
  		if(newc != c){
  			ans++;
  		}
  		c = newc;
  	}
  }
  cout << ans << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
class SegmentTree():

    def __init__(self,init_val,n,func): #init_valは長さnの配列 O(2*n)
        self.unit=0
        self.size=pow(2,n-1).bit_length() #n以上の最小の2のべき乗
        self.seg=[self.unit]*2*self.size #セグメントツリー本体
        self.f=func #セグ木により異なる関数
        
        for i in range(n):
            self.seg[i+self.size-1]=init_val[i] 
        
        for i in range(self.size-2,-1,-1):
            self.seg[i]=self.f(self.seg[2*i+1],self.seg[2*i+2])
    
    def update(self,k,x): #k番目の要素をxに変更する O(logN)
        k+=self.size-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=self.f(self.seg[2*k+1],self.seg[2*k+2])
    
    def query(self,p,q): #[p,q)のクエリに答える　半開区間であることに注意 O(logN)
        if q<=p:
            return self.unit

        p+=self.size-1
        q+=self.size-2
        res=self.unit

        while q-p>1:

            if (p&1)==0:
                res=self.f(res,self.seg[p])

            if (q&1)==1:
                res=self.f(res,self.seg[q])
                q-=1
            p//=2
            q=(q-1)//2
        
        if p==q:
            res=self.f(res,self.seg[p])
        else:
            res=self.f(self.f(res,self.seg[p]),self.seg[q])
        
        return bin(res).count('1')

def main():
    n=int(input())
    s=input()

    dic={i:j for i,j in zip('abcdefghijklmnopqrstuvwxyz',[2**i for i in range(26)])}
    l=[0]*n

    for i in range(n):
        l[i]=dic[s[i]]
    
    def f(x,y):
        return x|y

    st=SegmentTree(l,n,f)
    
    q=int(input())
    for _ in range(q):
        a=list(map(str,input().split()))
        a[0]=int(a[0])

        if a[0]==1:
            a[1]=int(a[1])
            st.update(a[1]-1,dic[a[2]])
        
        else:
            a[1]=int(a[1])-1
            a[2]=int(a[2])
            print(st.query(a[1],a[2]))
            
if __name__=='__main__':
    main()



Measured memory_bytes: 31384
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(void){
    int a,b[2000],c=0;
    cin>>a;
    for(int i=0;i<a*2;i++){
        cin>>b[i];
    }
    for(int i=0;i<a*2;i=i+2){
        c=b[i+1]-b[i]+1+c;
    }
    cout<<c<<endl;
}

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

int main()
{
	int n,m,j,k,i,T;
	int a,b;
	while (cin>>a>>b)
	{
		if (b%a==0)
		cout<<a+b<<endl;
		else
		cout<<b-a<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b;
  cin >> a >> b;
  a *= b;
  if (a % 2) cout << "Odd" << endl;
  else cout << "Even" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
tasks = []
for i in range(n):
    aa,ba = map(int,input().split())
    tasks.append([aa,ba])

tasks = sorted(tasks, key=lambda x: x[1])

now = 0
ok = 1
for i in range(n):
    now += tasks[i][0]
    #print(now,tasks[i][1])
    if now > tasks[i][1]:
        ok = 0

if ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 86488
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000000 + 7;
const ll INF = 99999999;
const ll MAX_V = 105;
const double EPS = 10e-8;
const double PI = 3.14159265359;

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a>b)cout << a-1 << endl;
    else cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll K;
    cin >> N >> K;
    int M = 61;
    vvec<int> ne(M,vec<int>(N));
    vec<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
        ne[0][i] = A[i];
    }
    for(int k=1;k<M;k++){
        for(int i=0;i<N;i++){
            ne[k][i] = ne[k-1][ne[k-1][i]];
        }
    }
    ll now = 0;
    for(int k=M-1;k>=0;k--){
        if(K>=(1LL<<k)){
            K -= 1LL<<k;
            now = ne[k][now];
        }
    }
    cout << now+1 << "\n";

}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

void solve() {
	int l; cin >> l;
	vector<pair<pair<int, int>, int>> ans;

	for(int i = 2; i < 20; i++) {
		ans.push_back({ {i, i + 1}, 0 });
		ans.push_back({ {i, i + 1}, 1 << (19 - i) });
	}

	int w = 0;
	while(l >= 262144) {
		ans.push_back({ {1, 2}, w });
		w += 262144;
		l -= 262144;
	}
	for (int i = 2; i <= 20; i++) {
		if (l >> (20 - i) & 1) {
			ans.push_back({ {1, i}, w });
			w += 1 << (20 - i);
		}
	}

	cout << 20 << " " << ans.size() << endl;
	rep(i, ans.size()) cout
		<< ans[i].first.first << " "
		<< ans[i].first.second << " "
		<< ans[i].second << endl;
}

int main() {

	solve();

	return 0;
}


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

using namespace std;

int main(void){
int a[3];
for(int i = 0; i < 3; ++i) cin >> a[i];
sort(a, a + 3);
cout << a[0] << " " << a[1] << " "<< a[2] << endl;
    return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    while(true){
        ll a,d,n; cin >> a >> d >> n;
        if(a==0 && d==0 && n==0) break;
        int cnt = 0;
        while(true){
            if(IsPrime(a)) cnt++;
            if(cnt==n) break;
            a += d;
        }
        cout << a << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;

int N; vector<ll> A;
void input()
{
    cin>>N;
    for(int i=0;i<N;++i){
        ll a; cin>>a; A.emplace_back(a);
    }
}

void solve()
{
    sort(A.begin(),A.end(),greater<ll>());
    ll ans=0;
    map<ll,int> M;
    M[A[0]]++;
    for(int i=1;i<N;++i){
        ans+=M.rbegin()->first;
        M[M.rbegin()->first]--;
        if(M.rbegin()->second==0) M.erase(M.rbegin()->first);
        M[A[i]]+=2;
        // cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 11188
#include<bits/stdc++.h>
using namespace std;
const int INF=2E9;

int main(){
    int N;
    cin >> N;
    int res=N;
    for(int i=0;i<=N;i++){
        int cnt=0;
        int t=i;
        while(t>0) cnt+=t%6, t/=6;
        t=N-i;
        while(t>0) cnt+=t%9, t/=9;
        res=min(res,cnt);
    }
    cout << res <<endl;
    return 0;
}


Measured memory_bytes: 256
// tzl ak IOI! 

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}

template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }

template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }

template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }

template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }

#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif

void TZL();

void RANK1();

#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI

	TZL();
	RANK1();

#define tzl return
#define caisi 0
#define myy ;
	tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}

//---------------------------head----------------------------

int n;
LL T, t, lst, ans;

void TZL()
{
	scf(n, T);
	lst = 0;
	forn(i, 1, n)
	{
		scf(t);
		if(t <= lst) ans += t + T - lst, lst = t + T;
		else ans += T, lst = t + T;
	}
	printf("%lld\n", ans);
}

void RANK1()
{
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	int K;
	cin >> N >> K;
	vector<int>x(N);
	int sum = 0;
	rep(i, N) {
		cin >> x[i];
		sum += min(x[i], K - x[i])*2;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();		
		Map<String,Long> m = new HashMap<>();
		long result = 0L;
		char[] tmp = new char[10];		
		for(int i = 0; i < n; i++) {
			tmp = next().toCharArray();
			Arrays.sort(tmp);
			String tmps = new String(tmp);
			if(m.containsKey(tmps)) {
				m.put(tmps, m.get(tmps) + 1L);
			}else {
				m.put(tmps, 1L);
			}
		}
		
		for(String key:m.keySet()) {
			long v = m.get(key);
			if(v > 1) {
				result += v * (v - 1) / 2;
			} 
		}
		
		System.out.println(result);
	}

 
	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}
 
	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 45044
#include <iostream>
#include <set>
#include <string>
#include <algorithm>

using namespace std;

int n;
string w[101]; 

int main(){
	cin >> n;
	cin >> w[0];
	set<string> val;
	val.insert(w[0]);
	for(int i=1;i<n;i++){
		cin >> w[i];
		if(w[i].compare(0,1,w[i-1],w[i-1].size()-1,1) != 0){
			cout << "No" << endl;
			return 0;
		}
		val.insert(w[i]);
	}
	if(val.size()<n){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**************************
 * Cavaliers are invincible !!!
 * Au: Hany01
 * Email: hany01@foxmail.com
****************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define Rep(i , j) for (register int i = 0 , i##_end_ = j; i < i##_end_ ; ++ i)
#define For(i , j , k) for (register int i = (j) , i##_end_ = (k) ; i <= i##_end_ ; ++ i)
#define Fordown(i , j , k) for (register int i = (j) , i##_end_ = (k) ; i >= i##_end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Mod (1000000007)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr , __VA_ARGS__)
#else
#define debug(...)
#endif

inline void File() {
#ifdef hany01 
	freopen("a.in" , "r" , stdin);
    freopen("a.out" , "w" , stdout);
#endif
}

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
    register char c_; register int _ , __;
    for (_ = 0 , __ = 1 , c_ = getchar() ; !isdigit(c_) ; c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_) ; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const int maxn = 200005;

int n, a[maxn], b[maxn], Ans, A[maxn], B[maxn], ansnow;

int main()
{
	File();

    n = read();
    For(i, 1, n) a[i] = read();
    For(i, 1, n) b[i] = read();

    For(bit, 0, 29) {
        For(i, 1, n) A[i] = a[i] % (1 << bit), B[i] = b[i] % (1 << bit);
        sort(A + 1, A + 1 + n), sort(B + 1, B + 1 + n);
        int l1, l2;
        l1 = 1, l2 = n + 1;
        ansnow = 0;
        while (l1 <= n) {
            while ((A[l1] + B[l2 - 1]) & (1 << bit)) -- l2;
            ansnow += n - l2 + 1;
            ++ l1;
        }
        LL cnta, cntb;
        cnta = 0;
        cntb = 0;
        For(i, 1, n) {
            if (a[i] >> bit & 1) ++ cnta;
            if (b[i] >> bit & 1) ++ cntb;
        }
        if (((n - cntb) * cnta + (n - cnta) * cntb + ansnow) % 2) Ans |= (1 << bit);
    }
    cout << Ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

int main(void) {
    int N, M; cin >> N >> M;
    vector<long long> A(N);
    vector<pair<int, long long>> BC(M);
    rep(i, N) cin >> A[i];
    rep(i, M) {
        cin >> BC[i].second >> BC[i].first;
    }

    sort(A.begin(), A.end());
    sort(BC.begin(), BC.end(), std::greater<pair<int, int>>());

    int j = 0;
    rep(i, N) {
        if (BC[j].second <= 0) j++;
        if (j >= M) continue;
        if (BC[j].first < A[i]) continue;
        A[i] = BC[j].first;
        BC[j].second--;
    }

    cout << accumulate(A.begin(), A.end(), 0ll) << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

    int x,y;
    cin>>x>>y;

    if((4*x-y)%2==0 && (y-2*x)%2 ==0 && 4*x>=y && y>= 2*x)cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    
  
}

Measured memory_bytes: 3628
#!/usr/bin/env python3

from math import factorial

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

blue = k
red = n-k

mod = 10**9 + 7

fac_list = [1]

for i in range(1, 2001):
    fac_list.append(fac_list[-1]*i)


def comb(a, b):
    ans = fac_list[a]//(fac_list[b]*fac_list[a-b])
    return ans % mod


for i in range(1, k+1):
    gap = red+1

    ans = comb(gap, i) * comb(blue-1, i-1)
    print(ans % mod)

# (n-k+1)!/(n-k)!

# (n-k+2)!/(n-k)!-(n-k+1)!/(n-k)!


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    string ans = "NO";
    int X = read();
    if (X == 3 || X == 5 || X == 7) ans = "YES";
    printf("%s\n", ans.c_str());
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
p_list = [int(i) for i in input().split()]

p_list = [0] + p_list

cum_list = []
p_sum = 0
for p in p_list:
    p_sum += p
    cum_list.append(p_sum)
    
cum_list = np.array(cum_list)
sum_list = cum_list[k:]-cum_list[:-k]
index = np.argmax(sum_list)

kitaichi = k/2 + sum_list[index]/2

print(kitaichi)

Measured memory_bytes: 33968
#include <iostream>
#include <string>
#include <map>
using namespace std;
string s,s1;
long long n,ans;
map<string,int> mp,mpc;
int main(void){
    cin>>n;
    mp["357"]=1;
    mp["375"]=1;
    mp["537"]=1;
    mp["573"]=1;
    mp["735"]=1;
    mp["753"]=1;
        
    for(int k=0;k<8;k++){    
        for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
            s1 = itr->first;
            for(int j=0;j<3;j++){
                for(int i=0;i<s1.size()+1;i++){
                s=s1;
                if(j==0) s.insert(i,"3");
                else if(j==1) s.insert(i,"5");
                else s.insert(i,"7");
                auto itr2 = mpc.find(s);       
                if( itr2 == mpc.end() ) {
                    mpc[s]=1;
                    }
                }
            }
        }
        mp=mpc;
    }
    mp["357"]=1;
    mp["375"]=1;
    mp["537"]=1;
    mp["573"]=1;
    mp["735"]=1;
    mp["753"]=1;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(stoll(itr->first)<=n){
            ans++;
            //cout<<itr->first<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 44672
import java.util.Scanner;
public class Main {
	static int N;
	public static int dfs(int a) {
		if(a%3!=0&&a%5!=0) {
			return a;
		}
		else {
			return 0;
		}
	}
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		long ans=0;
		for(int i=0;i<N;i++) {
			ans+=dfs(N-i);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if((n|m)==0){
				return;
			}
			int[][] place = new int[2][m];
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					place[0][j] = j+1;
					int tmp = stdIn.nextInt();
					if(tmp>0){
						place[1][j]++;
					}
				}
			}
			for(int i=0;i<m;i++){
				for(int j=m-1;j>i;j--){
					if(place[1][j]>place[1][j-1]){
						int tmp = place[1][j];
						place[1][j] = place[1][j-1];
						place[1][j-1] = tmp;
						tmp = place[0][j];
						place[0][j] = place[0][j-1];
						place[0][j-1] = tmp;
					}
				}
			}
			for(int i=0;i<m-1;i++){
				System.out.print(place[0][i]+" ");
			}
			System.out.println(place[0][m-1]);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int cnt=0;
	int max_cnt=INT_MIN;
	for(int i=n-1;i>0;i--)
	{
		if(arr[i]<=arr[i-1])
			cnt++;
		else
		{
			max_cnt=max(max_cnt,cnt);
			cnt=0;
		}
	}
	max_cnt=max(max_cnt,cnt);
	cout<<max_cnt<<'\n';
	return 0;
	
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
    char s[10];
    int i, Ccnt=0;

    scanf("%s", s);

    i=1;

    if(s[0] != 'A'){
        printf("WA\n");
        return 0;
    }

    while(s[i] != '\0'){
        if(s[i] == 'C'){
            if(i == 1 || s[i+1] == '\0'){
                printf("WA\n");
                return 0;
            }
            else
                Ccnt++;
        }

        else if(s[i] < 'a' || 'z' < s[i]){
            printf("WA\n");
            return 0;
        }

        i++;
    }

    if(Ccnt == 1)
        printf("AC\n");
    else
        printf("WA\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

ll calc(ll hp) {
   if (hp == 1) return 1;

   ll t = calc(hp / 2);
   return t * 2 + 1;
}

int main() {
    ll hp;
    cin(hp);

    print(calc(hp));
    return 0;
}

Measured memory_bytes: 256