akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, List<List<Integer>>> sp = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			if (sp.keySet().contains(str)) {
				sp.get(str).get(0).add(sc.nextInt());
			} else {
				sp.put(str, new ArrayList<>());
				sp.get(str).add(new ArrayList<>());
				sp.get(str).add(new ArrayList<>());
				sp.get(str).get(0).add(sc.nextInt());
			}
			sp.get(str).get(1).add(i + 1);
		}
		
		List<Integer> result = new ArrayList();
		
		while (sp.size() > 0) {
			String str = Collections.min(sp.keySet());
			int max = Collections.max(sp.get(str).get(0));
			result.add(sp.get(str).get(1).get(sp.get(str).get(0).indexOf(max)));
			int index = sp.get(str).get(0).indexOf(max);
			sp.get(str).get(0).remove(index);
			sp.get(str).get(1).remove(index);
			if (sp.get(str).get(0).size() <= 0) {
				sp.remove(str);
			}
		}
		
		for (int num : result) {
			System.out.println(num);
		}
	}
}


Measured memory_bytes: 21844
from collections import deque

def solve(board, start, end, W, H):

    check = [[False for j in range(W + 2)] for i in range(H + 2)]
    q = deque()
    t = (start[0], start[1], 0)
    q.append(t)
    while True:
        p = q.popleft()
        x = p[0]
        y = p[1]
        g = p[2]
        if (x, y) == end:

            return g

        if check[y][x]:
            continue
        else:
            check[y][x] = True

        if not board[y - 1][x] == 'X':
            q.append((x, y - 1, g + 1))
        if not board[y + 1][x] == 'X':
            q.append((x, y + 1, g + 1))
        if not board[y][x - 1] == 'X':
            q.append((x - 1, y, g + 1))
        if not board[y][x + 1] == 'X':
            q.append((x + 1, y, g + 1))


def main():
    H, W, N = map(int, input().split())

    board = [['X' for j in range(W + 2)] for i in range(H + 2)]
    number = 'S123456789'
    place = [(0, 0)] * (N + 1)
    for i in range(H):
        s = input()
        for j in range(W):
            board[i + 1][j + 1] = s[j]
            if s[j] in number:
                place[number.index(s[j])] = (j + 1, i + 1)

    ans = 0
    for i in range(N):
        ans += solve(board, place[i], place[i + 1], W, H)

    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 23732
#include<stdio.h>
#define MAX 1000

int main(){
	int i=0,l,tmp=0;
	char c[MAX+1]={};
	int sum;
	while(1){
		sum=0;
		scanf("%s", c);
		if(c[0]=='0'){break;}
		for(i=0; i<MAX; i++){
			if(c[i]=='\0'){break;}
			tmp = c[i] - '0';
			sum += tmp;
			//printf("%d:",sum);
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 536
import java.util.*;

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

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

int main(){
  int n, k;
  vector<int> v;

  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end(), greater<int>());

  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += v[i];
  }

  cout << sum << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i, a, n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i, a, n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i, a, n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i, a, n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i, a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
//constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;

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

inline void init() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}

template<class T>
inline istream &operator>>(istream &input, vector<T> &v) {
    for (auto &elemnt : v)input >> elemnt;
    return input;
}

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

int main() {
    init();
    int x, y;
    cin >> x >> y;
    cout << (x+1) + (y+1) - (gcd(x,y) + 1)<<endl;

    return 0;
}



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

int main() {
  int N, l, i=0;
  cin >> N;
  vector<int> A(N);
  while(cin >> l){
    A[i] = l;
    i++;
    if(N <= i){
      break;
    }
  };

  int ans = 0;

  ans = accumulate(A.begin(), A.end(), 0) - A.size();

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
N, D = map(int,input().split())
X = [list(map(int, input().split())) for i in range(N)]

seisu_count = 0
for l in range(N):

    for r in range(l+1, N):
        total = 0
        for z in range(D):
            y_z = abs(X[l][z] - X[r][z])
            y_z_2 = y_z * y_z
            total += y_z_2
        
        sqr_total = math.sqrt(total)
        if sqr_total.is_integer():
            seisu_count += 1

print(seisu_count)

Measured memory_bytes: 9188
N = int(input())

iSP = []
for i in range(N):
    S, P = input().split()
    iSP.append([i + 1, S, int(P)])

iSP.sort(key = lambda x: x[2], reverse = True)    
iSP.sort(key = lambda x: x[1])

for x in iSP:
    print(x[0])

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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 1e5 + 5;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    ld res = 0;
    int n , x;
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> x;

        res += 1.0 / x;
    }
    cout << fixed << setprecision(5) << 1 / res;
}


