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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

// 3乗で通したお詫びにO(NlogN)で通します
// 参考 : https://twitter.com/SayakaAmemiya/status/1249515024541859842

template<int mod, int proot> struct NTT {
	int get_mod() { return mod; }
	int pow(int a, int b) {
	int res = 1;
		for (; b; b >>= 1) {
			if (b & 1) res = (int64_t) res * a % mod;
			a = (int64_t) a * a % mod;
		}
		return res;
	}
	int inv(int i) { return pow(i, mod - 2); }
	void ntt(std::vector<int> &a, bool inverse) {
		int n = a.size();
		assert((n & -n) == n);
		int h = pow(proot, (mod - 1) / n);
		if (inverse) h = inv(h);
		
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k > (i ^= k); k >>= 1);
			if (j < i) std::swap(a[i], a[j]);
		}
		for (int i = 1; i < n; i <<= 1) {
			int base = pow(h, n / i / 2);
			int w = 1;
			
			std::vector<int> ws(i);
			for (int j = 0; j < i; j++) ws[j] = w, w = (int64_t) w * base % mod;
			
			for (int j = 0; j < n; j += i << 1) {
				for (int k = 0; k < i; k++) {
					int u = a[k + j];
					int d = (int64_t) a[k + j + i] * ws[k] % mod;
					a[k + j] = u + d >= mod ? u + d - mod : u + d;
					a[k + j + i] = d > u ? u + mod - d : u - d;
				}
			}
		}
		if (inverse) {
			int ninv = inv(a.size());
			for (auto &i : a) i = (int64_t) i * ninv % mod;
		}
	}
};

int main() {
	int n = ri();
	int back[3] = { 0 };
	int forward[3] = { 0 };
	std::vector<int> a(n);
	{
		char tmp[4096];
		scanf("%s", tmp);
		for (int i = 0; i < n; i++) {
			a[i] = tmp[i] == 'R' ? 0 : tmp[i] == 'G' ? 1 : 2;
			back[a[i]]++;
		}
	}
	
	int64_t res = 0;
	// j - i != k - jを無視したの
	for (int j = 0; j < n; j++) {
		back[a[j]]--;
		res += forward[(a[j] + 1) % 3] * back[(a[j] + 2) % 3];
		res += forward[(a[j] + 2) % 3] * back[(a[j] + 1) % 3];
		forward[a[j]]++;
	}
	// j - i == k - jで相異なるものを引く
	int n2 = 1;
	for (; n2 < n + n - 1; n2 <<= 1);
	NTT<998244353, 3> ntt;
	std::vector<int> count[3];
	for (auto &i : count) i.resize(n2);
	for (int i = 0; i < n; i++) count[a[i]][i]++;
	for (auto &i : count) ntt.ntt(i, false);
	
	std::vector<int> conved[3]; // conved count[i], count[(i + 1) % 3]
	for (int i = 0; i < 3; i++) {
		auto &cur = conved[i];
		cur.resize(n2);
		for (int j = 0; j < n2; j++) cur[j] = (int64_t) count[i][j] * count[(i + 1) % 3][j] % 998244353;
		ntt.ntt(cur, true);
	}
	for (int j = 0; j < n; j++) res -= conved[(a[j] + 1) % 3][j + j];
	
	printf("%" PRId64 "\n", res);
	
	return 0;
}


Measured memory_bytes: 4016
n, a, b = [int(item) for item in input().split()]
if n < a + (b-1) or n > a + (b-1) * a:
    print(-1)
    exit()
for i in range(a):
    print(n - a + i + 1, end=" ")
n -= a
if n == 0:
    print("")
    exit()
loop = n // (b-1)
option = n % (b-1)
for j in range(b-1):
    if option > 0:
        for i in range(loop+1):
            print(n - loop - 1 + i + 1, end=" ")
        n -= loop + 1
        option -= 1
    else:
        for i in range(loop):
            print(n - loop + i + 1, end=" ")
        n -= loop
print("")

Measured memory_bytes: 5308
#include "stdio.h"

int main()
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if ((x - r) < 0 || (x + r) > w || (y - r) < 0 || (y + r) > h)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}

