akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

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

    vector<bool> p(n, true);
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        vector<int> indecies;
        for (int j = 0; j < d; ++j) {
            int index;
            cin >> index;
            indecies.push_back(index);
        }
        for (const auto& index : indecies) {
            if (p[index - 1]) {
                p[index - 1].flip();
            }
        }
    }
    cout << accumulate(p.begin(), p.end(), 0) << endl;

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            ReadInt(out n, out k);
            var H = ReadLongArray().OrderBy(x => x);
            
            long answer = H.Take(Math.Max(n - k, 0)).Sum();
            Console.WriteLine(answer);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 38912
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 1; i <= n; i++)
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin >> n;
  int a[200020];
  int b[200020] = {0};
  vector<int> c;

  REP(i,n)cin >> a[i];

  for(int i = n;i > 0;i--){
    int cnt = 0;
    for(int j = 2;j * i <= n;j++){
      cnt += b[i*j];
    }
    if(cnt % 2 != a[i]){b[i]++;m++;c.push_back(i);}
  }
  cout << m << endl; 
  for(int i = 0;i < c.size();i++)cout << c[i] << " ";
}

Measured memory_bytes: 5364
#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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	ll ans = 0;
	rep(i,n-1) {
		ll t = v[i+1] - v[i];
		if (t * a < b) ans += t * a;
		else ans += b;
	}
	cout << ans << endl;
}

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

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


using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

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


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

    int odd = 0; int div4 = 0;
    for (auto it: a)
    {
        if (it%2) odd++;
        if (it%4==0) div4++;
    }

    int div2 = n - odd - div4;

    if (odd<=div4 || odd==div4+1 && div2==0) cout<<"Yes";
    else cout<<"No";

}



Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a % 2 == 1 && b % 2 == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<pair<ll, ll>> v;
    if(n%2){
        rep(i, n-1) v.emplace_back(i+1, n);
        n -= 1;
    }
    rep(i, n){
        FOR(j, i+1, n){
            if(j==n-1-i) continue;
            v.emplace_back(i+1, j+1);
        }
    }
    
    cout << v.size() << endl;
    for(auto x: v) cout << x.first << ' ' << x.second << endl;;
}


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

double check(double x1, double y1, double x2, double y2, double x3, double y3){
	double ab = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	double bc = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
	double ca = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
	double s = (ab + bc + ca) * 0.5;
	double S = sqrt(s * (s - ab) * (s - bc) * (s - ca));
	return S;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
	
	double abc = check(x1, y1, x2, y2, x3, y3);
	double abp = check(x1, y1, x2, y2, xp, yp);
	double bcp = check(x2, y2, x3, y3, xp, yp);
	double cap = check(x3, y3, x1, y1, xp, yp);
	
	double var = abc - (abp + bcp + cap);
	if(var <= 0.001 && var >= -0.001){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	}
	
	return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int n,s[100000];
	map<int,int> m;
	map<int,int>::iterator it;
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d",&s[i]);
		m[s[i]]++;
	}
	int ans=0;
	for(it=m.begin(); it!=m.end(); it++) {
		if(it->first > it->second){
			ans+=it->second; 
		}else if(it->first < it->second){
			ans+=it->second - it->first;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main () {
  int n,m;
  cin >> n >> m;
  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3544
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define mp(i,j) make_pair(i,j)
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

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

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 Main()
{
	string S; cin >> S;
	char prev = '#';
	bool res = true;
	rep(i,4) {
		if (prev == S[i]) {
			res = false;
			break;
		}
		prev = S[i];
	}
	cout << (res ? "Good" : "Bad") << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

struct Edge {
    int to, cost;
};

vector<vector<Edge>> G;
vector<bool> visited;
vector<int> dist;

bool dfs(int v,int p=-1, int c=0) {
    visited[v] = true;
    dist[v] = c;
    for (Edge e : G[v]) {
        if (e.to == p) continue;
        if (visited[e.to]) {
            if (dist[e.to] != c + e.cost) {
                return false;
            }
        }
        else {
            if (!dfs(e.to,v,c + e.cost)) return false;
        }
    }
    return true;
}

int main() {
    int N,M; input(N,M);
    visited.resize(N, false);
    dist.resize(N);
    G.resize(N, vector<Edge>());
    REP(i,M) {
        int l, r, d; input(l,r,d);
        l--; r--;
        G[l].push_back({r,d});
        G[r].push_back({l,-d});
    }
    bool flag = false;
    REP(i, N) {
        if (visited[i]) continue;
        if (!dfs(i)) {
            flag = true;
            break;
        }
    }
    if (flag) {
        puts("No");
    }
    else {
        puts("Yes");
    }
    getchar(); getchar();
}

Measured memory_bytes: 12928
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    Map<Integer, Integer> z = new HashMap<>();
    int i = 1;
    int tmp = s;
    
    while(true) {
      z.put(i, tmp);
      if(tmp%2 == 0) {
        tmp = tmp/2;
      } else {
        tmp = 3*tmp+1;;
      }
      
      if(z.containsValue(tmp)) {
        System.out.println(i+1);
        break;
      }
      i++;
    }
  }
}
//need to work on more about HashMap 

Measured memory_bytes: 35800
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))
C=[list(map(int,input().split())) for i in range(M)]

