akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  	int x,y,c;
	cin >> y >> x;
  	vector<string> a(y);
  	for(int i = 0; i<y;i++)	
    	cin >> a[i];
  	for(int i = 0; i < y; i++) {
      	for(int j = 0; j<x; j++) {
			if(a[i][j] =='#') {
              	c=0;
              	if(j!=x-1 && a[i][j+1] == '#')
                  	c++;
          		if(i!=y-1 && a[i+1][j] == '#')
                  	c++;
             	if(c!=1 && !(i==y-1 &&j==x-1)) {
                  	cout << "Impossible\n";
                	return 0; 
                }
            }
        }
    }
  	for(int i = 0; i < y; i++) {
      	for(int j =0; j<x; j++) {
          	if(a[i][j] =='#') {
              	c=0;
              	if(j != 0 && a[i][j-1] == '#')
                  	c++;
          		if(i!= 0 && a[i-1][j] == '#')
                  	c++;
             	if(c!=1 && !(i==0 && j==0)) {
                  	cout <<"Impossible\n";
                	return 0; 
                }
            }
        }
    }
  	cout << "Possible\n";
  	
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    int n;
    cin >> n;
    vll a(n);
    vll cnt(n+1);
    repz(i,n)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }

    ll total = 0;

    for (int i = 1; i <= n; i++)
        total += (cnt[i]*(cnt[i]-1))/2;

    repz(i,n)
    {
        ll val = total;
        val -= (cnt[a[i]]*(cnt[a[i]]-1))/2;
        val += ((cnt[a[i]]-1)*(cnt[a[i]]-2))/2;
        cout << val << endl;        
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    char s[4];
    cin >> s;
    int ans=0;
    for(int i=0; i<3; i++){
        if(s[i]=='1'){
            ans++;
        }
    }
    cout << ans;
    
    return 0;
}

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

/* Driver code */
int main()  
{  
    ll n, i, z;
    cin>>n;
    ll A[200000], B[200000];
    for(i=0; i<n; i++)
    cin>>A[i]>>B[i];
    sort(A, A+n);
    sort(B, B+n);
    if(n%2==1)
    {
        z = B[n/2]-A[n/2]+1;
    }
    else
    {
        z = B[n/2]+B[n/2-1]-A[n/2]-A[n/2-1]+1;
    }
    cout<<z;
    return 0;  
}  

Measured memory_bytes: 6720
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd

N, M = map(int, input().split())
H = list(map(int, input().split()))
H = np.array(H)
G = [[] for _ in range(N)]

for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    G[A].append(B)
    G[B].append(A)

ans = 0
for i in range(N):
    u = i
    path = G[u]
    if len(path) == 0:
        ans += 1
    elif H[u] > np.max(H[path]):
        ans += 1

print(ans)



Measured memory_bytes: 45136
//B - Counting Roads 2017/05/13
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    for(int i=0;i<m;++i){
        cin >> a[i] >> b[i];
    }
    for(int i=1;i<=n;++i){
        int ans=0;
        for(int j=0;j<m;++j){
            if(a[j]==i) ++ans;
            if(b[j]==i) ++ans;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int K = scan.nextInt();
			
			int[] H = new int[N];
			//ArrayList<Integer> hp  = new ArrayList<Integer>();
			
			
			for(int i = 0;i<N;i++) {
				H[i] = scan.nextInt();
			}
			
			Arrays.sort(H);
			
			
			
			
			if(N<=K) {//必殺技だけで全員倒せる
				System.out.println(0);
			}else{
				long kaisuu = 0;
				for(int i = 0;i<N-K;i++) {
					kaisuu +=(long)H[i];
				}
				
				
				
				System.out.println(kaisuu);
			}
        }
    }
}
			
			
			
			
			
			

Measured memory_bytes: 86180
import math


class Vector2():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, v):
        return Vector2(self.x+v.x, self.y+v.y)

    def __sub__(self, v):
        return Vector2(self.x-v.x, self.y-v.y)

    def __mul__(self, v):
        return Vector2(self.x*v, self.y*v)

    def __truediv__(self, v):
        return Vector2(self.x/v, self.y/v)

    def __abs__(self):
        return math.sqrt(float(self.x*self.x+self.y*self.y))

    def dot(self, v):
        return self.x*v.x+self.y*v.y

    def cross(self, v):
        return self.x*v.y-self.y*v.x

    def norm(self):
        d = abs(self)
        return Vector2(self.x/d, self.y/d)


x1, y1, x2, y2 = map(int, input().split())
v12 = Vector2(x2-x1, y2-y1).norm()
q = int(input())
for i in range(q):
    x, y = map(int, input().split())
    v = Vector2(x-x1, y-y1)
    d = v12.dot(v)
    a = Vector2(x1+v12.x*d, y1+v12.y*d)
    p = Vector2(x, y)
    b = p+(a-p)*2.0
    print(f"{b.x:.9f} {b.y:.9f}")