Measured memory_bytes: 584
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char arr[] = sc.next().toCharArray();
        int max = 0;
        for(int i = 1 ; i < arr.length - 1 ; i++){
            HashSet<Character> first = new HashSet<>();
            for(int j = i-1; j>=0 ; j-- ){
                first.add(arr[j]);
            }
            int count = 0;
            HashSet<Character> set=  new HashSet<>();
            for(int j = i ; j < arr.length ; j++ ){
                if(!set.contains(arr[j])){
                    if(first.contains(arr[j])){
                        count++;
                    }
                    set.add(arr[j]);
                }
            }
            max = Math.max(max,count);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23124
from math import sqrt
q3 = sqrt(3)
fmt = "%.8f %.8f"
def koch(x0, y0, x1, y1, c):
    if c == n:
        return (fmt % (x0, y0),)
    xp = (x0*2 + x1) / 3
    yp = (y0*2 + y1) / 3

    xq = (x0 + x1*2) / 3
    yq = (y0 + y1*2) / 3

    dx = (x1 - x0) / 6
    dy = (y1 - y0) / 6

    xr = xp + (dx - dy * q3)
    yr = yp + (dx * q3 + dy)

    return koch(x0, y0, xp, yp, c+1) + koch(xp, yp, xr, yr, c+1) + koch(xr, yr, xq, yq, c+1) + koch(xq, yq, x1, y1, c+1)
n = int(input())
print(*koch(0, 0, 100, 0, 0)+(fmt % (100, 0),), sep='\n')

Measured memory_bytes: 8136
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	long long int n,i,sum=0;
	cin >> n;
	
	for (i=1; i<=n; i++){
		if (i%3 != 0 && i%5 != 0){
			sum += i;
		}
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279

int x;
int num[] = {1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000};

void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	scanf("%d", &x);
	if(x==1000)	printf("1000");
  	else{
      for(int i=0;;i++){
		if(num[i]<=x && x<num[i+1]){
          printf("%d", num[i]);
          break;
      	  }
		}
    }
	return 0;
}

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

int main(){
  long long a,b,c,l;
  while(cin>>a>>b){
    l = a*b;
    while(b){
      c = a;
      a = b;
      b = c % b;
    }
    cout<<a<<" "<<l/a<<endl;
  }
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (s.find(x) != s.end()) {
            s.erase(x);
        } else {
            s.insert(x);
        }
    }
    cout << s.size();
}

Measured memory_bytes: 8316
#include <vector>
#include <queue>
#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()
{
  int n, x;
  cin >> n >> x;
  int a, min = 1000, max = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    if (a < min) min = a;
    if (a > max) max = a;
  }
  int ans = n;
  x -= sum;
  ans += x / min;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int v[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &v[i]);
    int o[100005], e[100005];
    for (i = 0; i < n; i++)
        if (i % 2 == 0)
            e[i / 2] = v[i];
        else
            o[i / 2] = v[i];
    int m = n / 2;
    qsort(e, m, sizeof(int), asc);
    qsort(o, m, sizeof(int), asc);
    e[m] = o[m] = -1;
    int e1, ne1, o1, no1;
    ne1 = no1 = 0;
    int x = 1;
    for (i = 1; i <= m; i++)
        if (e[i] == e[i - 1])
            x++;
        else
        {
            if (x > ne1)
            {
                ne1 = x;
                e1 = e[i - 1];
            }
            x = 1;
        }
    x = 1;
    for (i = 1; i <= m; i++)
        if (o[i] == o[i - 1])
            x++;
        else
        {
            if (x > no1)
            {
                no1 = x;
            o1 = o[i - 1];
            }
            x = 1;
        }
    if (e1 != o1)
    {
        printf("%d\n", n - ne1 - no1);
        return 0;
    }
    int no2, ne2;
    no2 = ne2 = 0;
    if (e[0] == e1)
        x = 0;
    else
        x = 1;
    for (i = 1; i <= m; i++)
        if (e[i] == e[i - 1] && e[i] != e1)
            x++;
        else
        {
            if (x > ne2)
                ne2 = x;
            if (e[i] == e1)
                x = 0;
            else
                x = 1;
        }
    if (o[0] == o1)
        x = 0;
    else
        x = 1;
    for (i = 1; i <= m; i++)
        if (o[i] == o[i - 1] && o[i] != o1)
            x++;
        else
        {
            if (x > no2)
                no2 = x;
            if (o[i] == o1)
                x = 0;
            else
                x = 1;
        }
    if (no2 < ne2)
        ne1 = ne2;
    else
        no1 = no2;
    printf("%d\n", n - no1 - ne1);
    return 0;
}

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