Measured memory_bytes: 256
import heapq

n,e=map(int,input().split())
G=[[] for _ in range(n)]
for index in range(e):
    s,t,w=map(int,input().split())
    #要素はリスト
    G[s].append([w,t])
    G[t].append([w,s])

#ノード0から始める
def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in G[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in G[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

ans=prim_heap()
print(ans)


Measured memory_bytes: 34972
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int m1 = sc.NextInt();
        int d1 = sc.NextInt();
        int m2 = sc.NextInt();
        int d2 = sc.NextInt();
        Console.WriteLine(m1 < m2 ? 1 : 0);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27488
// Reference: https://en.wikipedia.org/wiki/Fenwick_tree
pub struct FenwickTree<T> {
    n: usize,
    ary: Vec<T>,
    e: T,
}

impl<T: Clone + std::ops::AddAssign<T>> FenwickTree<T> {
    pub fn new(n: usize, e: T) -> Self {
        FenwickTree {
            n,
            ary: vec![e.clone(); n],
            e,
        }
    }
    pub fn accum(&self, mut idx: usize) -> T {
        let mut sum = self.e.clone();
        while idx > 0 {
            sum += self.ary[idx - 1].clone();
            idx &= idx - 1;
        }
        sum
    }
    /// performs data[idx] += val;
    pub fn add<U: Clone>(&mut self, mut idx: usize, val: U)
    where
        T: std::ops::AddAssign<U>,
    {
        let n = self.n;
        idx += 1;
        while idx <= n {
            self.ary[idx - 1] += val.clone();
            idx += idx & idx.wrapping_neg();
        }
    }
    /// Returns data[l] + ... + data[r - 1].
    pub fn sum(&self, l: usize, r: usize) -> T
    where
        T: std::ops::Sub<Output = T>,
    {
        self.accum(r) - self.accum(l)
    }
}


use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    let n = input.next().unwrap().parse().unwrap();
    let q = input.next().unwrap().parse().unwrap();
    let mut tree = FenwickTree::<u64>::new(n, 0);
    for i in 0..n {
        let a: u64 = input.next().unwrap().parse().unwrap();
        tree.add(i, a);
    }
    for _ in 0..q {
        match input.next().unwrap().parse().unwrap() {
            0 => {
                let p = input.next().unwrap().parse().unwrap();
                let x: u64 = input.next().unwrap().parse().unwrap();
                tree.add(p, x);
            }
            1 => {
                let l = input.next().unwrap().parse().unwrap();
                let r = input.next().unwrap().parse().unwrap();
                println!("{}", tree.sum(l, r));
            }
            _ => {}
        }
    }
}


Measured memory_bytes: 21448
from collections import defaultdict
n = int(input())
v = list(map(int,input().split()))
a = v[::2]
b = v[1::2]
def calc(l):
    d = defaultdict(int)
    for x in l:
        d[x] += 1
    return sorted([(d[x], x) for x in d],reverse=True)
A = calc(a)
B = calc(b)
al,ax = A[0]
bl,bx = B[0]
if ax != bx:
    print(n-al-bl)
else:
    ar,ay = A[1] if len(A) > 1 else (0,None)
    br,by = B[1] if len(B) > 1 else (0,None)
    print(min(n-al-br,n-ar-bl))

Measured memory_bytes: 21212
use std::io;

fn main() {
    let mut N = String::new();
    let mut P = String::new();
    io::stdin().read_line(&mut N);
    io::stdin().read_line(&mut P);
    let vecN :Vec<&str> = N.trim().split_whitespace().collect();
    let mut vecP :Vec<usize> = P.trim().split_whitespace().map(|e| e.parse::<usize>().unwrap()).collect();
    let n :usize = vecN[0].parse().unwrap();
    let k :usize = vecN[1].parse().unwrap();
    vecP.sort();
    let mut total :usize = 0;
    for i in 0..k{
        total += vecP[i];
    }
    println!("{}",total);
}


Measured memory_bytes: 2156
n,k = map(int,input().split())
p = 10 ** 9 + 7

ans = 0
max=0
min=0

a=[0]*(n+1)
b=[0]*(n+2)

for i in range(n+1):
    a[i]=i
    b[i+1]=a[i]+b[i]

if n>=k:
    for i in range(k,n+2):
        min=b[i]
        max=b[n+1]-b[n+1-i]
        ans=ans+max-min+1
else:
    ans=1

ans = ans % p

print(ans)

Measured memory_bytes: 27076
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#13:53(2)
n = int(input())
v = list(map(int,input().split()))
E = [[0,i] for i in range(1,10**5+1)]
O = [[0,i] for i in range(1,10**5+1)]
for j in range(n):
  if j % 2 == 0:
    E[v[j]-1][0] += 1
  else:
    O[v[j]-1][0] += 1
E.sort()
E.reverse()
O.sort()
O.reverse()
if E[0][1] != O[0][1]:
  print( n - E[0][0] - O[0][0] )
else:
  can = [ n - E[1][0] - O[0][0] , n - E[0][0] - O[1][0] ]
  print(min(can))

Measured memory_bytes: 34028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    string a, b, c;
    cin >> a >> b >> c;

    cout << (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
XYH = []
for i in range(N):
    tmp = list(map(int, input().split()))
    if tmp[2] != 0:
        xyh = tmp
    XYH.append(tmp)

def calc(XYH, xyh):
    for tarx in range(101):
        for tary in range(101):
            tarh = xyh[2] + abs(xyh[0] - tarx) + abs(xyh[1] - tary)
            if all(h==max(tarh - abs(tarx - x) - abs(tary - y), 0) for x, y, h in XYH):
                return list(map(str, [tarx, tary, tarh]))
    
print(" ".join(calc(XYH, xyh)))

Measured memory_bytes: 3064
import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long money , goen ,gohyaku;
    money = sc.nextInt();
    goen = (money % 500) / 5 * 5;
    gohyaku = (money / 500) *1000;
    System.out.println(goen + gohyaku);
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define scnf scanf
#define scnaf scanf
#define CRLF <<'\n';
#define ALL(v) v.begin,v.end()
#define SIZE(v) (int)v.size()
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,int> pip;
typedef vector<int> vi;
typedef long long ll;
#define BLK 707

int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    int arr[n];
    pip que[q];
    rep(i,0,n)
        scanf("%d",&arr[i]),arr[i]--;
    rep(i,0,q){
        int a,b;
        scanf("%d%d",&a,&b);
        a--,b--;
        que[i] = pip(ii(a,b),i);
    }
    sort(que,que+q,[](pip a,pip b){
                     if (a.first.first/BLK==b.first.first/BLK)
                         return (a.first.first/BLK & 1) ? (a.first.second < b.first.second) : (a.first.second > b.first.second);
                     else
                         return a.first.first/BLK<b.first.first/BLK;
                 });
    int ans[q];
    int L=0,R=-1;
    int cnt[n];
    memset(cnt,0,sizeof cnt);
    int num=0;
    rep(i,0,q){
        int l=que[i].first.first,r=que[i].first.second;
        while(L < l){
            if (--cnt[arr[L]] == 0)
                num--;
            L++;
        }
        while(L > l){
            --L;
            if (cnt[arr[L]]++ == 0)
                num++;
        }
        while(R<r){
            ++R;
            if (cnt[arr[R]]++ == 0)
                num++;
        }
        while(R>r){
            if (--cnt[arr[R]]==0)
                num--;
            R--;
        }
        ans[que[i].second] = num;
    }
    rep(i,0,q)
        printf("%d\n",ans[i]);





}


Measured memory_bytes: 15464
#include <iostream>
using namespace std;
const int maxn = 505;
int a[maxn][maxn];
int main(int argc, char const *argv[])
{
	int n,m,q;
	cin>>n>>m>>q;
	for(int i = 1;i <= m; ++i)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		a[u][v]++;
	}
	for(int i = n;i >= 1; --i)
	{
		for(int j = 1;j <= n; ++j)
		{
			a[i][j] += a[i][j - 1];
			a[i][j] += a[i + 1][j];
			a[i][j] -= a[i + 1][j - 1];
		}
	}
	while(q--)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		cout<<a[u][v]<<endl;
	}
	return 0;
}

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