Measured memory_bytes: 5728
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,M = 0,C = 0;
  cin >> N >> M >> C;
  vector<ll>B(M);
  rep(i,M){
    cin >> B[i];
  }
  vector<vector<int>> A(N, vector<int>(M));
  rep(i,N){
    rep(j,M){
      cin >> A.at(i).at(j);
    }
  }
  ll count = 0,ans = 0;
  rep(i,N){
    count = 0;
    rep(j,M){
      count += A.at(i).at(j) * B[j];
      }
    if(count + C > 0){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    var lines = input.split("\n");
    var N = lines.shift() - 0;
    var ryo = new Array(N);
    for (var n = 0; n < N; n++) {
        var nums = lines[n].split(" ");
        ryo[n] = {
            taka : nums[0] - 0,
            aoki : nums[1] - 0,
        };
        ryo[n].wa = ryo[n].taka + ryo[n].aoki;
    }
    ryo.sort(function(a, b) { return b.wa - a.wa; });
    var koufuku = 0, c = 0;
    for (var n = 0; n < N; n += 2) {
        koufuku += ryo[n].wa;
    }
    ryo.forEach(function(value) {koufuku -= value.aoki});
    console.log(koufuku);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); ++i) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }
  cout << T << endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;


int main(){
  string s;
  cin >> s;
  int ans=700;
  rep(i,3){if(s[i]=='o')ans+=100;}
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

struct activites
{
    int a, b, c;
    activites()
    {
        a = b = c = 0;
    }
};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<vector<int>> v(n + 1, vector<int>(3));
    activites cur, prev;
    int a, b, c;
    for (int i = 1; i <= n; i++)
    {
        cin >> a >> b >> c;
        cur.a = max(prev.b, prev.c) + a;
        cur.b = max(prev.a, prev.c) + b;
        cur.c = max(prev.a, prev.b) + c;
        prev = cur;
    }
    cout << max(cur.c, max(cur.a, cur.b));
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int t[110], n, m, min;

void solve (int l, int r)
{
	int i, i2, ts;
	i2 = 0;
	ts = 0;
	i = 0;
	
	if (l > r){
		return;
	}
	
	
	while (i < m){
		
		ts += t[i2];
		i2++;
		if (ts == (l + r) / 2){
			i++;
			ts = 0;
		}
		else if (ts > (l + r) / 2){
			i2--;
			i++;
			ts = 0;
		}
		if (i2 == n){
			break;
		}
	}
	if (i2 == n){
		if (min > (l + r) / 2){
			min = (l + r) / 2;
		}
		solve(l, (l + r) / 2 - 1);
	}
	else{
		solve((l + r) / 2 + 1, r);
	}
}
	
	

int main(void)
{
	int i;
	
	while (1){
		
		scanf("%d %d", &m, &n);
		min = 1500050;
		
		if (m == 0 && n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &t[i]);
		}
		solve(0, 1500000);
		printf("%d\n", min);
	}
	return (0);
}

Measured memory_bytes: 596
N = int(input())
a = list(map(int, input().split()))

amin = min(a)
amax = max(a)
if abs(amin) < abs(amax):
    index = a.index(amax)
    a = list(map(lambda x: x + amax, a))
else:
    index = a.index(amin)
    a = list(map(lambda x: x + amin, a))

ans = [(index+1, i+1) for i in range(N)]
if a[0] > 0:
    ans += [(i+1, i+2) for i in range(N-1)]
else:
    ans += [(i+1, i) for i in range(N-1, 0, -1)]
print(len(ans))
print('\n'.join(map(lambda xy: '%d %d' % xy, ans)))


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

int main(){
string s;
  cin >> s;
  
long long int ans =0,ant =0;
  
  for(int i=0;i<s.size();i++){
    
    if(s[i] == 'S'){
      ans++;
    }
    else if(s[i] == 'T' && ans >0){
      ans--;
    }
      else if(s[i] == 'T' && ans ==0){
        ant++;
      }
      
    }
    cout << ant + ans << endl;
  }
    

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
#include <type_traits>