using namespace std; 

int main(){
	
	
	int a,b,c,d,e,k; 
	
	cin >> a >> b >> c >> d >> e >> k;
	
	bool ok = true; 
	
	
	if(e-a>k){
		ok = false;
	}
	
	if(!ok){
		cout << ":(" << endl;
	}else{
		cout << "Yay!" << endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18,MOD = 998244353;

signed main(){
	int N;
	cin>>N;
	vector<int>cnt(N,0);
	vector<int>d(N);
	REP(i,N){
		cin>>d[i];
		if(d[i]==0&&i!=0){
			cout<<0<<endl;
			return 0;
		}
	}
	sort(ALL(d));
	int ans = 1;
	REP(i,N){
		if(d[i])(ans *= cnt[d[i]-1]) %= MOD;
		cnt[d[i]]++;
	}
	cout<<ans<<endl;
}

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

using P = pair<long long, long long>;
long long n;
vector<long long> a, res;
vector<P> v;

void solve();

int main() {
  cin >> n;
  a.resize(n);
  for (auto& p : a) cin >> p;
  solve();
  for (auto p : res) cout << p << endl;
  return 0;
}

void solve() {
  for (int i = 0; i < n; ++i) v.push_back(P(a[i], i));
  v.push_back(P(0, n));
  res.assign(n, 0);
  sort(v.begin(), v.end(), greater<P>());
  long long now = n + 1;
  for (int i = 0; i < n; ++i) {
    now = min(now, v[i].second);
    res[now] += (i + 1) * (v[i].first - v[i + 1].first);
  }
}

Measured memory_bytes: 6384
s = input()
ans = 0

def check(sub):
    check_s = set(list("ACGT"))
    for c in sub:
        if not c in check_s:
            return 0
    return len(sub)    
    
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        ans = max(ans, check(s[i:j]))

print(ans)


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

int main() {
  int N, K, X, Y; cin >> N >> K >> X >> Y;
  int cost;
  if( N <= K )
    cost = N * X;
  else {
    cost = K * X + (N - K) * Y;
  }
  cout << cost;
}

Measured memory_bytes: 256
k, a, b = map(int, input().split())

if b - a <= 2:
    print(k + 1)
else:
    tmp = (k - a + 1) // 2
    ans = a + (b - a) * tmp
    if (k - a + 1) % 2 == 1:
        ans += 1
    print(ans)


Measured memory_bytes: 9164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;

const int RANGE = 120;

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

    ll X;
    cin >> X;
    vector<ll> list(RANGE*2+2);
    for (ll i = -RANGE; i <= RANGE; i++) {
        list[i + RANGE] = pow(i, 5LL);
    }
    for (ll i = -RANGE; i <= RANGE; i++) {
        for (ll j = -RANGE; j <= RANGE; j++) {
            if (list[i+RANGE] - list[j+RANGE] == X) {
                cout << i << " " << j << endl;
                goto end;
            }
        }
    }
    end:
    return 0;
}

Measured memory_bytes: 4068
num = gets.to_i
num = gets.split(" ").map(&:to_i)

max = num[0]
min = num[0]
sum = 0
num.each{|i|
  sum += i
  if max < i then
    max = i
  end
  if min > i then
    min = i
  end
}

printf "%d %d %d\n", min, max, sum;

Measured memory_bytes: 9112
import java.io.PrintWriter

val br = System.`in`.bufferedReader()
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val d = readInteger()
    val cList = readLongList()
    val satisfyTable = Array(d) { readLongList() }

    for (i in 0 until d) {
        out.println(i % 26 + 1)
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 38320
H, W = map(int, input().split())

aLst = [list(map(str, input().split())) for i in range(H)]

deIndex = []
for i in range(H):
    if aLst[i][0].count('.') == W:
        deIndex.append(i)
deIndex.sort(reverse=True)

for i in deIndex:
    del aLst[i]
H -= len(deIndex)
deIndex.clear()

for i in range(W):
    kCnt = 0
    for j in range(H):
        if aLst[j][0][i] == '.':
            kCnt += 1

    if kCnt == H:
        deIndex.append(i)
if len(deIndex) == 0:

    for i in range(H):
        print(''.join(aLst[i]))
else:
    deIndex.sort(reverse=True)
    tmplist = [['' for i in range(W)] for j in range(H)]
    for j in range(H):
        tmplist[j] = list(aLst[j][0])

    for i in range(H):
        for j in deIndex:
            del tmplist[i][j]

    W -= len(deIndex)
    for i in range(H):
        print(''.join(tmplist[i]))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<string> lstS = new List<string>();
            for (int i = 0; i < sS.Length; i++) { lstS.Add(sS.Substring(i, 1)); }
            lstS.Sort();                                                                                // 文字もそのまま昇順
            string sOut = "No";
            if ((lstS[0] == lstS[1]) && (lstS[2] == lstS[3]) && (lstS[1] != lstS[2])) { sOut = "Yes"; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = n / 2;
            int[] a = in.nextIntArray(n);

            Map<Integer, Integer> map1 = new TreeMap<>();
            Map<Integer, Integer> map2 = new TreeMap<>();
            map1.put(0, 0);
            map2.put(0, 0);

            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    map1.merge(a[i], 1, Integer::sum);
                } else {
                    map2.merge(a[i], 1, Integer::sum);
                }
            }

            List<Map.Entry<Integer, Integer>> list1 = new ArrayList<>(map1.entrySet());
            List<Map.Entry<Integer, Integer>> list2 = new ArrayList<>(map2.entrySet());
            list1.sort((e1, e2) -> e2.getValue() - e1.getValue());
            list2.sort((e1, e2) -> e2.getValue() - e1.getValue());

            if (list1.get(0).getKey().equals(list2.get(0).getKey())) {
                out.println(2 * m - Math.max(list1.get(0).getValue() + list2.get(1).getValue(), list1.get(1).getValue() + list2.get(0).getValue()));
            } else {
                out.println(2 * m - list1.get(0).getValue() - list2.get(0).getValue());
            }
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 46212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	vector<vector<ll>>dp(pow(10, 6),vector<ll>(3,-INF));
	ll n;
	cin >> n;
	vector<vector<ll>>a(n,vector<ll>(3));
	rep(i, n)rep(k, 3)cin >> a[i][k];
	rep(i, 3)dp[0][i] = a[0][i];
	for (ll i = 1; i < n; i++) {
		rep(pre, 3) {
			rep(now,3) {
				if (pre == now)continue;
				else {
					chmax(dp[i][now],a[i][now]+dp[i-1][pre]);
				}
			}
		}
	}
	cout << *max_element(all(dp[n-1])) << endl;
}


