akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]

class Util():
    def round_up(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

N = cin.int()
S = cin.stringList(N)
A = [0] * 5
for key,value in itertools.groupby(sorted(S),key = lambda x : x[0]):
    if key in "MARCH":
        A["MARCH".index(key)] = len(list(value))
ans = 0        
for p in itertools.combinations(range(5),3):
    ans += A[p[0]] * A[p[1]] * A[p[2]]
print(ans)

Measured memory_bytes: 61528
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long d;
    while (cin >> d) {
        long long sum = 0;
        for (int i=d; i<=600-d; i+=d) {
            sum += i * i * d;
        }
        cout << sum << "\n";
    }
    return 0;
}

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

using namespace std;

int minExp(int a, int b) {
  long long c = a;
  while (c < b) {
    c *= 2;
  }
  
  return c / a;
}

int main() {
  int N, K;
  
  cin >> N >> K;
  
  long long max = minExp(1, K);
  long long sum = 0;
  
  for (int i = 0; i < N; i++) {
    sum += max / minExp(i + 1, K);
  }
  
  cout << setprecision(9) << (double)sum / (N * max) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin>>n;
	char s[101];
	char t[101];
	 
	scanf("%s %s", s, t);  
	string w = "";
	int l = 0;
	while(l<n) {
		w+=s[l];
		w+=t[l];
		l++;
	}
	cout << w;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        q: u32,
        s: chars,
        lr: [[usize; 2]; q]
    }
    let mut m: [u32; 100009] = [0; 100009];
    for i in 2..n+1 {
        m[i] = if s[i-2] == 'A' && s[i-1] == 'C' { m[i-1] + 1 } else { m[i-1] }; 
    }
    for lr_ in lr {
        println!("{}", m[lr_[1]] - m[lr_[0]]);
    }
}


Measured memory_bytes: 9428
program answer
  implicit none
  integer :: X

  read(*,*) X
  if(400<=X.and.X<=599) then
     write(*,*) '8'
  else if(600<=X.and.X<=799) then
     write(*,*) '7'
  else if(800<=X.and.X<=999) then
     write(*,*) '6'
  else if(1000<=X.and.X<=1199) then
     write(*,*) '5'
   else if(1200<=X.and.X<=1399) then
      write(*,*) '4'
   else if(1400<=X.and.X<=1599) then
      write(*,*) '3'
    else if(1600<=X.and.X<=1799) then
       write(*,*) '2'
    else if(1800<=X.and.X<=1999) then
       write(*,*) '1'
    end if

    stop
   end program answer

Measured memory_bytes: 2860
#include <iostream>
#include <vector>
#include <bitset>

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

  std::vector<int> S(M);

  for (int i=0; i<M; i++) {
    std::bitset<10> ss(0);

    int k;
    std::cin >> k;

    for (int j=0; j<k; j++) {
      int s;
      std::cin >> s;
      ss.set(s-1);
    }

    S[i] = ss.to_ulong();
  }

  std::vector<int> P(M);
  for (int i=0; i<M; i++) std::cin >> P[i];

  int ans = 0;

  for (int j=0; j<1<<N; j++) {
    int on_M = 0;
    for (int i=0; i<M; i++) {
      auto c = std::bitset<10>(S[i] & j).count();
      if (c % 2 == P[i]) on_M++;
    }
    if (on_M == M) ans++;;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

    if N % K == 0:
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9996
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
p=lnii()
c=lnii()

ans=-10**18
for i in range(n):
  ini_x=i
  x=i
  point=[]

  t_ans=0
  cnt=0
  t_max=-10**18
  while True:
    x=p[x]-1
    t_point=c[x]
    point.append(t_point)
    t_ans+=t_point
    t_max=max(t_max,t_ans)
    cnt+=1
    if x==ini_x:
      break

  if t_ans<0:
    ans=max(ans,t_max)
  else:
    num=k//cnt
    num-=1
    c_ans=t_ans*num
    c_max=c_ans
    zan=k-(num*cnt)
    for j in range(zan):
      x=p[x]-1
      c_ans+=c[x]
      c_max=max(c_max,c_ans)
    ans=max(ans,c_max)

print(ans)

Measured memory_bytes: 81080
N = int(input())
flag = 0

for h in range(1,3500):
    for n in range(1,3500):
        x = 4*h*n
        y = N*(h+n)
        if x<=y:
            continue
        tmp = (N*h*n)/(x-y)
        if tmp.is_integer():
            print(h,n,int(tmp))
            flag = 1
            break
    if flag == 1:
        break


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  vector<int> AA;
  AA.push_back(A);
  AA.push_back(B);
  AA.push_back(C);
  int Fans=0,Sans=0;
  string ans="NO";
  rep(i,3){
    if(AA[i]==5)Fans+=1;
    if(AA[i]==7)Sans+=1;
  }
  if(Fans==2&&Sans==1)ans="YES";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	while (true) {
		LL N;
		cin >> N;
		if (N == 0) {
			break;
		}
		LL l = 0;
		LL r = 0;
		LL u = 0;
		LL d = 0;
		vector<vector<LL>> v(N, vector<LL>(2, 0));
		FOR(i, 1, N) {
			LL n, dd;
			cin >> n >> dd;
			if (dd == 0) {
				v[i][0] = v[n][0] - 1;
				v[i][1] = v[n][1];
			}
			else
				if (dd == 1) {
					v[i][0] = v[n][0];
					v[i][1] = v[n][1] - 1;
				}
				else
					if (dd == 2) {
						v[i][0] = v[n][0] + 1;
						v[i][1] = v[n][1];
					}
					else
						if (dd == 3) {
							v[i][0] = v[n][0];
							v[i][1] = v[n][1] + 1;
						}
			if (v[i][0] > l) {
				l = v[i][0];
			}
			if (v[i][0] < r) {
				r = v[i][0];
			}
			if (v[i][1] > u) {
				u = v[i][1];
			}
			if (v[i][1] < d) {
				d = v[i][1];
			}
		}
		cout << l - r + 1 << " " << u - d + 1 << endl;
	}
}

