akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
struct Card
{
    char suit;
    int value;
    mixin Proxy!value;
}
size_t partition(T)(T A)
{
    auto x = A[A.length - 1];
    auto i = -1;
    for (auto j = 0; j < A.length - 1; j++)
    {
        if (A[j] <= x)
        {
            i++;
            A[i].swap(A[j]);
        }
    }
    A[i + 1].swap(A[A.length - 1]);
    return i + 1;
}
void quick_sort(T)(T A)
{
    if (A.length >= 2)
    {
        auto q = partition(A);
        quick_sort(A[0..q]);
        quick_sort(A[q + 1..$]);
    }
}

void main()
{
    int[] a = readln().strip.split(' ').map!(x => x.to!int).array;
    auto count = a[0];
    auto cards = new Card[count];
    for (int i = 0; i < count; i++)
    {
        auto j = readln().strip.split(' ').array;
        auto k = j[0][0];
        auto l = j[1].to!int;
        cards[i].value = l;
        cards[i].suit = k;
    }
    auto cards2 = cards.dup;
    quick_sort(cards);
    writeln(cards2.sort.equal!((x, y) => x.suit == y.suit && x.value == y.value)(cards) ? "Stable" : "Not stable");
    
    for (int i = 0; i < count; i++)
    {
        writeln(cards[i].suit, " ", cards[i].value);
    }
}


Measured memory_bytes: 5484
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() 
{
int n;
vector<int>arr;
int num;

cin>>n;
for(int i=0;i<n;i++)
{
	cin>>num;
	arr.push_back(num);
}


int max=0;
int cnt=0;


for(int i=0;i<n-1;i++)
{
	if(arr[i]>=arr[i+1])
	{
		cnt+=1;
	}
	else
	{
		cnt=0;
	}

if(cnt>max)
{
	max = cnt;
}
}



cout<<max;


}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x=0 ,y=0,m,n,i,j,k;
   cin >> n >> m;
   string s;
   map<int,int>mp,mp1;
   for(i = 0 ;i<m ;i++)
   {
       cin >> k >>s;
       if(s == "AC" && mp1[k]==0)
        {
            x++;y+=mp[k];
            mp1[k]=1;
        }
       else
        mp[k]++;
   }
   cout<<x<<" "<<y<<endl;
}




Measured memory_bytes: 12928
H1, M1, H2, M2, K = list(map(int, input().split()))
h = H2-H1
if M1 <= M2:
  time = M2-M1
  time = h* 60+time
else:
  time = 60 + M2- M1
  time = (h-1)*60+time
print(time-K)

Measured memory_bytes: 9176
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26208
#include <iostream>

int A[100010];
int B[100010];

int main(){
    int a, b, m;
    std::cin >> a >> b >> m;
    int minA = 100010, minB = 100010;
    for(int i = 0; i < a; i++){
        std::cin >> A[i];
        minA = std::min(minA, A[i]);
    }
    for (int i = 0; i < b; i++) {
        std::cin >> B[i];
        minB = std::min(minB, B[i]);
    }
    int min = minA + minB;
    for(int i = 0; i < m; i++){
        int x, y, c;
        std::cin >> x >> y >> c;
        min = std::min(min, A[x-1]+B[y-1]-c);
    }
    std::cout << min << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, L, N);
    ll ans = 0;
    REP(i, N)
    {
        for (ll j = i + 1; j < N; ++j)
        {
            for (ll k = j + 1; k < N; ++k)
            {
                vi X = {L[i], L[j], L[k]};
                SORT(X);
                ans += X[2] < X[0] + X[1] and X[0] < X[1] and X[1] < X[2];
            }
        }
    }
    OUT(ans);
}

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

#define LL long long

const int N = 200;
const long long mod = 1e9 + 7;

using namespace std;