Measured memory_bytes: 60416
package main

import "fmt"

func main() {
    var a, b int
    fmt.Scan(&a, &b)

    if a*b % 2 == 0 {
        fmt.Println("Even")
        return
    }
    
    if a*b % 2 != 0 {
        fmt.Println("Odd")
        return
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a ,b,c,d;
  cin  >> a>>b>> c>>d;
  if(abs(c-a) <= d || (abs(a-b) <= d && abs(c-b) <= d))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = IR(n)
    s = defaultdict(lambda : 0)
    for i in a:
        s[i] ^= 1
    print(sum(s.values()))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 53852
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N,M;cin >> N >> M;
    vector<int> A(M);rep(i,M)cin >> A[i];

    int sum = 0;
    rep(i,M)sum += A[i];
    int ans = N - sum;

    if(ans < 0)ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3668
fun main() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }

    val z = (1..n).count { it % k == 0 }
    var res = z.toLong() * z * z

    if (k % 2 == 0) {
        val h = (1..n).count { it % k == (k / 2) }
        res += h.toLong() * h * h
    }
    println(res)
}

Measured memory_bytes: 36996
H, W, K = map(int, input().split())
MOD = (10 ** 9) + 7

dp = [[0] * W for _ in range(H+1)]
dp[0][K-1] = 1

