akhauriyash/Code-Regression huggingface dataset:
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1
2
4
8
9
15"""
        output = """Yay!"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """15
18
26
35
36
18"""
        output = """:("""
        self.assertIO(input, output)

def resolve():
    a=[int(input()) for i in range(5)]
    k=int(input())
    for i in range(4):
        for j in range(i+1,5):
            if a[j]-a[i]>k:
                print(':(')
                return()
    else:
        print('Yay!')


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 51436
flags = [False for i in range(9)]
rows = []
for i in range(3):
    rows += list(map(int, input().split()))
N = int(input())
for ii in range(N):
    b = int(input())
    for i in range(9):
        if b == rows[i]:
            flags[i] = True
ans = False
# print(rows)
for r in range(3):
    base = r*3
    # print(rows[base:base+3:1])
    if sum(flags[base:base+3:1]) == 3:
        ans = True
    # print(rows[r::3])
    if sum(flags[r::3]) == 3:
        ans = True
# print(rows[0::4])
if sum(flags[0::4]) == 3:
    ans = True
# print(rows[2:7:2])
if sum(flags[2:7:2]) == 3:
    ans = True
if ans:
    print('Yes')
else:
    print('No')

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

def solve(N):
    for a in range(1, 3501):
        Na = N * a
        a4N = 4*a-N
        for b in range(a, 3501):
            d = a4N*b-Na
            if d:
                w, r = divmod(Na*b, d)
                if r == 0 and w > 0:
                    print(a,b,w)
                    return
solve(N)


Measured memory_bytes: 2940
import java.util.Scanner;

//Haunted House
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<9;i++){
			String s = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(s+" "+(a+b)+" "+(200*a+300*b));
		}
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  int n,q,m,i,j,b[128],w;
  while(scanf("%d%d",&n,&q),n!=0){
    for(i=0;i<128;i++){b[i]=0;}
    for(i=0;i<n;i++){
      scanf("%d",&m);
      for(j=0;j<m;j++){
        scanf("%d",&w);
        b[w]++;
      }
    }
    w=0;
    for(i=1;i<128;i++){
      if(b[w]<b[i]){w=i;}
    }
    if(b[w]<q){printf("0\n");}
    else{printf("%d\n",w);}
  }
  return 0;
}



Measured memory_bytes: 2020
#include<iostream>
#include<cmath>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    double A,B,H,M;
    double judge;
    const double PI = acos(-1);
    cin >> A >> B >> H >> M;
    double degree_sub = H/12 - 11*M/720;
    if(degree_sub < 0){
        judge = -1;
    }else{
        judge = 1;
    }
    double ans = sqrt(pow(A,2.0) + pow(B,2.0) - 2*A*B*cos(2*PI*judge*(H/12 - 11*M/720)));
    cout << setprecision(20) << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
from collections import deque
n = int(input())
# 97: a
q = deque([["a", 97, 1]])
while q:
    s, num, count = q.pop()
    if count<n:
        for i in range(num+1, 96, -1):
            q.append([s+chr(i), max(num, i), count+1])
    else:
        print(s)

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k;
ll ans = INF;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    vll x(n);
    rep(i, 0, n) cin >> x[i];
    rep(i, 0, n-k+1) {
        ans = min(ans, min(abs(x[i]) + abs(x[i] - x[i + k - 1]), abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1])));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define fr(a,b) for(int i=a;i<b;i++)
#define RAJVI ios_base::sync_with_stdio(false);
#define DAIICT cin.tie(NULL);cout.tie(NULL);

bool checksorted(int n,int A[])
{
    int B[n],cnt=0;

    fr(0,n)
    {
        B[i]=A[i];
    }
    
    sort(B,B+n);
    fr(0,n)
    {
        if(A[i]!=B[i])
        cnt++;
    }
    if(cnt==0||cnt==2)
    return true;
    else return false;
}

int main()
{
    RAJVI
    DAIICT;
    int n;
    cin>>n;
    int A[n];
    fr(0,n)
    {
        cin>>A[i];
    }
    checksorted(n,A);
    if(checksorted(n,A))
    cout<<"YES";
    else cout<<"NO";

    

}

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

namespace ConsoleApp14
{
    class Class34
    {
        static void Main()
        {
            var HN = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = HN[0];
            int N = HN[1];
            int[] DP = new int[H + 1];
            for (int i = 1; i <= H; i++) DP[i] = int.MaxValue;
            DP[0] = 0;

            for(int i = 0; i < N; i++)
            {
                var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for(int j = 0; j < H; j++)
                {
                    if (DP[j] != int.MaxValue)
                    {
                        int k = Math.Min(H, j + AB[0]);
                        DP[k] = Math.Min(DP[k], DP[j] + AB[1]);
                    }
                }
            }
            Console.WriteLine(DP[H]);
        }
    }
}


Measured memory_bytes: 13396
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}

fn main() {
    let mut input = format!("");
    std::io::stdin().read_line(&mut input).expect("");
    let v: Vec<u64> = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect(""))
        .collect();
    println!("{}", gcd(v[0], v[1]));
}



Measured memory_bytes: 5036
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		int n = Integer.parseInt(in);
		String in2 = sc.nextLine();
		int a = Integer.parseInt(in2);
		int nn = n * n;
		System.out.println(nn - a);

	}

}

Measured memory_bytes: 22868
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		HashSet<Integer> h = new HashSet<>();
		for(int i = 0;i < k;i++){
			int d = saori.saori_hayami();
			for(int j = 0;j < d;j++){
				h.add(saori.saori_hayami());
			}
		}
		int ans = 0;
		for(int i =1 ;i <= n;i++){
			if(!h.contains(i))ans++;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32924
n=int(input())
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
import collections
c = collections.Counter(prime_factorize(n))
ans=0
for x in list(c.values()):
  now=1
  i=1
  while now<x+1:
    now+=(i+1)
    i+=1
  ans+=(i-1)
print(ans)

Measured memory_bytes: 9464
#include<stdio.h>

int main(){
  int h,n;
  scanf("%d%d",&h,&n);
  int a;
  int ans=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    ans+=a;}
  if(ans>=h){
    printf("Yes\n");}
  else{
    printf("No\n");}


  return 0;
}


Measured memory_bytes: 128
n, q = map(int, input().split())
s = input()
sum = [0 for _ in range(n+1)]
for i in range(n-1):
  sum[i+2] = sum[i+1]
  if s[i] == 'A' and s[i+1] == 'C':
    sum[i+2] += 1
for _ in range(q):
  l, r = map(int, input().split())
  print(sum[r] - sum[l])

Measured memory_bytes: 6152
#include <iostream>
#include <vector>
#include <math.h>
#include <map>
using namespace std;

int gcd(int x, int y)
{
    int r;
    // ユーグリッドの互除法
    while((r=x%y)!= 0)  // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
    return y;
}

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

    long long sum=0;
    for(int i=1; i<=K; i++) {
        for(int j=1; j<=K; j++) {
            for(int k=1; k<=K; k++) {
                sum+=gcd(i,(gcd(j,k)));
            }
        }
    }
    cout<<sum<<endl;

    return 0;
}

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

int main(){
    int N,sum=0;
    cin>>N;
    vector<int> B(N-1),A(N);
    for(int i=0;i<N-1;i++){
        cin>>B.at(i);
    }
    
    A.at(0)=B.at(0);
    A.at(N-1)=B.at(N-2);
    
    for(int i=1;i<N-1;i++){
        A.at(i)=min(B.at(i),B.at(i-1));
    }
    
    for(int i=0;i<N;i++){
        sum += A.at(i);
    }
    
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = [ -int(x) for x in input().split()]
heapq.heapify(a)

for _ in range(m):
    cur = heapq.heappop(a)
    heapq.heappush(a, -(-cur//2))
print(-sum(a))

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

int main(){
  int H, W; cin >> H >> W;
  vector<vector<int>> dist(10, vector<int> (10));
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> dist[i][j];
    }
  }
  for(int k = 0; k < 10; k++){
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  vector<vector<int>> A(H, vector<int> (W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A[i][j];
      if(A[i][j] != -1){
        ans += dist[A[i][j]][1];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
n = gets.to_i
s = []
n.times do
    input = gets.chomp
    s << input
end

m = gets.to_i
t = []
m.times do
    input = gets.chomp
    t << input
end

moneys = []
s.each do |str|
    money = s.count(str) - t.count(str)
    moneys << money
end

puts moneys.max > 0 ? moneys.max : 0

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

string S, T;

int main() {
    cin >> S >> T;

    string str = T.substr(0, T.length() - 1);

    cout << ((str == S) ? "Yes" : "No") << endl;
    
    return 0;
}


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

#define REP(i,init, n) for(int i=init;i<n;i++)
#define REPE(i,init, n) for(int i=init;i<=n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    int r, d, x2000;
    cin >> r >> d >> x2000;
    lli ans = x2000;
    REP(i, 0, 10) {
        ans = r * ans - d;
        cout << ans << endl;
    }
}


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

int main(){
  int n;
  int a;
  int nummax = 1;
  int nummin = 1e9;
  cin >> n;
  
  for ( int i = 0; i < n; i++ ){
    cin >> a;
    nummax = max(nummax, a);
    nummin = min(nummin, a);
  }
  
  cout << nummax - nummin << endl;
}

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

int main(void){
    int k, m=0;
    cin >> k;
    int a, b;
    cin >> a >> b;
    bool suc = false;
    while(m <= b){
        m += k;
        if(m>=a && m<=b){suc = true; break;}
    }
    if(suc) cout << "OK\n";
    else cout << "NG\n";
    return 0;
}

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

int main(){
	int k;
	cin>>k;
	rep(i, k) cout<<"ACL";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>

using u64 = unsigned long long int;
using s64 = long long int;
using u32 = unsigned int;

constexpr u32 mod = 1000000007;

int n;

u32 pow2[200001];

void reduce(u64 *a, u64 *b){
  u64 s, t, u, v;
  s = v = 1;
  u = t = 0;
  
  while(*a){
    u64 q = *b / *a;
    u64 r = *b % *a;
    std::tie(s, t, u, v) = std::forward_as_tuple(u, v, s + q*u, t + q*v);
    *b = *a;
    *a = r;
  }
  *a = u;
  *b = v;
}


u64 hash(u64 a, u64 b){
  static constexpr u64 p = (1ULL<<61) - 1;
  static constexpr u64 base = 1445861656621423872;
  static constexpr u32 basel = base & ((1U << 31) - 1);
  static constexpr u32 baseu = base >> 31;

  u32 al = a & ((1U << 31) - 1);
  u32 au = a >> 31;

  u64 w = al * baseu + au * basel;
  u64 wl = w & ((1U << 31) - 1);
  u64 wu = w >> 31;
  u64 z = al * basel + (wl << 31) + ((wu + (au * baseu)) << 1);

  return (z + b) % p;
}

/*
u64 hash(u64 a, u64 b){
  u64 s, t, u, v;
  s = v = 1;
  u = t = 0;
  u64 x = 0;
  
  while(a){
    u64 q = b / a;
    u64 r = b % a;
    std::tie(s, t, u, v) = std::forward_as_tuple(u, v, s + q*u, t + q*v);
    b = a;
    a = r;
    x ^= q;
  }
  a = u;
  b = v;
  return x^a^b;
}
*/

int main(){

  scanf("%d", &n);
  pow2[0] = 1;
  for(int i = 1; i <= n; i++){
    pow2[i] = 2 * pow2[i-1];
    if(pow2[i] >= mod) pow2[i] -= mod;
  }

//  using quot = std::pair<u64, u64>;
  using quot = u64;
  std::vector<quot> vp, vn;
  u32 zeroa = 0;
  u32 zerob = 0;
  u32 zero2 = 0;

  for(int i = 0; i < n; i++){
    s64 a, b;
    scanf("%lld%lld", &a, &b);
    if(a == 0 && b == 0) zero2++;
    else if(a == 0) zeroa++;
    else if(b == 0) zerob++;
    else if((a^b) >= 0){
      u64 ua = std::abs(a);
      u64 ub = std::abs(b);
      reduce(&ua, &ub);
//      vp.emplace_back(ua, ub);
      vp.push_back(hash(ua, ub));
    }
    else {
      u64 ua = std::abs(a);
      u64 ub = std::abs(b);
      reduce(&ua, &ub);
//      vn.emplace_back(ub, ua);
      vn.push_back(hash(ub, ua));
    }
  }

  std::sort(vp.begin(), vp.end());
  std::sort(vn.begin(), vn.end());

  std::vector<std::pair<quot, u32> > vpp, vnn;
//  quot prev = {0, 0};
  quot prev = -1;
  for(auto const &x: vp){
    if(x == prev) vpp.back().second++;
    else{
      vpp.emplace_back(x, 1);
      prev = x;
    }
  }
//  prev = {0, 0};
  prev = -1;
  for(auto const &x: vn){
    if(x == prev) vnn.back().second++;
    else{
      vnn.emplace_back(x, 1);
      prev = x;
    }
  }

  u64 ans = (pow2[zeroa] + pow2[zerob] + mod - 1) % mod;
  auto ip = vpp.begin(), in = vnn.begin();
  while(ip != vpp.end() && in != vnn.end()){
    if(ip->first == in->first){
      ans = ans * (pow2[ip->second] + pow2[in->second] + mod - 1) % mod;
      ++ip, ++in;
    }
    else if(ip->first < in->first){
      ans = ans * pow2[ip->second] % mod;
      ++ip;
    }
    else {
      ans = ans * pow2[in->second] % mod;
      ++in;
    }
  }
  while(in != vnn.end()){ ans = ans * pow2[in->second] % mod; ++in; }
  while(ip != vpp.end()){ ans = ans * pow2[ip->second] % mod; ++ip; }

  ans = (ans + zero2 + mod - 1) % mod;
  printf("%llu\n", ans);

  return 0;
}


Measured memory_bytes: 9772
X,N=map(int,input().split())
p=set(map(int,input().split()))
if X not in p:
	print(X)
else:
	x=X-1
	while x in p:
		x-=1
	y=X+1
	while y in p:
		y+=1
	a,b=X-x,y-X
	if a==b:
		if x<y:
			print(x)
		else:
			print(y)
	elif a<b:
		print(x)
	else:
		print(y)

Measured memory_bytes: 61732
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        System.out.println(8 - (X-400) / 200);


    }

}




Measured memory_bytes: 35616
n,m,l = map(int,input().split())

A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for i in range(m)]
C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for i in range(n):
    print(" ".join(map(str,C[i])))



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

const int MAXN = 1e5 + 121;

int n;
long long a[MAXN], b[MAXN];
long long ans;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) 
 	cin >> a[i] >> b[i]; 
  
  for (int i = n - 1; i >= 0; i--) {
  	a[i] += ans; 
    if (a[i] % b[i] == 0)
      	continue;
    if (a[i] < b[i])
      ans += (b[i] - a[i]);
    else {
      b[i] = ((a[i] + b[i] - 1) / b[i]) * b[i];
      ans += (b[i] - a[i]);
    }
  }
  cout << ans << '\n';
 return 0; 
}

Measured memory_bytes: 1916
#include<stdio.h>
int main(){
  int A[101], n, i, j, t, sw = 0;

  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  for ( i = 1; i <= n; i++ ){
    for ( j = n; j >= i+1; j-- ){
      if ( A[j] < A[j-1] ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
	sw++;
      }
    }
  }

  for ( i = 1; i <= n; i++ ){
    if (i>1) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

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

    const int L = 20000;
    const int M = 10000;
    const int N = 2000;

    auto match = [&](char x, char y) { return x == '?' or y == '?' or x == y; };
    
    auto preproc = [&](string S, string T) {
        vector<bool> v(L, true);
        int n = S.size(), m = T.size();
        for_(i,0,n) for_(j,0,m) if (!match(S[i], T[j])) v[i-j+M] = false;
        return v;
    };

    vector<bool> ab = preproc(a, b);
    vector<bool> bc = preproc(b, c);
    vector<bool> ac = preproc(a, c);

    int ans = 1L << 30, A = a.size(), B = b.size(), C = c.size();
    for_(i,-2*N,2*N+1) for_(j,-2*N,2*N+1) {
        if (ab[i+M] and ac[j+M] and bc[j-i+M]) {
            int L = min(0, min(i, j));
            int R = max(A, max(B+i, C+j));
            ans = min(ans, R - L);
        }
    }
    cout << ans << endl;
}

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

char s[20];
int n, cnt[30];
typedef long long ll;
map <ll, int> mp;

const int base = 503, mod = 1e9 + 7;

int main() {
    cin >> n;
    while (n --) {
        scanf("%s", s);
        int n = strlen(s);
        memset(cnt, 0, sizeof cnt);
        for (int i = 0; i < n; i ++) cnt[s[i]-'a'] ++;
        long long hh = 0;
        for (int i = 0; i < 26; i ++) hh = hh * base + cnt[i] + 100;
        mp[hh] ++;
    }
    long long rlt = 0;
    for (auto x : mp) {
        rlt += 1ll * x.second * (x.second - 1) / 2;
    }
    cout << rlt << endl;
    return 0;
}


Measured memory_bytes: 6528
require 'prime'

class Integer
  def my_divisor_list2
    return [1] if self == 1
    Prime.prime_division(self).map do |e|
      Array.new(e[1]+1).map.with_index do |element, i|
        e[0]**i
      end
    end.inject{|p,q| p.product(q)}.map do |a|
      [a].flatten.inject(&:*)
    end.sort
  end
end

a, b = gets.split(' ').map(&:to_i)

as = a.my_divisor_list2
bs = b.my_divisor_list2

ks = as & bs

p ks.reject { |k|
  k != 1 && ks.any? { |k2| k2 != 1 && k != k2 && k % k2 == 0 }
}.length


Measured memory_bytes: 5496
for k in range(1,10):
    print('?',10**k,flush=True)
    if input()=='N':
        i=10**(k-1)+1
        j=10**k-1
        while i<j:
            m=(i+j)//2
            print('?',m*10,flush=True)
            if input()=='Y':
                j=m
            else:
                i=m+1
        print('!',i,flush=True)
        break
else:
    for k in range(10):
        print('?',10**(k+1)-1,flush=True)
        if input()=='Y':
            print('!',10**k,flush=True)
            break

Measured memory_bytes: 3404
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    int r,c;
    vvi data;
    vi result;
    cin >> r >> c;
    F(i, 0, r){
        int sum = 0;
        vi temp;
        F(k, 0, c){
            int l;
            cin >> l;
            sum += l;
            temp.pb(l);
        }
        temp.pb(sum);
        data.pb(temp);
    }

    F(i, 0, c+1){
        int sum = 0;
        F(k, 0, r){
            sum += data[k][i];
        }
        result.pb(sum);
    }

    F(i, 0, r){
        F(k, 0, c){
            cout << data[i][k] << space;
        }
        cout << data[i][c];
        cout << endl;
    }
    F(i, 0, c){
        cout << result[i] << space;
    }
    cout << result[c];
    cout << endl;
}



Measured memory_bytes: 3204
// g++ -std=gnu++1y -O2 xxx.cpp

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

void swap(int& a, int& b) {
    int tmp = a;
    a = b;
    b = tmp;
}

int main() {
    int a,b,c; cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld double
#define F first
#define S second
#define sz size
#define pb push_back

using namespace std;

const int MAXN = 1e6 + 5;
const int inf = 1e9 + 7;
const ll INF = 1e18;

int n, l[15], sum;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> l[i];
        sum += l[i];
    }
    for (int i = 1; i <= n; i++) {
        if (l[i] >= sum - l[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

#include <string>
using std::string;

int main()
{
  int n;
  cin >> n;
  
  int64_t sum = 0;
  
  for (int i = 1; i <= n; i ++)
    if (!( ((i % 3) == 0) || ((i % 5) == 0) )) sum += i;
    
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
const long long mod = 1000000007;
vector<edge>G[22];
signed main() {
	int l; cin >> l;
	int V = 0;
	rep(i, 20) {
		if ((1 << i) <= l&&l < (1 << (i + 1)))V = i + 1;
	}
	rep(i, V-1) {
			G[i].push_back({ i + 1,0 });
			G[i].push_back({ i + 1,1 << i });
	}
	int nm = 1 << (V-1);
	int ed = (V-1)* 2;
	for (int i = V - 1; i >= 0; i--) {
		if (nm + (1 << i) <= l) {
			G[i].push_back({ V-1,nm});
			nm += 1 << i;
			ed++;
		}
	}
	cout << V << ' ' << ed << endl;
	rep(i, V) {
		rep(j, G[i].size()) {
			cout<<i+1<<' ' << G[i][j].to+1 << ' ' << G[i][j].cost << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
 
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
using pt = complex <db>;
 
const int N = 63;
const db EPS = 1e-9;
int n, k;
db x[N], y[N], c[N];
 
vector <pt> uh(pt c1, db r1, pt c2, db r2) {
	  db dq = norm(c1-c2), rq=r1*r1-r2*r2;
	  pt c = (c1+c2)+(c2-c1)*rq/dq; c*=.5;
	  db dt=2*dq*(r1*r1+r2*r2)-dq*dq-rq*rq;
	  if (dt < -EPS) return {};
	  if (dt < EPS) return {c};
	  dt=sqrt(dt)/2/dq;
	  pt d = (c2-c1)*pt(0,1)*dt;
	  return {c+d, c-d};
}

bool good(db t) {
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      auto pts = uh({x[i], y[i]}, t/c[i], {x[j], y[j]}, t/c[j]);
      for (pt p : pts) {
        int cnt = 0;
        for (int l = 0; l < n; ++l) {
          pt o = {x[l], y[l]};
          db d = abs(o-p);
          if (d - EPS < t/c[l]) {
            cnt++;
            if (cnt >= k) return true;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    pt p(x[i], y[i]);
    int cnt = 0;
    for (int l = 0; l < n; ++l) {
      pt o = {x[l], y[l]};
      db d = abs(o-p);
      if (d - EPS < t/c[l]) {
        cnt++;
        if (cnt >= k) return true;
      }
    }
  }
  return false;
}
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> c[i];
	}
	int magic = 100;
	db l = 0, r = 1e10;
	while (magic--) {
		db m = (l + r) * 0.5;
		if (good(m)) {
			r = m;
		}	else {
			l = m;
		}
	}
	cout << setprecision(50) << r;
}


Measured memory_bytes: 384
def cmb(n, r, mod):
  if ( r<0 or r>n ):
    return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 2*10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )
k = int(input())
s = str(input())
l = len(s)
ans = 0
def power(a,n):
  ans = 1
  while n:
    if n%2:
      ans = (ans*a)%mod
    a = (a*a)%mod
    n >>= 1
  return ans%mod  
y = 1
for i in range(l,l+k+1):
  x = power(26,l+k-i)
  ans = (ans+ x*y*cmb(i-1,l-1,mod))%mod
  y = (y*25)%mod
print(ans)

Measured memory_bytes: 201796
import sys
from typing import List, Tuple, Dict
from dataclasses import dataclass, field

import scipy
import numpy as np
from numba import jit

D = int(input())  # 日数 D = 365
C = np.array(list(map(int, input().split())), dtype=int)  # 満足度の下がりやすさ 26個
S = np.array([list(map(int, input().split())) for _ in range(D)], dtype=int)  # d日目にコンテストiを行ったときの満足度


@dataclass()
class Node:
    date: int
    value: int
    result: list = field(default_factory=list)

    def __lt__(self, other) -> bool:
        return self.value < other.value

    def output(self) -> str:
        assert len(self.result) == D
        return '\n'.join(self.result)


def calc_satisfaction(plan: List[int]) -> int:
    assert len(plan) == D
    res = 0
    last = np.zeros(26)

    for d in range(D):
        p = plan[d] - 1
        res += S[d][p]
        last[p] = d + 1

        for i in range(26):
            res -= C[i] * (d + 1 - last[i])

    return int(max(10 ** 6 + res, 0))


plan = []
for d in range(D):
    t = 0
    max_s = 0
    for i, s in enumerate(S[d]):
        if s > max_s:
            t = i + 1
            max_s = s

    plan.append(t)

print(plan, file=sys.stderr)
print(calc_satisfaction(plan), file=sys.stderr)
print('\n'.join(map(lambda x: str(x), plan)))


Measured memory_bytes: 93684
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

res=0
for i in range(n):
  if i>k-1 and t[i-k]==t[i]:
    t[i]="n"
  if t[i]=="r":
    res+=p
  elif t[i]=="s":
    res+=r
  elif t[i]=="p":
    res+=s
  
print(res)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve(){
    string s;
    cin>>s;
    ll n=s.size();
    rep(i,n) cout<<"x";
    cout<<endl;


}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main() {
	int data[100], in, i;
	scanf("%d", &in);
	for (i = 0; i < in; i++) {
		scanf("%d", &data[i]);
	}
	for (int j = in; j > 0; j--) {
		printf("%d", data[j - 1]);
		if (j != 1) printf(" ");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2088
A, B = map(int, input().split())

def prime_factorize(n):
    res = set()
    i = 2
    while i * i <= n:
        if n % i == 0:
            res.add(i)
            while n % i == 0:
                n //= i
        i += 1
    if n != 1:
        res.add(n)
    return res

ans = prime_factorize(A) & prime_factorize(B)
print(len(ans) + 1)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll d;
    cin >> d;
    vector<ll> c(26);
    for(i = 0;i < 26;++i){
        cin >> c.at(i);
    }
    vector<vector<ll>> s(d,vector<ll>(26));
    for(i = 0;i < d;++i){
        rep(j,26){
            cin >> s.at(i).at(j);
        }
    }
    for(i = 0;i < d;++i){
        cout << 1 << endl;
    }


    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
 
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
int main()
{
    int x, y;
    cin>>x>>y;
    if(x==1 and y==1)
        cout<<1000000;
    else if(x==1 and y==2 or y==1 and x==2)
        cout<<500000;
    else if(x==1 and y==3 or y==1 and x==3)
        cout<<400000;
    else if(x==2 and y==2)
        cout<<400000;
    else if(x==2 and y==3 or y==2 and x==3)
        cout<<300000;
    else if(x==3 and y==3)
        cout<<200000;
    else if(x==1 and y>3 or y==1 and x>3)
        cout<<300000;
    else if(x==2 and y>3 or y==2 and x>3)
        cout<<200000;
    else if(x==3 and y>3 or y==3 and x>3)
        cout<<100000;
    else
        cout<<0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split(" ");
  var A= parseInt(input[0], 10);
  var B= parseInt(input[1], 10);
  
    
   
for (var i = 0; i <20 ; i++){
            var N =A * i - (i-1);
            if (N >= B){
               console.log(i);
                    break;}
                    }
           
 
}
 
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 11468
/* ITP1_7_C */
#include <stdio.h>

/* ????????¨???????¨????????????? */
int sum_per_row(int line_array[], short elem_count);


int main(void)
{
	short r = 0, c = 0;
	
	// ??????????????\????????????
	scanf("%hd %hd", &r, &c);
	
	// ????¨?????????????????????????1??????1??????????¢?????????????
	r += 1;
	c += 1;
	
	short ii, jj;
	
	int sheat_array[r][c];
	
	// ?????????
	for( ii = 0; ii < r; ii++ )
	{
		for( jj = 0; jj < c; jj++ )
		{
			sheat_array[ii][jj] = -1;
		}
	}
	
	// ??¨?????\????????????
	for( ii = 0; ii < r - 1; ii++ )
	{
		for( jj = 0; jj < c - 1; jj++ )
		{
			scanf("%d", &sheat_array[ii][jj]);
		}
	}
	
	// ????????¨???????¨????????¨????
	int column_array[r];
	for( ii = 0; ii < c; ii++ )
	{
		for( jj = 0; jj < r; jj++ )
		{
			column_array[jj] = -1;
			column_array[jj] = sheat_array[jj][ii];
		}
		sheat_array[jj - 1][ii] = sum_per_row(column_array, r);
	}
	
	// ????????¨???????¨????????¨????
	int line_array[c];
	for( ii = 0; ii < r; ii++ )
	{
		for( jj = 0; jj < c; jj++ ){
			line_array[jj] = -1;
			line_array[jj] = sheat_array[ii][jj];
		}
		sheat_array[ii][jj - 1] = sum_per_row(line_array, c);
	}
	
	// ????????????
	for( ii = 0; ii < r; ii++ )
	{
		for( jj = 0; jj < c; jj++ )
		{
			printf("%d", sheat_array[ii][jj] );
			if( jj < c - 1)
			{
				printf(" ");
			}
			else
			{
				printf("\n");
			}
		}
	}
	
	return 0;
}

/* ????????¨???????¨????????´? */
int sum_per_row(int line_array[], short elem_cnt)
{
	short ii;
	int sum = 0;
	for( ii = 0; ii < elem_cnt; ii++ )
	{
		if( 0 > line_array[ii] )
		{
			continue;
		}
		sum += line_array[ii];
	}
	return sum;
}

Measured memory_bytes: 644
#include<stdio.h>
int main()
{
	int goal,sai,map[1001]={0},kazu[1001]={0},saikoro=1,end[1000]={0},count=0;
	scanf("%d %d",&goal,&sai);
	while(goal!=0&&sai!=0){
	for(int i=1;i<goal+1;i++){
		scanf("%d",&map[i]);
	}
	for(int i=1;i<sai+1;i++){
		scanf("%d",&kazu[i]);
	}
	for(int i=1;i<sai+1;i++){
		if(i==1){
		saikoro=saikoro+kazu[i]+map[1+kazu[i]];
		}
		else
		saikoro=saikoro+kazu[i]+map[saikoro+kazu[i]];
		if(goal<=saikoro){
			end[count]=i;
			break;
		}
	}
	saikoro=1;
	count++;
		scanf("%d %d",&goal,&sai);
	}
	for(int i=0;i<count;i++){
		printf("%d\n",end[i]);
	}
	return 0;
}

Measured memory_bytes: 1040
#include<stdio.h>

int solve(int m) {
  int result = 0;
  int tmp = 0;
  int array[5] = {500,100,50,10,5};
  int i;

  for(i=0; i<5; i++) {
    tmp = m / array[i];
    m -= tmp * array[i];
    result += tmp;
  }

  return result + m;


}

int main(void) {
  int m;

  while(scanf("%d",&m) != EOF) {
    if(m == 0) break;
    printf("%d\n",solve(1000 - m));
  }

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    cout << (N + 1) / 2 << endl;
}

Measured memory_bytes: 256
using System;


namespace Contest
    {


        class Program
        {


            static void Main(string[] args)
            {
                var n = int.Parse(Console.ReadLine());

                if(n % 1000 == 0)
                {
                    Console.WriteLine(0);
                } else
                {
                    Console.WriteLine(1000 - (n % 1000));
                }

            }
        }
    }


Measured memory_bytes: 27524
gets
tree = gets.split.map(&:to_i)
tree.unshift(-114514)

def parent(i)
  i / 2
end

def left(i)
  2 * i
end

def right(i)
  2 * i + 1
end

tree.size.times do |i|
  next if i == 0
  print("node ",i,": key = ",tree[i],",") if i == 1
  print("node ",i,": key = ",tree[i],", parent key = ",tree[parent(i)],",") if i > 1
  print(" left key = ",tree[left(i)],",") if left(i) <= tree.size - 1
  print(" right key = ",tree[right(i)],",") if right(i) <= tree.size - 1
  puts " "
end


Measured memory_bytes: 8672
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  vector<ll> v(5);
  rep (i, n) {
    string tmp;
    cin >> tmp;
    if (tmp[0] == 'M') v[0]++;
    else if (tmp[0] == 'A') v[1]++;
    else if (tmp[0] == 'R') v[2]++;
    else if (tmp[0] == 'C') v[3]++;
    else if (tmp[0] == 'H') v[4]++;
  }

  ll ans = 0;
  rep (i, 5) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += v[i] * v[j] * v[k];
      }
    }
  }
  P(ans);

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll p, q, r;
    cin >> p >> q >> r;

    ll ans = 0;

    ans = p + q;

    if (ans > q+r)
            ans = q+r;

    if (ans > r+p)
            ans = r+p;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; 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 < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; 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 < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n, a, b) = get!(usize, usize, usize);

    println!("{}", min(n * a, b));
}


Measured memory_bytes: 8572
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  const A = lines[1].split(' ').map(line => +line)
  const obj = { A }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { A } = parseLines(lines)
  A.sort((a: number, b: number) => b - a)
  let alice = 0
  let bob = 0
  for (let i = 0; i < A.length; i++) {
    if (i % 2 === 0) {
      alice += A[i]
    } else {
      bob += A[i]
    }
  }
  return `${alice - bob}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7756
N, W = map(int, input().split())
V = []
for i in range(N):
    V.append(list(map(int, input().split())))
    
DP = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if(j >= V[i][1]):
            DP[i+1][j] = max(DP[i][j], DP[i+1][j-V[i][1]]+V[i][0])
        else:
            DP[i+1][j] = DP[i][j]
print(DP[N][W])


Measured memory_bytes: 16136
#include <stdio.h>
int main(void){
    int cards[4][13] = {0};
    int a;
    scanf("%d",&a);
    char b;
    int c;
    
    for(int i=0; i<a; i++)
    {
        scanf(" %c %d",&b,&c);
        if(b=='S')
        {
            cards[0][c-1]=1;
        }
        if(b=='H')
        {
            cards[1][c-1]=1;
        }
        if(b=='C')
        {
            cards[2][c-1]=1;
        }
        if(b=='D')
        {
            cards[3][c-1]=1;
        }
    }
    
    char syms[4] = {'S','H','C','D'};
    int i = 0, j = 0;
    for(;i<4;i++)
    {
        for(j=0;j<13;j++)
        {
            if(cards[i][j] == 0)
            {
                printf("%c %d\n",syms[i] , j+1);
            }
        }
    }
   
    
}



Measured memory_bytes: 2148
<?php
  $n = (int)trim(fgets(STDIN));
  $l = explode(" ", trim(fgets(STDIN)));
  sort($l);
//   print_r($l);
  $cnt = 0;
  for($i=0; $i<$n; $i++){
      for($j=$i+1; $j<$n; $j++){
          $ab = $l[$i]+$l[$j];
          $top = $j;
          $btm = $n;
          while($top+1 < $btm){
              $cen = intdiv($top+$btm,2);
              if($ab > $l[$cen]){
                  $top = $cen;
              }else{
                  $btm = $cen;
              }
          }
          $cnt += ($top-$j);
      }
  }
  echo $cnt;

Measured memory_bytes: 16476
a = list(input())
b = list(input())
c = []
flag = False

if len(a) != len(b):
  flag = True
  b.append("X")

for i in range(len(a)):
    c += a[i] + b[i]

if flag == True:
  c.pop()
  print("".join(c))
else:
  print("".join(c))

Measured memory_bytes: 3064
N=int(input())
H=list(map(int,input().split()))[::-1]
flag=True
base=H[0]
for i in range(N-1):
    if H[i]+1==H[i+1]:
        H[i+1]-=1
    elif H[i]>=H[i+1]:
        continue
    else:
        flag=False
print("Yes" if flag else "No")

Measured memory_bytes: 15020
#include<algorithm>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
typedef pair<int, int> P;

P lr[100000];
int n, mr[100000];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d %d", &lr[i].first, &lr[i].second);
    sort(lr, lr + n);

    mr[n - 1] = lr[n - 1].second;
    for (int i = n - 2; i >= 0; i--) mr[i] = min(mr[i + 1], lr[i].second);
    set<int> s;
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        int res = 0;
        if (s.empty()) res = max(lr[i].second - lr[i].first + 1, 0) +
            max(mr[i + 1] - lr[n - 1].first + 1, 0);
        else {
            res = max(*s.begin() - lr[i].first + 1, 0) +
                max(mr[i + 1] - lr[n - 1].first + 1, 0);
            res = max(res, max(lr[i].second - lr[i].first + 1, 0) +
                max(min(*s.begin(), mr[i + 1]) - lr[n - 1].first  + 1, 0));
        }
        s.emplace(lr[i].second);
        ans = max(ans, res);
    }
    printf("%d\n", ans);
    return 0;
} 


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

int main(){
  int N;
  cin >> N;
  int L[N];
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  sort(L, L+N);
  int sum = 0;
  for(int i = 0; i < N - 1; i++){
    sum += L[i];
  }
  cout << (sum > L[N-1] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256