LL n,k;

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin>>n>>k;
    LL ans = 2e9;
    if( k - n >= 2019 ){
        ans = 0;
    }
    else{
        for( LL i=n; i <= k; i++ ){
            for( LL j=n; j <= k; j++ ){
                if( i == j )continue;
                ans = min( ans , ( i * j ) % 2019 );
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<vector>
using namespace std;
bool cmp(string left,string right){
    if(left.size() < right.size())return 1;
    if(left.size() > right.size())return 0;
    else {
        if(left < right)return 1;
        else return 0;
    }
}
int main(){
	int n;
	cin >> n;
	map<string,int> D;
	vector<string> S;
	for(int i = 0; i < n; i++){
        string d;
        int a;
        cin >> d >> a;
        D[d] += a;
	}
	map<string,int>::iterator it = D.begin();
	while(it != D.end()){
	    S.push_back((*it).first);
	    it++;
	}
	sort(S.begin(),S.end(),cmp);
	for(int i = 0; i < S.size(); i++){
        cout << S[i] << " " << D[S[i]] << endl;
	}
	return 0;
}

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

int main(int argc, char *argv[])
{
  int n, m, n_input, m_input;
  int change_card1, change_card2;
  
  while(1) {
    int exsum = 200, com = 0, nsum = 0, msum = 0;
    vector<int> nv, mv;
    cin >> n >> m;
    if (n == 0 && m == 0) {
      return 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> n_input;
      nsum += n_input;
      nv.push_back(n_input);
    }
    for (int i = 0; i < m; i++) {
      cin >> m_input;
      msum += m_input;
      mv.push_back(m_input);
    }

    if (nsum > msum) {
      int sumsub, odd;
      sumsub = nsum - msum;
      odd = sumsub % 2;
      if (odd != 0) {
	cout << "-1" << endl;
	continue;
      }
      sumsub = sumsub / 2;
      for (int i = 0; i < nv.size(); i++) {
	for (int j = 0; j < mv.size(); j++) {
	  int sub = 0;
	  sub = nv[i] - mv[j];
	  if(sumsub == sub) {
	    
	    com = nv[i] + mv[j];
	    if (com < exsum ) {
	      exsum = com;
	      change_card1 = nv[i];
	      change_card2 = mv[j];
	    }
	  }
	}
      }
      if (exsum == 200) cout << "-1" << endl;
      else cout << change_card1 << " " << change_card2 << endl;
    }
    

    if (nsum <= msum) {
      int sumsub, odd;
      sumsub = msum - nsum;
      odd = sumsub % 2;
      if (odd != 0) {
	cout << "-1" << endl;
	continue;
      }
      sumsub = sumsub / 2;
      for (int i = 0; i < mv.size(); i++) {
	for (int j = 0; j < nv.size(); j++) {
	  int sub = 0;
	  sub = mv[i] - nv[j];
	  if(sumsub == sub) {

	    com = mv[i] + nv[j];
	    if (com < exsum ) {
	      exsum = com;
	      change_card2 = mv[i];
	      change_card1 = nv[j];
	    }
	  }
	}
      }
      if (exsum == 200) cout << "-1" << endl;
      else cout << change_card1 << " " << change_card2 << endl;

    }

  }
}

Measured memory_bytes: 3144
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	string x;
	cin >> x;
	int n = 0, w = 0, e = 0;
	int s = 0;
	rep(i, 0, x.size()) {
		if (x[i] == 'N')n++;
		if (x[i] == 'S')s++;
		if (x[i] == 'E')e++;
		if (x[i] == 'W')w++;
	}
	Yes(((n == 0 && s == 0) || (s > 0 && n > 0)) && ((w == 0 && e == 0) || (w > 0 && e > 0)));
	return 0;
}

Measured memory_bytes: 256
# include <math.h>
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <algorithm>
# include <iostream>

# define For(i,x,y)   for((i)=(x);i<(y);(i)++)
# define MAX(x,y)   ((x)>(y)? (x):(y))
# define MIN(x,y)   ((x)<(y)? (x):(y))
# define sz(a)      (sizeof(a))
# define mem(a)     (memset((a),0,sizeof(a)))

# define fop freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
# define print(x) (printf("%d\n",x))
# define scan(x) (scanf("%d",&x))
# define printc(x) (printf("%c\n",x))
# define scanc(x) (scanf("%c",&x))
# define INF 0x7fffffff

using namespace std;
typedef long long           ll;
int v[25],m,n;
double a[25],b[25],c[25],d[25][25],ans;
int dfs(int i,int j,double x)
{
    int k;
    double kk=0;
    // printf("%d %d %lf\n",i,j,x);
    if (j>=m)
    {

        if (x>ans) ans=x;
        return 0;
    }
    if (i>n) return 0;
    v[i]=1;
    For (k,1,n+1)
      if (v[k]) kk+=d[i][k];
    dfs(i+1,j+1,x+kk);
    v[i]=0;
    dfs(i+1,j,x);
    return 0;
}
int main()
{
    int i,j;
    scan(n);scan(m);
    mem(v);
    For(i,1,n+1)
    {
        scanf("%lf%lf%lf",&a[i],&b[i],&c[i]);
    }
    For (i,1,n+1)
      For (j,1,n+1)
        d[i][j]=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]);
    dfs(1,0,0);
    printf("%.10lf\n",ans);
    return 0;
}

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

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

	string S;
	long long count_M=0,count_A=0,count_R=0,count_C=0,count_H=0;
	for(int i=0;i<N;i++){
		cin>>S;
		if(S.at(0) == 'M'){
			count_M += 1;
		}else if(S.at(0) == 'A'){
			count_A +=1;
		}else if(S.at(0) == 'R'){
			count_R +=1;
		}else if(S.at(0) == 'C'){
			count_C +=1;
		}else if(S.at(0) == 'H'){
			count_H +=1;
		}
	}

	long long ans = count_M * count_A * count_R
	+ count_M * count_A * count_C
	+ count_M * count_A * count_H
	+ count_M * count_R * count_C
	+ count_M * count_R * count_H
	+ count_M * count_C * count_H
	+ count_A * count_R * count_C
	+ count_A * count_R * count_H
	+ count_A * count_C * count_H
	+ count_R * count_C * count_H;

	cout<<ans<<endl;
}


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