multi = [
  1, # 0
  2, # 1
  3, # 2
  5, # 3
  8, # 4
  13,# 5
  21 # 6
]

def f(num, l, r):
  left = max(0, l)
  right = num-1 - min(r, num-1)
  return multi[left] * multi[right]

for h in range(1, H+1):
  for w in range(W):
    dp[h][w] += dp[h-1][w] * f(W, w-1, w+1)
    if w > 0:
      dp[h][w] += dp[h-1][w-1] * f(W, w-2, w+1)
    if w < W - 1:
      dp[h][w] += dp[h-1][w+1] * f(W, w-1, w+2)
    dp[h][w] %= MOD

print(dp[H][0])

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

int main(){
  int N,H,W;
  cin >> N >> H >> W;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){cin >> A[i] >> B[i];}
  int ans=0;
  for(int i=0;i<N;i++){
    if(A[i]>=H && B[i]>=W){ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
 int a[100];
 int n,i,j,v,k;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d",&a[i]);
 }
 for(i=0;i<n;i++){
  v=a[i];
  j=i-1;
  while(j>=0&&a[j]>v){
   a[j+1]=a[j];
   j--;
  }
  a[j+1]=v;
  for(k=0;k<n;k++){
     if(k==n-1){
        printf("%d\n",a[k]);
       }else{
        printf("%d ",a[k]);
   }
  }
  
 }

}

  
 

Measured memory_bytes: 1748
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        double r = sc.nextDouble();
 
        System.out.printf("%.10f %.10f\n",r*r*Math.PI,(2*r)*Math.PI);
    }
}


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

int arr[3];