Measured memory_bytes: 3020
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
	string S;
	cin >> S;
	int tmp1 = 0, tmp2 = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (i % 2) {
			if (S[i] == '0') ++tmp1;
		}
		else {
			if (S[i] == '1') ++tmp1;
		}
	}
	for (int i = 0; i < S.size(); ++i) {
		if (i % 2) {
			if (S[i] == '1') ++tmp2;
		}
		else {
			if (S[i] == '0') ++tmp2;
		}
	}
	cout << min(tmp1, tmp2);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll h, w, O[3100][3100], I[3100][3100], ans;
string s[4100];
int main() {
	cin >> h >> w;
	REP(i, h)cin >> s[i];
	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == 'O')O[i][j]++;
			else if (s[i][j] == 'I')I[i][j]++;
		}
	}
	REP(i, h) {
		REPR(j, w - 2) {
			O[i][j] += O[i][j + 1];
		}
	}
	REPR(i, h - 2) {
		REP(j, w) {
			I[i][j] += I[i + 1][j];
		}
	}
	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == 'J')ans += O[i][j] * I[i][j];
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 169348
import math
while True:
	n = int(input())
	if n == 0: break
	s = list(map(int, input().split()))
	sum = 0
	for i in range(n):
		sum += s[i]
	m = sum / n
	a = 0
	for i in range(n):
		a += (s[i] - m)**2
	print(math.sqrt(a / n))



Measured memory_bytes: 5696
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll h,w,a,b;
    ci(h>>w>>a>>b);
  if(h==1){
    FOR(i,0,w){
      if(i<a){
        cout<<0;
      }
      else{
        cout<<1;
      }
    }
    cout<<""<<endl;
  }
  else if(w==1){
    FOR(i,0,h){
      if(i<b){
        cout<<1<<endl;
      }
      else{
        cout<<0<<endl;
      }
    }
  }

  else{
  FOR(i,0,h){
    FOR(j,0,w){
      if(i<b&&j<a){
        cout<<0;
      }
      else if(i<b&&j>=a){
        cout<<1;
      }
      else if(i>=b&&j<a){
        cout<<1;
      }
      else{
        cout<<0;
      }
    }
    cout<<""<<endl;
  }
  }
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def f(n):
    r = 2
    ret = 1
    for i in range(n, n-r, -1):
        ret *= i
    for i in range(1, r+1):
        ret //= i
    return ret * 2 + n


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo

@mt
def slv(N, M, A):
    A.sort(reverse=True)
    print(A)
    b = Bisect(f)

    i = b.bisect_left(M, 1, N)
    if f(i) != M:
        i -= 1
    l = f(i)

    ans = 0
    for j in range(i):
        ans += A[j] * 2
        ans += A[j] * (i-1)

    rem = M - l
    print(i, l, rem)
    j = 0
    while rem != 0:
        ans += A[j] + A[i]
        rem -= 1
        if rem == 0:
            break
        ans += A[j] + A[i]
        rem -= 1
        if rem == 0:
            break
        j += 1


    return ans

import numpy as np
@mt
def slv2(N, M, A):
    C = Counter(A)
    L = 1 << (max(A).bit_length() + 1)
    B = [C[i] for i in range(L)]
    D = np.fft.rfft(B)
    D *= D
    E = list(map(int, np.round(np.fft.irfft(D).real)))
    ans = 0
    c = 0
    i = L - 1

    while c != M:
        n = E[i]
        if c + n > M:
            n = M-c
        c += n
        ans += i * n
        i -= 1

    return ans

def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv2(N, M,A))

    # N = 10**5
    # M = random.randint(1, N**2)
    # A = [random.randint(1, 10**5) for _ in range(N)]
    # print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 46780
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define gcd(x,y) __gcd(x,y) 
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*(y/z);
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  cout << fixed << setprecision(16);
  ll n;
  cin>>n;
  vec a(n);
  loop(i,n){
    cin>>a[i];
  }
  map<ll,ll> check;
  loop(i,n){
    if(check[a[i]]==0)check[a[i]]++;
    else check[a[i]]--;
  }
  ll ans=0;
  loop(i,n){
    if(check[a[i]]){
      ans++;
      check[a[i]]=0;
    }
  }
  putout(ans);
  
  
}


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

string toUpper(string s){
    string t=s;
    for(int i=0;i<s.size();i++){
        t[i]=toupper(s[i]);
    }
    return t;
}

int main(){
    
    string word,str;
    int i=0;
    
    cin>>word;
    word=toUpper(word);
    
    while(1){
        cin>>str;
        if(str=="END_OF_TEXT") break;
        str=toUpper(str);
        if (str==word) i++;
    }
    
    cout<<i<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3172
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
#define endl "\n"
#define f first
#define se second
#define int long long
#define pb push_back
#define all(x) x.begin(), x.end()
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {int operator()(int x) const { return x ^ RANDOM; }};
string toString(long long x){stringstream ss;ss << x;string str = ss.str();return str;}
long long fastpow(long long x,long long k){if(!k)return 1;if(k & 1)return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
long long ans = fastpow(x,k/2);ans %= MOD;ans *= ans;ans %= MOD;return ans;}
long long sumF(long long x){int s = 0;while(x)s += x%10,x /= 10;return s;}
bool isS(char c){return (c >= 'a' && c <= 'z');}
bool isB(char c){return (c >= 'A' && c <= 'Z');}
bool isD(char c){return (c >= '0' && c <= '9');}
bool isSqrt(long long x){ long long f = sqrt((long double)x + 0.5); return f*f == x;}
bool isCubic(long long x) {long long f = cbrt((long double)x + 0.5); return f*f*f == x;}
long long lcm(long long a,long long b){return a * (b / __gcd(a,b));}
vector<long long> divVec(long long x){vector<long long> tmp;for(long long i = 1;1LL*i*i <= x;i++){if(x % i == 0){tmp.push_back(i);if(x / i != i)
tmp.push_back(x / i);}sort(tmp.begin(),tmp.end());}return tmp;}
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
int primeFactorsCnt(long long n){int ret = 0;if(n % 2 == 0)ret++;while (n % 2 == 0)n = n/2;for (int i = 3; i*i <= n; i = i + 2){if(n % i == 0)ret++;while (n % i == 0)
n = n/i;}if (n > 2)ret++;return ret;}
long long mulmod(long long a,long long b){return (a%MOD  * b%MOD) % MOD;}
long long minusmod(long long a,long long b){return ((((a % MOD) - (b % MOD)) % MOD) + MOD) % MOD;}
long long plusmod(long long a,long long b){return ((a % MOD) + (b % MOD)) % MOD;}
int bitCnt[65];
int32_t main()
{
    IO;
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
        for(int j = 0;j <= 60;j++)
        {
            if(arr[i] & (1LL << j)) bitCnt[j]++;
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j <= 60;j++)
        {
            ans += ((1LL << j)%MOD) * (arr[i] & (1LL << j) ? (n - bitCnt[j]) : bitCnt[j]);
            ans %= MOD;
        }
    }
    cout << mulmod(ans,fastpow(2,MOD-2));
    return 0;
}


