akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (ll i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	int A, B;
	cin >> A >> B;
	int d = B - A;
	int e = d * (d + 1) / 2;
	cout << e - B << endl;
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if(a <= 5) cout << 0 << "\n";
	if(a >= 6 && a <= 12) cout << b / 2 << "\n";
	if(a > 12) cout << b << "\n";
	return 0;
}


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

namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();

            var N = cin.next();
            var K = cin.nextInt();

            var S = cin.next();

            var s = S.ToArray();
            s[K - 1] = Char.ToLower(s[K - 1]);
            Console.WriteLine(new String(s));
        }
    }
    
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
/*
		String[] tmp = scanner.nextLine().split(" ");
		String a   = Integer.toBinaryString(Integer.parseInt(tmp[0]));
		String b   = Integer.toBinaryString(Integer.parseInt(tmp[1]));
*/

		int n = Integer.parseInt(scanner.nextLine());

		if(n >= 30) {
			System.out.println("Yes");

		}else {


		System.out.println("No");
		}
	}
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,b,c=0;cin>>n;
  vector<ll> a(n+1);
  for(int i=0;i<=n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    cin>>b;
    if(a[i]>=b){
      c+=b;
      b=0;
    }else{
      c+=a[i];
      b-=a[i];
    }
    if(a[i+1]>=b){
      c+=b;
      a[i+1]-=b;
    }else{
      c+=a[i+1];
      a[i+1]=0;
    }
  }
  cout<<c;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	long long int A, B, t, a;
	cin >> N >> A >> B;
	for (int i = 1; i < N; i++) {
		cin >> t >> a;
		for (long long int j = max(A / t, B / a); ; j++) {
			if (t * j >= A && a * j >= B) {
				A = t * j;
				B = a * j;
				break;
			}
		}
	}
	cout << A + B << endl;
}

Measured memory_bytes: 256
def sgn(X):
    if X > 0:
        return 1
    elif X < 0:
        return -1
    else:
        return 0

N, L = map(int, input().split())

taste = [0] * N
taste[0] = 10000

for i in range(N):
    taste[i] = L + i

taste2 = list(map(abs, taste))

print(sum(taste) - sgn(sum(taste)) * min(taste2))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int a, b, c, x_max, y_max;
  cin >> a >> b >> c >> x_max >> y_max;
  int max = (x_max > y_max)? x_max*2 : y_max*2;

  long min = 999999999999;
  for(int z=0; z<=max; z++){
    int x;
    int y;
    if(x_max - z/2 >= 0){
      x = x_max - z/2;
    }else{
      x = 0;
    }

    if(y_max - z/2 >= 0){
      y = y_max - z/2;
    }else{
      y = 0;
    }
    long money = a*x + b*y + c*z;

    if(min > money){
      min = money;
    }
  }

  cout << min;

  return 0;
}


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

int main() {
    int N, /*count=1,*/ f=0, min = 1000000001;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    deque<int> d;
    
    for(int i=0; i<N; i++) {
        int p = lower_bound(d.begin(), d.end(), A[i]) - d.begin();
        if(!p) d.push_front(A[i]);
        else d[p-1] = A[i];
    }

    cout << d.size() << endl;

    return 0;

}

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<long long> vll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