int main(){
	int i;
	for(i = 0; i < 3; i++) scanf("%d", &arr[i]);
	sort(arr, arr + 3);
	printf("%d\n", arr[2] - arr[0]);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=[2]+limii()
cnt=0
ans=[]
mat=[0]*(n+1)
for i in range(1,n+1)[::-1]:
    temp=0
    for j in range(2*i,n+1,i):
        temp+=mat[j]
    
    if temp%2!=arr[i]:
        mat[i]=1

for i in range(n+1):
    if mat[i]==1:
        ans.append(i)
        cnt+=1

print(cnt)
print(*ans)


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char a[100] = {} ,b[100] = {};

    Scs(a);
    Scs(b);

    int le = max( strlen(a) , strlen(b) );
    if( strlen(a) > strlen(b) ){
        printf ("GREATER\n");
        return 0;
    }
    if( strlen(a) < strlen(b) ){
        printf ("LESS\n");
        return 0;
    }
    Rep(i,le){
        if( a[i] > b[i] ){
            printf ("GREATER\n");
            break;
        }
        if( a[i] < b[i] ){
            printf ("LESS\n");
            break;
        }
        if( a[i] == b[i] ){
            if( i == le-1 ){
                printf("EQUAL\n");
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
dirs = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)}

N = int(input())
P = {d: [] for d in dirs}
for i in range(N):
    x, y, d = input().split()
    x, y = map(int, (x, y))
    P[d].append((x, y))

def fst(x): return x[0]
def snd(x): return x[1]
inf = float('inf')

# 方向別のX・Yの最大最小
S = {d: {'xmin': min(map(fst, P[d]), default= inf),
         'xmax': max(map(fst, P[d]), default=-inf),
         'ymin': min(map(snd, P[d]), default= inf),
         'ymax': max(map(snd, P[d]), default=-inf) }
     for d in dirs}

vars = ('xmax', 'xmin', 'ymax', 'ymin')
maxmin = {'max': max, 'min': min}
dirs = {d: {'x': dirs[d][0], 'y': dirs[d][1]} for d in dirs}

# S[L][xmax] - t1 == max(S[U][xmax], S[D][xmax])  t < t1 -> S[UD] < S[L]
# S[R][xmax] + t2 == max(S[U][xmax], S[D][xmax])  t < t2 -> S[R]  < S[UD]
# S[L][xmax] - t3 == S[R][xmax] + t3              t < t3 -> S[R]  < S[L]

# 変化がある時刻の集合
T = set()
T.add(0)
for v in vars:
    u, d, c1, c2 = ('R', 'L', 'U', 'D') if v.startswith('x') else \
                   ('U', 'D', 'R', 'L')
    C  = maxmin[v[-3:]](S[c1][v], S[c2][v])
    t1 =  S[d][v] - C
    t2 = -S[u][v] + C
    t3 = (S[d][v] - S[u][v]) / 2
    T.update([t1, t2, t3])

q = inf
for t in (t for t in T if 0 <= t and t != inf):
    Q = {v: maxmin[v[-3:]](S[d][v] + t * dirs[d][v[0]] for d in dirs)
         for v in vars}
    q = min(q, (Q['xmax'] - Q['xmin']) * (Q['ymax'] - Q['ymin']))

print(q)


Measured memory_bytes: 16880
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int x=0,y=0;
    for(int i=0;i<s.length();i++)
    {
        x=0;
        if(s[i]=='R')
        {
            x++;
            while(s[i]==s[i+1])
            {
                x++;
                i++;
            }
            y=max(x,y);
        }
    }
    cout<<y<<endl;  
    
}

Measured memory_bytes: 3616
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         String input = infile.readLine();
         int N = input.length();
         String res = "Yes";
         for(int i=0; i < N/2; i++)
            if(input.charAt(i) != input.charAt(N-1-i))
               res = "No";
         int a = 0;
         int b = N/2-1;
         while(a < b)
         {
            if(input.charAt(a) != input.charAt(b))
               res = "No";
            a++;
            b--;
         }
         a = N/2+1;
         b = N-1;
         while(a < b)
         {
            if(input.charAt(a) != input.charAt(b))
               res = "No";
            a++;
            b--;
         }
         System.out.println(res);
      }
   }

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

signed main() {
  int N,M;
  cin >> N >> M;
  if(N == 1){
	  if(M != 1){
		  cout << M-2 << endl;
		  return 0;
	  }
	  else{
		  cout << 1 << endl;
		  return 0;
	  }
  }
  else if(M == 1){
	  if(N != 1){
		  cout << N-2 << endl;
		  return 0;
	  }
	  else{
		  cout << 1 << endl;
		  return 0;
	  }
  }
  else{
  cout << (N-2)*(M-2) << endl;
}
}