Measured memory_bytes: 2560
n = gets.to_i
sum = 0
n.times do |i|
    # puts i +1
    if (i+1) % 15 == 0
        next
    elsif (i+1) % 5 == 0
        next
    elsif (i+1) % 3 == 0
        next
    else
        sum = sum + (i+1)
    end
end
puts sum

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

int main() {
	int n, y;
	cin >> n >> y;
	int x = -1;
	int z = -1;
	int o = -1;
	for(int i = 0; i <= n; i ++) {
		for(int j = 0; j <= n - i; j++) {
			if((y - (i * 10000 + j * 5000)) % 1000 == 0 && (y - (i * 10000 + j * 5000)) / 1000 == n - i - j) {
				x = i;
				z = j;
				o = (y - (i * 10000 + j * 5000)) / 1000;
			}
		}
	}
	cout << x << " " << z << " " << o << endl;
}


Measured memory_bytes: 256
import numpy as np
from fractions import gcd

N, X = (int(i) for i in input().split())
x = np.array([int(i) for i in input().split()])

diff = abs(x-X)
intermediate_gcd = diff[0]

for i in range(len(x)-1):
    intermediate_gcd = gcd(intermediate_gcd, diff[i+1])

print(intermediate_gcd)

Measured memory_bytes: 24180
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<ll,ll>;
const ll INF=1e+15;
typedef tuple<int,int,int> T;

class edge {
public:
    ll to;
    ll cost;
		ll time;
		edge(){}
    edge(ll t, ll c, ll d) {
        to = t;
        cost = c;
				time= d;
    }
};




int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m,s;
	cin>>n>>m>>s;
	vector<vector<edge>> G(n);
	vector<vector<edge>> C(n);

	vector<vector<ll>> dist(n,vector<ll> (2505));


//	P G1(n);

//	P C1(n);
	rep(i,m){
		int u1,v1,a2,b2;
		cin>>u1>>v1>>a2>>b2;
		u1--;v1--;
	//	G1[i]=make_pair(u1,v1);
	//	C1[i]=make_pair(a2,b2);
		G[u1].push_back(edge(v1,a2,b2));
		G[v1].push_back(edge(u1,a2,b2));
	//	C[u1].push_back(edge(v1,b2));
	//	G[v1].push_back(edge(u1,b2));
	}


	vector<P> F(n);
	rep(i,n){
		ll c1,d1;
		cin>>c1>>d1;
		F[i]=make_pair(c1,d1);
	}

	rep(i,n)rep(j,2505) dist[i][j] = INF;
	priority_queue<T, vector<T>, greater<T>> que;
//	que.push(T(0,0,0));
	//dist[0][0]=0;
	if (s>2500)s=2500;

		dist[0][s] = 0;

		que.push(T(0,0,s));

//cost, to[1][],to[][1]
	while (!que.empty()) {
		T tnow=que.top();
		que.pop();
		ll c1,a1,b1;
	//	cout<<c1<<' '<<a1<<' '<<b1<<endl;
		tie(c1,a1,b1)=tnow;
		if (dist[a1][b1] < c1) continue;

//上に伸ばす

			ll cnow=F[a1].first;
			ll dnow=F[a1].second;
		//	cout<<cnow<<' '<<dnow<<endl;
	//		rep(j,cnow+1){
			//	cout<<j<<'j'<<endl;
			ll temp=b1+cnow;
				if (temp>2500) temp=2500;

					if (dist[a1][temp]>dist[a1][b1]+dnow){
						dist[a1][temp]=dist[a1][b1]+dnow;
						que.push(T(dist[a1][temp], a1,temp));

					}
		//	}


//横に伸ばす


			for (edge e : G[a1]) {
			//	cout<<e.time<<'t'<<e.cost<<'c'<<e.to<<"to"<<b1<<'b'<<endl;
				if (b1>=e.cost){
					if (dist[e.to][b1-e.cost] > dist[a1][b1] + e.time) {
							dist[e.to][b1-e.cost] = dist[a1][b1] + e.time;
							que.push(T(dist[e.to][b1-e.cost], e.to,b1-e.cost));
					}
			}
		}



	}

