akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#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 FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

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

const int INF = 1e9;
const int MOD = 1e9+7;


struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(void){
    int n, m;
    while(cin >> n >> m, n){
        vector<pii> drop(n);
        REP(i, n){
            cin >> drop[i].first;
            drop[i].second = i;
        }
        sort(drop.rbegin(), drop.rend());
        UnionFind uf(n);
        vector<pipii> edge(m);
        REP(i, m){
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            edge[i] = pipii(c, pii(a, b));
        }
        sort(edge.begin(), edge.end());
        vi up(n, 0);
        int ans = 0;
        int first = drop[0].second;
        REP(i, n){
             int v = drop[i].second;
             //cout << "up : " << v << endl;
             up[v] = 1;
             if(i != n - 1 && drop[i].first == drop[i+1].first) continue;
             /*
             REP(j, n){
                if(up[j]) cout << j << ":";
             }cout << endl;
             */
             FOR(e, edge){
                int a = (*e).second.first, b = (*e).second.second;
                if(!up[a] || !up[b]) continue;
                if(!uf.findSet(a, b)){
                    //cout << a << ":" << b << ":" << (*e).first << endl;
                    uf.unionSet(a, b);
                    ans += (*e).first;
                }
             }
             if(uf.size(first) != i + 1){
                 uf = UnionFind(n);
                 ans = 0;   
             }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1460
#include<stdio.h>

int main(){
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	int m=10;
	if(a%10<m&&a%10!=0)m=a%10;
	if(b%10<m&&b%10!=0)m=b%10;
	if(c%10<m&&c%10!=0)m=c%10;
	if(d%10<m&&d%10!=0)m=d%10;
	if(e%10<m&&e%10!=0)m=e%10;
	int ans=0;
	ans+=a/10*10+(a%10==0?0:10);
	ans+=b/10*10+(b%10==0?0:10);
	ans+=c/10*10+(c%10==0?0:10);
	ans+=d/10*10+(d%10==0?0:10);
	ans+=e/10*10+(e%10==0?0:10);
	ans-=(10-m);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
int main(){
    fast;
    ll a,b;
    cin>>a>>b;
    if(a==1&&b==1){
        cout<<1000000<<endl;
    }else{
        if(b==1){
            b=300000;
        }else if(b==2){
            b=200000;
        }else if(b==3){
            b=100000;
        }else{
            b=0;
        }
        if(a==1){
            a=300000;
        }else if(a==2){
            a=200000;
        }else if(a==3){
            a=100000;
        }else{
            a=0;
        }
        cout<<a+b;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] P = new int[N];
    for (int i = 0; i < N; i++) {
      P[i] =sc.nextInt();
    }
    
    int sum = 0;
    for (int i = 0; i < K; i++) {
      sum += P[i];
    }
    int max = sum;
    if (N > K) {
      for (int i = 0; i < N-K; i++) {
        sum = sum - P[i] + P[i + K];
        if (sum > max) {
          max = sum;
        }
      }
    }
    double expVal = (max + K) / 2.0;
    
    System.out.println(expVal);
  }
}

Measured memory_bytes: 78132
fun main(args:Array<String>) {
  val (a, b, k) = readLine()!!.split(" ").map(String::toLong)

  val ins = (a..listOf(a+k-1,b).min()!!).toSet() + (listOf(b-k+1,a).max()!!..b).toSet() 

  ins.toList().sorted().map(::println)
}


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

int main(int argc, char *argv[]) {
  int N, M, gcf;
  scanf("%d %d", &N, &M);

  for (gcf = M / N; gcf >= 1; gcf--) {
    if (M % gcf == 0)
      break;
  }
  printf("%d\n", gcf);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int MAX_N = 5077;
const int MAX_K = 5077;

int pref[MAX_N][MAX_K], suff[MAX_N][MAX_K];
int a[MAX_N], n, k;

void solve() {
	cin >> n >> k;

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

	pref[0][0] = 1;
	suff[0][0] = 1;

	for(int i = 0; i < n; ++i) {
		for(int val = 0; val < MAX_K; ++val) {
			if(pref[i][val]) {
				int val2 = std::min(MAX_K - 1, val + a[i]);

				pref[i + 1][val] = 1;
				pref[i + 1][val2] = 1;
			}
		}
	}

	for(int i = 0; i < n; ++i) {
		for(int val = 0; val < MAX_K; ++val) {
			if(suff[i][val]) {
				int val2 = std::min(MAX_K - 1, val + a[n - 1 - i]);

				suff[i + 1][val] = 1;
				suff[i + 1][val2] = 1;
			}
		}
	}

	int answ = 0;

	for(int i = 0; i < n; ++i) {
		int r = 0;
		int j = n - 1 - i;
		int need = 0;

		for(int l = MAX_K - 1; l >= 0; --l) {
			if(pref[i][l]) {
				while(r < MAX_K && (suff[j][r] == 0 || l + a[i] + r < k)) {
					++r;
				}

				//cout << l << ' ' << a[i] << ' ' << r << '\n';

				if(r < MAX_K) {
					if(r + l < k) {
						need = 1;
						break;
					}
				}
			}
		}

		if(need == 0)
			++answ;
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 200960
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

struct Data
{
  int _1;
  int _2;
};

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N + 1);
  A[0] = 0;
  for(int i = 1; i < A.size(); ++i)
    std::cin >> A[i];

  std::vector<Data> p(N + 1);
  for(int i = 0; i < N - 1; ++i)
  {
    p[i]._1 = std::abs(A[i] - A[i + 1]);
    p[i]._2 = std::abs(A[i] - A[i + 2]);
  }
  p[N - 1]._1 = std::abs(A[N - 1] - A[N]);
  p[N - 1]._2 = std::abs(A[N - 1] - A[0]);
  p[N]._1 = std::abs(A[N] - A[0]);

  int ans = 0;
  for (auto&& d: p)
    ans += d._1;

  for (int i = 0; i < N; ++i)
  {
    std::cout << (ans - p[i]._1 - p[i + 1]._1 + p[i]._2) << '\n';
  }
  std::cout << std::flush;
  return 0;
}


Measured memory_bytes: 2432
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 1e6+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int n, k, c;
int dp[maxn];
char s[maxn];

int main() {
    n=read(), k=read(), c=read(); scanf("%s", s+1);
    for(int i=n; i; --i) {
        if(s[i]=='x') dp[i]=dp[i+1];
        else dp[i]=max(dp[i+1],dp[i+c+1]+1);
    }
    if(dp[1]>k) return 0;
    vector<int> v;
    for(int i=1; i<=n; ++i) {
        if(s[i]=='x') dp[i]=dp[i-1];
        else {
            int pre=max(0,i-c-1);
            if(dp[i-1]+dp[i+1]<k) {
                v.push_back(i);
                assert(dp[pre]+dp[i+c+1]+1>=k);
            }
            dp[i]=max(dp[i-1],dp[pre]+1);
        }
    }
    for(int pt: v) printf("%d\n", pt);
}

Measured memory_bytes: 3444
#include<cstdio> 
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

struct node { int t,next; }a[200010];

int f[100010][2],head[100010],n,tot;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void add(int x,int y) { a[++tot].t=y;a[tot].next=head[x];head[x]=tot; }

inline void dfs(int x,int y)
{
	f[x][0]=0;f[x][1]=1;
	for (int i=head[x];i;i=a[i].next)
	{
		int t=a[i].t;
		if (t==y) continue;
		dfs(t,x);
		f[x][0]+=f[t][1];
		f[x][1]+=min(f[t][0],f[t][1]);
	}
}

int main()
{
	n=rd();tot=0;
	for (int i=1;i<n;i++)
	{
		int x=rd(),y=rd();
		add(x,y);add(y,x);
	}
	dfs(1,0);
	puts(!(n&1)&&min(f[1][0],f[1][1])==n/2?"Second":"First");
	return 0;
}

Measured memory_bytes: 2944
// AOJ 0616 JOI Park
// 2018.2.27 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 150000
typedef struct { int s; long long t; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, long long t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define BINF 0x10
#define INF  0x1010101010101010LL
#define MAX  100002
int hi[MAX], *to[MAX], *d[MAX];
long long dist[MAX];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long dijkstra(int N, int C, long long sum)
{
	int i, s, e;
	long long t, ans;

	memset(dist, BINF, N << 3);
	qsize = 0;
	enq(1, 0), dist[1] = 0;
	while (qsize) {
		s = que[0].s, deq();
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], t = dist[s] + d[s][i]; 
			if (dist[e] > t) dist[e] = t, enq(e, t);
		}
	}

	ans = INF;
	qsize = 0;
	for (s = 1; s < N; s++) enq(s, dist[s]);
	while (qsize) {
		s = que[0].s, deq();
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i];
			if (dist[e] < 0) sum -= d[s][i];
		}
		t = sum + dist[s] * C;
		if (t < ans) ans = t;
		dist[s] = -1;
	}
	return ans;
}

int main()
{
	int N, M, C, a, b, _d, i, j, k;
	long long sum;
	int *memo;

	N = in(), N++, M = in(), C = in();

	memo = malloc(12*M);
	j = 0, i = M; while (i--) {
		memo[j++] = a = in(), hi[a]++;
		memo[j++] = b = in(), hi[b]++;
		memo[j++] = in();
	}

	for (a = 1; a < N; a++) if (hi[a]) {
		to[a] = malloc(hi[a] << 2);
		d [a] = malloc(hi[a] << 2);
	}

	sum = 0;
	memset(hi, 0, N << 2);
	j = 0; while (M--) {
		a = memo[j++], b = memo[j++], _d = memo[j++];
		k = hi[a]++, to[a][k] = b, d[a][k] = _d;
		k = hi[b]++, to[b][k] = a, d[b][k] = _d;
		sum += _d;
	}
	free(memo);

	printf("%lld\n", dijkstra(N, C, sum));
	return 0;
}


Measured memory_bytes: 13064
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	vector<int> a;
	a.resize(n);
	for(int i=0; i<n; i++) cin >> a[i];

	int max_i = 0;
	for(int i=0; i<n; i++){
		if(a[max_i]<a[i]) max_i = i;
	}
	a[max_i] = (int)(a[max_i] / 2);
	int sum(0);
	for(int i=0; i<n; i++){
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

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

const int MX = 100005;

vector<int> G[MX];
int dfs(int x, int p){
	int g = 0;
	for(int c : G[x]){
		if( c == p ) continue;
		g ^= (dfs(c, x)+1);
	}
	return g;
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if( dfs(1, 0) == 0 ) printf("Bob\n");
	else printf("Alice\n");
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
int main()
{
    int n,x;cin>>n>>x;
    vector<int> a(n);
    for(int i = 0; i<n; i++) cin>>a[i];
    sort(a.begin(), a.end());
    int i;
    for(i = 0; i < n; i++){
        x -= a[i];
        if(x < 0) break;    
    }
    if(x < 0) cout << i << endl;
    else if(x == 0) cout << n << endl;
    else cout << n - 1 << endl;
    
    return 0;
}

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

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

  if (S[5] > '0') cout << "TBD" << endl;
  else if (S[6] > '4') cout << "TBD" << endl;
  else cout << "Heisei" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {

        static int MaxHappy(int N, int[,] a)
        {
            int[,] dp = new int[N + 1, 3];

            for(int j = 0; j < 3; j++)
            {
                dp[0, j] = 0;
            }

            for(int i = 1; i <= N; i++)
            {
                for(int j = 0; j < 3; j++)
                {
                    for(int k = 0; k < 3; k++)
                    {
                        if (j == k) continue; 
                        if(dp[i - 1, j] + a[i - 1, k] > dp[i, k])
                        {
                            dp[i, k] = dp[i - 1, j] + a[i - 1, k];
                        }
                        
                    }
                }
            }

            int max_happines = 0;
            for(int i = 0; i < 3; i++)
            {
                if(max_happines < dp[N, i])
                {
                    max_happines = dp[N, i];
                }
            }

            return max_happines;
        }
        

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[,] a = new int[N, 3];

            for(int i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                for(int j = 0; j < 3; j++)
                {
                    a[i, j] = int.Parse(input[j]);
                }
            }


            Console.WriteLine(MaxHappy(N, a));

        }
    }
}

Measured memory_bytes: 17344
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  char n;
  cin >> n;
  
  //vector<int> a(n);  rep(i, 0, n) cin >> a[i];
  char ans = (n+1);
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

int main() {
	ll k;
	cin >> k;

	queue<ll> que;
	rep1(i,9) que.push(i);
	while (!que.empty()) {
		ll v = que.front();
		que.pop();

		k--;
		if (k == 0) {
			cout << v << endl;
			return 0;
		}

		//cout << k << ", " << v << endl;

		if(v%10-1 >= 0) que.push(10*v+v%10-1);
		que.push(10 * v + v % 10);
		if(v%10+1 <= 9) que.push(10 * v + v % 10 + 1);
	}
}


Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        A: u32,
        B: u32,
        C: u32,
        X: u32,
    }

    let mut count = 0;
    for i in 0..A+1 {
        for j in 0..B+1 {
            for k in 0..C+1 {
               if X == 500*i + 100*j + 50*k {
                   count += 1;
               }
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<ll> L(n);
    for (ll &l : L) cin >> l;

    ll ans = LINF, sum_back = accumulate(L.begin(), L.end(), 0LL);
    ll sum_front = 0;
    for (int i = 0; i < n - 1; i++) {
        sum_front += L[i];
        sum_back -= L[i];
        ans = min(ans, abs(sum_front - sum_back));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4836
from collections import Counter
from math import floor

def solve():
    h, w = map(int, input().split())
    word_dict = dict(Counter(list("".join([input() for _ in range(h)]))))

    g1 = (w % 2) & (h % 2)
    g2 = floor((w % 2) * h/2) + floor((h % 2) * w/2)
    g4 = floor(h/2) * floor(w/2)
    
    for k, v in word_dict.items():
        if (g1 > 0) and v % 4 == 1 or v % 4 == 3:
            g1 -= 1
            word_dict[k] -= 1
            v -= 1
        while (g4 > 0) and v >= 4:
            g4 -= 1
            word_dict[k] -= 4
            v -= 4
        while (g2 > 0) and v >= 2:
            g2 -= 1
            word_dict[k] -= 2
            v -= 2
            
    print("No" if [1 for v in word_dict.values() if v != 0] else "Yes")
    
if __name__=="__main__":
    solve()


Measured memory_bytes: 39984
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int line;
    while(cin>>line,line){
        int have,aiz_m,usu_m,aiz_max;
        cin>>have>>aiz_m>>usu_m>>aiz_max;
        bool kawa=0;
        for(int i=min(aiz_max,have/aiz_m);i>0&&!kawa;i--){
            for(int now=have-i*aiz_m,j=now/usu_m;j>-1&&!kawa;j--){
                if(have-j*usu_m>=0&&i+j>=line){
                    cout<<i<<" "<<j<<endl;
                    kawa=1;
                }
            }
        }
        if(!kawa)cout<<"NA\n";
    }
}

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



int main() {
 	long long n,a,b ;

  cin >> n >> a >>b;

   
  if((b-a)%2==0){
  cout << (b-a)/2 << endl;
  }
  else if((b-a)%2==1){
    if(a+b-1<=2*n-a-b+1){
    cout << (a+b-1)/2 << endl;
  }
     else if(a+b-1>2*n-a-b+1){
    cout << (2*n-a-b+1)/2<< endl;
  }
  }
}
  

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] count = new int[N + 1];
        for(int i = 0; i < N - 1; i++) {
            int input = sc.nextInt();
            count[input]++;
        }
        for(int i =0 ; i < N ; i++) {
            System.out.println(count[i + 1]);
        }
    }
}