int main(){
    int n;
    cin >> n;
    vector<int> v(n),c(n);
    rep(i,n){
        cin >> v[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    int tmp=0;
    rep(i,n){
        if(v[i]>c[i]){
            tmp+=v[i]-c[i];
        }
    }
    cc(tmp);
}

Measured memory_bytes: 256
q=int(input())
n =10**3
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
lists=[]
for i in prime:
    lists.append(i)  
lists=sorted(lists) 

checklist=[0]*(10**5+1)
checklist[0]=0
checklist[1]=0
count=0
for i in range(2,10**5+1):
    if i%2==0:
        checklist[i]=checklist[i-1]
    elif i%2!=0:
        if (all(i%j!=0 for j in lists) or i in lists) and (all(((i+1)//2)%j!=0 for j in lists) or (i+1)//2 in lists) :
            count+=1
            checklist[i]=checklist[i-1]+1
        else:
            checklist[i]=checklist[i-1]

listss=[0]*q
for i in range(q):
    a,b=map(int,input().split())
    c=checklist[b]-checklist[a-1]
    listss[i]=c
for i in listss:
    print(i)


Measured memory_bytes: 8640
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  ll a[200000];
  cin >> n >> m;
  lep(i,1,n)cin >> d[i];
  a[n] = d[n];
  pel(i,n-1,1)a[i] = max(a[i+1],d[i]);
  l = 0;
  rep(i,1,n)l = max(l,a[i+1]-d[i]);
  ll ans = 0;
  rep(i,1,n)if(a[i+1]-d[i] == l)ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main() {
  char x;
  cin>>x;
  if(x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

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


Measured memory_bytes: 256
var n;
var t = [];

function gcd(a, b){
	return b > 0 ? gcd(b, a % b) : a;
}

function solve(i){
	if(i == -1){
		return 1;
	}

	var a = solve(t[i][2]);
	var b = solve(t[i][3]);
	var c = gcd(a, t[i][0]);
	var d = gcd(b, t[i][1]);
	var p = a / c;
	var q = b / d;
	var g = gcd(p, q);
	return (p * q / g) * (t[i][0] + t[i][1]);
}

function main(){
	while(n = scan()){
		rep(n, function(i){
			var a = scan();
			var b = scan();
			var g = gcd(a, b);
			t[i] = [b / g, a / g, scan() - 1, scan() - 1];
		});
		var c = [];
		rep(n, function(i){
			c[t[i][2]] = c[t[i][3]] = true;
		});
		var p;
		rep(n, function(i){
			if(!c[i]){
				p = i;
			}
		});
		print(solve(p));
	}
}
 
function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/);
	main();
});

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

int main(){
  int N;
  cin >> N;
  
  vector<int> mochi(N);
  for(int i=0;i<N;i++){cin >> mochi.at(i);}
  sort(mochi.begin(), mochi.end());
  //for(int i=0;i<N;i++){cout << mochi.at(i)<<",";}cout<<endl;

  int size=0;
  int count=0; 
  
  for(int i=0;i<N;i++){
    if(size < mochi.at(i)){
      size = mochi.at(i);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  int N, K;
  cin >> N >> K;
  vector<P> v(N);
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    v[i] = P(x, y);
  }
  sort(v.begin(), v.end(), [](P a, P b) {
    return a.first < b.first;
  });

  ll ans = -1;
  for (int l = 0; l < N-K+1; l++) {
    for (int r = l+K-1; r < N; r++) {
      vector<P> v2(r-l+1);
      copy(v.begin()+l, v.begin()+r+1, v2.begin());
      sort(v2.begin(), v2.end(), [](P a, P b) {
        return a.second < b.second;
      });
      ll dx = v[r].first - v[l].first;
      for (int i = 0; i < v2.size()-K+1; i++) {
        ll dy = v2[K-1+i].second - v2[i].second;
        ll area = dx * dy;
        ans = ans < 0 ? area : min(ans, area);
      }
    }
  }
  cout << ans << endl;
}

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

const long long INF = 1LL<<60;

// 典型的な個数制限なしナップサック問題との違い
// モンスターの体力を 以下にすれば勝ち, というところが異なる
//  mgaic[i][h] : i種類の魔法でdamage hを与えるときの
    //  消費魔力の最小値とする
 

vector<vector<long long>> magic(1010, vector<long long>(101010, INF)); //　最小値問題のためINFで初期化する

int main(void){
    int H, N;
    cin >> H >> N;
    
    vector<long long> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
    
    magic[0][0] = 0;
    
    // 魔法の種類iを0~N-1まで動かす
    for (int i = 0; i < N; i++){
        
        // damageを0~Hまで動かす
        // モンスターの体力を 0以下にすれば勝ち
        // -> 魔法で与えるdamage hの上限は, H+10000である
        //　ここがわからなかった！！！！
        for (int j = 0; j <= H+10003; j++){
            
            //魔法を使わない
            magic[i+1][j] = min(magic[i+1][j], magic[i][j]);
            
            //魔法を使う
            if (j - a[i] >= 0) magic[i+1][j] = min(magic[i+1][j], magic[i+1][j-a[i]] + b[i]);
        }
    }
    
    long long ans = INF;
    
    for (int i = 0; i < 10003; i++) ans = min(ans, magic[N][H+i]);
    cout << ans << endl;
   
}


Measured memory_bytes: 801024
n=int(input())
v=list(map(int,input().split()))
a=dict()
b=dict()

def mkdc(l):
    di=dict()
    for i in range(len(l)):
        if l[i] in di:
            di[l[i]]+=1
        else:
            di[l[i]]=1
    return di

e,o=[],[]      
for i in range(int(n/2)):
    e.append(v[2*i])
    o.append(v[2*i+1])
#print(e)
de=mkdc(e)
do=mkdc(o)
#print(de)
de=sorted(de.items(),key=lambda d: d[1],reverse=True)
do=sorted(do.items(),key=lambda d: d[1],reverse=True)
de.append((0,0))
do.append((0,0))
#de=sorted(de)
#print(de)
if do[0][0]==de[0][0]:
    print(n- do[0][1]-max(de[1][1],do[1][1]))
else:
    print(n-de[0][1]-do[0][1])

Measured memory_bytes: 20224
import math

n = int(input())
base = [int(input()) for i in range(5)]

time = math.ceil(n / base[0])
base_min = base[0]

for i in range(1,5):
  if base_min <= base[i]:
    time = time + 1
  elif base[i] < base_min:
    time = time + math.ceil( (n - base[i]*(math.ceil(n/base_min)-1) )/base[i]) 
    base_min = base[i]
print(time)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#include<vector>
int main()
{
  int n; cin>>n;
  vector<int> cnt(1e4+5);
  for(int x = 1 ; x <= 105; x++)
    for(int y = 1 ; y <= 105;y++)
      for(int z = 1 ; z <= 101 ; z++)
        if(x*x + y*y + z*z + x*y + y*z + z*x < 1e4 + 5)
          cnt[x*x + y*y + z*z + x*y + y*z + z*x]++;
  for(int i = 1 ; i <= n ; i++)
  {cout<<cnt[i]<<endl;}
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  string S;
  ll ans=0;
  cin >> S;
  const int N = S.size();
  rep(i, N){
    if(i != N-1){rep(j, N-i-1){
      ans += (S[i] - '0') * pow(10, j) * pow(2, N-2-j);
    }}
    ans += (S[i] - '0') * pow(10, N-i-1) * pow(2, i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	x := make([]int, 5)
	for i := 0; i < 5; i++ {
		scanner.Scan()
		x[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(x))
}
func solve(x []int) int {
	for i, xi := range x {
		if xi == 0 {
			return i + 1
		}
	}
	panic("")
}


Measured memory_bytes: 1756
#include <unistd.h>
#include <stdio.h>

int main(void)
{
  int a, b, c;
  a = 0;
  b = 0;
  c = 0;
  scanf("%d %d %d", &a, &b, &c);
  if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5))
  {
    write(1, "YES", 3);
    return 0;
  }
  write(1, "NO", 2);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int nn,pp;
  while(cin >> nn >> pp,nn || pp){
    int i;
    vector<int>n(50),p(50);
    int wan=pp;
    for(i=0;;i++){
      if(i==nn)
	i=0;
      if(wan==0){
	wan=n[i];
	n[i]=0;
      }else{
	wan--;
	n[i]++;
      }
      if(pp==n[i])
	break;
    }
    cout << i << endl;

  }
}

Measured memory_bytes: 1196
# 素因数分解
def primeFactorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f**2 <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

# 本文
N = int(input())

ans_dict = {}
for i in range(2, N + 1):
    buf = primeFactorize(i)

    for j in buf:
        if not j in ans_dict:
            ans_dict[j] = 1
        else:
            ans_dict[j] += 1

ans = 1
for i in ans_dict.values():
    ans *= (i + 1)

print(ans % (10**9 + 7))

Measured memory_bytes: 41436
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#define inf 1<<29
using namespace std;
int h,w,c[10][10],min_c[10][10],a[205][205],ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>h>>w;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			cin>>c[i][j];
			min_c[i][j]=c[i][j];
		}
	}
	for(int k=0;k<=9;k++){
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				min_c[i][j]=min(min_c[i][j],min_c[i][k]+min_c[k][j]);
			}
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
			if(a[i][j]!=-1){
				ans+=min_c[a[i][j]][1];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
n,w = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    for p in range(w+1):
        if p >= ls[i][0]:
            dp[i+1][p] = max(dp[i][p],dp[i][p-ls[i][0]]+ls[i][1])
        else:
            dp[i+1][p] = dp[i][p]
print(dp[n][w])

Measured memory_bytes: 150200
using System;

namespace ITP1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int a = int.Parse(strs[0]);
            int b = int.Parse(strs[1]);
            int c = int.Parse(strs[2]);
            if (a < b && b < c) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8820
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

   
int main(){
    ll n,k;
    cin >> n >> k;
    ll d[k] = {};

    ll ans = 0;
    rep(i,1,n+1)d[i%k]++;
    rep(a,0,k){
	ll b,c;
	b = c = (k-a)%k;
	if((b+c)%k == 0)ans += d[a] * d[b] * d[c];
    }
    P(ans);
    return  0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  int res = a[n / 2] - a[n/2-1];
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 640
s = input()

ans = 100100100100

for i in range(2):
    cnt = 0
    t = str(i)
    for i in s:
        if t != i:
            cnt += 1
            
        t = 1 - int(t)    
        t = str(t)
    
    ans = min(ans,cnt)
    
print(ans)

Measured memory_bytes: 9248
#include<stdio.h>
int main ()
{
	int a,b,c,d,e,i,j,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	i=a/b;
	j=a%b;
	if(j>0)
	{
		i=i+1;
	}
	x=a/d;
	y=a%d;
	if(y>0)
	{
		x=x+1;
	}
	i=i*c;
	x=x*e;
	if(i<x)
	{
		printf("%d\n",i);
	}
	if(i>x)
	{
		printf("%d\n",x);
	}
	if(i==x)
	{
		printf("%d\n",i);
	}
	
	
	
	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////
bool is_prime(int n) {
	for (int i = 2; i*i <= n; ++i) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

int main() {
	ll n; cin >> n;
	vector<ll>v;
	ll sum = 0;
	REP(i, n) {
		ll a; cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end(),greater<ll>());
	sum += v[0];
	n -= 2;
	int key = 1;
	while (n > 0) {
		if (n==1) {
			sum += v[key];
			break;
		}
		else {
			sum += v[key] * 2;
			key++;
			n -= 2;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 5360
use std::io;


fn main() {
    let (a, b, c) = {
        let i = read::<isize>();
        (i[0], i[1], i[2])
    };
    let ans = if b - a == c - b { "YES" } else { "NO" };
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	int a[n],b[n],c[n-1];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>b[i];
		sum+=b[i];
	}
	for(int i=0;i<n-1;i++){
		cin>>c[i];
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[j]==i&&a[j+1]==i+1){
				sum+=c[i-1];
				if(a[j]==i){
					break;
				}
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

class Point
{
public:
  double x, y;
  Point (double x = 0, double y = 0) : x(x), y(y) {}
  Point operator + (Point p) {return Point(x + p.x, y + p.y); }
  Point operator - (Point p) {return Point(x - p.x, y - p.y); }
  Point operator * (double a) {return Point(a * x, a * y); }
  Point operator / (double a) {return Point(x / a, y / a); }

  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const
  {
    return equals(x, p.x) && equals(y, p.y);
  }
};

typedef Point Vector;
typedef vector<Point> Polygon;

struct Segment
{
  Point p1, p2;
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
  Segment(double x1, double y1, double x2, double y2)
  {
    p1 = Point(x1, y1);
    p2 = Point(x2, y2);
  }
};

typedef Segment Line;

class Circle
{
public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
};


// dot and cross product
double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b)
{
  return a.x * b.y - a.y * b.x;
}

Point project(Segment s, Point p)
{
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}

int main()
{
  double x1, y1, x2, y2;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
  Segment s(x1, y1, x2, y2);
  int q;
  scanf("%d", &q);
  while (q--)
  {
    Point p;
    scanf("%lf%lf", &p.x, &p.y);
    Point proj = project(s, p);
    printf("%.8lf %.8lf\n", proj.x, proj.y);
  }
  return 0;
}



Measured memory_bytes: 2760
n=int(input())
a=list(map(int,input().split()))

a.sort()

table=[True]*1000001
count=0
if n==1:
  count=1
else:
  for i in range(0,n):
    pp=a[i]
    if table[pp]==True:
      if i==0:
        if pp!=a[i+1]:
          count+=1
        for j in range(pp,1000001,pp):
          table[j]=False
      elif i==n-1:
        if pp!=a[n-2]:
          count+=1
      else:
        if pp!=a[i+1] and pp!=a[i-1]:
          count+=1
        for j in range(pp,1000001,pp):
          table[j]=False
      
print(count)


Measured memory_bytes: 32204
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int> ls(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> ls[i];
        ls[i] += ls[i - 1];
    }

    int count = 0;
    for (int i = 0; i <= n; i++)
    {
        if (ls[i] <= x)
        {
            count++;
        }
    }
    cout << count << endl;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<int> red(a), green(b), col(c);
    for (int i = 0; i < a; i++)cin >> red[i];
    for (int i = 0; i < b; i++)cin >> green[i];
    for (int i = 0; i < c; i++)cin >> col[i];
    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    sort(col.rbegin(), col.rend());

    red.resize(x);
    green.resize(y);

    vector<int> cal;

    for (auto &xx: red)cal.push_back(xx);
    for (auto &xx: green)cal.push_back(xx);
    for (auto &xx: col)cal.push_back(xx);

    sort(cal.rbegin(), cal.rend());
    cout << accumulate(cal.begin(), cal.begin() + x + y, 0ll);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
   ll n,k; 
  cin >> n >> k ;
  VI a(n);
   map<ll,ll> cnt;
  rep(i,n){
    cin >> a.at(i);
  }
  ll st,rp;
  ll x=1; 
  rep(i,n){
    if(cnt.count(x)){
      st=cnt.at(x);
      rp=i-cnt.at(x);
      break;
    }
    else{
      cnt[x]=i;
      x=a.at(x-1);
    }
  }
  if(k<st){
    for(pair<ll,ll> p:cnt){
      ll key=p.first;
      ll va=p.second;
      if(va==k){
        cout << key << endl;
      }
    }
  }
  else{
   ll l=(k-st)%rp;
  for(pair<ll,ll> p:cnt){
    ll key=p.first;
    ll va=p.second;
    if(va-st==l){
      cout << key <<endl;
      break;
    }
  }
  }
}

Measured memory_bytes: 16364
#include <iostream>
#include<stdio.h>
#include <cmath>
using namespace std;
int main(){


    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    double b=sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));

    printf("%f",b);

return 0;
}


Measured memory_bytes: 3220
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n_vertex = Integer.parseInt(sc.next());
        int n_path = Integer.parseInt(sc.next());
        boolean[][] connected = new boolean[n_vertex][n_vertex];
        for(int i=0; i<n_vertex; i++){
            for(int j=0; j<n_vertex; j++){
                connected[i][j]=false;
            }
        }
        int a=0, b=0;
        for(int i=0; i<n_path; i++){
            a = Integer.parseInt(sc.next())-1;
            b = Integer.parseInt(sc.next())-1;
            connected[a][b]=true;
            connected[b][a]=true;
        }
        
        ArrayList<Integer> a_perm = new ArrayList<Integer>(n_vertex);
        
        for(int i=1; i<=n_vertex; i++){
            a_perm.add(i);
        }
        
        int count=0;
        boolean all_ok = true;
        for(int i=1; i<n_vertex; i++){
            if(!connected[a_perm.get(i-1)-1][a_perm.get(i)-1]) all_ok=false;
        }
        if(all_ok) count++;
        
        
        for(int i=1; i<factorial(n_vertex-1); i++){
            a_perm = nextPerm(a_perm);
            all_ok = true;
            for(int j=1; j<n_vertex; j++){
                if(!connected[a_perm.get(j-1)-1][a_perm.get(j)-1]) all_ok=false;
            }
            if(all_ok) count++;
        }
        
        System.out.println(count);
    }
    
    private static ArrayList<Integer> nextPerm(ArrayList<Integer> former){
        int pivot=-1;
        int ln = former.size();
        for(int i = ln; i>1; i--){
            if(former.get(i-2) < former.get(i-1)){
                pivot = i-2;
                break;
            }
        }
        if(pivot==-1) return null;
        int pivot_fig = former.get(pivot);
        
        int min_pos=pivot+1;
        int min=former.get(min_pos);
        for(int i=ln-1; i > pivot+1; i--){
            if((former.get(i) < min)&&(former.get(i) > pivot_fig)){
                min_pos=i;
                min=former.get(min_pos);
            }
        }
        Collections.swap(former, pivot, min_pos);
        Collections.sort(former.subList(pivot+1, ln));
        return former;
        
    }
    private static int factorial(int n) {
        int ans=1;
        for(int i=n; i>0; i--){
            ans*=i;
        }
        return ans;
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  vector<int> a(n+1);
  vector<int> b(n+1);
  for(i=0;i<n-1;i++){
    cin>>a.at(i);
    b.at(a.at(i))++;
  }for(i=1;i<n+1;i++){
    cout<<b.at(i)<<endl;
  }
}

Measured memory_bytes: 4844
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

LL X,Y,Z,a[100010],b[100010],N,val[100010];
int ind[100010],aux[100010];

struct elem{
    LL val,p;
    elem(){}
    elem(LL val, LL p) : val(val), p(p) {}
    bool operator < (const elem &other) const{
        return (val==other.val ? p>other.p : val>other.val);
    }
};

set<elem> bs; multiset<LL,greater<LL>> bg;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> X >> Y >> Z;
    N=X+Y+Z;

    LL i; LL res=0;
    for (i=1; i<=N; i++){
        int x;
        cin >> a[i] >> b[i] >> x;
        a[i]-=x,b[i]-=x;
        res+=x;
    }

    for (i=1; i<=N; i++) ind[i]=i;
    sort(ind+1,ind+N+1,[](int x, int y){ return a[x]>a[y];});

    for (i=1; i<=N; i++) aux[i]=a[ind[i]];
    for (i=1; i<=N; i++) a[i]=aux[i];

    for (i=1; i<=N; i++) aux[i]=b[ind[i]];
    for (i=1; i<=N; i++) b[i]=aux[i];

    LL sum=0;
    for (i=N; i>X; i--){
        bs.insert({b[i],i});
        sum+=b[i];
    }

    for (i=X+1; i<=X+Y+1; i++){
        while (bs.size()>X+Y-i+1){
            auto it = --bs.end();
            sum-=(*it).val;
            bs.erase(it);
        }

        val[i]=sum;
        if (bs.count({b[i],i})){
            bs.erase({b[i],i});
            sum-=b[i];
        }

    }

    LL crb=0,best=-(1LL<<60); sum=0;
    for (i=1; i<=X; i++){
        crb+=b[i];
        bg.insert(a[i]-b[i]);
        sum+=a[i]-b[i];
    }

    for (i=X; i<=X+Y; i++){
        best=max(best,crb+sum+val[i+1]);

        bg.insert(a[i+1]-b[i+1]);
        sum+=a[i+1]-b[i+1];
        crb+=b[i+1];

        sum-=*(--bg.end());
        bg.erase(--bg.end());
    }

    cout << best+res << "\n";
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}



int main() {
	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC";
	else cout << "ABC";
	return 0;
}













Measured memory_bytes: 3628
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

c_list = list(c.items())

#print(c_list)

tmp_list = []
for tmp in c_list:
    if tmp[1] >= 2:
        tmp_list.append(tmp)


tmp_list.sort(reverse=True, key=lambda x: x[0])

if len(tmp_list) == 0 or (len(tmp_list) == 1 and tmp_list[0][1] < 4):
    print(0)
else:
    if tmp_list[0][1] < 4:
        print(tmp_list[0][0]*tmp_list[1][0])
    else:
        print(tmp_list[0][0]**2)


Measured memory_bytes: 69912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;  
    int n;
    cin>>n;
  	int h1[n],h2[n],a[n],ans=0;
  	map<int,int> m;
  	for(int i=0;i<n;++i)
    {
      cin>>a[i];
      h1[i]=i+1-a[i];
      h2[i]=i+1+a[i];
      m[h2[i]]++;
    }
  	for(int i=n-1;i>=0;--i)
    {
      	ans+=m[h1[i]];
      	m[h2[i]]--;
    }
    cout<<ans;
}

Measured memory_bytes: 31004
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	k := eGetInt(scanner)
	as := make([]int, n)
	for i := 0; i < len(as); i++ {
		as[i] = eGetInt(scanner)
	}
	acc := make([]int, n+1)
	for i := 0; i < len(as); i++ {
		acc[as[i]]++
	}
	sort.Sort(sort.Reverse(sort.IntSlice(acc)))
	count := 0
	for i := k; i < len(acc); i++ {
		count += acc[i]
	}
	fmt.Println(count)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a,b,c;

int main(){
    cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

ll compute(ll n){
	ll ret = 0;
	for(int i = 1; i < 40; i++){
		ll tot = (1LL<<(i + 1));
		ll tmp = n%tot;
		if(tmp > (1LL<<i)){
			tmp -= (1LL<<i);
			ret += (tmp&1)*(1LL<<i);
		}
	}
	ll tmp = n%4;
	if(tmp == 2 || tmp == 3)ret++;
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll a, b;
	cin>>a>>b;
	ll ans = compute(b + 1)^compute(a);
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    string a;
    cin >> a;
    int cnt = 0;
    for (int i = 0; i + 2 < n; ++i) {
        if (a[i] == 'A' && a[i + 1] == 'B' && a[i + 2] == 'C') ++cnt;
    }
    cout << cnt;
}

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

L, R = map(int, input().split())
if (R - L) > 3000:
    print(0)
    exit()
else:
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


Measured memory_bytes: 3568
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  a,b,c = input_list()
  a, b = b, a
  a, c = c, a
  print(a, b, c)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 66156
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS r = new FS();
		int a = r.nextInt();
		int b = r.nextInt();
		int c = r.nextInt();
		int count = 1;
		if(a != b) count++;
		if(a != c && b != c) count++;
		System.out.println(count);
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 7892
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

S = input()
ok = True
while S:
    if S.startswith("hi"):
        S = S[2:]
    else:
        ok = False
        break
if ok:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 6608