rep(i,n-1){
	ll ans=INF;
	rep(j,2500){
		ans=min(ans,dist[i+1][j]);
	}
	cout<<ans<<endl;


}

//cout<<ans;




}


Measured memory_bytes: 10492
#include <stdio.h>

int main(void)
{
  int A,B,max = 0;
  scanf("%d %d",&A,&B);
  
  if(A > B)
  {
    max = A*2 - 1;
  }
  if(A == B)
  {
    max = A + B;
  }
  if(A < B)
  {
    max = B*2 - 1;
  }
  printf("%d",max);
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, M;
	cin >> N >> M;

	if (N == M)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	//system("pause");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    string str;
    cin >> str;
    int a = (str[0]-'0')*10 + str[1]-'0';
    int b = (str[2]-'0')*10 + str[3]-'0';
    int num = 0;
    if(a <= 12 && b <= 12 && a!=0 && b != 0){
        cout << "AMBIGUOUS" << endl;
    }else if(a <= 12 && a != 0){
        cout << "MMYY" << endl;
    }else if(b <= 12 && b != 0){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
count = 0

def includeOdd(l):
    ans = False
    for i in range(n):
        if l[i] % 2 == 1:
            ans = True
    return ans


while True:
    if includeOdd(li):
        break
    li = [x / 2 for x in li]
    count += 1
    
print(count)


Measured memory_bytes: 3064
#include<iostream>

int main(){
	int n, x = 0;
	int l[100000], r[100000];
	std::cin >> n;
	for (int lp = 0; lp < n; lp++) {
		std::cin >> l[lp] >> r[lp];
	}
	for (int lp1 = 0; lp1 < n; lp1++) {
		x += (r[lp1] - l[lp1]) + 1;
	}
	std::cout << x << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 200000
#define MIN -2000000000

int maxv( int a, int b )
{
	if ( a > b ) {
		return a;
	} else {
		return b;
	}
}

int minv( int a, int b )
{
	if ( a > b ) {
		return b;
	} else {
		return a;
	}
}

int main()
{
	int n = 0, i = 0, max = MIN, min;
	int val[MAX];

	scanf( "%d", &n );

	while( i < n ) {
		scanf( "%d", &val[i] );
		i++;
	}

	min = val[0];
	for ( int j = 1 ; j < n ; j++ ) {
		max = maxv( max, val[j] - min );
		min = minv( min, val[j] );
	}

	printf( "%d\n", max );
	return 0;
}



Measured memory_bytes: 2572
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a[3];
    
    rep(i, 3)   cin >> a[i];
    
    sort(a, a + 3);
    int sum = 0;
    FOR(i, 1, 3){
        sum += a[i] - a[i - 1];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
Q = int(input())

#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

l = [0]*(10**5+1)
for i in range(1, 10**5+1):
    if i%2 and is_prime(i) and is_prime((i+1)//2):
        l[i] = 1

for i in range(len(l)-1):
    l[i+1] += l[i]

for _ in range(Q):
    ll, rr = map(int, input().split())
    print(l[rr]-l[ll-1])

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

int main()
{
  string a, b;
  cin >> a >> b;
  
  int n = a.length(), m = b.length();
  int dp[n+1][m+1];
  
  for(int i=0;i<=n;++i)
  {
      for(int j=0;j<=m;++j)
      {
          if(i == 0 || j == 0) dp[i][j] = 0;
          else if(a[i-1] == b[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
          else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
  }
  string ans;
  int i = n, j = m;
  while(i > 0 && j > 0)
  {
      if(a[i-1] == b[j-1])
      {
          ans += a[i-1];
          i--;
          j--;
      }
      else
      {
          if(dp[i][j-1] > dp[i-1][j])
          {
              j--;
          }
          else i--;
      }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<string, int> SI;

const int MAX_N = 5005;


vector<SI> ax;
vector<int> G[MAX_N];
map<string, int> tag;
int price[MAX_N];

bool cmp (SI a, SI b ){
	if (a.second != b.second ) return a.second < b.second;

	string s = a.first;
	string t = b.first;

	return s[0] < t[0];
}
bool used[MAX_N];

void dfs (int start, int curr ){
	used[curr] |= true;

	price[start] = min (price[start], price[curr] );
	rep (i, G[curr].size() ){
		int u = G[curr][i];
		if (u != start && !used[u] ) dfs (start, u );
	} // end rep
}

int main()
{
	memset (price, 0, sizeof (price ) );
	rep (i, MAX_N ) G[i].clear();
	ax.clear();

	ios_base::sync_with_stdio(0);
	int N; cin >> N;
	ax.resize (N );
	rep (i, N ){
		string a;
		int x;
		cin >> a >> x;
		ax[i].first = a;
		ax[i].second = x;
	} // end rep
	sort (ALL (ax ), cmp );

	tag.clear();
	rep (i, N ) tag[ax[i].first] = i;

	rep (i, N ) price[i] = ax[i].second;

	int M; cin >> M;
	rep (j, M ){
		string s, t;
		cin >> s >> t;
		int u = tag[s];
		int v = tag[t];
		G[u].push_back (v );
		G[v].push_back (u );
	} // end rep

	rep (j, N ){
		memset (used, false, sizeof (used ) );
		dfs (j, j );
	} // end rep
		
	int res = 0;
	rep (i, N ) res += price[i];
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1908
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n;
	char c;
	string s;
	in(n);
	in(s);
	rep(i, 0, s.size()) {
		c = s[i] + n;
		if (c > 'Z') {
			c -= 26;
		}
		out(c);
	}
	outn("");
	

	return 0;


}


Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,k;
int arr[505];
int check(int val)
{
    multiset<int>ms;
    for(int i=0;i<n;i++)
        if(arr[i]%val!=0)
            ms.insert(arr[i]%val);
    int ctr=0;
    while(ms.size())
    {
        if(ms.size()==1)
            return 0;
        int a=*ms.begin();
        int b=*ms.rbegin();
        ms.erase(ms.find(a));
        ms.erase(ms.find(b));
        b=val-b;
        while(true)
        {
            int mini=min(a,b);
            ctr+=mini;
            a-=mini;
            b-=mini;
            if(a==b)
                break;
            if(!ms.size())
                return 0;
            if(a>0)
            {
                b=*ms.rbegin();
                ms.erase(ms.find(b));
                b=val-b;
            }
            else
            {
                a=*ms.begin();
                ms.erase(ms.find(a));
            }
        }
    }
    return ctr<=k;
}
int32_t main()
{
    IOS;
    cin>>n>>k;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    int ans=1;
    for(int i=1;i*i<=sum;i++)
    {
        if(sum%i==0)
        {
            if(check(i))
                ans=max(ans,i);
            if(check(sum/i))
                ans=max(ans,sum/i);
        }
    }
    print(ans);
}

Measured memory_bytes: 3684
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, p;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    n=s.size();
    p=2019;
    ll ans = 0;
    if (p == 2 || p == 5)
    {
        rep(i, n)
        {
            if ((s[n - i - 1] - '0') % p == 0)
                ans += n - i;
        }
    }
    else
    {
        vector<ll> val(p, 0);
        ll tenfactor = 1;
        ll cur = 0;
        val[cur]++; //最初の0
        rep(i, n)
        {
            cur = (cur + (s[n - i - 1] - '0') * tenfactor) % p; //i+1桁目までのあまり
            tenfactor *= 10;
            tenfactor %= p;
            val[cur]++;
        }
        rep(i, p)
        {
            ans += val[i] * (val[i] - 1) / 2;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3700
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]

num = [999] * N

no = 99999999999999
L = []
for s, c in sc:
    if s in L:
        if num[s-1] != c:
            no = -1
    num[s-1] = min(num[s-1], c)
    L.append(s)


if N == 1:
    if num[0] == 999:
        num[0] = 0
else:
    if num[0] == 999:
        num[0] = 1
    elif num[0] < 1:
        no = -1

for i in range(1, N):
    if num[i] == 999:
        num[i] = 0

print(min(int("".join(map(str, num))), no))

Measured memory_bytes: 3064
# coding=utf-8

if __name__ == '__main__':
    X, K, D = map(int, input().split())

    ABS_X = abs(X)

    if K * D <= ABS_X:
        ans = ABS_X - (K * D)

    else:
        r = ABS_X // D
        l = ABS_X // D + 1
        if r % 2 == K % 2:
            ans = abs(ABS_X - D * r)
        else:
            ans = abs(ABS_X - D * l)

    print(ans)



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

long long dp[1001][1001] = {0};

int main() {

    string t,b;

    cin >> t >> b;

    int s1 = t.size(),s2 = b.size();

    dp[0][0] = 1;

    for(int i=0;i<s1;i++){
        dp[i+1][s2] += dp[i][s2];
        dp[i+1][s2] %= 1000000007;
        for(int j=0;j<s2;j++){
            if(t[i] == b[j]){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= 1000000007;
            }
            dp[i+1][j] += dp[i][j];
        }
        /*for(int y=0;y<=s2;y++){
            for(int x=0;x<=s1;x++){
                cout << dp[x][y] << " ";
            }
            cout << endl;
        }
        cout << endl;*/
    }
/*
    for(int j=0;j<s2;j++){
        for(int i=0;i<s1;i++){
            if(b[j] == t[i]) {
                dp[i + 1][j + 1] = dp[i][j];
            }
            dp[i+1][j] = dp[i][j];

        }
    }
*/
/*
    for(int y=0;y<=s2;y++){
        for(int x=0;x<=s1;x++){
            cout << dp[x][y] << " ";
        }
        cout << endl;
    }
*/




    /*for(int i=0;i<=s1;i++){
        for(int j=0;j<=s2;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << dp[s1][s2] << endl;
    return 0;
}

Measured memory_bytes: 11048
#include<bits/stdc++.h>
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 10007
#define pb push_back
#define MAXN 505
#define ff first
#define sf second.first
#define ss second.second
using namespace std;
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef vector<int> VE;
typedef map<int, int> MAP;

int n, a;

signed main()
{
    cin >> n >> a;
    cout << n - a + 1 << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int MIN=9999;
string S;

int main(){
    long long int N,M,A[100002];
    priority_queue<long long int,vector<long long int> > que;
    cin >> N >> M;
    for(int i=0;i<N;i++)
        cin >> A[i];
    for(int i=0;i<N;i++)
        que.push(A[i]);
    for(int i=0;i<M;i++){
        long long int k=0;
        k = que.top();
        que.pop();
        que.push(k/2);
    }
    long long int sum=0;
    for(int i=0;i<N;i++){
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
    
  return 0;
}

Measured memory_bytes: 2168
class UnionFind:
    """
    size の要素数の UnionFind を管理する
    data 中の負数の要素が根となる
    """

    def __init__(self, size):
        # 根は子を含む集合のデータ数を負数でもつ
        self.data = [-1] * size

    def merge(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y: return False

        # y の方がデータ数を多く
        if self.data[x] < self.data[y]:
            x, y = y, x

        # y に x をつなげる
        self.data[y] += self.data[x]
        self.data[x] = y
        return True

    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]

    def size_(self, x):
        """
        根は負数でデータ数を管理しているのでそれを返す
        """
        return -self.data[self.root(x)]


N, M = [int(_) for _ in input().split()]
AB = []
for i in range(M):
    AB.append([int(_) - 1 for _ in input().split()])
AB.reverse()

ans = [0] * M

uf = UnionFind(N)

for i, (a, b) in enumerate(AB):
    a_s = uf.size_(a)
    b_s = uf.size_(b)
    if uf.merge(a, b):
        ans[i] = a_s * b_s
    if i > 0:
        ans[i] += ans[i - 1]

tmp = (N * (N - 1)) // 2
for a in ans[:-1][::-1]:
    print(tmp - a)
print(tmp)


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

const int N = (int) 2e6 + 10 ;
const int inf = (int) 1e9 ;

int arr[N] , F[N] , cnt[30] ;

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    memset( cnt , 0 , sizeof(cnt) ) ;
    int n ; scanf("%d" , &n ) ;
    for( int i = 1 ; i <= n ; i++ ) {
        scanf("%d" , &arr[i] ) ;
    }
    long long ans = 0 ;
    for( int i = 1 , r = 1 , sum = 0 , xr = 0 ; i <= n ; i++ ) {
        while( r <= n && (sum + arr[r]) == (xr ^ arr[r]) ) {
            sum += arr[r] ;
            xr ^= arr[r] ;
            r += 1 ;
        }
        ans += (r - i) ;
        sum -= arr[i] ;
        xr ^= arr[i] ;
    }
    printf("%lld\n" , ans ) ;
    return 0 ;
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main() {
	// your code goes here
	string s;
	cin>>s;
	int n=s.length();
	string a="";
	string b="";
	    int m =n/2;
	    for(int i=0;i<m;i++) a+="01";
	 if(n&1)   a+="0";
	for(int i=0;i<n;i++) if(a[i]=='1') b+="0"; else b+="1";
	int ans1=0;
	int ans2=0;
	for(int i=0;i<n;i++){ if(s[i]!=a[i]) ans1++; if(s[i]!=b[i]) ans2++;} 
	cout<<min(ans2,ans1)<<endl;
	
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#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 RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 2e5+10;
struct Union_Find{
    int d[SIZE],num[SIZE];
    void init(int n){
        REP(i,n)d[i]=i,num[i]=1;
    }
    int find(int x){
        return (x!=d[x])?(d[x]=find(d[x])):x;
    }
    bool uu(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return 0;
        if(num[x]>num[y])swap(x,y);
        num[y]+=num[x];
        d[x]=y;
        return 1;
    }
}U1,U2;
VI d[SIZE];
int an[SIZE],cnt[SIZE];
int main(){
    DRIII(N,K,L);
    U1.init(N);
    U2.init(N);
    REP(i,K){
        DRII(x,y);
        x--;y--;
        U1.uu(x,y);
    }
    REP(i,L){
        DRII(x,y);
        x--;y--;
        U2.uu(x,y);
    }
    REP(i,N){
        d[U1.find(i)].PB(i);
    }
    REP(i,N){
        REP(j,SZ(d[i])){
            int x=d[i][j];
            cnt[U2.find(x)]++;
        }
        REP(j,SZ(d[i])){
            int x=d[i][j];
            an[x]+=cnt[U2.find(x)];
        }
        REP(j,SZ(d[i])){
            int x=d[i][j];
            cnt[U2.find(x)]=0;
        }
    }
    REP(i,N)printf("%d ",an[i]);
    return 0;
}


Measured memory_bytes: 15616
#include<stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a == b && a == c){
		puts("1\n");
	}else if(a != b && a!= c && b != c){
		puts("3\n");
	}else{
		puts("2\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m);
    rep(i,m)
    {
        cin>>a[i];
    }
    ll sum=accumulate(a.begin(),a.end(),0);
    ll ans=n-sum;
    if(ans<0)cout<<-1<<endl;
    else cout<<ans<<endl;
 
    return 0;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

ll GCD(ll a,ll b){
    if(a < b)return GCD(b,a);
    ll r = INF;
    while(r){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(){
   ll N,M;
   cin >> N >> M;
   ll ans = 1;
  /* if(M % N == 0){
       cout << M / N << endl;
       return 0;
   }*/
   for(ll i = M/N;1 <= i;i--){
       if(M % i == 0){
           cout << i << endl;
           break;
       }
   }
}


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

int n, a, b, p[mx];

int main(){
	scanf("%d%d%d", &n, &a, &b);
	for(int i = 0; i < n; i++) scanf("%d", &p[i]);
	sort(p, p+n);
	int t = upper_bound(p, p+n, a) - p;
	int u = upper_bound(p, p+n, b) - p;

	printf("%d\n", min(min(t, u-t), n-u));

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int X,A,B;
	cin>>X>>A>>B;
	X-=A;
	X%=B;
	cout<<X<<endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

const int Mod = 1e9 + 7;
int N, Bin[33], key;
int f[2][2097153];

void init() {
	Bin[0] = 1;
	for(int i = 1; i < 31; ++i)
		Bin[i] = Bin[i - 1] << 1;
	f[0][0] = 1;
	return;
}
inline int Nex_Com(int key) {
	int b, h, l;
	b = key & -key;
	h = key + b;
	l = ((h ^ key) >> 2) / b;
	return h | l;
}
inline int add(int aa, int bb) {
	int res = aa + bb;
	return res >= Mod ? res - Mod : res;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	init();
	cin >> N;
	int tmp, key, str = 0, upper = 1 << N;
	for(reg int i = 0; i < N; ++i) {
		key = 0;
		for(reg int j = 0; j < N; ++j) {
			cin >> tmp;
			key = (key << 1) | tmp;
		}
		str |= Bin[i];
		for(reg int j = str; j < upper; j = Nex_Com(j))
			for(reg int k = 0; k < N; ++k)
				if(Bin[k] & j & key) {
					f[1][j] = add(f[1][j], f[0][j ^ Bin[k]]);
				}
		memcpy(f[0], f[1], sizeof f[0]), memset(f[1], 0, sizeof f[1]);
	}
	cout << f[0][upper - 1] << endl;
	return 0;	
}

Measured memory_bytes: 16640