using namespace std;
typedef long long ll;
typedef bitset<64> bs;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  ll rest = 0;
  for (int i = 2; i < n; ++i)
    rest ^= a[i];
  ll sum = a[0] + a[1];
  bs x, y, z(rest);
  auto fail = []() {
    cout << -1;
    exit(0);
  };
  vector<int> v;
  ll xx = 0;
  for (int i = 60; i >= 0; --i) {
    if (!z[i]) {
      if (sum >= (1ll << (i + 1))) {
        x.set(i), y.set(i);
        sum -= (1ll << (i + 1));
        xx += (1ll << i);
      }
    } else {
      if (sum >= (1ll << i))
          v.emplace_back(i);
      else
        fail();
      sum -= (1ll << i);
    }
  }
  if (sum != 0)
      fail();
  for (int i : v) {
      if (xx + (1ll << i) < a[0]) {
          x.set(i);
          xx += (1ll << i);
      }
      else
          y.set(i);
  }
  if (xx > a[0] || xx == 0)
    fail();
  cout << a[0] - xx;
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

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

    if(k == 0){
        cout << n*n << endl;
        return 0;
    }

    ll ans=0;
    for(ll i=k+1; i<=n; i++){
        ans += (n / i) * (i - k);
        ans += max(0LL, (n % i) - k + 1LL);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#include<bitset>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
    int n;
    cin >> n;
    long long int a[n] ={};
    long long int cnt=0;
    LP(i,n){
        string temp;
        cin >> temp;
        sort(temp.begin(),temp.end());
        for(int j=0;j<temp.size();j++){
            a[i] += temp[j] - 'a' + 1;
            a[i]*=30;
        }

    }
    sort(a,a+n);
long long int b = 0;
    for(int i=1;i<n;i++){
if(a[i] == a[i-1]){
b++;
}
else{
if(b != 0)cnt += (b + 1)* b /2;
b = 0;
}
    }
    if(b != 0)cnt += (b + 1)* b /2;
 //   LP(i,n)cout << a[i] << endl;
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 1024
import numpy as np
from numba import njit
 
@njit
def f(A):
  N = len(A)
  cnt = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        cnt += (A[k] < A[i] + A[j])
  return cnt
 
N = int(input())
A = np.int32(input().split())
A.sort()
print(f(A))


Measured memory_bytes: 110100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main() {
   int N;
   cin >> N;
   int A[N];
   A[0] = 0;
   int ans[N];
    for(int i=0;i<N;i++){
        ans[i] = 0;
    }
   for(int i=1;i<N;i++){
       cin >> A[i];
       ans[A[i]-1]++;
   }
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }



}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, temp;
    vector<int> v = {};

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> temp;
        v.push_back(temp);
    }

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

    float result = v[0];

    for (int i = 1; i < n; i++) {
        result = (result + v[i]) / 2;
    }

    cout << result;
}

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

using namespace std;

const int INF = 1<<28;

int Count(const vector<int>& C, int N) {
    vector<int> dp(N + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < C.size(); i++)
        for (int j = 0; j + C[i] <= N; j++)
            if (dp[j] < INF) dp[j + C[i]] = min(dp[j + C[i]], dp[j] + 1);
    return dp[N];
}

int N, M;
int main() {
    cin >> N >> M;
    vector<int> C(M);
    for (int i = 0; i < M; i++) cin >> C[i];
    cout << Count(C, N) << endl;
    return 0;
}

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

vector<int> L;
int N, t, ans;

int main(){
	scanf("%d", &N);
	for(int i=0;i<2*N;i++)scanf("%d", &t), L.push_back(t);
	sort(L.begin(), L.end());
	for(int i=0;i<2*N;i+=2)ans+=L[i];
	printf("%d\n", ans);
	return 0;
}
/*
5
100 1 2 3 14 15 58 58 58 29

2
1 3 1 2
*/