Measured memory_bytes: 3632
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        //110110011
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        int H=sc.nextInt();
        int W=sc.nextInt();
        int h=sc.nextInt();
        int w=sc.nextInt();
        

        out.println(H*W-h*W-w*H+h*w);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int id,T;
    P(int id, int T) {
        this.id=id;
        this.T=T;
    }
    public int compareTo(P p){
        return id-p.id; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22996
N = int(input())
SP = []
for n in range(N):
  S, P = [sp for sp in input().split()]
  P = int(P)
  SP.append([S, 100-P, n+1])
SP = sorted(SP, key=lambda x:x[0:2])
for n in range(N):
  print(SP[n][2])

Measured memory_bytes: 3060
fn main () {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let st: Vec<_> = (0..n).map(|_| (s.next().unwrap(), s.next().unwrap().parse::<i32>().unwrap())).collect();
	let x = s.next().unwrap();
	let ans = st.iter().fold((0, false), |r, &(s, t)|{
		if r.1 {
			(r.0 + t, true)
		} else {
			(r.0, &s == &x)
		}
	}).0;
	println!("{}", ans);
}


Measured memory_bytes: 4352
import sys

def main():
    INF = -2**60
    N, M = map(int, sys.stdin.buffer.readline().split())
    XYZ = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

    sgn = [[1,1,1], [1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
    ans = INF 
    for a, b, c in sgn:
        dp = [INF]*(M+1)
        dp[0] = 0
        for x, y, z in XYZ:
            for j in range(M-1, -1, -1):
                if dp[j] == INF: continue
                s = dp[j]+ a*x + b*y + c*z
                if s > dp[j+1]:
                    dp[j+1] = s
        if dp[M] > ans:
            ans = dp[M]
    print(ans)

main()


Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const ll MAX = (ll)1e5;

ll N, M;
ll fact[MAX + 10];

ll ini_fac(){
  fact[0] = 1;
  for(ll i = 0; i <= MAX; i++){
    fact[i+1] = (fact[i] * (i+1)) % MOD;
  }
}

int main(){
  cin >> N >> M;
  ll ans = 0;
  if(abs(N - M) >= 2) {ans = 0;}
  else{
    ini_fac();
    if(abs(N - M) == 1){
      ans = (fact[N] * fact[M]) % MOD;
    }else{
      ans = (2 * (fact[N] * fact[M]) % MOD) % MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> cnt(n, 0);
    vector<ll> ans;
    rrep(i, n) {
        ll sum = 0;
        for(ll j = i; j < n; j += (i + 1)) {
            sum += cnt[j];
        }
        if ((sum % 2) != a[i]) {
            cnt[i]++;
            ans.push_back(i);
        }
    }
    printf("%lld\n", sz(ans));
    rep(i, sz(ans)) printf("%lld%s", ans[i] + 1, (i == (sz(ans) - 1)) ? "\n" : " ");
    return 0;
}


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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
ll dp[110][100100];
int main()
{
	cout << setprecision(10);
	int n , w ; cin >> n >> w;
	vector<ll> weight(110), value(110);
	rep(i,n){
		cin >> weight[i] >> value[i];
	}

	rep(i,110){
		rep(j,100100){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;

	rep(i,n){
		for(int sum_value=0; sum_value < 100060 ; sum_value++){
			//取ったときに価値がsum_valueを超えるなら取ればいい
			if(sum_value-value[i] >= 0){
				//取るか
				chmin(dp[i+1][sum_value],dp[i][sum_value-value[i]] + weight[i]);
			}
			//取らない
			chmin(dp[i+1][sum_value],dp[i][sum_value]);
		}
	}
	ll ans = 0;
	rep(V,100100){
		if(dp[n][V] <= w){
			ans = V ;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 86272
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,x;
    string s;
    cin>>n;
    ll c4=0,ce=0,co=0;
    while(n--)
    {
        cin>>x;
        if(x%4==0) c4++;
        else if(x%2==0) ce++;
        else co++;
        
    }
    if(c4>=co)
    cout<<"Yes"<<endl;
    else if(co==c4+1&&ce==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
   
   
   
   
   
    return 0;
}





Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

int main(void) {
  ll n;
  cin >> n;
  vecll a(5);
  rep(i,5){
    cin >> a[i];
  }

  sortall(a);
  prt((n-1)/a[0]+1+4);


}


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

using namespace std;

int main(void) {
  int N;

  cin >> N;

  vector<int> num(N, 0);

  int temp;

  for (int i = 0;i < N-1;i++) {
    cin >> temp;
    num[temp-1]++;
  }

  for (int i = 0;i < N;i++) {
    cout << num[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
string s;

int main() {
  int a,b,c,x,y;cin >> a >> b>> c>> x>> y;
  int out;
  if (a+b <= 2*c) {
    out = a*x + b*y;
  } else {
    int p2 = 2 * c * max(x,y);
    int p3 = 2 * c * min(x,y);
    if (x>y) {
      p3 += a * (x-y);
    } else {
      p3 += b * (y-x);
    }
    out = min(p2, p3);
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
x=list(map(int, input().split(" ")))
x_s=sorted(x)
v1=x_s[int(len(x)/2)-1]
v2=x_s[int(len(x)/2)]
for i in x:
    if i>=v2:
        print(v1)
    else:
        print(v2)


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

bool pd(int x) {
    int res = 0, t = x;
    while(t)
        res *= 10, res += t % 10, t /= 10;
    return res == x;
}

int main() {
    int x;
    cin >> x;
    for(int i = 0; ; ++i) {
        if(pd(x - i)) {
            cout << x - i << endl;
            return 0;
        }
        if(pd(x + i)) {
            cout << x + i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define fi first 
#define se second
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef map<int,int> mi;
int n,k;
int t[100010],d[100010];
pi p[100010];
mi mp; 
ll rec(int a,int b,ll sum){
  ll res=sum+mp.size()*mp.size();
  if(a<0||b>=n) return res;
  while(mp[p[a].se]<2){
    a--;
    if(a<0) return res;
  }
  while(mp[p[b].se]!=0){
    b++;
    if(b>=n) return res;
  }
  sum-=p[a].fi;sum+=p[b].fi;
  mp[p[a].se]--;mp[p[b].se]++;
  return max(res,rec(a-1,b+1,sum));
}
int main(){
  scan(n);scan(k);
  rep(i,n){
    scan(t[i]);scan(d[i]);
  }
  rep(i,n){
    p[i].fi=d[i];p[i].se=t[i];
  }
  sort(p,p+n,greater<pi>());
  ll sum=0;
  rep(i,k){
    sum+=p[i].fi;
    mp[p[i].se]++;
  }
  prin(rec(k-1,k,sum));

  
  
  
  
  return 0;
}


Measured memory_bytes: 6016
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long N, long long M){
    if(N % 2 == 0){
        ll num_adj = N/4;
        ll num_skip = M - num_adj;
        ll i = 1;
        while(M > 0 && i <= num_adj){
            cout << i <<" " << N+1-i<<endl;
            i++;
            M--;
        }
        while(M > 0){
            cout << i << " " << N-i <<endl;
            i++;
            M--;
        }
    }
    else {
        ll i = 1;
        while(M > 0){
            cout << i << " " << N+1-i<<endl;
            i++;
            M--;
        }
    }
        
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
char S[150];
char S1[150];


int main(void){
 int n,k;
 cin>>n>>k;
 if(n<k)std::cout<<1<<std::endl; 
 else{
  if(n%k==0)std::cout<<0<<std::endl;
  else std::cout<<1<<std::endl;
 }
 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
 
int n;
ll cnt=0;
ll r,g,b;
string s;
 
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>s;
   for(int i=0;i<n;++i){
       for(int j=i+1;j<n;++j){
           int k=j+(j-i);
           if(k>n-1) continue;
           if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k]) cnt++;
       }
   }
 
   for(int i=0;i<n;++i){
       if(s[i]=='R') r++;
       else if(s[i]=='G') g++;
       else b++;
   }
   printf("%lld\n",r*g*b-cnt);
 
 
    return 0;
}

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

using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main() {
  int N;
  while(cin >> N && N){
  string s;
  int prev = 0;
  int cnt = 0;
  bool l = 0, r = 0;
  rep(i, N) {
    cin >> s;
    if(s == "lu") { l = 1; }
    if(s == "ru") { r = 1; }
    if(s == "ld") { l = 0; }
    if(s == "rd") { r = 0; }
    if(!prev && l && r) { prev = 1; cnt ++; }
    else if(prev && !l && !r) { prev = 0; cnt ++; }
  }
  cout << cnt << endl;}
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<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);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    double s = (a[n - 1] + a[n - 2]) / 2.0;
    for (int i = n - 3; i >= 0; i--) {
        s = (s + a[i]) / 2.0;
    }
    cout << fixed << setprecision(10) << s << endl;
}


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

using namespace std;
int main()
{
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	if(S[K - 1] >= 'A' && S[K - 1] <= 'Z')
	{
		S[K - 1] += 32;
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

Q = int(input())

for _ in range(Q):
    b,m,e = map(int,input().split())
    A = A[:b]+A[e-(e-m)%(e-b):e]+A[b:e-(e-m)%(e-b)]+A[e:]

print(*A)


Measured memory_bytes: 5828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int c = Integer.parseInt(strArr[2]);
		System.out.println(Integer.min(b / a, c));
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 23252