akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

char maze[20][20];
int d1[20][20];
int d2[20][20];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MAX = 10000;
int H, W;

pair<int, int> bfs(int a, int b){
    rep(i, H){
        rep(j, W){
            d1[i][j] = MAX;
        }
    }
    queue<pair<int, int> > Q;
    Q.push(make_pair(a, b));
    d1[a][b] = 0;
    int x = a;
    int y = b;
    int z = 0;

    while(!Q.empty()){
        pair<int, int> p = Q.front(); Q.pop();
        rep(i, 4){
            if(p.first+dx[i] >= 0 && p.first+dx[i] < H && p.second+dy[i] >= 0 && p.second+dy[i] < W && maze[p.first+dx[i]][p.second+dy[i]] == '.' && d1[p.first+dx[i]][p.second+dy[i]] == MAX){
                d1[p.first+dx[i]][p.second+dy[i]] = d1[p.first][p.second] + 1;
                Q.push(make_pair(p.first+dx[i], p.second+dy[i]));
                x = p.first+dx[i];
                y = p.second+dy[i];
                z = d1[x][y];
            }
        }
    }

    return make_pair(x, y);
}

int main() {
    cin >> H >> W;
    rep(i, H){
        rep(j, W){
            cin >> maze[i][j];
        }
    }
    int a, b;
    int ans = 0;
    rep(i, H){
        rep(j, W){
            if(maze[i][j] == '.'){
                a = i;
                b = j;
                pair<int, int> p = bfs(a, b);
                ans = max(ans, d1[p.first][p.second]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<998244353>;

//--------------------------- Solve ---------------------------//


void solve() {
    int n, k; cin >> n >> k;
    vector<int> l(k), r(k);
    for (int i = 0; i < k; i++) cin >> l[i] >> r[i];

    vector<mint> dp(n+1), cumsum(n+1);
    cumsum[1] = 1;
    for (int i = 1; i <= n; i++) {
        if (i > 2) cumsum[i] += cumsum[i-1];
        cumsum[i] += dp[i];
        for (int j = 0; j < k; j++) {
            if (i + l[j] <= n) dp[i+l[j]] += cumsum[i];
            if (i + r[j] + 1 <= n) dp[i+r[j]+1] -= cumsum[i];
        }
    }

    cout << cumsum[n] << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 6332
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char[] chs = sc.next().toCharArray();
			
			int answer = 0;
			for(int i = 0; i < chs.length / 2; i++) {
				if(chs[i] != chs[chs.length - 1 - i]) {
					answer += 1;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


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

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

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

// ----------------------------------------------------------
char field[111][111];

int main() {
    rep(i, 111) rep(j, 111){
        field[i][j] = 'x';
    }
    ll h, w;
    cin >> h >> w;
    rep(i, h) rep(j, w) {
        cin >> field[i][j];
    }
    rep (i, h) {
        bool flag = true;
        rep(j, w) {
            if (field[i][j] == '#') {
                flag = false;
                break;
            }
        }
        if (flag) {
            rep(j, w) {
                field[i][j] = 'x';
            }
        }
    }
    rep (j, w) {
        bool flag = true;
        rep(i, h) {
            if (field[i][j] == '#') {
                flag = false;
                break;
            }
        }
        if (flag) {
            rep(i, h) {
                field[i][j] = 'x';
            }
        }
    }
/*
    rep(i, h) {
        rep(j, w) {
            cout << field[i][j];
        }
        cout << endl;
    }
*/
    rep(i, h) {
        bool temp = false;
        rep(j, w) {
            if (field[i][j] != 'x') {
                cout << field[i][j];
                temp = true;
            }
        }
        if (temp) {
            cout << endl;
        }
    }
    return 0;
}

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

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int ans = 0;
    for(int i=l; i<=r; ++i){
        if(i%d==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

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

    int n = sc.nextInt();

    int a = (n / 2) + (n % 2 == 1 ? 1 : 0);
    double b = (double)a / (double)n;
    System.out.println(String.format("%.10f", b));
  }
}

Measured memory_bytes: 24020
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

a,b,c,d = inpl()
AB = abs(a-b)<=d
BC = abs(b-c)<=d
AC = abs(c-a)<=d

if AC or (AB and BC):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 4204
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

H, W = map(int, readline().split())

white_y = [0] * H
white_x = [1] * W

masu = []
for i in range(H):
    yoko = list(readline().decode("utf-8"))
    if not "#" in yoko:
        white_y[i] = 1
    for j, x in enumerate(yoko):
        if x == "#":
            white_x[j] = 0
    masu.append(yoko)

# print(white_y)
# print(white_x)

for i in range(H):
    if white_y[i] == 1:
        continue
    s = ""
    for j in range(W):
        if white_x[j] == 1:
            continue
        s += masu[i][j]
    print(s)
    

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoderSolve
{
    class Solve
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();

            long ans = 0;
            for(var i = 0; i < N; i++)
            {
                ans += Math.Min(2 * x[i], 2 * Math.Abs(K - x[i]));
            }
            Console.WriteLine(ans);
          

            Console.Out.Flush();
        }
    }



    public class Calculation
    {
        
    }
}


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

class dice {
    private:
    int surf[6];
    public:
    dice(int a[6]);
    void move_N();
    void move_S();
    void move_E();
    void move_W();
    void show();
};

dice::dice(int a[6]){
    for(int i = 0; i < 6; i++){
        surf[i] = a[i];
    }
}

void dice::move_S(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[4];
    surf[1] = buf[0];
    surf[4] = buf[5];
    surf[5] = buf[1];

}

void dice::move_N(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[1];
    surf[1] = buf[5];
    surf[4] = buf[0];
    surf[5] = buf[4];

}

void dice::move_W(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[2];
    surf[2] = buf[5];
    surf[3] = buf[0];
    surf[5] = buf[3];

}

void dice::move_E(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[3];
    surf[2] = buf[0];
    surf[3] = buf[5];
    surf[5] = buf[2];

}

void dice::show(){
    cout << surf[0] << endl;
}

int main(){
    int a[6],b[6];
    string dir;
    int flag = 0;
    for(int i = 0; i < 6; i++){
        cin >> a[i];
    }
    /*
    for(int i = 0; i < 6; i++){
        cin >> b[i];
    }
    */
    dice A(a);
    cin >> dir;
    //cout << dir.length();
    for(int i = 0; i < dir.length(); i++){

        switch(dir[i]){
            case 'E':
                A.move_E();
            break;
            case 'S':
                A.move_S();
            break;
            case 'W':
                A.move_W();
            break;
            case 'N':
                A.move_N();
            break;
            default:
                flag = 1;
            break;
        }
        //A.show();
    }

    A.show();



}


Measured memory_bytes: 3172
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextLong();
		}
		
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    while(a[i]%2 == 0){
		        result++;
		        a[i] /= 2;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 33728
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

a, b, c = map(int, input().split())
k = int(input())

count = 0
while a >= b:
    b *= 2
    count += 1

while b >= c:
    c *= 2
    count += 1

if count <= k:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 68036
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ALL(a)  (a).begin(),(a).end()

void _main(){
    int x,y; cin>>x>>y;
    int t,k;
    t = y-2*x;
    k = 4*x-y;
    string out;
    if(t>=0&&k>=0&&t%2==0&&k%2==0) out = "Yes";
    else out = "No";
    cout << out << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3120
#include <iostream>
#include <stack>
#include <vector>

int main() {
  int n, q;
  std::cin >> n >> q;
  std::vector<std::stack<int>> s(n);

  for (int i = 0; i < q; ++i) {
    int c, t;
    std::cin >> c >> t;
    switch (c) {
    case 0:
      int x;
      std::cin >> x;
      s.at(t).push(x);
      break;
    case 1:
      if (s.at(t).size() > 0)
        std::cout << s.at(t).top() << std::endl;
      break;
    case 2:
      if (s.at(t).size() > 0)
        s.at(t).pop();
      break;
    }
  }
}



Measured memory_bytes: 4420
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

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

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

int main() {
	ll X, Y;
	cin >> X >> Y;
	if (X < Y)swap(X, Y);
	string A = "Alice", B = "Brown";

	if(abs(X - Y) <= 1LL) cout << B << endl;
	else cout << A << endl;
	return 0;
}


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

int input_data[5];

int main(void){
	for(int i = 0; i < 5; i++){
		scanf("%d", &input_data[i]);
	}
	for(int i = 0; i < 5; i++){
		for(int j = i + 1; j < 5; j++){
			if(input_data[i] < input_data[j]){
				swap(input_data[i], input_data[j]);
			}
		}
	}
	for(int i = 0; i < 5; i++){
		printf("%d", input_data[i]);
		if(i != 4) printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2680
#include<stdio.h>

int main()
{
    int n,i,j,c=0,numb=1;
    scanf("%d",&n);
    if(n<105) printf("0\n");
    else if(n==105) printf("1\n");
    else {
        for(i=107;i<=n;i+=2)
        {
            c=0;
            for(j=1;j<=n;j+=2)
            {
                if(i%j==0) c++;
            }
            if(c==8) numb++;
        }
        printf("%d\n",numb);
    }
    return 0;
}


Measured memory_bytes: 128
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
  // cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
       ll n;
       cin>>n;
       ll a[n+2];
       for(int i=1;i<=n;i++)
        cin>>a[i];
      ll ans=0;
      for(int i=1;i<=n;i++)
      {
        for(int j=i+1;j<=n;j++)
        {
          for(int k=j+1;k<=n;k++)
          {
              if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
                ans++;
          }
        }
      }
      cout<<ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
#define ALL(v) (v).begin(), (v).end()
const int mod = INF+7;
using namespace std;

bool prim(int n){
  bool flag=true;
  srep(i,2,(int)sqrt(n)+1){
    if(n%i==0){
      flag=false;
      break;
    }
  }
  return flag;
}

int element(int i, int N){
  int count=0;
  int radix=i;
  bool primary=prim(i);
  if(primary==false){
    return count;
  }
  else{
    while(radix<N){
      count+=N/radix;
      radix*=i;
    }
    return count;
  }
}

int main(){
  int N;
  cin >> N;
  int *ele=(int *)malloc(sizeof(int)*(N+1));
  srep(i, 2, N+1){
    ele[i]=element(i, N);
  }

  int count74=0;
  int count24=0;
  int count14=0;
  int count4=0;
  int count2=0;
  srep(i, 2, N+1){
    if(ele[i]>=74){
      count74++;
    }
    if(ele[i]>=24){
      count24++;
    }
    if(ele[i]>=14){
      count14++;
    }
    if(ele[i]>=4){
      count4++;
    }
    if(ele[i]>=2){
      count2++;
    }
  }

  int sum=0;
  if(count4>=2){
    sum+=count4*(count4-1)/2*(count2-2);
  }
  if(count14>=1){
    sum+=count14*(count4-1);
  }
  if(count24>=1){
    sum+=count24*(count2-1);
  }
  if(count74>=1){
    sum+=count74;
  }

  printf("%d\n", sum);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cstdlib>
#include <typeinfo>
#include <list>
#include <stdio.h>
#include <math.h>

using namespace std;

const int MAX_N = 101;
const int MAX_W = 10001;

int main() {
  int n, w;
  scanf("%d %d", &n, &w);
  vector<int> values(MAX_N);
  vector<int> weights(MAX_N);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &values[i], &weights[i]);
  }

  vector<vector<int>> dp(MAX_N, vector<int>(MAX_W, 0));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= w; j++) {
      if (weights[i] > j) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - weights[i]] + values[i]);
      }
    }
  }
  printf("%d\n", dp[n][w]);
  return 0;
}

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

int main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N), B(N);
    for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

    long long res = 0;
    for(int k=-1; k<30; ++k) {
        if(k == -1 || ((K >> k) & 1)) {
            long long mask = 0;
            for(int i=0; i<k; ++i) {
                mask |= (1LL << i);
            }
            for(int i=k+1; i<30; ++i) {
                mask |= (K & (1LL << i));
            }

            long long tmp = 0;
            for(int i=0; i<N; ++i) {
                if((mask | A[i]) == mask) tmp += B[i];
            }
            res = max(res, tmp);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u)
{
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].p == NIL) cout << "root, ";
    else if(T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";
    cout << "[";
    for(int i=0, c=T[u].l; c!=NIL; i++, c=T[c].r)
    {
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p)
{
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r, p);
    if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main()
{
    int d, v, c, l, r;
    cin >> n;
    for(int i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
    for(int i=0; i<n; i++)
    {
        cin >> v >> d;
        for(int j=0; j<d; j++)
        {
            cin >> c;
            if(j==0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(int i=0; i<n; i++) if(T[i].p == NIL) r = i;
    rec(r,0);
    for(int i=0; i<n; i++) print(i);
    return 0;
}



Measured memory_bytes: 7780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    auto a = InputVec(N);
    ll res = 1ll << 50;
    for (int i = -100; i <= 100; ++i) {
        ll cost = 0;
        for (int j = 0; j < N; ++j) {
            cost += (a[j] - i) * (a[j] - i);
        }
        res = min(cost,res);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K, a, b;
    cin >> K >> a >> b;
    if(a+2 >= b){
        cout << K+1 << "\n";
        return 0;
    }else{
        if(K <= a-1){
            cout << K+1 << "\n";
        }else{
            ll cnt = (K-(a-1))/2;
            if((K-(a-1))%2){
                cout << a+cnt*(b-a)+1 << "\n";
            }else{
                cout << a+cnt*(b-a) << "\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
ll dp[3][505];
char s[500005],t[500005],u[500005];
bool dame,flag;

int main(){
	cin >> n >> k;
	pu(n/k);
	n = n % k;
	pu(".");
	for(i=0;i<100;i++){
		n *= 10;
		pu(n/k);
		n = n % k;
	}
	el;
	return 0;
}

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

using ll = long long;

int main() {
  ll N,x;
  cin >> N >> x;
  vector<ll> a(N);
  for(auto &e: a) {
    cin >> e;
  }
  sort(begin(a),end(a));
  partial_sum(begin(a),end(a),begin(a));
  ll ans = upper_bound(begin(a),end(a),x) - begin(a);
  if (a.back() < x) --ans;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int d[10];
  for(int i = 0; i < 10; ++i) {
    cin >> d[i];
  }
  sort(d,d+10);
  for(int i = 0; i < 3; ++i) {
    cout << d[9-i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n >> m;
  vector<P> p(m);
  rep(i,m) cin >> p[i].first >> p[i].second;
  rep(x,1000) {
    int keta = 1;
    int nx = x/10;
    vector<int> d(1,x%10);
    while (nx) {
      keta++;
      d.push_back(nx%10);
      nx /= 10;
    }
    reverse(d.begin(),d.end());
    if (keta != n) continue;
    bool ok = true;
    rep(i,m) {
      if (d[p[i].first-1] != p[i].second) ok = false;
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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


  //input
  ll D;
  cin >> D;
  vl c(26);
  rep(i, 26) cin >> c[i];


  //preparation
  vpl C(26);
  rep(i,26) C[i] = pl (c[i], i);
  sort(all(C), greater<pl>());


  //output
  rep2(i, D) {
    ll day=i, cnt=0;
    while(day & 1) {day/=2; cnt++;}
    cout << C[cnt].second+1 << newl;
  }


  return 0;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {
	public static long calc(long a, long b, long c) {
		return a-(a/b+a/c-a/lcm(b,c));
	}
	
	public static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long A = stdIn.nextLong();
		long B = stdIn.nextLong();
		long C = stdIn.nextLong();
		long D = stdIn.nextLong();
		
		System.out.println(calc(B,C,D)-calc(A-1,C,D));

	}

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pb push_back
#define sbit __builtin_popcount
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define sz(a) (int)a.size()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sp(x) setprecision(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define val_at(x) find_by_order(x)
#define idx_of(x) order_of_key(x)
#define scni(x) scanf("%d",&x)
#define prt(x) printf("%d\n",x)
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> myset;
const int mod=1e9+7;
const int mex=1e6+1;
inline ll power(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0)
    {
        if(b&1)
        ans=ans*temp;
        ans=ans%mod;
        temp=temp*temp;
        temp=temp%mod;
        b/=2;
    }
    return ans;
}
int pr[mex];
vec prime;
inline void seive()
{
    rp(i,2,mex) pr[i]=1;
    for(int i=2;i*i<mex;i++)
    {
        if(pr[i])
        for(int j=i*i;j<mex;j+=i)
        pr[j]=0;
    }
    vec prime;
    rp(i,2,mex)
    {
        if(pr[i]) prime.pb(i);
    }
}
ll int xx,xy,d1;
void exeu(ll int a1,ll int b1)
{
    if(b1==0)
    {
        xx=1;
        xy=0;
        d1=a1;
    }
    else
    {
        exeu(b1,a1%b1);
        ll int temp=xx;
        xx=xy;
        xy=temp-(a1/b1)*xy;
    }
}
ll int modinv(ll int A,ll int M)
{
    exeu(A,M);
    return (xx%M+M)%M;
}
int main()
{
    fast
    ll int k,x;
    cin>>k>>x;
    ll int ans=k*500;
    if(ans>=x) cout<<"Yes\n";
    else cout<<"No\n";
    
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr int mod = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 892
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;

bool cond(const int limit, const int N, const int K) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        // cnt += (as[i] + limit - 1) / limit;
        cnt += (as[i] - 1) / limit;
    }
    return cnt <= K;
}

int solve(const int N, const int K) {
    int left = 0, right = 1000 * 1000 * 1000 + 1, mid;
    while (right - left > 1) {
        mid = left + (right - left) / 2;
        // printf("left: %d, right: %d, mid: %d\n", left, right, mid);
        if (cond(mid, N, K)) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return right;
}

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    cout << solve(N, K) << endl;

    return 0;
}


Measured memory_bytes: 3988
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstring>
#include <string.h>
using namespace std;

int main(void) {
	char Judge[4];
	int count[4] = { 0,0,0,0 };

	int N = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> Judge;

		if (!strcmp(Judge, "AC"))
			(count[0])++;
		else if (!strcmp(Judge, "WA"))
			(count[1])++;
		else if (!strcmp(Judge, "TLE"))
			(count[2])++;
		else
			(count[3])++;
	}

	cout << "AC" << " x " << count[0] << "\n";
	cout << "WA" << " x " << count[1] << "\n";
	cout << "TLE" << " x " << count[2] << "\n";
	cout << "RE" << " x " << count[3] << "\n";

	system("pause");
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll N,D;
  cin>>N>>D;
  int cnt(0);
  for(int i(0);i<N;i++){
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y <= D*D) cnt++;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3632
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    c = collections.Counter(a)
    cnt = 0
    for i in c:
        if c[i] % 2 == 1:
            cnt += 1
    print(cnt)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 21736
import sys
import numpy as np
input = sys.stdin.readline

n, t = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x:(x[0], -x[1]))

dp = np.array([0]*t)
ans = 0

for a, b in ab:
    ans = max(ans, dp[-1] + b)
    dp[a:] = np.maximum(dp[:-a]+b, dp[a:])
print(max(ans, dp[-1]))

Measured memory_bytes: 13032
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let r = read::<usize>();
    let s = read::<usize>();
    let p = read::<usize>();
    let t = read::<String>();
    let mut enem_hands: Vec<char> = vec![];
    for c in t.chars() {
        enem_hands.push(c);
    }
    let mut hand_point_graph = HashMap::new();
    hand_point_graph.insert('r', r);
    hand_point_graph.insert('s', s);
    hand_point_graph.insert('p', p);
    let mut win_graph = HashMap::new();
    win_graph.insert('r', 'p');
    win_graph.insert('s', 'r');
    win_graph.insert('p', 's');
    let mut hands = vec!['a'; n];
    let mut points = vec![0; n];
    for i in 0..n {
        hands[i] = *win_graph.get(&enem_hands[i]).unwrap();
        points[i] = *hand_point_graph.get(&hands[i]).unwrap();
        if i >= k {
            let prev = i - k;
            if hands[i] == hands[prev] && points[prev] != 0 {
                points[i] = 0;
            }
        }
    }
    println!("{}", points.iter().sum::<usize>());
}


Measured memory_bytes: 6396
n=int(input())
a=[]
b=[]
ans=0

for i in range(n):
    a.append(input())
m=int(input())
for i in range(m):
    b.append(input())
for i in a:
    if i not in b:
        ans=max(ans,a.count(i))
    else:
        ans=max(ans,a.count(i)-b.count(i))
print(ans)

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e-a > k) {
   cout << ":(" << endl;
}
else {
   cout << "Yay!" << endl;
}
}


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

int n[5];
void val(int num){
   for(int i=0;i<6;i++){
      n[i]=(num%10);
      num/=10;
   }

}
int main(){
  int A,B,count=0;
  cin>>A>>B;
  for(int i=A;i<=B;i++){
     val(i);
     if(n[0]==n[4]&&n[1]==n[3]) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

int n, A[MX];
int cnt[16];

int B[1<<16];
int D[1<<16];

int d(int mask){
    int &res=D[mask];
    if(res<inf) return res;
    for(int i=mask; i>0; i=(i-1)&mask)
        if(B[i]>=0) res=min(res, d(mask^i)+B[i]-1);
    return res;
}

bool valid(int s){
    int res=0;
    for(int i=0; i<16; i++) if(s&(1<<i)) res^=i;
    return res==0;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<n; i++){
        int u,v,c; cin>>u>>v>>c;
        A[u]^=c, A[v]^=c;
    }

    for(int i=0; i<n; i++) cnt[A[i]]++;
    int ans=0, mask=0;
    for(int i=1; i<16; i++) ans+=cnt[i]/2, cnt[i]%=2;
    for(int i=1; i<16; i++) if(cnt[i]) mask|=(1<<i);

    for(int i=0; i<(1<<16); i++){
        if(valid(i)) B[i]=__builtin_popcount(i);
        else B[i]=-1;
    }

    for(int i=0; i<(1<<16); i++) D[i]=inf;
    D[0]=0;

    ans+=d(mask);

    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    Int N; cin >> N;
    Int ans = 0;
    if (N % 2 == 0) {
        while (N) {
            ans += N / 10;
            N /= 5;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M;
  while (cin >> N >> M, N && M) {
    int r, q;
    vector<vector<int>> record(M, vector<int>(1261, 0));

    cin >> r;
    rep(i, r) {
      int t, n, m, s;
      cin >> t >> n >> m >> s;
      n--;
      m--;
      if (s) record[m][t]++;
      else record[m][t]--;
    }
    
    rep(i, M) rep(t, 1261)
        if(t) record[i][t] += record[i][t-1];

    cin >> q;
    rep(i, q) {
      int ts, te, m;
      cin >> ts >> te >> m;
      m--;

      int ans = 0;
      REP(t, ts, te) ans += (record[m][t] != 0);
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 50952
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long double
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
    ll n,d;
    cin>>n>>d;
    ll cnt=0;
    while(n--){
        ll x,y;
        cin>>x>>y;
        x = x*x;
        y = y*y;
        ll temp = sqrt(x+y);
        if(temp <= d) cnt++;
    }
    cout<<cnt;

}

int main(){
    fastio;
    ll t;
    t = 1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}



Measured memory_bytes: 3784
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=2005;
int a[3*maxn],maxx[maxn][maxn],maxval[maxn],nxtval[maxn];
void chmax(int &x,int y)
{
    x=max(x,y);
    return;
}
void upd(int val,int t,int x,int y)
{
    if(val==-1) return;
    int nxt=max(maxx[x][y],val+t);
    maxx[x][y]=maxx[y][x]=nxt;
    chmax(nxtval[x],nxt);
    chmax(nxtval[y],nxt);
    return;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=3*n;i++)
        scanf("%d",&a[i]);
    memset(maxx,-1,sizeof(maxx));
    memset(maxval,-1,sizeof(maxval));
    maxx[a[1]][a[2]]=maxx[a[2]][a[1]]=0;
    maxval[a[1]]=maxval[a[2]]=0;
    int add=0;
    for(int i=1;i<n;i++)
    {
        memset(nxtval,-1,sizeof(nxtval));
        int u=a[i*3],v=a[i*3+1],w=a[i*3+2];
        if(u==v&&v==w) {add++; continue;}
        else if(u==v||v==w||w==u)
        {
            int p=max(min(u,max(v,w)),min(v,w)),q=u+v+w-2*p;
            for(int nxt=1;nxt<=n;nxt++)
            {
                if(nxt==p||nxt==q) continue;
                upd(maxx[p][nxt],1,q,nxt);
            }
            int tmp=maxx[q][q];
            upd(maxx[p][q],1,q,q);
            upd(maxx[p][p],1,p,q);
            upd(tmp,1,p,p);
        }
        else
        {
            upd(maxx[u][u],1,v,w);
            upd(maxx[v][v],1,u,w);
            upd(maxx[w][w],1,u,v);
        }
        for(int nxt=1;nxt<=n;nxt++)
        {
            upd(maxval[nxt],0,u,nxt);
            upd(maxval[nxt],0,v,nxt);
            upd(maxval[nxt],0,w,nxt);
        }
        int allmax=-1;
        for(int j=1;j<=n;j++)
            chmax(allmax,maxval[j]);
        upd(allmax,0,u,v);
        upd(allmax,0,u,w);
        upd(allmax,0,v,w);
        for(int j=1;j<=n;j++)
            maxval[j]=max(maxval[j],nxtval[j]);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
            if(~maxx[i][j])
                chmax(ans,maxx[i][j]+(i==a[3*n]&&j==a[3*n]));
    printf("%d\n",ans+add);
    return 0;
}
/*
2
1 2 1 2 2 1
 
3
1 1 2 2 3 3 3 2 1
 
3
1 1 2 2 2 3 3 3 1
   */


Measured memory_bytes: 19568
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, a, b, ans = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		if (a <= i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10 && i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10 <= b) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,j,a,n,x,card[5][14];
    char ch;
    
    for(i=0;i<5;i++){
        for(j=0;j<14;j++){
            card[i][j]=0;
        }
    }
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%c",&ch);
        scanf("%c %d",&ch,&a);
        if(ch=='S') card[0][a]=1;
        else if(ch=='H') card[1][a]=1;
        else if(ch=='C') card[2][a]=1;
        else if(ch=='D') card[3][a]=1;
    }
    
        for(j=1;j<=13;j++){
            if(card[0][j]!=1) printf("S %d\n",j);
        }
        for(j=1;j<=13;j++){
            if(card[1][j]!=1) printf("H %d\n",j);
            
        }
        for(j=1;j<=13;j++){
            if(card[2][j]!=1) printf("C %d\n",j);
        }
        for(j=1;j<=13;j++){
            if(card[3][j]!=1) printf("D %d\n",j);
        }
                return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, ans, c[501], s[501], f[501];

int main(){
	cin >> n;
	for(int i=0;i<n-1;i++){
		cin >> c[i] >> s[i] >> f[i];
	}
	for(int j=0;j<n-1;j++){
		ans=0;
		for(int i=j;i<n-1;i++){
			if(ans>s[i]){
				if(ans%f[i]!=0){
					ans=(ans/f[i])*f[i]+f[i]+c[i];
				}else{
					ans+=c[i];
				}
			}else{
				ans=s[i]+c[i];
			}
		}
		cout << ans << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256