Measured memory_bytes: 256
#include<stdio.h>

int a[1000][1000];
int way,n;
//int call=0;

int square(int i, int j, int k){
  int x,y;

  //call++;
  if(i+k>n||j+k>n)
    return 0;

  for(x=i;x<i+k;x++){
    for(y=j;y<j+k;y++){
      if(!a[x][y])
	return 0;
    }
  }
  return k;
}

int main(){
  int i,j,k,c,max;

  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;

    max=0;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	for(;;){
	  c=getchar();
	  if(c=='.'){
	    a[i][j]=1;
	    max=1;
	    break;
	  }
	  else if(c=='*'){
	    a[i][j]=0;
	    break;
	  }
	}
      }
    }
    
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	for(k=1;k<=n;k++){
	  int tmp=square(i,j,k);
	  if(max<tmp)
	    max=tmp;
	  else if(tmp==0)
	    break; 
	}
      }
    }
    printf("%d\n",max);
  }
  //printf("Call:%d\n",call);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

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

const int max_N = 100005;
int N;

void dfs(int x, int col, vector<vector<int>>& g, vector<int>& c){
	for(int y : g[x]){
		if(c[y] == -1){
			c[y] = col;
			dfs(y, col, g, c);
		}
	}
}

void color(vector<vector<int>>& g, vector<int>& c){
	int col = 0;
	rep(i, N){
		if(c[i] == -1){
			c[i] = col;
			dfs(i, col, g, c);
		}
		col++;
	}
}

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

	int K, L;
	cin >> N >> K >> L;

	vector<vector<int>> g1(N, vector<int>());
	vector<vector<int>> g2(N, vector<int>());

	rep(i, K){
		int p, q;
		cin >> p >> q;
		g1[p-1].push_back(q-1);
		g1[q-1].push_back(p-1);
	}

	rep(i, L){
		int p, q;
		cin >> p >> q;
		g2[p-1].push_back(q-1);
		g2[q-1].push_back(p-1);
	}

	vector<int> c1(N, -1);
	vector<int> c2(N, -1);

	color(g1, c1);
	color(g2, c2);

	// cout << "c1:";
	// rep(i, N) cout << c1[i] << ",";
	// cout << endl;

	// cout << "c2:";
	// rep(i, N) cout << c2[i] << ",";
	// cout << endl;

	map<pii, int> mp;
	rep(i, N){
		pii x = (pii){c1[i], c2[i]};
		auto it = mp.find(x);
		if(it == mp.end()){
			mp[x] = 0;
		}
		mp[x]++;
	}

	rep(i, N){
		pii x = (pii){c1[i], c2[i]};
		cout << mp[x] << (i == N-1 ? "\n" : " ");
	}
}


Measured memory_bytes: 27776
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n;
  cin >> n;

  vector<int> f(n);
  rep(i, n) {
    int open = 0;
    rep(j, 10) {
      int k; cin >> k;
      if (k == 1) open |= (1 << j);
    }
    f[i] = open;
  }

  vector<vector<ll>> p(n, vector<ll>(11));
  rep(i, n) rep(j, 11) cin >> p[i][j];

  ll ans = -INF;
  for (int i = 1; i < (1<<10); i++) {
    ll tmp = 0;
    for (int j = 0; j < n; j++) {
      bitset<11> bs((i & f[j]));
      tmp += p[j][bs.count()];
    }
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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



int main() {
    string s; cin >> s;
    vector<ll> vec(s.size()+1, 0);
    ll m = 1;
    for (int i = s.size()-1; i >= 0; i--) {
        vec[i] = (vec[i+1] + m * (s[i] - '0')) % 2019;
        m *= 10;
        m %= 2019;
    }
    sort(vec.begin(), vec.end());
    vec.push_back(-1);
    ll tmp = vec[0], memo = 1, ans = 0;
    for (int i = 1; i < vec.size(); i++) {
        if (vec[i] == tmp) memo++;
        else {
            ans += memo * (memo-1) / 2;
            memo = 1;
            tmp = vec[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6720
let m = 1046527

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let to_x = Array.make 128 0

let to_key s =
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(to_x.(Char.code s.[i]))) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  to_x.(Char.code 'A') <- 1;
  to_x.(Char.code 'C') <- 2;
  to_x.(Char.code 'G') <- 3;
  to_x.(Char.code 'T') <- 4;
  let n = read_int () in
  let t = Array.make m "\000" in
  let rec doit i =
    if i < n then begin
      begin match split (read_line ()) ' ' with
      | ["insert"; s] -> insert s t
      | ["find"; s] -> print_endline (if find s t then "yes" else "no")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 20796
import java.util.*;

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

    int k = sc.nextInt();
    String s = sc.next();

    if(s.length() <= k){
      System.out.println(s);
    } else {
      System.out.println(s.substring(0, k) + "...");
    }
  }
}


Measured memory_bytes: 38580
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 1000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,m;
cin>>n>>m;
ll arr[n];
rep(i,0,n)
cin>>arr[i];
sort(arr,arr+n);
vector<pair<ll,ll> > v;
rep(i,0,m)
{
	ll x,y;
	cin>>x>>y;
	v.push_back({y,x});
}
sort(v.begin(),v.end());
ll z=m-1;
int x=0;
bool b=true;
while(x<n&&b)
{
 if(z<0)
 break;
   pair<ll,ll> p=v[z--];

   	if(p.fi>arr[x])
   	{
		ll a=p.se;
		while(x<n&&a)
		{
			if(arr[x]<p.fi){

			arr[x]=p.fi;
			x++;
			a--;}
			else
			{

			b=true;
			break;}
		}
	   }
	   else
	   b=false;

   
}
ll sum=0;
rep(i,0,n)
{

sum+=arr[i];}
cout<<sum;
}







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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)