A.sort()
SUM=[0]
for a in A[::-1]:
    SUM.append(SUM[-1]+a)
SUM=SUM[::-1]

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

LIST=[0]

for x,y in C:
    while x>0 and len(LIST)<N+1:
        LIST.append(LIST[-1]+y)
        x-=1

    if len(LIST)==N:
        break


ANS=max([LIST[i]+SUM[i] for i in range(len(LIST))])

print(ANS)


Measured memory_bytes: 83736
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);

  int n;
  int ans = 0;

  cin >> n;

  int i=1;
  while(i * i <= n){
    ans = i * i;
    i++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#累積xor
#累積和

N = int(input())
A = [0] + list(map(int,input().split()))

#累積xor
ruiseki_xor = [A[i] for i in range(N+1)]
for i in range(1,N+1,1):
    ruiseki_xor[i]=ruiseki_xor[i-1]^A[i]

#累積和
ruiseki = [0]*(N+1)
for i in range(1,N+1,1):
    ruiseki[i]=ruiseki[i-1]+A[i]

ans = 0
cersol = 1
for i in range(1,N+1,1):
    ans += cersol-i
    for j in range(cersol,N+1,1):
        if ruiseki[j]-ruiseki[i-1] == ruiseki_xor[j]^ruiseki_xor[i-1]:
            ans += 1
            cersol = j
        else:
            cersol = j
            break
        
        

print(ans)


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

int main(){
  int n;
  cin >> n;
  vi a(n-1), ans(n,0);
  rep(i,n-1) {
    cin >> a[i];
    ans[a[i]-1] ++;
  }
  rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 4784
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.ST                 as ST
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n $ BS.unpack <$> BS.getLine
toPair [x, y] = (x, y)

main = do
  a   <- readInts 3
  [n] <- readInt
  b   <- concat <$> readInts n
  putStrLn $ solve a b

solve :: [[Int]] -> [Int] -> String
solve a b | ans       = "Yes"
          | otherwise = "No"
 where
  a' = map (map (\x -> x `elem` b)) a
  ans =
    True
      `elem` ( all (== True) [a' !! 0 !! 0, a' !! 0 !! 1, a' !! 0 !! 2]
             : all (== True) [a' !! 1 !! 0, a' !! 1 !! 1, a' !! 1 !! 2]
             : all (== True) [a' !! 2 !! 0, a' !! 2 !! 1, a' !! 2 !! 2]
             : all (== True) [a' !! 0 !! 0, a' !! 1 !! 0, a' !! 2 !! 0]
             : all (== True) [a' !! 0 !! 1, a' !! 1 !! 1, a' !! 2 !! 1]
             : all (== True) [a' !! 0 !! 2, a' !! 1 !! 2, a' !! 2 !! 2]
             : all (== True) [a' !! 0 !! 0, a' !! 1 !! 1, a' !! 2 !! 2]
             : all (== True) [a' !! 0 !! 2, a' !! 1 !! 1, a' !! 2 !! 0]
             : []
             )



Measured memory_bytes: 380
n,m,k=map(int,input().split())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))

a=[0]
b=[0]

for i in range(n):a.append(a[i]+aa[i])
for i in range(m):b.append(b[i]+bb[i])

ans=0
j=m
for i in range(n+1):
    if(a[i]>k):break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 134088
n,k = map(int,input().split())
h = [int(input()) for _ in range(n)]
h.sort()
minv = float('inf')
for i in range(n-k+1):
  if minv > h[i+k-1]-h[i]:
    minv = h[i+k-1]-h[i]

print(minv)

Measured memory_bytes: 7384
#include"bits/stdc++.h"
#define int long long
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
using namespace std;
const int mod=1000000007;
const int MAX_H=1000,MAX_W=1000;
int H,W;
vector<string> a;
int dx[2]={1,0},dy[2]={0,1};
int dp[MAX_H][MAX_W];

signed main(){
	cin>>H>>W;
	a.resize(H);
	REP(i,H) cin>>a[i];
	dp[H-1][W-1]=1;
	for(int i=H-1;i>=0;--i){
		for(int j=W-1;j>=0;--j){
			if(a[i][j]=='.'){
				if(i!=H-1) dp[i][j]+=dp[i+1][j];
				if(j!=W-1) dp[i][j]+=dp[i][j+1];
			}
			else dp[i][j]=0;
			dp[i][j]%=mod;
		}
	}
	cout<<dp[0][0]<<endl;
}

Measured memory_bytes: 9088
S = input()
K = int(input())
# A, B = map(int, input().split())
# A = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(N)]
# s = input()
ar = []
#
for i in S:
    ar.append(int(i))
#
# sum = 0
# for i in ar:
#     sum += pow(i, K)
#     if sum >= K:
#         print(i)
#         break

for i in range(len(ar)):
    if ar[i] == 1:
        if i + 1 == K:
            print(1)
            break
    else:
        print(ar[i])
        break

Measured memory_bytes: 2940
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  A+=B;
  C+=D;
  if(A>C) printf("Left\n");
  else if(A<C) printf("Right\n");
  else printf("Balanced\n");
  return 0;
}

Measured memory_bytes: 1624
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h> 
using namespace std; 

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int k, x;
    cin>>k>>x;
    (k*500>=x)?cout<<"Yes\n":cout<<"No\n";
    
	return 0;
}

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

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

    LL n;
    cin>>n;
    LD a=(LD)n/3;
    a=a*a*a;
    cout<<fixed<<setprecision(12)<<a<<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()
{
  int n; cin >> n;
  vector<string> s(n);
  rep(i, n)
  {
    string str;
    cin >> str;
    s[i] = str;
  }
  sort(s.begin(), s.end());

  int maximum = 1;
  vector<string> ans(1);
  ans[0] = s[0];
  int count = 1;
  int i = 1;
  while (i < n)
  {
    if (s[i] == s[i - 1])
      count++;
    else
      count = 1;
    if (count == maximum)
      ans.push_back(s[i]);
    else if (count == maximum + 1)
    {
      ans.clear();
      ans.push_back(s[i]);
      maximum = count;
    }
    else if (count > maximum + 1)
      maximum = count;
    i++;
  }
  for (auto p : ans)
    cout << p << endl;
}


Measured memory_bytes: 15988
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,aa[220000],cntl=0;
pair<int,int> p[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>s;
    rep(i,3){
        if(s[i]=='7'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 10476
import itertools
N,K=map(int,input().split())
c=(N-1)*(N-2)//2
if c<K:
    print(-1)
    exit()
Edges=[]
for i in range(1,N):
    Edges.append([1,i+1])
cnt=0
for x in itertools.combinations(range(1,N),2):
    if cnt==c-K:
        break
    Edges.append([x[0]+1,x[1]+1])
    cnt+=1
print(len(Edges))
for x,y in Edges:
    print(x,y)

Measured memory_bytes: 4120
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=5e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }


void solve() {
     int n,k;
     cin>>n>>k;
     int x=n;
     if(x>k) {
		   x=x%k;
		 }
		 
     while(1) {
		   int diff=abs(x-k);
		   if(diff<x) {
			      x=diff;
			   }
		   else
		      break;	   
		 }
		 
	cout<<x<<endl;	 
              
}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
void fast(){
cin.tie(0);
cin.sync_with_stdio(0);
}
long long gcd(long long l,long long r){
    if(r==0)
        return l;
    else return(gcd(r,l%r));
}
int main()
{
    fast();
 int n;
 cin>>n;
 long long x,xx;long long a[n];
 cin>>x;
 for(int i=0;i<n;i++)
 {
     cin>>xx;
     a[i]=abs(x-xx);
 }
 sort(a,a+n);
 long long g_c_d=a[0];
 for(int i=0;i<n;i++)
 {
   g_c_d=gcd(g_c_d,a[i]);
 }
 cout<<g_c_d;
}


Measured memory_bytes: 1024
def main():
    N, K = map(int,input().split())
    P = [int(i) for i in input().split()]
    value = [((i + 1)  / 2 ) for i in P]
    now = sum(value[:K])
    ans = now
    for i in range(K,N,1):
        add = (value[i] - value[i - K])
        now = now + add
        if now > ans :
            ans = now

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24676
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_chars {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
    ($n:expr) => {
        {
            (0..$n)
                .map(|_| get_chars!())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (n, m, target) = get!(usize, usize, u64);
    let books = get!(u64;; n);

    let mut ans = u64::max_value();
    for bit in 0..(1 << n) {
        let mut skills = vec![0; m];
        let mut cost = 0;
        for (i, book) in books.iter().enumerate() {
            if bit & (1 << i) != 0 {
                cost += book[0];
                for j in 1..book.len() {
                    skills[j - 1] += book[j];
                }
            }
        }
        if skills.iter().all(|s| *s >= target) {
            ans = ans.min(cost);
        }
    }
    if ans == u64::max_value() {
        println!("{}", -1);
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2140
# -*- coding: utf-8 -*-

A = int(input()) # 500円
B = int(input()) # 100円
C = int(input()) # 50円
X = int(input()) # 金額

ans = 0
tmp_x = 0

for i in range(0, A + 1):
    for j in range(0, B + 1):
        for k in range(0, C + 1):
            tmp_x = (500 * i) + (100 * j) + (50 * k)
            if X == tmp_x:
                ans += 1

print(ans)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
 
	vector<int> v(5);
	rep(i,5) scanf("%d", &v[i]);
	
	int min=9, ind=0;
	rep(i,5){
 
		if (v[i]%10!=0 and v[i]%10 <= min){
			min = v[i]%10;
			ind = i;
		}
	}
	int ans = v[ind];
	v.erase(v.begin()+ind);
 
	for (auto i : v){
		if (!(i%10)) ans += i;
		else ans += i + (10 -(i%10));
	}
 
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3764
//状态:
//题号:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
ll a[200005];
int n;
ll sum;
map<ll,int> mp;
ll calc(ll num){
	return num*(num-1)/2;
}
ll ans;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	for(int i=0;i<n;i++)sum+=a[i],mp[sum]++;
	for(map<ll,int>::iterator it=mp.begin();it!=mp.end();it++){
		if(it->first==0ll)ans+=it->second+calc(it->second);
		else if(it->second>1)ans+=calc(it->second);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
 string s ;
 cin >> s ;
 string t ;
 cin >> t ;
 int counter = 0 ;
 for (int i=0 ; i<s.size() ; i++)
    if (s[i] != t[i])
      counter++ ;
 cout << counter << endl ;
}

Measured memory_bytes: 3848
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

int32_t main()
{
    IOS
    
    
    int n;
    cin>>n;
    double a[n];
    double sum=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        sum+=(double)1/a[i];
    }
    sum=(double)1/sum;
    printf("%0.10lf",sum);

}



Measured memory_bytes: 256
local function btc2jpy(btc)
    return btc * 380000.0
end
local N = io.read("n")
local total_in_jpy = 0.0
for i=1,N do
    local amount, _, currency = io.read("n", 1, 3, "l")
    --print(amount, currency, string.len(currency))
    if currency == 'BTC' then
        amount = btc2jpy(amount)
    end
    total_in_jpy = total_in_jpy + amount
end
print(total_in_jpy)


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

int main() {
  int x;
  cin >> x;
  
  int h = 0;
  vector<int> coin = {500, 5};
  vector<int> b = {1000, 5};

  rep(i, 2) {
    if (x < coin[i]) continue;
    int t = x / coin[i];
    h += b[i] * t;
    x -= coin[i] * t;
  }
  
  cout << h << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int keta(int n) {
  int k = 0;
  while (n > 0) {
    k++;
    n /= 10;
  }
  return k;
}
int main2() {
  int N = nextInt();
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (keta(i) % 2 == 1)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main() {
  string a;
  cin>>a;
  if(a.at(0)==a.at(1)&&a.at(2)==a.at(3)&&!(a.at(0)==a.at(2))){
    cout <<"Yes"<<endl;
  }
  else if(a.at(0)==a.at(2)&&a.at(1)==a.at(3)&&!(a.at(0)==a.at(3))){
    cout<<"Yes"<<endl;
  }
  else if(a.at(0)==a.at(3)&&a.at(1)==a.at(2)&&!(a.at(0)==a.at(1))){
    cout<<"Yes"<<endl;
  }
  else if(a.at(1)==a.at(2)&&a.at(0)==a.at(3)&&!(a.at(0)==a.at(1))){
    cout<<"Yes"<<endl;
  }
   else if(a.at(1)==a.at(3)&&a.at(0)==a.at(2)&&!(a.at(0)==a.at(1))){
    cout<<"Yes"<<endl;
  }
   else if(a.at(3)==a.at(2)&&a.at(0)==a.at(1)&&!(a.at(0)==a.at(2))){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static boolean[] vis;
	static boolean[][] graph;
	static int n;
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		//宣言と初期化
		n = sc.nextInt();//頂点数
		int m = sc.nextInt();//辺の数
		int[] a = new int[m];//辺の片方
		int[] b = new int[m];//辺の片方
		graph = new boolean[n][n];//a to bの橋があるかTorF
		vis = new boolean[n];//n個目の頂点を訪れたかTorF
		//入力
		for(int i = 0; i < m; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
		}
		//solve
		long ans = 0;
		for(int i = 0; i < m; i++) {//m回 = 辺の数だけ回す
			for(int j = 0; j < n; j++) {//全ての頂点を訪れていない
				vis[j] = false;
			}
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;//i本目の橋切断
			/*
			 * dfsで頂点をできるだけ訪れる
			 */
			dfs(0);//頂点0から探索

			boolean isBridge = false;
			for(int j = 0; j < n; j++) {//全ての頂点を訪れたか判定
				if(!vis[j]) {
					isBridge = true;
				}
			}
			if(isBridge) ans++;
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;//橋復活
		}
		System.out.println(ans);
	}
	static void dfs(int x) {
		if(vis[x]) return;//2周目なら終わる
		vis[x] = true;//訪れる
		for(int i = 0; i < n; i++) {
			if(graph[x][i]==false) continue;
			dfs(i);
		}
	}
}

Measured memory_bytes: 21972
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

LL n,MOD,x,y,dp[100010],ans[100010],pro[200];
vector <LL> g[100010];

LL dfs(LL pos,LL no)
{
  dp[pos]=1;
  rep(i,g[pos].size()) if(g[pos][i]!=no) dp[pos]=dp[pos]*(dfs(g[pos][i],pos)+1)%MOD;
  //cout<<pos<<' '<<dp[pos]<<'p'<<endl;
  return dp[pos];
}

void dfs2(LL pos,LL no,LL val)
{
  //cout<<pos<<' '<<val<<endl;
  ans[pos]=dp[pos]*(val+1)%MOD;
  LL t=floor(sqrt((LL)g[pos].size()));
  //cout<<t<<endl;
  LL pro[400];
  rep(i,395) pro[i]=1;
  rep(i,g[pos].size()) if(g[pos][i]!=no) pro[i/t]=pro[i/t]*(dp[g[pos][i]]+1)%MOD;
  LL res;
  rep(i,g[pos].size())
  {
    if(g[pos][i]==no) continue;
    res=val+1;
    rep(j,(g[pos].size()-1)/t+1) if(j!=i/t) res=res*pro[j]%MOD;
    for(int j=i/t*t;j<min((LL)g[pos].size(),(i/t+1)*t);j++) 
    if(g[pos][j]!=no&&j!=i) res=res*(dp[g[pos][j]]+1)%MOD;
    dfs2(g[pos][i],pos,res);
  }
}

int main()
{
  cin>>n>>MOD;
  rep(i,n-1)
  {
    scanf("%lld%lld",&x,&y);
    g[x].pb(y);
    g[y].pb(x);
  }
  dfs(1,0);
  dfs2(1,0,0);
  repn(i,n) printf("%lld\n",ans[i]);
  return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  int n,a,b;
  int ans, t, an = 0;
	cin >> n >> a >> b;

  rep(i,1,n+1){
    ans = 0;
    t = i;
    rep(j,0,5){
      ans += t%10;
      t /= 10;
    }
    if(a <= ans && ans <= b) an += i;
  }
  printf("%d\n", an);
	return 0;
}

Measured memory_bytes: 256
S=input()
a=[0]*13
a[0]= 1

for c in S:
  dp=[0]*13
  for i in range(13):
    dp[(i*10)%13]=a[i]%(10**9+7)
  dp+=dp

  if c=='?':
    for i in range(13):
      a[i]=sum(dp[i+4:i+14])
  else:
    for i in range(13):
      a[i]=dp[i+13-int(c)]

print(a[5]%(10**9+7))


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

struct S {
	int number;
	int n;
	bool operator <(const S& b) {
		return n < b.n;
	}
};
S A[100010];
int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i].n;
		A[i].number = i + 1;
	}
	sort(A, A + N);
	for (int i = 0; i < N; i++) {
		cout << A[i].number << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1536
import math

def f(a,b):
    return max(len(str(a)), len(str(b)))

n = int(input())
v = -1
for i in range(1, math.ceil(math.sqrt(n)) + 1):
    if n % i == 0:
        t = f(int(i), int(n/i))
        if v == -1 or v > t:
            v = t
print(v)

Measured memory_bytes: 3060
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	M := nextInt()
	An := make([]int, N)
	var sum, count int
	for i := 0; i < N; i++ {
		An[i] = nextInt()
		sum += An[i]
	}
	for _, Ai := range An {
		if sum > Ai*(4*M) {
			count++
		}
	}
	// fmt.Println(sum, sum/(4*M), count)
	if count > N-M {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    string S;
    cin >> S;

    char c = S[0];
    if (c == S[1]) {
        if (c != S[2] && S[2] == S[3]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if (c == S[2]) {
        if (c != S[1] && S[1] == S[3]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if (c == S[3]) {
        if (c != S[1] && S[1] == S[2]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def get_min_point(points, ratio)

  ap, bp = points
  ar, br = ratio

  if ap * br == bp * ar
    return points
  end

  an = get_min_count(ap, ar)
  bn = get_min_count(bp, br)

  mn = [an, bn].max
  result = [ar*mn, br*mn]
  result
end

def get_min_count(ap, ar)
  if ap % ar == 0
    (ap / ar)
  else
    (ap / ar) + 1
  end
end

inputs = readlines.map(&:chomp)
points = inputs[1].split(" ").map(&:to_i)
ratios = inputs[2..-1].map {|x| x.split(" ").map(&:to_i) }

ratios.each do |ratio|
  points = get_min_point(points, ratio)
end

puts points.reduce(:+)


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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    string s;
    cin >> s;
    int res = s.size();
    FOR(i, 1, s.size()) if(s[i - 1] != s[i]) chmin(res, max(i, (int)s.size() - i));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
ll f[5010][5010],n,A,B,p[5010];
int main(){
	read(n);read(A);read(B);
	for(int i=1;i<=n;i++) read(p[i]);
	memset(f,63,sizeof(f));
	for(int i=1;i<=n;i++){
		f[i][p[i]]=(i-1)*A;
		for(int j=1;j<=n;j++){
			f[i][j]=min(f[i][j],f[i-1][j]+(p[i]>j?A:B));
			if(j<p[i]) f[i][p[i]]=min(f[i][p[i]],f[i-1][j]);
		}
	}
	ll ans=1e18;
	for(int i=1;i<=n;i++) ans=min(ans,f[n][i]);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 196480
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)
    cin>>i;
  map<int,int> B;
  for(int i:A)
    B[i]++;
  int k=0;
  for(pair<int,int> p:B)
    k+=(p.second-1)*p.second/2;
  for(int i=0;i<N;i++){
    cout<<k-(B[A[i]]-1)<<endl;
  }
}

Measured memory_bytes: 12688
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    ll ans;
    cin >> a >> b;
    ans = 0;
    ll l = a.length();
    REP(i, l){
        if(a[i] != b[i]) ans ++;
    }

    cout << ans <<"\n";
	return 0;
}

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

public class Main {


    public static void main(String args[] ) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String Origin = br.readLine();
        String Serch = br.readLine();

        String[] origin = Origin.split("");
        String[] serch = Serch.split("");
        int plusi = PlusI(serch);
        StringBuilder sb = new StringBuilder();

        int Origin_length = origin.length;
       // System.out.println( SameString(serch) );
        int equal_point = Origin.indexOf(Serch );
        for(int i = 0 ; equal_point>-1; ){

            equal_point = Origin.indexOf(Serch , i);

           if(equal_point>-1){
        	   //System.out.println(equal_point);
        	   sb.append(equal_point + "\r\n");
        	   i = equal_point+plusi;
           }
           else{
        	    break;
           }

        }

        System.out.print(sb);
    }


    public static int PlusI(  String[] Serch ){


    	for(int j = 0; j < Serch.length; j++ ){

    	    if( Serch[j].equals(Serch[0]) && 0 < j){
    	    	return j;
    	    }

    	}


        return Serch.length;


    }


    public static boolean SearchWord(String[] Origin , String[] Serch , int i){


    	boolean SerchCheck = false;
    	for(int j = i , k = 0; k < Serch.length; j++ , k++){

    	    if( Serch[k].equals(Origin[j]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }


    public static boolean SameString(String[] Serch ){


    	boolean SerchCheck = false;
    	for(int i = 0 ; i < Serch.length; i++){

    	    if( Serch[0].equals(Serch[i]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }



}

Measured memory_bytes: 24800
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long x;
    scanf("%ld", &x);
    if(x<1200) {
        printf("ABC\n");
    }
    else {
        printf("ARC\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    long int A,B,N;
    scanf("%ld %ld %ld",&A,&B,&N);
    double width=(double)B/A;    
    if(width<1){
        if(N<B){
            long int ans=N*A/B;
            printf("%ld\n",ans);
        }else{
            long int ans=(B-1)*A/B;
            printf("%ld\n",ans);
        }
    }else{
        if(N<B){
            long int ans=N*A/B;
            printf("%ld\n",ans);
        }else{
            printf("%ld\n",A-1);
        }
    }
    return 0;
}

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

int main(){
  int n, x, count;
  for(;;){
    cin >> n; cin >> x;
    if(0 == n && 0 == x)
      break;
    count = 0;
    for(int i = 1; i <= n - 2; i++)
      for(int j = i + 1; j <= n - 1; j++)
  for(int k = j + 1; k <= n; k++)
    if(i + j + k == x)
      count++;
    
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> G[3 * N];
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u * 3].push_back(v * 3 + 1);
        G[u * 3 + 1].push_back(v * 3 + 2);
        G[u * 3 + 2].push_back(v * 3);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    vector<int> d(3 * N);
    vector<int> used(3 * N, -1);
    queue<P> q;
    q.push(P(3 * s, 0));
    used[3 * s] = 1;
    while(!q.empty()){
        P v = q.front();
        q.pop();
        d[v.first] = v.second;
        for(int j: G[v.first]){
            if(used[j] == -1) {
                q.push(P(j, v.second + 1));
                used[j] = 1;
            }
        }
    }
    if(used[3 * t] == -1) cout << -1 << endl;
    else cout << d[3 * t] / 3 << endl;
}

Measured memory_bytes: 21928
#include<stdio.h>


int main()
{

    int a,b,nd=0,x,y,i,sum=0;

    scanf("%d",&a);


   for(i=1;i<=a;i++){

    x=i;
    while(x != 0)
    {
        x /= 10;
        nd++;
    }


    if(nd%2!=0) sum++;

    nd=0;
   }



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






    return 0;

}



Measured memory_bytes: 1704
#include <stdio.h>

void update(int v, int* min, int* max) {
	if (*min > v) *min = v;
	if (*max < v) *max = v;
}

int main(void) {
	int a, b, c;
	int min, max;
	if (scanf("%d%d%d", &a, &b, &c) != 3) return 1;
	min = max = a;
	update(b, &min, &max);
	update(c, &min, &max);
	printf("%d %d\n", min, max);
	return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
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 (a>b) { a=b; return 1; } return 0; }

int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = max(max(a+b, a-b), a*b);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
    int n,m,x=0,y=0,i,j;
    scanf("%d%d",&n,&m);
    for(i=1,j=1;i<=n;i++)
    {

        x+=j*m;
        j=j*10;
    }
    for(i=1,j=1;i<=m;i++)
    {

        y+=j*n;
        j=j*10;
    }
    if(x==y)
        printf("%d",x);
    else if(x<y)
        printf("%d",y);
    else
        printf("%d",x);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;


long long int divide(long long int h,long long w){
	if(h %2 == 0){
		return (h/2)*w;
	}
	if(w %2 == 0){
		return (w/2)*h;
	}
	
	long long int mi = min(h,w);
	long long int ma = max(h,w);
	return (ma/2)*mi;
	
}

long long int calcRes(long long int rect1,long long int rect2,long long int rect3){
	long long int ma = max(rect1,max(rect2,rect3));
	long long int mi = min(rect1,min(rect2,rect3));
	
	return ma - mi;
}

int main() {
	int h,w;
	cin >> h >> w;
	cout << (h-1)*(w-1) <<endl;
	
	return 0;
}


Measured memory_bytes: 888