Measured memory_bytes: 61832
#include <stdio.h>

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long A[100001], B[100001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	for (i = 0; i < N; i++) scanf("%lld", &(B[i]));
	
	int count = 0;
	long long total[2] = {}, dif[100001], sum = 0;
	for (i = 0; i < N; i++) {
		total[0] += A[i];
		total[1] += B[i];
		dif[i] = A[i] - B[i];
	}
	if (total[0] < total[1]) printf("-1\n");
	else {
		merge_sort(dif, N);
		for (i = 0; dif[i] < 0; i++) {
			count++;
			sum -= dif[i];
		}
		for (i = N - 1; sum > 0; i--) {
			count++;
			sum -= dif[i];
		}
		printf("%d\n", count);
	}

	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int min = Integer.MAX_VALUE;
		int max = 0;
		for (int i = 0; i < a.length; i++) {
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i]);
		}
		System.out.println(max - min);
	}
}


Measured memory_bytes: 23124
n = int(input())
p = list(map(int,input().split()))
#print(p)
cnt =0
check=0

for x in p:
    #print('cnt'+ str(cnt))
    #print('check'+ str(check))
    cnt += 1
    #print(x)
    if x == cnt:
        continue
    else:
        check += 1

#print('cnt'+ str(cnt))
#print('check'+ str(check))