void solve();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main(void) {
    init();
    solve();
    return 0;
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    ll partialSum = 0;
    ll sum = 0;
    rep(i, n) {
        sum += a[i] * partialSum;
        partialSum += a[i];
        sum %= 1000000007;
        partialSum %= 1000000007;
    }
    cout << sum % 1000000007 << "\n";
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	const long long p = (long long)1e9+7;
	string s;
	cin >> s;
	long long d[s.size()][13];
	if (s[0] == '?') {
		for (int i = 0; i < 10; i++)
			d[0][i] = 1;
		for (int i = 10; i < 13; i++)
			d[0][i] = 0;
	} else {
		for (int i = 0; i < 13; i++)
			d[0][i] = 0;
		d[0][s[0]-'0'] = 1;
	}

	for (int i = 1; i < s.size(); i++) {
		if (s[i] == '?') {
			for (int j = 0; j < 13; j++)
				d[i][j] = 0;
			for (int j = 0; j < 13; j++) {
				for (int k = 0; k <= 9; k++) {
					int tmp = (j * 10 + k)%13;
					d[i][tmp] += d[i-1][j];
					d[i][tmp] %= p;
				}
			}
		} else {
			for (int j = 0; j < 13; j++)
				d[i][j] = 0;
			for (int j = 0; j < 13; j++) {
				long long tmp = (j*10 + s[i]-'0')%13;
				d[i][tmp] = d[i-1][j];
			}
		}
	}
	cout << d[s.size()-1][5] << endl;
	return 0;
}

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

// 素数判定
bool isPrime(int p) {
  if(p < 2) return false;
  if(p == 2) return true;
  if(p % 2 == 0) return false;
  
  for(int i = 3; i * i <= p; i += 2){
    if(p % i == 0) return false;
  }
  return true;
}

int main() {
  vector<int> x(1e5 + 1);
  for(int i = 1; i <= 1e5; i++){
    if(isPrime(i)) x.at(i)++;
  }
  
  vector<int> y(1e5 + 1);
  for(int i = 1; i <= 1e5; i++){
    if(i % 2 == 0){
      y.at(i) += y.at(i - 1);
      continue;
    }
    if(x.at(i) == 1 && x.at((i + 1) / 2) == 1) y.at(i)++;
    y.at(i) += y.at(i - 1);
  }
  
  int q;
  cin >> q;
  
  for(int i = 0; i < q; i++){
    int l, r;
    cin >> l >> r;
    cout << y.at(r) - y.at(l - 1) << endl;
  }
}

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

struct Lazseg{
  static const int MAX=1<<18;
  int n;
  int dat[2*MAX-1],laz[2*MAX-1];
  Lazseg(){}
  Lazseg(int n_){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++)
      dat[i]=laz[i]=0;
  }
  inline void eval(int len,int k){
    if(k*2-1<n*2-1){
      laz[k*2+1]+=laz[k];
      laz[k*2+2]+=laz[k];
    }
    dat[k]+=laz[k]*len;
    laz[k]=0;
  }
  int update(int a,int b,int x,int k,int l,int r){
    /*
    if(r<=a||b<=l)return;
    if(a<=l&&r<=b){
      laz[k]+=x;
      return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
    return;
    */
    
      eval(r-l,k);
      if(r<=a||b<=l) return dat[k]+laz[k]*(r-l);
      if(a<=l&&r<=b) return dat[k]+(laz[k]+=x)*(r-l);
      eval(r-l,k);
      return dat[k]=update(a,b,x,k*2+1,l,(l+r)/2)+update(a,b,x,k*2+2,(l+r)/2,r);
    
  }
  int query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return 0;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return vl+vr;
  }
};