using namespace std;

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

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

	if (s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int id = 0;
string s;

int hhash(string p){
    int ret = -1;
    if(s[id] == '['){
        id++;
        switch(s[id++]){
        case '+':
            ret = hhash(p) | hhash(p);
            break;
        case '*':
            ret = hhash(p) & hhash(p);
            break;
        case '^':
            ret = hhash(p) ^ hhash(p);
            break;
        }
    }else{
        ret = p[s[id]-'a'] - '0';
    }
    id++;
    // cout << id << " " << ret << endl;
    return ret;
}

int main(){
    cin >> s;
    while(s != "."){
        string p;
        cin >> p;
        int ans = 0;
        id = 0;
        int enc = hhash(p);
        for(int i=0; i<10000; i++){
            string t = "";
            for(int j=1; j<10000; j*=10){
                t += (i/j)%10 + '0';
            }
            reverse(t.begin(), t.end());
            id = 0;
            if(hhash(t) == enc) ans++;
        }
        cout << enc << " " << ans << endl;
        cin >> s;
    }
}



Measured memory_bytes: 3100
#include <stdio.h>
int m;
long long ans, y, x;
long long c[200000];
long long d[200000];
int main() {
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%lld%lld", d + i, c + i);
		ans += c[i];
		y += d[i] * c[i];
	}
	ans--;
	while (y >= 10) {
		x = y / 10;
		ans += x;
		y -= 9 * x;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3328
x,y=map(int,input().split())
ans=0
if x*y>0:
    if x<=y:
        ans=y-x
    else:
        ans=x-y+2
elif x*y==0:
    if x<=y:
        ans=y-x
    else:
        ans=x-y+1
else:
    ans=abs(abs(x)-abs(y))+1
print(ans)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

aa = [[a[i], i] for i in range(n)]
bb = [[b[i], i] for i in range(n)]

aa.sort()
bb.sort()

flag = 0
for i in range(n):
    if aa[i][0] > bb[i][0]:
        print("No")
        exit(0)
    if i and aa[i][0] <= bb[i - 1][0]:
        flag = 1

if flag:
    print("Yes")
    exit(0)

sta = [0] * 100005

from bisect import *
from collections import defaultdict

mp = defaultdict(int)

pos = 0
cnt = 1
while cnt <= n - 1:
    sta[pos] = 1
    # print(pos, a[pos])
    pos = bisect_left(bb, [a[pos],-1])
    pos = bb[pos][1]
    cnt += 1
    if sta[pos] and cnt <= n - 1:
        print("Yes")
        exit(0)

print("No")


Measured memory_bytes: 95632
s = input()
l = [0]
rl = []
c = "R"
for i in range(len(s)):
    if c == "R":
        if s[i] == "L":
            c = "L"
            rl.append(i)
    else:
        if s[i] == "R":
            c = "R"
            l.append(i)
            
l.append(i+1)

pr = []
for i in range(len(l)-1):
    ss = s[l[i]:l[i+1]]
    pl = [0 for k in range(l[i+1] - l[i])]
    ind = rl[i] - l[i]
    cr = ss.count("R")
    cl = ss.count("L")
    c = cr//2 + (cl+1)//2
    cn = len(ss) - c
    pl[ind] = c
    pl[ind-1] = cn
    pr += pl
    
" ".join(map(str, pr))
print(" ".join(map(str, pr)))

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

int main()
{
	int a[2 * 100000];
	list<int> b;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		if (i%2 == 0){
			b.push_back(a[i]);
		}
		else {
			b.push_front(a[i]);
		}
	}
	if (n % 2 == 1) {
		b.reverse();
	}

	int index = 0;
	for (auto itr = b.begin(); itr != b.end(); ++itr, index++) {
		cout << *itr;
		if (index != n - 1) {
			cout << " ";
		}
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 10168
A, B, K = gets.split.map(&:to_i)
if B-A < K*2
  (A..B).each do |num|
    puts num unless num.between?(A+K, B-K)
  end
else
  array = (A..(A+K-1)).to_a
  array += ((B-K+1)..B).to_a
  puts array
end


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

int main(){
    int h1,h2,k1,k2,a,b,c,d;

    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;

    int kouji=0;

    for(int i=0; i<h1; i++){
        kouji = kouji + a;
    }

    kouji += (h1/10)*c;

    for(int i=0; i<h2; i++){
        kouji = kouji + b;
    }

    kouji += (h2/20)*d;

    int ken = 0;
    
    for(int i=0; i<k1; i++){
        ken = ken + a;
    }

    ken +=(k1/10)*c;

    for(int i=0; i<k2; i++){
        ken = ken + b;
    }

    ken += (k2/20)*d;

    if(kouji>ken){
        cout << "hiroshi" << endl;
    }else if(kouji<ken){
        cout << "kenjiro" << endl;
    }else{
        cout << "even" << endl;
    }

    return 0;

}


Measured memory_bytes: 3120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,w;cin>>n>>w;
    vin f(n);rep(i,n)cin>>f[i];
    sort(all(f));
    vvll dp(n,vll(w+1));
    rep(i,w+1)dp[0][i]=1;
    int sum=0;
    rep(i,n-1){
        sum+=f[i];
        rep(j,w+1){
            if(j>=f[i+1]){
                if(sum<=j-f[i+1])dp[i+1][j]=dp[i][j-f[i+1]];
                else dp[i+1][j]=(dp[i][j]+dp[i][j-f[i+1]])%inf;
            }
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout<<dp[n-1][w]<<endl;
}


Measured memory_bytes: 18684
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
int main(void)
{
    double r,S,L;
    scanf("%lf",&r);
    
    S=r*r*PI;
    L=2*r*PI;
    
    printf("%.6f %.6f\n",S,L);
    
    return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

	static short[][] cost;
	static short[] d;
	static final short INF = Short.MAX_VALUE/4;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		byte n = scan.nextByte();
		cost = new short[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cost[i][j] = INF;
			}
		}
		d = new short[n];
		short m = scan.nextShort();
		for (int i = 0; i < m; i++) {
			String[] line = scan.next().split(",");
			cost[Integer.parseInt(line[0])-1][Integer.parseInt(line[1])-1] = Short.parseShort(line[2]);
			cost[Integer.parseInt(line[1])-1][Integer.parseInt(line[0])-1] = Short.parseShort(line[3]);
		}
		String[] line = scan.next().split(",");
		byte[] s = new byte[]{(byte)(Integer.parseInt(line[0])-1),(byte)(Integer.parseInt(line[1])-1)};
		int money = Integer.parseInt(line[2])-Integer.parseInt(line[3]);

		for (int j = 0; j < 2; j++) {
			boolean[] used = new boolean[n];
			for (int i = 0; i < n; i++) d[i] = INF;
			d[s[j]] = 0;
			while (true) {
				byte v = -1;
				for (byte i = 0; i < n; i++) {
					if (!used[i] && (v == -1 || d[i] < d[v]))
						v = i;
				}
				if (v == -1)
					break;
				used[v] = true;
				for (byte i = 0; i < n; i++) {
					d[i] = (short) Math.min(d[i], d[v] + cost[v][i]);
				}
			}

			money-=d[s[1-j]];
		}

		System.out.println(money);
	}
}

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

int main(){
	double r, p, a, b;
	
	p = 3.141592653589;
	
	cin >> r;
	
	a = r*r*p;
	b = 2*p*r;
	
	printf("%f %f\n", a, b);
	
	return 0;
}


Measured memory_bytes: 3212
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}

 long long int sumXOR(ll arr[], int n)
{
     long long int sum = 0;
    for (int i = 0; i <=60; i++)
    {
        //  Count of zeros and ones
        long long zc = 0, oc = 0;

        // Individual sum at each bit position
        long long int idsum = 0;
        for (int j = 0; j < n; j++)
        {
            if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;
        }

        // calculating individual bit sum
        idsum = (oc * ((zc * ((1ll << i)%Mod))%Mod))%Mod;

        // final sum
        sum =(sum+ idsum)%Mod;
    }
    return sum%Mod;
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;



        cin>>n;


        long long ara[n+2];

        for(i=0; i<n; i++)
            cin>>ara[i];

         cout<<sumXOR(ara,n)<<endl;


}



Measured memory_bytes: 5972
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int Q = sc.nextInt();
        int R = sc.nextInt();
        int count =0;
            if(P + Q <= Q + R && P+Q<= P+R) {
                System.out.println(P + Q);
            }else if(Q+R <= P+Q && Q+R <= P+R){
                System.out.println(Q+R);
            }else{
                System.out.println(P+R);
            }
      

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string.h>

using namespace std;


bool func(int *arr, bool taros_turn, int n, int k){
    if(k==0){
        if(taros_turn)return false;
        return true;
    }
    if(k<0){
        if(taros_turn)return true;
        else return false;
    }
    //for k>0
    if(taros_turn){
        for(int i=0; i<n; i++){
            bool temp = func(arr, !taros_turn, n, k-arr[i]);
            if(temp) return true;
        }
        return false;
    }
    else{
        for(int i=0; i<n; i++){
            bool temp = func(arr, !taros_turn, n, k-arr[i]);
            if(temp==false)return false;//if its not taros turn and even if one scenario taro looses jiro will
            //choose that scenario as he is playing optimally
        }
        return true;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    int arr[n];
    for(int i=0; i<n; i++)cin>>arr[i];

    bool dp[2][k+1];
    //0 means taros turn
    //1 means jiros turn
    dp[0][0] = false;
    dp[1][0] = true;

    for(int i=1; i<k+1; i++){
        //iterate through arr
        //first if taros turn
        dp[0][i] = false;
        for(int j=0; j<n; j++){
            bool temp1;
            if(i-arr[j]<0) temp1 = false;
            else temp1 = dp[1][i-arr[j]];

            if(temp1){
                // cout<<"changed at 0,"<<i<<endl;
                dp[0][i] = true;
                break;
            }
        }
        //second if not taros turn
        dp[1][i] = true;
        for(int j=0; j<n; j++){
            bool temp1;
            if(i-arr[j]<0) temp1 = true;
            else temp1 = dp[0][i-arr[j]];

            if(temp1==false){
                dp[1][i] = false;
                break;
            }
        }
        // cout<<"k = "<<i<<" "<<dp[0][i]<<" "<<dp[1][i]<<endl;
    }
    //now collect the result
    if(dp[0][k])cout<<"First"<<endl;
    else cout<<"Second"<<endl;


    // //now call the function
    // bool taros_turn = true;

    // bool taro_wins = func(arr, taros_turn, n, k);

    // if(taro_wins)printf("First\n");
    // else printf("Second\n");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    long long ans = 0;
    long long M = a[0];
    for (int i = 1; i < n; ++i) {
        ans += max(0ll, M - a[i]);
        M = max(M, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
mod = 10**9+7
fact = [1]*(10**6+1)
for i in range(10**6):
    fact[i+1] = (i+1)*fact[i]%mod

n,a,b = map(int,input().split())
ans = pow(2,n,mod)-1
ca = 1
for k in range(a):
    ca *= n-k
    ca %= mod
ca *= pow(fact[a],mod-2,mod)
cb = 1
for k in range(b):
    cb *= n-k
    cb %= mod
cb *= pow(fact[b],mod-2,mod)

ans -= ca+cb
ans %= mod
print(ans)

Measured memory_bytes: 48876
N, K = map(int, input().split())

ans = 0
if K % 2 == 1:
  ans = int(N / K) ** 3
else:
  cnt = 0
  for i in range(1, N + 1):
    if i % K == int(K / 2):
      cnt += 1
  ans = int(N / K) ** 3 + cnt ** 3

print(ans)

Measured memory_bytes: 3060
N,M=map(int,input().split())
H=list(map(int,input().split()))
top=[True]*N
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]<=H[B-1]:
        top[A-1]=False
    if H[A-1]>=H[B-1]:
        top[B-1]=False
print(sum(top))

Measured memory_bytes: 20036
#include<stdio.h>
#include<stdlib.h>

static int compareInt(const void* a, const void* b);
static int compareInt(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return bNum - aNum;
}
int main(){
  int N;
  /*個数の入力*/
  scanf("%d",&N);
  int a[N];
  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  int b[N];
  for(int i=0;i<N;i++){
    b[i]=a[i];
  }
  qsort(b, N, sizeof(int), compareInt);
  for(int i=0;i<N;i++){
    if(a[i]==b[0]){
      printf("%d\n",b[1]);
    }else{
      printf("%d\n",b[0]);
    }
  }
  return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;
ll dp[110][10]; //
int main(void)
{
    ll H, W, K;
    cin >> H >> W >> K;

    dp[0][0] = 1;               //高さ:1 横:1 前の情報は0に限られる
    for (int h = 0; h < H; ++h) //高さ
    {
        for (int bit = 0; bit < (1 << (W - 1)); ++bit) //幅
        {
            bool judge = true;

            for (int i = 0; i < W - 1; ++i)
            {
                if ((bit >> i) & 1 && (bit >> (i + 1)) & 1)
                    judge = false;
            }
            if (!judge)
                continue;

            int perm[10];
            for (int i = 0; i < W; ++i)
                perm[i] = i;

            for (int i = 0; i < W - 1; ++i)
            {
                if ((bit >> i) & 1)
                    swap(perm[i], perm[i + 1]);
            }

            for (int i = 0; i < W; ++i)
            {
                dp[h + 1][perm[i]] += dp[h][i];
                dp[h + 1][perm[i]] = dp[h + 1][perm[i]] % MOD;
            }
        }
    }
    cout << dp[H][K - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
n,k=map(int,input().split())
l=list(map(int,input().split()))
plus=[]
minus=deque()
for i in l:
    if i<0:
        minus.appendleft(abs(i))
    elif i>0:
        plus.append(i)
    else:
        k-=1
minus=list(minus)
lenp=len(plus)
lenm=len(minus)
if k==0:
    print(0)
else:
    tcounter=[]
    if lenp>=k:
        tcounter.append(plus[k-1])
        if lenm>=k:
            for i in range(1,k):
                tcounter.append(min(plus[k-1-i],minus[i-1])+plus[k-1-i]+minus[i-1])
            tcounter.append(minus[k-1])
        else:
            for i in range(1,lenm+1):
                tcounter.append(min(plus[k-1-i],minus[i-1])+plus[k-1-i]+minus[i-1])
    else:
        if lenm>=k:
            for i in range(k-lenp,k):
                tcounter.append(min(plus[k-1-i],minus[i-1])+plus[k-1-i]+minus[i-1])
            tcounter.append(minus[k-1])
        else:
            for i in range(k-lenp,lenm+1):
                tcounter.append(min(plus[k-1-i],minus[i-1])+plus[k-1-i]+minus[i-1])
                
            
         
    print(min(tcounter))

Measured memory_bytes: 62576
from sys import stdin,stdout
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
dp=[[-1,-1] for i in range(k+1)]
for i in range(1,k+1):
    for j in a:
        if i>=j:
            if dp[i-j][0]==-1 and dp[i-j][1]==-1:
                dp[i][0]=1
            elif dp[i-j][1]==1:
                dp[i][0]=1
    if dp[i][0]==-1:
        dp[i][1]=1
if dp[k][0]==1:
    print('First')
else:
    print('Second')
# print(dp)

Measured memory_bytes: 54192
#include <iostream>

using namespace std;

bool IsPrime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}

int main(void) {
  int X;
  cin >> X;
  while (!IsPrime(X)) X++;
  cout << X << endl;
  return 0;
}


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

vector <ll> v ;

int main()
{
int n ; cin >> n ; ll ans =0 ;
for (int i = 1 ; i<=n ; i++){
    if (i%3!=0 &&i%5!=0)ans+=i;
}
cout << ans ;
}


Measured memory_bytes: 3572
s=input()
alp=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ss=sorted(s)
for i in alp:
    if i not in ss:
        print(i)
        break
else:
    print('None')

Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int x[5];
  int ans=0;
  int m=10;
  REP(i,5){
    cin>>x[i];
    if(x[i]%10==0){
      continue;
    }else{
      m = min(m,x[i]%10);
    }
  }
  
  REP(i,5){
    if(x[i]%10==0){
      ans += x[i];
    }else{
      ans += x[i] + 10 - x[i]%10;
    }
  }
  
  if(m!=0){
    ans -= 10-m;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    bool f = 1;
    for (int i = 0; i < A; i++)
    {
        if (!(S[i] >= '0' && S.at(i) <= '9'))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if (S[A] != '-')
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = A + 1; i < A + B + 1; i++)
    {
        if (!(S.at(i) >= '0' && S.at(i) <= '9'))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int n;cin>>n;
    string s,t;cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
priority_queue<pair<int,int> >q;
const int N=100009;
int he[N],to[N<<1],ne[N<<1],g[N];
bool f[N];
int main(){
	int n,i,j,k,t=0,m;
	scanf("%d",&n);
	for(i=1;i<n;++i){
		scanf("%d%d",&j,&k);
		ne[++t]=he[j],to[t]=k,he[j]=t;
		ne[++t]=he[k],to[t]=j,he[k]=t;
	}
	scanf("%d",&k);
	while(k--){
		scanf("%d%d",&i,&j),g[i]=j,f[i]=1;
		q.push(make_pair(j,i));
	}
	for(m=1;m<=n;++m){
		i=q.top().second,q.pop();
		for(j=he[i];j;j=ne[j]){
			if(!f[to[j]])f[to[j]]=1,g[to[j]]=g[i]-1,q.push(make_pair(g[to[j]],to[j]));
			else if(g[to[j]]!=g[i]-1&&g[to[j]]!=g[i]+1)return puts("No"),0;
		}
	}
	puts("Yes");
	for(i=1;i<=n;++i)printf("%d\n",g[i]);
	return 0;
}

Measured memory_bytes: 4212
/*
Author : N_o_o_B
Created : March 14 2020 17:45:34 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll a,b,c;
    cin >>a  >> b >> c;
    if(c <= (a+b)){
        cout << "No" << endl;
    }
    else{
        ll lft = 4*a*b;
        ll rt = (c-a-b)*(c-a-b);
        if(lft < rt){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var (
    r,g,b,n int
    ans int
    )
  fmt.Scan(&r)
  fmt.Scan(&g)
  fmt.Scan(&b)
  fmt.Scan(&n)

  rm := n/r
  gm := n/g

  for ri:=0;ri<=rm;ri++ {
    for gi:=0;gi<=gm;gi++ {
      v := n - ri * r - g * gi
      if v >= 0 && v % b == 0  {
        ans += 1
      }
    }
  }
  fmt.Println(ans)
}


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

int main(void){
	int n,v[50];
	cin>>n;
	if(n == 0 || n == 1){
		cout<<1<<endl;
	}else{
		v[0] = v[1] = 1;
		for(int i = 2 ; i <= n ; i ++){
			v[i] = v[i-1] + v[i-2];
		}
		cout<<v[n]<<endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int g(int64_t a,int64_t b){
  if(a>b)
    return g(b,a);
  if(a==0)
    return b;
  return g(b%a,a);
}
int main(){
  int64_t a,b;
  cin>>a>>b;
  cout<<a*b/g(a,b)<<endl;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long x;
    cin >> x;
    long num = 1;
    while(num<=1000000){
        if((100*num<=x)&&(x<=105*num)){
            cout << 1 << endl;
            return 0;
        }
        num++;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(1000000)
 
ma_map = [ -1, 2, 5, 5, 4, 5, 6, 3, 7, 6 ]
N, M = (int(i) for i in input().split())
ma = list(int(i) for i in input().split())
memo = [-1] * 100000
 
def dfs(num):
	if memo[num] != -1: return memo[num]
	if num == 0: return 0
 
	ret = -1
	for p in ma:
		if 0 <= num - ma_map[p]:
			ret = max(dfs(num - ma_map[p]) * 10 + p, ret)
 
	memo[num] = ret
	return ret
 
ma.sort()
print(dfs(N))

Measured memory_bytes: 17116
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

int N,K;
const int MOD = 1000000007;
int main() {
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a.at(i);
    //dp[i][j]に、i人目までに飴をj個「以下」渡す方法の場合の数を保存
    mat dp(N,vec(K+1,0));
    if(K == 0){
        cout<<1<<endl;
        return 0;
    }
    rep(i,N){
        int ai = a.at(i);
        rep(j,K+1){
            ll &ndp = dp.at(i).at(j);
            if(i == 0) {
                ndp = min(j+1,ai+1);
                continue;
            }
            if(j != 0)ndp += dp.at(i).at(j-1);
            ndp += dp.at(i-1).at(j);
            if(j>=ai+1) ndp -= dp.at(i-1).at(j-ai-1);
            (ndp+=MOD)%=MOD;
        }
    }
    ll ans = dp.at(N-1).at(K)-dp.at(N-1).at(K-1);
    (ans+=MOD)%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
string s, keyence("keyence");
int main(){
    cin >> s;
    if(s.substr(0, 7) == keyence){ cout << "YES" << endl; return 0;}
    if(s.substr(s.size()-7, 7) == keyence){ cout << "YES" << endl; return 0;}
    for(int i=0; i<s.size() ;i++){
        for(int j=i; j<s.size(); j++){
            if(s.substr(0, i) + s.substr(j, s.size()-j) == keyence){
                cout <<"YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    string x, y;
    bool a = false;

    for(int i = 0; i < N/2; i++){
        x += S.at(i);
    }

    for(int i = N/2; i < S.size(); i++){
        y += S.at(i);
    }

    if(x == y){
        cout << "Yes";
    }else{
        cout << "No";
    }

//    cout << x << endl;
//    cout << y << endl;
}

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S; cin >> S;
  int K; cin >> K;

  int N = SZ(S);
  REP(i,N){
	int c = 'z' - S[i] + 1;
	if(S[i] > 'a' && c <= K){
	  S[i] = 'a';
	  K -= c;
	}
  }

  S.back() = ((S.back() - 'a') + K) % 26 + 'a';
  cout << S << endl;

  return 0;
}


Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  int a[H][W];
  int rem_h[H];
  int rem_w[W];
  string input;

  for(int h=0; h<H; ++h){
    cin >> input;
    if(input.find("#") != string::npos){
      rem_h[h] = 1;
    }else{
      rem_h[h] = 0;
    }
    for(int w=0; w<W; ++w){
      if(input[w] == '#'){
        a[h][w] = 1;
      }else{
        a[h][w] = 0;
      }
    }
  }

  int sharp;
  for(int w=0; w<W; ++w){
    sharp = 0;
    for(int h=0; h<H; ++h){
      if(a[h][w] == 1){
        ++sharp;
      }
    }
    if(sharp > 0){
      rem_w[w] = 1;
    }else{
      rem_w[w] = 0;
    }
  }

  for(int h=0; h<H; ++h){
    if(rem_h[h] == 0){
      continue;
    }else{
      for(int w=0; w<W; ++w){
        if(rem_w[w] == 0){
          continue;
        }
        if(a[h][w] == 1){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		//String S = sc.next();
		//int N = Integer.parseInt(sc.next());
		//out.println();
		// ArrayList<String> list = new ArrayList<String>();
		// list.stream().sorted().distinct();
		int a[] = new int[3];
		for(int i=0;i<3;i++){
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		out.println(a[0]+a[1]);
		
		out.flush();	
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

struct bit {
    vector<ll> v; // 部分和をbitで管理 仮想配列はa[1...n]
    bit(int n){ // bit(int n) : v(n + 1) {}
        v.resize(n + 1);
    }
    
    ll sum(int i){ // 仮想配列a[1]~a[i]の和を求める
        ll ret = 0;
        for(; i > 0; i -= i & -i){ // i & -i: iの1が立っている最高位bitをの2^を返す
            ret += v[i];
        }
        return ret;
    }
    
    void add(int i, ll w) { // index:iにwを加える
        for (; i < v.size(); i += i & -i) {
            v[i] += w;
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
    
    vector<vector<pair<int, int>>> W(M + 5);
    rep(i, N){
        int l, r;
        cin >> l >> r;
        W[r - l + 1].pb(mp(l, r));
    }
    
    vector<int> ans(M + 1);
    bit B(M + 5);
    int ok = N;
    rep(i, 1, M + 1){
        
        for(auto j: W[i]){
            B.add(j.first, 1);
            B.add(j.second + 1, -1);
        }
        ok -= W[i].size();
        ans[i] = ok;
        for(int j = i; j <= M; j += i) ans[i] += B.sum(j);
    }
    
    rep(i, 1, M + 1){
        output(ans[i]);
    }
    
    
    return 0;
}

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

int main(void){
    uint32_t    i,n,q;
    uint64_t    x;
    set<uint64_t>   S;

    cin >> n;
    for(i = 0; i < n; i += 1){
        cin >> q >> x;
        switch(q){
            case 0:
            S.insert(x);
            cout << S.size() << endl;
            break;
            case 1:
            S.find(x);
            cout << S.count(x) << endl;
            break;
            default:
            S.erase(x);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 12428
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

const int MAX=1000;

#define hoge(i,n) for(int i=0;i<n;i++)
int main(){
    int n,a[MAX],gap[MAX-1];
    while(cin>>n && n){
        hoge(i,n){
            scanf("%d", &a[i]);
        }
        sort(a,a+n);
        int mingap=20000000;
        hoge(i,n-1){
            gap[i]=a[i+1]-a[i];
            mingap=min(mingap,gap[i]);
        }
        cout << mingap <<endl;
    }
}

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=200010;
int n;
ll res;
int a[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,p=2,q=4;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    long long A=a[1],B=0,C=a[2]+a[3],D=0,ans=1LL<<60;
    for(int i=4;i<=n;i++) D+=a[i];
    for(int i=2;i<=n-2;i++) {
	B+=a[i],C-=a[i];
	while(p<i&&min(A,B)<min(A+a[p],B-a[p])) A+=a[p],B-=a[p],++p;
	while(q<n&&min(C,D)<min(C+a[q],D-a[q])) C+=a[q],D-=a[q],++q;
	ans=min(ans,max(A,max(B,max(C,D)))-min(A,min(B,min(C,D))));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

cpp_int rec(cpp_int h) {
	if (h == 1) {
		return 1;
	}
	else {
		return 2 * rec(h / 2) + 1;
	}
}

int main() {
	cpp_int h;
	cin >> h;
	
	cout << rec(h) << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    vector<ll> a(n);
    ll suma = 0;
    rep(i,n) {
        cin >> a[i];
        suma += a[i];
        suma %= MOD;
    }
    ll ans = 0;
    rep(i,n) {
        suma -= a[i];
        if(suma<0) suma += MOD;
        ans += a[i] * suma;
        ans %= MOD;
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

typedef vector<VI> mat;

mat mul(mat &A, mat &B) {
	mat C(A.size(), VI(B[0].size()));
	REP(i, A.size()) {
		REP(k, B.size()) {
			REP(j, B[0].size()) {
				C[i][j] = (C[i][j] + (A[i][k] * B[k][j])) % mod;
			}
		}
	}
	return C;
}

mat pow(mat A, int N) {
	mat B(A.size(), VI(A.size()));
	REP(i, A.size())B[i][i] = 1;
	while (N > 0) {
		if (N & 1)B = mul(A, B);
		A = mul(A, A);
		N /= 2;
	}
	return B;
}


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

	int N, K; cin >> N >> K;
	mat A(N, VI(N));
	REP(i, N)REP(j, N)cin >> A[i][j];

	mat a = pow(A, K);
	int ans = 0;
	REP(i, N)REP(j, N)ans = (ans + a[i][j]) % mod;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

ll n, m;

vi dp(300000, -1);

ll fact(ll x){
  if(x == 0) return 1;
  if(dp[x] != -1) return dp[x];
  return dp[x] = (fact(x-1) * x)%m;
}

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >>  n >> m;
    if(n<=m) while(m--) cout << n;
    else while(n--) cout << m;
    cout << endl;
    return 0;
}


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

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	string s, ss = "";
	
	cin >> s;
	
	for(int i = 1; i < 4; i++){
		if(s[i] == s[i-1]){
			cout << "Bad" << "\n";
			return 0;
		}
	}
	
	cout << "Good" << "\n";
	
	
	return 0;
}


Measured memory_bytes: 256