if check==0 or check==2:
    print('YES')
    
else:
    print('NO')

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

const int N = (2e5) + 5;
int n, a[N];

int main() { // claudio van
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  bool ok = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) {
      ok = 1;
    }
  }
  if (!ok) {
    cout << -1 << "\n";
    return 0;;
  }
  int ans = n, cur = 1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == cur) {
      ans--;
      cur++;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
   int x;
   cin>>x;
   
   if(x==1)
   cout<<0;
   
   if(x==0)
   cout<<1;

    return 0;
}


Measured memory_bytes: 3560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int k= 1;
        HashMap<String,Integer> hashMap = new HashMap<>();
        hashMap.put("SUN",7);
        hashMap.put("MON",6);
        hashMap.put("TUE",5);
        hashMap.put("WED",4);
        hashMap.put("THU",3);
        hashMap.put("FRI",2);
        hashMap.put("SAT",1);
        String s1;
        String s2;
        int a,b,c;
        double n;
        while(k-->0){
            a=s.nextInt();
            System.out.println(3*a*a);
        }
    }

    private static int binary_search(
            int arr[], int l,
            int h, int x)
    {
        while (l <= h) {
            int mid = (l + h) / 2;
            if (arr[mid] <= x)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 27016
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << a - b + 1 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(ll i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

#define INF pow(10, 11);
using namespace std;

/*
N 100
W 10^9
wi W
vi 10^3

N W
w1 v1
...
wN vN
 */

ll dp[102][100001];
ll N, W;
ll w[101];
ll v[101];
ll v_sum;

int main(){
  cin >> N >> W;

  REP(i,N){
    cin >> w[i] >> v[i];
    v_sum += v[i];
  }

  FOR_IN(j,1,v_sum+1)
    dp[0][j] = INF;
  
  REP(i,N){
    REP(j,v_sum+1){
      if(j<v[i])
        dp[i+1][j] = dp[i][j];
      else
        dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
    }
  }

  ll ans=0;
  REP(j,v_sum+1)
    if(dp[N][j]<=W) ans = j;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 79104
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let (N, X, T) = {
        let mut ws = s.split_whitespace();
        let N: i32 = ws.next().unwrap().parse().unwrap();
        let X: i32 = ws.next().unwrap().parse().unwrap();
        let T: i32 = ws.next().unwrap().parse().unwrap();
        (N, X, T)
    };

    let mut ret;

    if N > X {
        if N % X == 0 {
            ret = (N / X) * T;
        } else {
            ret = ((N / X) + 1) * T;
        }
    } else {
        ret = T;
    }

    println!("{}", ret);
}



Measured memory_bytes: 2136
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    double a=0,b=0,c=0,d=0,n,m,k,ans=0;
    string s,s2;
    cin >> n;
    VI p(n);
    rep(i,n){
        cin >> p[i];
    }
    rep(i,n){
        d += 1 / p[i];
    }

    cout << 1.0 / d <<endl;
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x,y;
    int arr[14];
    arr[1]=arr[3]=arr[5]=arr[7]=arr[8]=arr[10]=arr[12]=1;
    arr[4]=arr[6]=arr[9]=arr[11]=2;
    arr[2]=3;
    cin>>x>>y;
    if(arr[x]==arr[y])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 384
import collections

b = collections.deque()
n = int(input())
As = list(map(int, input().split()))
for i, a in enumerate(As):
    if i & 1:
        b.append(a)
    else:
        b.appendleft(a)
if n % 2 == 0:
    b.reverse()
print(*b)


Measured memory_bytes: 25540
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;

    for(int i=1; i<=1250; i++) {
        if((int)(i*0.08) == a && (int)(i*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }    
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(0<a){
		cout<<"Positive"<<endl;
		return 0;
	}
	if(b<0){
		if((b-a+1)%2!=0)
		cout<<"Negative"<<endl;
		else cout<<"Positive"<<endl;
		return 0;
	}
	cout<<"Zero"<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    int ch0 = getchar() - '0';
    int ch1 = getchar();
    int ch2 = getchar() - '0';
    getchar();
    getchar();
    getchar();
    int ch6 = getchar() - '0';
    int ch7 = getchar() - '0';
    if (ch7 < 0) {
        if (ch0 == 3) {
            puti(4 - ch2);
        }
        else if (ch0 == 2 && ch1 == ' ') {
            puti(ch2);
        }
        else
            puti(arr1[ch0][ch6]);
    }
    else if (ch6 == 9) {
        if (ch0 == 6) {
            puti(22888);
        }
        else if (ch0 == 9) {
            puti(25436);
        }
        else
            puti(arr1[ch0][ch7]);
    }
    else
        puti(arr1[ch0][ch7]);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1456
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = list(range(n))
        self.ranks = [0 for _ in range(n)]
 
    def get_root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.get_root(self.parents[x])
        return self.parents[x]
 
    def merge(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x != y:
            if self.ranks[x] < self.ranks[y]:
                self.parents[x] = y
            else:
                self.parents[y] = x
                if self.ranks[x] == self.ranks[y]:
                    self.ranks[x] += 1
 
def kruskal(n_nodes, edges):
    edges.sort(key=itemgetter(2))
    res = []
    uf = UnionFind(n_nodes)
    for e in edges:
        if uf.get_root(e[0]) != uf.get_root(e[1]):
            res.append(e)
            uf.merge(e[0], e[1])
    return res

N = INT()
xy = [LIST() for _ in range(N)]
ixy = list(enumerate(xy))
ixy.sort(key=lambda x:x[1][0])

edges = []

for (i, (x, y)), (j, (x1, y1)) in zip(ixy, ixy[1:]):
	edges.append((i, j, min(abs(x-x1), abs(y-y1))))

ixy.sort(key=lambda x:x[1][1])
for (i, (x, y)), (j, (x1, y1)) in zip(ixy, ixy[1:]):
	edges.append((i, j, min(abs(x-x1), abs(y-y1))))

tree = kruskal(N, edges)
print(sum(x[2] for x in tree))


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

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

    int a, b, c, A, B, C, tA, tB, tC;
    cin >> A >> B >> C;
    for(int i = 2; i <= N; i++)
    {
        cin >> a >> b >> c;
        tA = a + max(B, C);
        tB = b + max(C, A);
        tC = c + max(A, B);
        A = tA;
        B = tB;
        C = tC;
    }
    cout << max(A, max(B, C)) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, a, b, Q, K, x, y;
	cin >> N;
	vector<vector<pair<int, long>>> d(N);
	for (int i = 1; i < N; i++) {
		long c;
		cin >> a >> b >> c;
		d[a - 1].emplace_back(b - 1, c);
		d[b - 1].emplace_back(a - 1, c);
	}
	cin >> Q >> K;
	priority_queue<pair<long, int>, vector<pair<long, int>>, greater<pair<long, int>>> e;
	e.emplace(0, K - 1);
	vector<bool> f(N);
	vector<long> g(N, LONG_MAX);
	g[K - 1] = 0;
	while (!e.empty()) {
		pair<long, int> h = e.top();
		e.pop();
		f[h.second] = true;
		for (pair<int, long>& i : d[h.second]) {
			if (!f[i.first]) {
				if (g[h.second] + i.second < g[i.first]) {
					g[i.first] = g[h.second] + i.second;
					e.emplace(g[i.first], i.first);
				}
			}
		}
	}
	for (int i = 0; i < Q; i++) {
		cin >> x >> y;
		cout << g[x - 1] + g[y - 1] << endl;
	}
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1e15
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back

using namespace std;
const int N = 100005;
int n, m;
vector<int>v[N];
int vis[N] = {};


int dx[] = { -1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
int func(int n, int a[])
{
	int l = 0;
	int sum = a[0];
	for (int i = 1; i < n; i++)
	{
		if (a[i] < sum)
		{
			int diff = abs(a[i] - sum);
			l += diff;
			sum = a[i] + diff;
		}
		else {
			sum = a[i];
		}
	}
	return l;
}
vector<vector<int>>dp;

int32_t main()
{
	std::ios::sync_with_stdio(false);

// #ifndef ONLINE_JUDGE
// 	freopen("inputf.txt", "r", stdin);
// 	freopen("outputf.txt", "w", stdout);
// #endif

	int n, m;
	cin >> n >> m;
	int w[n], v[n];

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



	dp.resize(n + 1, vector<int>(m + 1));

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= m; j++)
		{

			if (i == 0 || j == 0)
				dp[i][j] = 0;
		}\

	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (w[i - 1] > j)
			{
				dp[i][j] = dp[i - 1][j];
			}
			else
			{
				dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
			}
		}
	}
	cout << dp[n][m] << endl;

	return 0;

}

Measured memory_bytes: 85588
package main
 
import(
  "fmt"
)
 
func main() {
  var s, t string
  fmt.Scan(&s, &t)
  cnt := 0
  if s[0] == t[0] {
    cnt++
  }
  if s[1] == t[1] {
    cnt++
  }
  if s[2] == t[2] {
    cnt++
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;
#define INF 1e9

int main()
{
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    vector<int> p(n + 1, INF);
    queue<int> q;

    p[n] = 0;
    q.push(0);
    for (int i = n - 1; i >= 0; i--)
    {
        while(1){

            if (q.size() == 0) {
                cout << "-1" << endl;
                return 0;
            }
            if (q.front() != INF && q.size() <= m) break; 
            q.pop();
        }
        if ( s[i] == '0') p[i] = q.front() + 1;
        q.push(p[i]);
    }
    
    vector<int> ans;
    int step = p[0];
    int olditr = 0;
    int itr = 1;
    while(itr <= n){
        if (step - 1 == p[itr]) {
            step--;
            ans.push_back(itr - olditr);
            olditr = itr;
        }
        itr++;
    }

    show(ans);

}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define LL long long
#define maxn 200005
using namespace std;

int main()
{
    LL n,k;
    cin>>n>>k;
    LL ans;
    if(n>=k)
    {
        LL tmp=n%k;
        ans=min(tmp,k-tmp);
    }
    else{
        ans=min(n,k-n);
    }
    cout<<ans<<endl;
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

  vector<ll> a(n),b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  ll ans=0;
  for(int d = 32; d >= 0; --d){
    REP(i,n) a[i] %= (1LL << (d + 1));
    REP(i,n) b[i] %= (1LL << (d + 1));
    sort(all(b));

    ll cnt = 0;
    ll cur = 1LL << d;
    REP(i,n){
      if(a[i] >= cur) cnt += lower_bound(all(b), 2*cur-a[i]) - b.begin() + n - (lower_bound(all(b), 3*cur-a[i]) - b.begin());
      else cnt += lower_bound(all(b), 2*cur-a[i])-lower_bound(all(b), cur-a[i]);
    }
    if(cnt % 2 == 1) ans += cur;
  }

  pl(ans)
  return 0;

}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;
    ll a = (N+999) / 1000 * 1000;
    cout << a-N << "\n";
}

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

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(c % i == 0) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  static int n, m;
  static boolean[][] a, b;
 
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    m = sc.nextInt();
    a = new boolean[n][n];
    
    for(int i = 0; i < n; i++){
      String line = sc.next();
      for(int j = 0; j < n; j++){
        if(line.charAt(j) == '#'){
          a[i][j] = true;
        }
      }
    }
    b = new boolean[m][m];
    for(int i = 0; i < m; i++){
      String line = sc.next();
      for(int j = 0; j < m; j++){
        if(line.charAt(j) == '#'){
          b[i][j] = true;
        }
      }
    }
    
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(i + m - 1 >= n || j + m - 1 >= n){
          continue;
        }
        boolean match = true;
        for(int k = 0; k < m; k++){
          for(int l = 0; l < m; l++){
            if(a[i + k][j + l] != b[k][l]){
              match = false;
              break;
            }
          }
        }
        if(match){
          System.out.println("Yes");
          return;
        }
      }
    }
 
    System.out.println("No");
    sc.close();
  }
}


Measured memory_bytes: 21716
#include<iostream>
using namespace std;
 
int main(){
    const int max_num=1001000;
    int prime[max_num];
    int prime2[max_num];
    int min_prime[169]={2 ,3 ,5 ,7 ,11 ,13 ,17 ,19 ,23 ,29 ,31 ,37 ,41 ,43 ,47 ,53 ,59 ,61 ,67 ,71 ,73 ,79 ,83 ,89 ,97 ,101 ,103 ,107 ,109 ,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277 ,281 ,283 ,293 ,307 ,311 ,313 ,317 ,331 ,337 ,347 ,349 ,353 ,359 ,367 ,373 ,379 ,383 ,389 ,397 ,401 ,409 ,419 ,421 ,431 ,433 ,439 ,443 ,449 ,457 ,461 ,463 ,467 ,479 ,487 ,491 ,499 ,503 ,509 ,521 ,523 ,541 ,547 ,557 ,563 ,569 ,571 ,577 ,587 ,593 ,599 ,601 ,607 ,613 ,617 ,619 ,631 ,641 ,643 ,647 ,653 ,659 ,661 ,673 ,677 ,683 ,691 ,701 ,709 ,719 ,727 ,733 ,739 ,743 ,751 ,757 ,761 ,769 ,773 ,787 ,797 ,809 ,811 ,821 ,823 ,827 ,829 ,839 ,853 ,857 ,859 ,863 ,877 ,881 ,883 ,887 ,907 ,911 ,919 ,929 ,937 ,941 ,947 ,953 ,967 ,971 ,977 ,983 ,991 ,997 ,1009 };
    int sosuu=0;
    int k=169;
 
    for(int i=0;i<169;i++){
        prime[i]=min_prime[i];
    }
    for(int i=1011;i<max_num;i+=2){
        sosuu=0;
        for(int j=0;j<169;j++){
            if(i%min_prime[j]==0){
                sosuu++;
            }
        }
        if(sosuu==0){
            prime[k]=i;
            k++;
        }
    }
    int l=0;
    for(int i=0;i<max_num;i++){
        if(i>=prime[l]){
            l++;
        }
        prime2[i]=l;
    }
 
    int n;
 
    while(cin>>n){
if(n==0){
break;
}
        cout<<prime2[2*n]-prime2[n]<<endl;
    }
 
    return 0;
}

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

int N;
int x[8],y[8];

int main(){
  scanf("%d",&N);
  rep(i,N){
    scanf("%d",&x[i]);
  }
  rep(i,N){
    scanf("%d",&y[i]);
  }
  vector<int> v(N);
  rep(i,N){
    v[i]=i+1;
  }
  int count=0;
  ll a=0,b=0;
  do{
    count++;
    int xmatch=0;
    int ymatch=0;    
    rep(i,N){
      if(v[i]==x[i]){
        xmatch++;
        if(xmatch==N){
          a=count;
        }
      }
      if(v[i]==y[i]){
        ymatch++;
        if(ymatch==N){
          b=count;
        }
      }
    }
  }while(next_permutation(v.begin(),v.end()));
  printf("%lld",abs(a-b));
  
}


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

using namespace std;

int main() {
	int H, W, M;
	cin >> H >> W >> M;
	vector<Int> cntH(H, 0), cntW(W, 0);
	set<pair<int, int>> st;
	for (int i = 0; i < M; ++i) {
		int h, w;
		cin >> h >> w;
		--h; --w;
		++cntH[h];
		++cntW[w];
		st.insert({ h, w });
	}

	vector<pair<Int, int>> pH;
	vector<pair<Int, int>> pW;
	for (int i = 0; i < H; ++i) { pH.emplace_back( cntH[i], i ); }
	for (int i = 0; i < W; ++i) { pW.emplace_back( cntW[i], i ); }
	sort(pH.rbegin(), pH.rend());
	sort(pW.rbegin(), pW.rend());

	Int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < min(13, W); ++j) {
			Int tmp = cntH[i] + pW[j].first - (int)(st.count({ i, pW[j].second }));
			ans = max(ans, tmp);
		}
	}
	for (int i = 0; i < W; ++i) {
		for (int j = 0; j < min(13, H); ++j) {
			Int tmp = cntW[i] + pH[j].first - (int)(st.count({ pH[j].second, i }));
			ans = max(ans, tmp);
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 39060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = 0;
        
        for(long a = 1; a <= n;a++){
            ans += (n - 1) / a;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35716