signed main(){
  int n,q;
  cin>>n>>q;
  Lazseg ls(n);
  for(int i=0;i<q;i++){
    int c,s,t,x;
    cin>>c;
    if(c){
      cin>>s>>t;
      cout<<ls.query(s-1,t,0,0,ls.n)<<endl;
    }else{
      cin>>s>>t>>x;
      ls.update(s-1,t,x,0,0,ls.n);
    }
  }
  return 0;
}



Measured memory_bytes: 7208
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int a1 = 300000;
    int a2 = 200000;
    int a3 = 100000;
    int ex = 400000;
    
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int ans = 0;
    if(X == 1){
      ans += a1;
    }else if(X == 2){
      ans += a2;
    }else if(X == 3){
      ans += a3;
    }
    
    if(Y == 1){
      ans += a1;
    }else if(Y == 2){
      ans += a2;
    }else if(Y == 3){
      ans += a3;
    }
    
    if(X == 1 && Y == 1){
      ans += ex;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

void solve() {
    string S; cin >> S;
    if(S[2] == S[3] and S[4] == S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	aa := make([]int, n)
	bb := make([]int, n)
	ma := make([]int, n)
	mb := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt(scanner)
	}

	ans := 0

	ms := MergeSort{}
	ms.init(n)

	for i := 0; i < 30; i++ {
		t := 1 << uint(i)
		for ii := 0; ii < n; ii++ {
			ma[ii] = aa[ii] % (t << 1)
			mb[ii] = bb[ii] % (t << 1)
		}
		ms.sort(0, n, mb)

		c := 0
		for ii := 0; ii < n; ii++ {
			c += n
			l := 0
			for iii := 1; iii <= 3; iii++ {
				r := n
				v := t*iii - ma[ii]
				for l < r {
					m := (l + r) >> 1
					if mb[m] >= v {
						r = m
						continue
					}
					l = m + 1
				}
				if iii%2 == 1 {
					c -= l
					continue
				}
				c += l
			}
		}
		c %= 2
		ans |= c << uint(i)
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func bsearch(a, n, t int, mb []int) int {
	l := 0
	r := n
	for l < r {
		m := (l + r) >> 1
		if a+mb[m] >= t {
			r = m
			continue
		}
		l = m + 1
	}
	return l
}

type MergeSort struct {
	n      int
	ll, rr []int
}

func (ms *MergeSort) init(n int) {
	ms.n = n
	ms.ll = make([]int, n/2+2)
	ms.rr = make([]int, n/2+2)
}

func (ms *MergeSort) sort(l, r int, aa []int) {
	if l+1 < r {
		m := (l + r) >> 1
		ms.sort(l, m, aa)
		ms.sort(m, r, aa)
	}
	ms.merge(l, r, aa)
}

func (ms *MergeSort) merge(l, r int, aa []int) {
	ll := ms.ll
	rr := ms.rr
	m := (l + r) >> 1
	for i := l; i < m; i++ {
		ll[i-l] = aa[i]
	}
	for i := m; i < r; i++ {
		rr[i-m] = aa[i]
	}

	ll[m-l] = 1 << 30
	rr[r-m] = 1 << 30
	lpos := 0
	rpos := 0
	for i := l; i < r; i++ {
		if ll[lpos] <= rr[rpos] {
			aa[i] = ll[lpos]
			lpos++
			continue
		}
		aa[i] = rr[rpos]
		rpos++
	}
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    string s; cin >> s;
    if (s[s.size()-1] == 's')
        cout << s << "es" << endl;
    else
        cout << s << 's' << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    ll h, w;
    cin >> h >> w;
    
    if (h == 1 || w == 1) {
        cout << 1 << endl; return 0;
    }
    ll ans = (ceil(h/2.0)) * (ceil(w/2.0)) + (h/2)*(w/2);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}



void SOLVE(){
    string s, t;
    cin >> s >> t;
    for(char c='a'; c<='z'; c++){
        string r = s;
        r+=c;
        if(r==t){
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif
    // init();
    ll TC;
    // cin >> TC;
    TC = 1;
    for(ll tc1=1; tc1<=TC; tc1++){
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k,cnt=0;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0;i<n;++i){
        cin>>arr[i];
        if(arr[i]>=k)
            cnt++;
    }
    cout<<cnt<<endl;
      
	return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

///
enum EPS = 1e-10;

///
double add(double a, double b) {
    if (abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
    return a + b;
}

///
struct P {
    double x, y;

    this(double x, double y) {
        this.x = x;
        this.y = y;
    }

    P opBinary(string op)(P p) {
        static if (op == "+") return P(add(x, p.x), add(y, p.y));
        else static if (op == "-") return P(add(x, -p.x), add(y, -p.y));
        else static assert(0, "Operator '"~op~"' not implemented");
    }

    P opBinary(string op)(double d) {
        static if (op == "*") return P(x * d, y * d);
        else static if (op == "/") return P(x / d, y / d);
        else static assert(0, "Operator '"~op~"' not implemented");
    }

    // dot product
    double dot(P p) {
        return add(x * p.x, y * p.y);
    }

    // cross product
    double det(P p) {
        return add(x * p.y, -y * p.x);
    }

    double dist(P p) {
        return sqrt((x - p.x)^^2 + (y - p.y)^^2);
    }

    P middle(P p) {
        return P((x + p.x)/2, (y + p.y)/2);
    }

    P rotate(double th) {
        return P(add(x * cos(th), -y * sin(th)), add(x * sin(th), y * cos(th)));
    }

    P rotate(P p, double th) {
        auto q = P(x - p.x, y - p.y).rotate(th);
        return P(q.x + p.x, q.y + p.y);
    }
}

void main()
{
    auto abhm = readln.split.to!(double[]);
    auto A = abhm[0];
    auto B = abhm[1];
    auto H = abhm[2];
    auto M = abhm[3];

    auto h = (H*60 + M) / (60 * 12) * 2 * PI;
    auto m = M / 60 * 2 * PI;

    auto a = P(A, 0).rotate(h);
    auto b = P(B, 0).rotate(m);
    writefln("%.12f", a.dist(b));
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  map<ll,int> mp;
  int n;
  cin >> n;
  rep(i,n){
    ll a;
    cin >> a;
    mp[a]++;
  }
  ll ans = 0;
  for(auto it : mp){
    ans+=(it.se%=2);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 6528
var
  i,j,a,c,b,n,tot:longint;
begin
  readln(a,b,c,n);
  for i:=0 to a do
    for j:=0 to b do
      if (n-i*500-j*100>=0) and (n-i*500-j*100<=c*50) then inc(tot);
  writeln(tot);
end.

Measured memory_bytes: 128
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    size_t n;
    scanf("%zu", &n);
    uint_fast16_t a[n];
    uint_fast16_t t = 0;
    uint_fast16_t min = UINT_FAST16_MAX;
    for (size_t i = 0; i < n; ++i) {
        scanf("%" SCNuFAST16, &a[i]);
        t += a[i];
        if (a[i] % 10 != 0 && a[i] < min) {
            min = a[i];
        }
    }
    if (t % 10 == 0) {
        printf("%" PRIuFAST16 "\n", min == UINT_FAST16_MAX ? 0 : t - min);
    } else {
        printf("%" PRIuFAST16 "\n", t);
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

void swap(int* a, int* b) {

	int work;

	work = *a;
	*a = *b;
	*b = work;
}

int main() {

	int w, n;
	cin >> w;
	cin >> n;

	int a[30];
	for (int i = 0; i < 30; i++)a[i] = i + 1;
	int x, y;
	char c;
	for (int i = 0; i < n; i++) {
		cin >> x >> c >> y;

		swap(&a[x - 1], &a[y - 1]);
	}

	for (int i = 0; i < w; i++) {
		printf("%d\n", a[i]);
	}

	//system("pause");
	return 0;
}


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

int main(){
	long long x; cin >> x;
	ll i = 0;
	while(true){
		ll a = x + i;
		bool cek = true;
		for(int j = 2; j*j <= a; j++){
			if(a%j == 0){
				cek = false;
				break;
			}
		}
		if(cek){
			cout << a << endl;
			break;
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

vector<vector<int>> G;
int visit[100010] = {};

void dfs(int node){
  visit[node] = 1;
  for(int next : G[node]){
    if(!visit[next])dfs(next);
  }
}

int main(void){
  int n,m;
  cin >> n >> m;
  G = vector<vector<int>>(n);
  for(int i = 0;i < m;++i){
    int a,b,p;
    cin >> a >> b >> p;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int res = 0;
  for(int i = 0;i < n;++i){
    if(!visit[i]){
      ++res;
      dfs(i);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 9216
/* ex4_3
   UMAboogie */

#include<stdio.h>
int snowfall(int elevation_w, int elevation_e); //雪の深さを計算する関数を宣言

int main(void){
  int elevation_a, elevation_b;
  scanf("%d %d",&elevation_a,&elevation_b); //2つの塔の雪の表面からの高さを入力
  int answer = snowfall(elevation_a,elevation_b); //関数を用いて雪の深さを計算
  printf("%d",answer); //答えを出力
  return 0;
}

int snowfall(int elevation_w, int elevation_e){ //関数を定義

  int diff = elevation_e - elevation_w; //2つの塔の高さの差を計算
  int height_e = 0; 
  for(int i = 1;i <= diff;i++){
    height_e += i; //西の塔の実際の高さは1+2+3+…+diffであるので、西の塔の実際の高さを計算
  }
  int depth = height_e - elevation_e; //雪の深さを計算
  return depth; //雪の深さの値を返す
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	string a, b;
	cin >> a >> b;
	int res = 0;
	for(int i = 0; i < 3; ++i){
		if(a[i] == b[i]){
			res++;
		}
	}

	cout << res;

    return 0;
}


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

#define BLACK 0
#define GRAY 1
#define WHITE 2

int tt;
int st[101];
int et[101];
int num[101][101];

void dfs(int*,int);
void visit(int*,int,int);

int main(){
  int i,j;
  int n,m,l,v;
  int color[101];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      num[i][j]=0;
    }
  }/*?????????*/

  for(i=1;i<=n;i++){
    scanf("%d%d",&v,&m);
    for(j=1;j<=m;j++){
      scanf("%d",&l);
      num[v][l]=1;
    }
  }

  dfs(color,n);

  return 0;
    
}

  
void dfs(int *color,int n){
  int i,j;
  for(i=1;i<=n;i++){
    color[i]=WHITE;
  }

  tt=0;

  for(i=1;i<=n;i++){
	if(color[i]==WHITE){
	  visit(color,n,i);
	}
    }
  
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,st[i],et[i]);
  }

}

void visit(int *color,int n,int i){
  int j;
  color[i]=GRAY;
  st[i]=++tt;

  for(j=1;j<=n;j++){
    if(num[i][j]==0) continue;
    if(color[j]==WHITE) visit(color,n,j);
  }

  color[i]=BLACK;
  et[i]=++tt;
    
}

Measured memory_bytes: 640
D = int(input())
C = list(map(int, input().split()))
S = [0] * D
for i in range(D):
  S[i] = list(map(int, input().split()))
         
         
t = [0] * (D + 1)
#for i in range(D):
#  t[i] = int(input())
  
last = [0] * (26)
last_score = 0
for i in range(1, D + 1):
  score = 0
  for j in range(26):
    score2 = 0
    score2 += S[i - 1][j]
    score2 -= C[j] * (i - last[j])
    #print(score2)
    if score < score2:
      score = score2
      t[i] = j
      last[j] = i
  last_score += score
    
#print(t)
for i in range(1, len(t)):
  print(max(12, t[i] + 1))
#print(last_score)    
    
    

Measured memory_bytes: 9428
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;
const int INF=1000000000;

vector<G> points(11,G(11,vector<int>(11,0)));
int maxsum=0;
bool ok=false;
int pow(int a,int b){
    int ans=1;
    rp(i,b) ans*=a;
    return ans;
}
void dfs(int n,int m,ll cur){
    if(n==0){
        int sum=0;
        rp(i,10){
            for(int j=i+1; j<10; j++){
                int iketa=cur/(pow(10,i))%10;
                int jketa=cur/(pow(10,j))%10;
              	iketa++; jketa++;
              	if(jketa-iketa<0) continue;
                sum+=points[i+1][j+1][jketa-iketa];
            }
        }
        maxsum=max(maxsum,sum);
        //cout << cur << " " << maxsum << endl;
        return;
    }
    for(int i=m; i>=0; i--){
      dfs(n-1,i,cur*10+i);
    }
}
int main(){
    int n,m,q;
    cin >> n >> m >> q;
    rp(i,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        points[a][b][c]=d;
    }
    dfs(n,m-1,0);
    cout << maxsum << endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>S;
	cout<<count(ALL(S),'1')<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main() 
{
    int n, x;
    cin >> n >> x;
    v_int a(n);
    irep(i, n) {
        cin >> a[i];
    }

    ll a_ans = 0;

    irep(i, n-1) {
        ll sum = a[i]+a[i+1];
        if(sum > x) { 
            a_ans += (sum - x);
            if(a[i+1] >= (sum - x)) {
                a[i+1] -= (sum - x);
            } else {
                a[i+1] = 0; 
            }
        }
    }

    cout << a_ans << endl;
    return 0;
}


Measured memory_bytes: 640