int main() {
  int K, A ,B;
  cin >> K >> A >> B;
  
  if(K <= B-A){
    cout << "OK" << endl;
  }
  
  else if(A%K == 0){
    cout << "OK" << endl;
  }
  
  else if(B%K-A%K < 0){
    cout << "OK" << endl;
  }
  
  else{
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	int SW = 100*A, S = 0;
	double e = (double)100*E/(E+100);
	A *= 100; B *= 100;
	for (int i = 0; A*i <= F; i++)
	{
		for (int j = 0; A*i+B*j <= F; j++)
		{
			int W = (A*i+B*j);
			for (int k = 0; W+C*k <= F; k++)
			{
				for (int l = 0; W+C*k+D*l <= F; l++)
				{
					int s = C*k+D*l;
					double P1 = (double)100*S/(SW);
					double P2 = (double)100*s/(W+s);
					if (P2 <= e && P1 < P2)
					{
						SW = W+s;
						S = s;
					}
				}
			}
		}
	}
	cout << SW << " " << S << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> cum(n);
    ll sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
        if (i > 0) cum[i] = cum[i-1]+a[i];
        else cum[i] = a[i];
    }
    ll ans = LLONG_MAX;
    rep(i,n-1) {
        ll x = cum[i];
        ll y = sum-x;
        ans = min(ans, abs(x-y));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
function Main(input) {
    input = input.split(" ");
    var A = parseInt(input[0],10);
    var B = parseInt(input[1],10);
    var tap = 1;
    var count = 0;
    while (tap < B){
      tap -= 1;
      tap += A;
      count++
    }
    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto H = RD;
	auto W = RD;

	writeln(min(H, W) == 1 ? 1 : (H*W+1) / 2);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
  if(m==0) return 1;
  if(i>=n) return 0;
  int res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,i,M;
  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int colors[100005];

bool is_bipartite_graph(const vector<vector<int>> &G, int v, int c){
  colors[v] = c;
  for(int u : G[v]){
    if(colors[u] == c){
      return false;
    }
    if(colors[u] == 0 && !is_bipartite_graph(G, u, -c)){
      return false;
    }
  }
  return true;
}


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

  ll N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  
  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if(is_bipartite_graph(G, 0, 1)){
    
    ll color1 = 0;
    ll color2 = 0;
    for(int i = 0; i < N; i++){
      if(colors[i] == 1){
        color1++;
      }else{
        color2++;
      }
    }

    cout << color1 * color2 - M << endl;

  }else{
    cout << N * (N-1) /2 - M << endl;
  }




  return 0;
}


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


int main()
{
  int n, x;
  cin >> n >> x;
  int d = 0;
  int ans = 0;
  rep(i, n)
  {
    if (d > x)
      break;
    ans++;
    int l;
    cin >> l;
    d = d + l;
  }
  if (d <= x)
    ans++;
  cout << ans << endl;
  return 0;
}

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

int main(){
	int x,y,z;
	while(1){
		cin>>x>>y>>z;
		if(x==0 && y==0 &&z==0)return 0;
		int dia[3];
		dia[0]=hypot(x,y)/2;
		dia[1]=hypot(y,z)/2;
		dia[2]=hypot(z,x)/2;
		int n;
		cin>>n;
		for(int i=0;i<n;i++){
			int r;
			cin>>r;
			if(r>dia[0] || r>dia[1] || r>dia[2]){
				cout<<"OK"<<endl;
			}else{
				cout<<"NA"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApABC115
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            a = int.Parse(Console.ReadLine());

            if (a == 22)
                Console.WriteLine("Christmas Eve Eve Eve");
            else if (a == 23)
                Console.WriteLine("Christmas Eve Eve");
            else if (a == 24)
                Console.WriteLine("Christmas Eve");
            else if (a == 25)
                Console.WriteLine("Christmas");

            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T>
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
template <typename T>
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;cin >> n >> m;
    if(n==m)cout << "Yes";
    else cout << "No";
    }

Measured memory_bytes: 256
a, b = map(int, input().split())
if a != 1 and b != 1:
    if a > b:
        print('Alice')
    if b > a:
        print('Bob')
    if a == b:
        print('Draw')

else:
    if a == 1 and b != 1:
        print('Alice')
    if a != 1 and b == 1:
        print('Bob')
    if a == b:
        print('Draw')


Measured memory_bytes: 2940
N=int(input())
S=list(map(int,input().replace('#','1').replace('.','0')))

cum=[0]
for i in range(N):
  cum.append(cum[-1]+S[i])
  
ans=10**20
for i in range(N+1):
  b = cum[i]
  w = N-i-(cum[-1]-cum[i])
  ans = min(ans,b+w)
  
print(ans)

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

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

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, M; cin >> N >> M;
  ll p2[10000]; rep(i,10000) p2[i] = i==0 ? 1 : p2[i-1]*2%MOD;
  ll inv2 = inv(2);
  ll invp2[100000]; rep(i,10000) invp2[i] = i==0 ? 1 : invp2[i-1]*inv2%MOD;

  ll dp[N][M+1] = {};
  rep(i,N) {
    if (i==0) rep(j,M+1) dp[i][j] = p2[j];
    else {
      ll now = 0;
      repr(j,1,M+1) {
        dp[i][j] = ( dp[i][j] + dp[i-1][j]*(j+1) ) % MOD;
        dp[i][j] = ( dp[i][j] + now*p2[j-1] ) % MOD;
        now = ( now + dp[i-1][j] * j % MOD * invp2[j] ) % MOD;
        // cout << i << " " << j << "->" << now << endl;
      }
    }
  }
  // rep(i,N) debug(dp[i], dp[i]+(M+1));

  ll result = dp[N-1][M];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 199140
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
map<ll,pair<ll,ll>>cnt;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(int i=0;i<n;i++){
    cin>>A[i];
    cnt[A[i]].F++;
    if(cnt[A[i]].F==1)cnt[A[i]].S=i;
  }
  vector<pair<ll,pair<ll,ll>>>pll;
  for(auto a:cnt){
    pll.pb(mp(a.F,mp(a.S.F,a.S.S)));
  }
  sort(ALL(pll),greater<pair<ll,pair<ll,ll>>>());
  vi ans(n+10);
  for(int i=0;i<pll.size()-1;i++){
    ll sa=pll[i].F-pll[i+1].F;
    ans[pll[i].S.S]+=sa*pll[i].S.F;
    pll[i+1].S.S=min(pll[i+1].S.S,pll[i].S.S);
    pll[i+1].S.F+=pll[i].S.F;
    // cout<<ans[pll[i].S.S]<<endl;
  }
  //cout<<pll.back().F<<endl;
  ans[0]+=pll.back().S.F*pll.back().F;
  for(int i=0;i<n;i++)
    cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 12020
#include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> A(5);
  for(int i=0;i<5;i++){
    cin>>A.at(i);
  }

  int k; cin>>k;

  bool flag = false;
  for(int i=0;i<4;i++){
    for(int j=1;j<5;j++){
      if(A.at(j)-A.at(i)>k){
        flag = true;
      }
    }
    if(flag) break;
  }
  if(flag){
    cout<<":("<<endl;
  }else{
    cout<<"Yay!"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v)*v;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll>T(N);
    cin >> T;

    ll lcm = T[0];
    FOR(i, 1, N) {
        lcm = LCM(lcm, T[i]);
    }

    cout << lcm << 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 PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin>>A>>B;

    int ans=0;
    int bit=0;
    bit=(B+1)/2-(A+1)/2;
    if(bit%2==0)bit=0;
    else bit=1;

    if(A%2==0&&B%2==1)ans=bit;
    else if(A==B) ans=A;
    else if(A%2==0&&B%2==0)ans=B^bit;
    else if(A%2==1&&B%2==1)ans=A^bit;
    else ans=A^B^bit;
    cout << ans << endl;

    



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    for(int i = N; i >= 0; i--){
        double root = sqrt(i);
        if (root == floor(root)){
            cout << setprecision(10) << root*root << endl;
            break;
        }
    }
    return 0;
}

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

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

    sort(a, a + n);
    reverse(a, a + n);

    int sa = 0, sb = 0;
    for (int i = 0; i < n; i++) (i % 2 ? sb : sa) += a[i];

    cout << sa - sb << 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 INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
bool calc(int n){
  bool a = false;
  for(int i=1; i*i<=n; i++){
    if(i*i==n) a=true;
  }
  return a;
}
int main() {
  cout << fixed << setprecision(10);
  string a,b;
  cin >> a >> b;
  int n = stoi(a+b);
  if(calc(n)){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, A, B, C, D;
	string S;

	cin >> N >> A >> B >> C >> D >> S;
	A--;
	B--;
	C--;
	D--;

	Int flag = 1;
	if (C < D) {
		for (Int i = A; i < C; i++) {
			if (S[i] == '#' && S[i + 1] == '#') {
				flag = 0;
				break;
			}
		}
		for (Int i = B; i < D; i++) {
			if (S[i] == '#' && S[i + 1] == '#') {
				flag = 0;
				break;
			}
		}

		cout << (flag ? "Yes" : "No") << "\n";

	}
	else {
		for (Int i = A; i < C; i++) {
			if (S[i] == '#' && S[i + 1] == '#') {
				flag = 0;
				break;
			}
		}
		for (Int i = B; i < D; i++) {
			if (S[i] == '#' && S[i + 1] == '#') {
				flag = 0;
				break;
			}
		}
		
		Int flag2 = 0;
		for (Int i = B-1; i < D; i++) {
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.')flag2 = 1;
		}

		if (flag2 == 1) {
			cout << (flag ? "Yes" : "No") << "\n";
		}
		else {
			cout << "No" << "\n";
		}
	}
}

Measured memory_bytes: 592
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int A[310];
double dp[310][310][310];
bool used[310][310][310];

double dfs(int x, int y, int z)
{
	if (!x && !y && !z)return 0.0;
	if (used[x][y][z])return dp[x][y][z];
	used[x][y][z] = true;

	double res = 1.0;
	if (x > 0)res += dfs(x - 1, y, z)*(double)x / N;
	if (y > 0)res += dfs(x + 1, y - 1, z)*(double)y / N;
	if (z > 0)res += dfs(x, y + 1, z - 1)*(double)z / N;
	double pz = 1.0 - (double)(x + y + z) / N;
	res /= (1.0 - pz);
	dp[x][y][z] = res;
	return res;
}

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

	int C[3] = { 0 };
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
		C[A[i] - 1]++;
	}

	printf("%.15lf\n", dfs(C[0], C[1], C[2]));

	return 0;
}

Measured memory_bytes: 238464
function main(lines) {
  const N = n();

  let cnt = 0;
  const abs = []
  for (let a = 1; a < N; a++) {
    for (let b = 1; b < N; b++) {
      if (a*b > N-1) break;
      cnt++;
    }
  }
  
  return cnt;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);
const getLines = (n) => lines.slice(lineCount, lineCount += n);

const ans = main(lines);
console.log( ans );

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい


int main(){
  ll n;
  cin >> n;
  vi a(n);
  map<ll , ll> mp;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }
  ll ans = 0 , tmp = 0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    tmp = itr->second;
    ans += tmp*(tmp-1)/2;
  }
  rep(i,n){
    cout << ans - mp[a[i]] + 1 << endl;
  }
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

Measured memory_bytes: 10240
from numpy import*
N,K=map(int,input().split())
m=zeros((3*K,3*K))
L=2*K
o=0
for _ in [0]*N:
 x,y,c=input().split()
 x,y=int(x)%L,int(y)%L
 t=c=='W'
 m[x,y]+=2*t-1
 o+=t
for _ in [0,0]:
 m[L:]=m[:K]
 m=cumsum(m,axis=0)
 m[:L]-=m[K:]
 m=m.T
m=m[:L,:L]
print(o-int((m+roll(roll(m,K,axis=0),K,axis=1)).min()))

Measured memory_bytes: 153036
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> h(n);
	for (auto &x : h)
		cin >> x;
	vector<int> dp(n);
	for (int i = n - 2; i >= 0; --i) {
		dp[i] = 1 << 30;
		for (int j = 1; j <= k && i + j < n; ++j)
			dp[i] = min(dp[i], dp[i + j] + abs(h[i] - h[i + j]));
	}
	printf("%d\n", dp[0]);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
static const int MAXN = 100010;
int lazy[MAXN] = {0};
int vexter[MAXN] = {0} , dis[MAXN] = {0} , color[MAXN] = {0} , ans[MAXN] = {0};
bool vis[MAXN][15] = {0};
vector <int> data[MAXN];
void Paint(int u , int d , int c)
{
    if(vis[u][d])   return;
    vis[u][d] = 1;
    if(!ans[u])  ans[u] = c;
    if(!d)  return;
    Paint(u, d - 1, c);
    for(auto v : data[u])
    {
        Paint(v , d - 1 , c);
    }
}
int main()
{
    int n , m , q;
    int u , d , c;
    scanf("%d%d" , &n , &m);
    for(int i = 0 ; i < m ; ++i)
    {
        scanf("%d%d" , &u , &d);
        data[u].push_back(d);
        data[d].push_back(u);
    }
    scanf("%d" , &q);
    for(int i = 1 ; i <= q ; ++i)
        scanf("%d%d%d" , vexter + i , dis + i , color + i);
    for(int i = q ; i > 0 ; --i)
        Paint(vexter[i] , dis[i] , color[i]);
    for(int i = 1 ; i <= n ; ++i)
        printf("%d\n" , ans[i]);
}


Measured memory_bytes: 9464
#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 <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


vector<int>G[200020];
bool visited[200020];

int cx, cy;
void dfs(int n) {
	if (visited[n])return;
	visited[n] = true;
	if (n <= 100000)cx++;
	else cy++;
	for (auto nex : G[n]) {
		if (!visited[nex]) {
			dfs(nex);
		}
	}
}

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

	int N; cin >> N;
	REP(i, N) {
		int x, y; cin >> x >> y;
		y += 100000;
		G[x].pb(y);
		G[y].pb(x);
	}
	ll ans = 0;
	REP(i, 200002) {
		cx = 0, cy = 0;
		dfs(i);
		ans += cx * cy;
	}
	ans -= N;
	print(ans);
}


Measured memory_bytes: 10240
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n,m;
    cin >>n>>m;
    ll Lmax=0,Rmin=MAX;
    for(int i=0;i<m;i++){
        ll l,r;
        cin >>l>>r;
        Lmax=max(Lmax,l);
        Rmin=min(Rmin,r);
    }
    ans=max(0LL,Rmin-Lmax+1);


    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  int ma = in();
  int mb = in();
  vvector<int> dp(n*10+1,vector<int>(n*10+1,INF));
  dp[0][0] = 0;
  rep(i,n){
    int a = in();
    int b = in();
    int c = in();
    per(j,n*10+1){
      per(k,n*10+1){
        int na = a + j;
        int nb = b + k;
        if(max(na,nb) >= n * 10 + 1)continue;
        chmin(dp[na][nb],dp[j][k] + c);
      }
    }
  }

  int ans = INF;
  rep(i,1,1000){
    int a = i * ma;
    int b = i * mb;
    if(max(a,b)>=n*10+1)continue;
    chmin(ans,dp[a][b]);
  }

  cout << (ans==INF?-1:ans) << endl;

  return 0;
}


Measured memory_bytes: 896