akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	if (B == 0) return 1;
	if (B % 2) return A * modpow(A, B - 1) % mod;
	ll half = modpow(A, B / 2);
	return half * half % mod;
}


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


	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	ll F[1001], FI[1001];
	F[0] = 1;
	rep1(i, 1000) {
		F[i] = F[i - 1] * i % mod;
	}
	FI[1000] = modpow(F[1000], mod - 2);
	for (int i = 1000; i > 0; i--) {
		FI[i - 1] = FI[i] * i % mod;
	}

	ll dp[1001][1001] = {};
	dp[0][0] = F[N];
	rep(i, N) {
		rep(j, N) {
			if (dp[i][j]) {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= mod;
				if (A <= i + 1 && i + 1 <= B) {
					for (int k = C; k <= D; k++) {
						int kari = j + k * (i + 1);
						if (kari <= N) {
							dp[i + 1][kari] += dp[i][j] * modpow(FI[i + 1], k) % mod * FI[k] % mod;
							dp[i + 1][kari] %= mod;
						}
						else break;
					}
				}
			}
		}
	}
	ll kotae = 0;
	rep(i, N + 1) {
		kotae += dp[i][N];
		kotae %= mod;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 8192
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int N = GetInt();
		int ans = 1;
		while(ans <= N/2)
			ans *= 2;
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main () {

	int x;
	cin >> x;
	int y = 0;
	int z = x;
	while (z > 0) {
		y += z % 10;
		z /= 10;	
	}
	if (x % y == 0) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
S = input()
d = 0
f = 0
for s in S:
    if s == 'a':
        if d+f < A+B:
            d += 1
            print("Yes")
        else:
            print("No")
    elif s == 'b':
        if d+f < A+B and f < B:
            print("Yes")
            f += 1
        else:
            print("No")
    else:
        print("No")




Measured memory_bytes: 4040
import java.util.*;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int s_front = s / 100;
        int s_back = s % 100;

        if (0 < s_front && s_front < 13) {
            if (0 < s_back && s_back < 13) {
                System.out.println("AMBIGUOUS");
            } else {
                System.out.println("MMYY");
            }
        } else {
            if (0 < s_back && s_back < 13) {
                System.out.println("YYMM");
            } else {
                System.out.println("NA");
            }
        }
    }
}






Measured memory_bytes: 22996
#include<iostream>
using namespace std;
int main() {
	int n, s[14] = {}, h[14] = {}, c[14] = {}, d[14] = {}, tmp;
	char m;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> m >> tmp;
		if (m == 'S') {
			s[tmp] = tmp;
		}
		else if (m == 'H') {
			h[tmp] = tmp;
		}
		else if (m == 'C') {
			c[tmp] = tmp;
		}
		else if (m == 'D') {
			d[tmp] = tmp;
		}
	}

	for (int i = 1; i <= 13;i++) {
		if (s[i] == 0) cout << "S " << i << endl;
	}
	for (int i = 1; i <= 13;i++) {
		if (h[i] == 0) cout << "H " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (c[i] == 0) cout << "C " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (d[i] == 0) cout << "D " << i << endl;
	}

}


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

vector<int> digits(int n)
{
    vector<int> v;
    while (n > 0)
    {
        v.push_back(n % 10);
        n /= 10;
    }
    return v;
}

int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; ++i)
    {
        vector<int> v = digits(i);
        int n = v.size();
        bool flag = true;
        for (int j = 0; j < n; ++j)
        {
            if (v[j] != v[n - 1 - j])
            {
                flag = false;
                continue;
            }
        }
        if (flag == true)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long LL;

#define A first
#define B second

const int MAXN = 2e5+5;

bool dfs(int a, int layer, const vector<vi>& g, vi& btoa,
			vi& A, vi& B) {
	if (A[a] != layer) return 0;
	A[a] = -1;
	trav(b, g[a]) if (B[b] == layer + 1) {
		B[b] = -1;
		if (btoa[b] == -1 || dfs(btoa[b], layer+2, g, btoa, A, B))
			return btoa[b] = a, 1;
	}
	return 0;
}

int hopcroftKarp(const vector<vi>& g, vi& btoa) {
	int res = 0;
	vi A(g.size()), B(btoa.size()), cur, next;
	for (;;) {
		fill(all(A), 0);
		fill(all(B), -1);
		/// Find the starting nodes for BFS (i.e. layer 0).
		cur.clear();
		trav(a, btoa) if(a != -1) A[a] = -1;
		rep(a,0,sz(g)) if(A[a] == 0) cur.push_back(a);
		/// Find all layers using bfs.
		for (int lay = 1;; lay += 2) {
			bool islast = 0;
			next.clear();
			trav(a, cur) trav(b, g[a]) {
				if (btoa[b] == -1) {
					B[b] = lay;
					islast = 1;
				}
				else if (btoa[b] != a && B[b] == -1) {
					B[b] = lay;
					next.push_back(btoa[b]);
				}
			}
			if (islast) break;
			if (next.empty()) return res;
			trav(a, next) A[a] = lay+1;
			cur.swap(next);
		}
		/// Use DFS to scan for augmenting paths.
		rep(a,0,sz(g)) {
			if(dfs(a, 0, g, btoa, A, B))
				++res;
		}
	}
}

int n, m[MAXN], r[MAXN];
vector<int> g[MAXN];
vector<vector<int> > e;
pii ans[MAXN]; bool vis[MAXN];

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

	cin >> n;
	e.resize(n-1);
	for (int i = 0; i < n-1; ++i) {
		int s;
		cin >> s;
		for (int j = 0; j < s; ++j) {
			int x; cin >> x;
			x--;
			e[i].push_back(x);
		}
	}

	vi ba(n, -1);
	int fl = hopcroftKarp(e, ba);
	if (fl < n-1) {
		cout << "-1\n";
		return 0;
	}
	ll s = 1LL*n*(n-1)/2;

	for (int i = 0; i < n; ++i) {
		if (ba[i] == -1)
			s = i;
		else {
			r[i] = ba[i];
			m[ba[i]] = i;
			// cout << ba[i] << ' ' << i << endl;
		}
	}
	//s is unmatched
	// cout << s << endl;
	for (int i = 0; i < n-1; ++i)
		for (int x : e[i])
			if (m[i] != x) {
				g[x].push_back(m[i]);
				// cout << x << ' ' << m[i] << endl;
			}

	//search from s
	queue<int> q;
	q.push(s);
	vis[s] = 1;
	int ct = 1;
	while (!q.empty()) {
		int t = q.front();
		q.pop();
		for (int x : g[t]) {
			if (vis[x])
				continue;
			vis[x] = 1;
			ct++;
			q.push(x);
			ans[r[x]] = pii(x, t);
			// cout << r[x] << ' ' << x << ' ' << t << endl;
		}
	}
	if (ct < n) {
		cout << "-1\n";
		return 0;
	}

	for (int i = 0; i < n-1; ++i)
		cout << ans[i].A+1 << ' ' << ans[i].B+1 << "\n";
}

Measured memory_bytes: 16736
/*
  Contest 065
  C - Reconciled?
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

using ll = long long int;

ll f (ll n) {
    ll r = 1;
    for (ll i = 2; i <= n; ++i)
        r = (r * i) % static_cast<ll>((1e9 + 7));
    return r;
}

/*
  combinations maths questions.
  for example
  D --> dog, M --> Monkey
  if abs(D - M) == 0
  let's D = M = 2
  can be 2 combinations where DMDM or MDMD therefore (D! * M!) * 2
  if abs(D - M) = 1
  DMD, MDM so D! * M!
  else abs(D - M) > 1
  0, because dog and monkey can't stand each other
 */

const ll M = (1e9 + 7);

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

    ll n = 0, m = 0;
    std::cin >> n >> m;
    if (std::abs(n - m) <= 1) {
        ll result = 1;
        for (int i = 1; i <= n; ++i)
            result = (result * i) % M;
        for (int i = 1; i <= m; ++i)
            result = (result * i) % M;
        if (n == m)
            result = (result << 1) % M;
        std::cout << result << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }


    return 0;
}


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

int main(){
  int n,s,ssum,smin=100000;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    ssum+=s;
    if(s%10!=0) smin=min(smin,s);
  }
  if(ssum%10)cout<<ssum;
  else  cout<<max(0,ssum-smin);
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
<?php
    fscanf(STDIN,"%d %d %d",$n,$a,$b);
    echo $a === 0 ? 0 : $n % ($a + $b) < $a ? $a * intdiv($n,($a + $b)) + ($n % ($a + $b)) : $a * intdiv($n,($a + $b)) + $a;
    echo PHP_EOL;
?>

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

int main() {
  string S;
  cin >> S;
  rep(i,S.size()) S[i]='x';
  cout << S << endl;
   
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main {
		public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
          
        if(N/100==7||(N/10)%10==7||N%10==7){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
	}
}

Measured memory_bytes: 35612
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(void)
{
        ll cnt[100010] = {0};
        int a;
        int b;
        int n;
        ll k;

        cin >> n >> k;
        REP(i,n){
                cin >> a >> b;
                cnt[a-1] += b;
        }

        ll sum = 0;
        int j;
        REP(j,100000){
                sum += cnt[j];
                if(sum >= k){
                        cout << j+1 << endl;
                        return 0;
                }
        }

        return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
double dp[303][303][303];
bool memo[303][303][303];
int n;
double rec (int x, int y, int z) {
  if (memo[x][y][z]) return dp[x][y][z];
  if (x == 0 && y == 0 && z == 0)  return 0;
  double& res = dp[x][y][z];
  memo[x][y][z] = true;
  if (x > 0) res += rec(x - 1, y, z) * x;
  if (y > 0) res += rec(x + 1, y - 1, z) * y;
  if (z > 0) res += rec(x, y + 1, z - 1) * z;
  res += n;
  res /= (x + y + z);
  return res;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  int x = 0, y = 0, z = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a == 1) x++;
    if (a == 2) y++;
    if (a == 3) z++;
  }
  cout << setprecision(20) << fixed << rec(x, y, z) << endl;
  return 0;
}

Measured memory_bytes: 243968
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		int D = scanner.nextInt();
		int count = 0;
		while(C > 0 && A > 0) {
			C = C - B;
			//System.out.println("Cは" + C);
			if(C <= 0) {
				count += 1;
				break;
			}
			A = A - D;
			//System.out.println("Aは" + A);
			if (A <= 0) {
				count -= 1;
				break;
			}
		}
		if (count >= 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35756
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n, k := readInt(), readInt()
	var l []int
	for i := 0; i < n; i++ {
		l = append(l, readInt())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(l)))
	sum := 0
	for i := 0; i < k; i++ {
		sum += l[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <algorithm>
#include <chrono>

auto trade(std::array<int, 3> const& cookies) {
  std::array<int, 3> updated;
  for (int i = 0; i < 3; i++)
    updated[i] = cookies[i] / 2 + cookies[(i + 1) % 3] / 2;
  return updated;
}

int main() {
  std::array<int, 3> cookies;
  for (auto& i : cookies)
    std::cin >> i;
  int count = 0;
  bool finished = false;
  auto start = std::chrono::system_clock::now();
  using namespace std::literals;
  while (std::chrono::system_clock::now() - start < 1500ms) {
    if (std::any_of(std::begin(cookies), std::end(cookies),
          [] (int n) { return n % 2 == 1; })) {
      finished=true;
      break;
    }
    cookies = trade(cookies);
    count++;
  }
  std::cout << (finished ? count : -1) << std::endl;
}


Measured memory_bytes: 384
;; D - Semi Common Multiple

(defun main ()
  (let* ((N (read))
         (M (read))
         (A (loop repeat N collect (read))))
    (princ (solve N M A))
    (fresh-line)))

(defun solve (N M A)
  (let* ((H (mapcar #'(lambda (x) (floor x 2)) A)) ; a_i / 2
         (lcm (reduce #'(lambda (l x) (if (> l M) l (lcm l x))) H)))
    (if (and (<= lcm M)
             (every #'(lambda (x) (oddp (floor lcm x))) H)) ; 全要素の奇数倍
        (ash (1+ (floor M lcm)) -1) ; M以下のlcmの奇数倍の個数
        0)))

(main)


Measured memory_bytes: 61924
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, y, i, j, flag=0, ans10, ans5, ans1;
  cin >> n >> y;
  y/=1000;
  for(i=0; i<n+1; i++)
    for(j=0; i+j<n+1; j++){
      if(10*i+5*j+(n-i-j)==y){
	flag++;
	ans10=i;
	ans5=j;
	ans1=n-i-j;
	break;
      }
    }
  if(flag>0) cout << ans10 << " " << ans5 << " " << ans1;
  else cout << -1 << " " << -1 << " " << -1;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

ll cnt = 0;

int d[3] = {3, 7, 5};

void dfs(vector<int> &A, int n, int N) {
    // 数列の長さが N に達したら打ち切り
    if (A.size() == n + 1)
        return;

    if (A.size() >= 3) {
        bool j1 = 0, j2 = 0, j3 = 0;
        ll exp = 1;
        ll num = 0;
        for (int i = A.size() - 1; i > -1; i--) {
            if (A[i] == 3)
                j1 = 1;
            else if (A[i] == 7)
                j2 = 1;
            else if (A[i] == 5)
                j3 = 1;
            num += A[i] * exp;
            exp *= 10;
        }
        if (num <= N && j1 && j2 && j3) {
            cnt++;
        }
    }

    // 0からMまでの数字
    for (int v = 0; v < 3; ++v) {
        A.push_back(d[v]);
        dfs(A, n, N);
        A.pop_back();
    }
}

int main() {
    ll N;
    cin >> N;
    int n = to_string(N).size();
    vector<int> A;
    dfs(A, n, N);
    cout << cnt << endl;
}

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

fn main() {
    let (_, q) = scan!(usize, usize);
    let s = scan!();
    let mut nums = vec![0; s.len()];
    for (i, (s0, s1)) in s.chars().zip(s[1..].chars()).enumerate() {
        if s0 == 'A' && s1 == 'C' {
            nums[i + 1] += 1;
        }
    }

    for i in 0..nums.len() - 1 {
        nums[i + 1] += nums[i]
    }

    for _ in 0..q {
        let (l, r) = scan!(usize, usize);
        if l == 1 {
            println!("{}", nums[r - 1]);
        } else {
            println!("{}", nums[r - 1] - nums[l - 1]);
        }
    }
}


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

int main(){
	int N, K, i;
	cin >> N >> K;
	int h[N];
	for(i=0; i<N; i++){
		cin >> h[i];
	}
	
	int ans=0;
	for(i=0; i<N; i++){
		if(h[i]>=K)	ans++;
	}
	
	cout << ans << endl;
	return 0;
}


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

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

int main() {
    int n;
    cin>>n;
    int a=0;
    ll ans=0;
    rep(i, n) {
        int t;
        cin >> t;
        if (t==0) {
            a=0;
        }
        else if (t%2 and a) {
            ans += (t+a)/2;
            a=0;
        }
        else if (t%2) {
            ans += t/2;
            a=1;
        }
        else if (t%2==0 and a){
            ans += t/2;
            a=1;
        }
        else {
            ans += t/2;
            a=0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    static int n;
    static int lw;
    static int[] w;
    static int[] v;
    static long[][] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        lw = sc.nextInt();
        w = new int[n];
        v = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        dp = new long[n + 1][100001];
        nap(0);
        System.out.println(dp[n][lw]);
    }
    static void nap(int i) {
        if (i == n) {
            return;
        }
        for (int j = 0; j <= lw; j++) {
            if (j >= w[i]) {
                dp[i + 1][j] = Math.max(dp[i][j - w[i]] + v[i], dp[i][j]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
        nap(i + 1);
    }
}

Measured memory_bytes: 126928
n=int(input())
def func(i,j,m): #m以下の整数で先頭がi末尾がjであるものの個数
  ret=0
  s=len(str(m))
  m0=int(str(m)[0])
  if s==1:
    if i==j and i<=m:
      return 1
    else:
      return 0
  if s==2:
    if 10*i+j<=m:
      return 2 if i==j else 1
    else:
      return 1 if i==j else 0
  if i<m0:
    for si in range(s-1):
      ret+=pow(10,si)
  elif i==m0:
    if j<=int(str(m)[-1]):
      ret+=int(str(m)[1:-1])+1
    else:
      ret+=int(str(m)[1:-1])
    for si in range(s-2):
      ret+=pow(10,si)
  elif i>m0:
    for si in range(s-2):
      ret+=pow(10,si)
  return ret if i!=j else ret+1
ans=0
d={}
for i in range(1,10):
  for j in range(1,10):
    a=func(i,j,n)*func(j,i,n)
    ans+=a
    #if a>0:
    #  print(i,j,func(i,j,n),func(j,i,n))

print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

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

int N = 210000 - 1; // 必要な数よりも大きい2^nよりも大きい数を入れるとよい
long long int B1[210000], B2[210000];

void add(int a, long long int w, long long int BIT[]){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
	}
}

long long int sum(int a, long long int BIT[]){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	long long int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

void init(long long int BIT[]){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	init(B1);
	init(B2);
	
	for(int i = 0; i < q; i++){
		long long int num, a, b, c;
		cin >> num;
		if(num == 0){
			cin >> a >> b >> c;
			add(a, c, B1);
			add(b + 1, -c, B1);
			add(a, -(a - 1) * c, B2);
			add(b + 1, b * c, B2);
		}else{
			cin >> a >> b;
			a--;
			long long int num1 = sum(a, B1) * a + sum(a, B2);
			long long int num2 = sum(b, B1) * b + sum(b, B2);
			cout << num2 - num1 << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX_N = 1000000; 

vector<int> prime(MAX_N);
vector<bool> is_prime(MAX_N+1);
vector<int> ans_vec(MAX_N+1, 0);

// n以下の素数を返す
void sieve(int n){
    int p = 0;
    rep(i, n+1) is_prime.at(i) = true;
    is_prime.at(0) = is_prime.at(1) = false;
    rep2(i, 2, n+1){
        if(is_prime.at(i)){
            prime.at(++p) = i;
            for (int j = 2*i; j <= n; j+= i) is_prime.at(j) = false;
        }
    }
    return;
}

int main(){
    int q, l, r_max=0, ans = 0;
    cin >> q;
    vector<int> left(q), right(q);
    rep(i, q){
        cin >> left.at(i) >> right.at(i);
        chmax(r_max, right.at(i));
    }
    sieve(1000000);
    rep2(i, 2, r_max+1){
        if(is_prime.at(i) && is_prime.at((i+1)/2)) {
            ans_vec.at(i) = ans_vec.at(i-1) + 1;
        }
        else ans_vec.at(i) = ans_vec.at(i-1);
    }
    rep(i, q){
        cout << ans_vec.at(right.at(i)) - ans_vec.at(left.at(i)-1) << endl;
    }
}

Measured memory_bytes: 11896
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using static System.Console;

namespace KochCurv
{
    internal class Program
    {
        private static List<Vector2> vertices;
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            vertices = new List<Vector2>();
            vertices.Add(new Vector2(0f));
            Koch(n, new Vector2(0f), new Vector2(100f, 0f));
            
            vertices.Add(new Vector2(100f, 0f));
            Output(vertices);
        }

        static Vector2 Koch(int n, Vector2 startPos, Vector2 endPos)
        {
            if (n == 0) return endPos;
            var s = new Vector2((2f * startPos.x + 1f * endPos.x) / 3f, (2f * startPos.y + 1f * endPos.y) / 3f);
            var t = new Vector2((1f * startPos.x + 2f * endPos.x) / 3f, (1f * startPos.y + 2f * endPos.y) / 3f);
            var u = t.Rotate(s, Radians(60));
            
            vertices.Add(Koch(n - 1, startPos, s));
            vertices.Add(Koch(n - 1, s, u));
            vertices.Add(Koch(n - 1, u, t));
            Koch(n - 1, t, endPos);
            // vertices.Add(Koch(n - 1, t, endPos));
            return endPos;
        }

        static double Radians(double angle)
        {
            return angle * (Math.PI / 180);
        }

        static void Output(IEnumerable<Vector2> list)
        {
            var sw = new StreamWriter(OpenStandardOutput()) {AutoFlush = false};
            SetOut(sw);
            foreach (var vec in list)
            {
                
                WriteLine(vec.x + " " + vec.y);
                
            }
            Out.Flush();
            
        }
    }

    public struct Vector2
    {
        #region Constructor
        public Vector2(double xy)
        {
            this.x = xy;
            this.y = xy;
        }
        public Vector2(double x, double y)
        {
            this.x = x;
            this.y = y;
        }
        #endregion
        
        public double x;
        public double y;

        /// <summary>
        /// pointsを起点にradiansだけ回転させる
        /// </summary>
        /// <param name="points"></param>
        /// <param name="radians"></param>
        /// <returns></returns>
        public Vector2 Rotate(Vector2 points, double radians)
        {
            var x = (this.x - points.x) * Math.Cos(radians) - (this.y - points.y) * Math.Sin(radians) + points.x;
            var y = (this.x - points.x) * Math.Sin(radians) + (this.y - points.y) * Math.Cos(radians) + points.y;
            return new Vector2(x, y);
        }
    }
}


Measured memory_bytes: 16212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	int n = 0;
	rep(i, s.size()) {
		if (s[i] == '/')continue;
		n *= 10;
		n += s[i] - '0';
	}
	cout << (n <= 20190430 ? "Heisei" : "TBD") << endl;

}

Measured memory_bytes: 3548
n = int(input())
A = list(map(int, input().split()))
A.sort()
while len(A) > 1:
  a = [A[0]]
  for i in range(1, len(A)):
    if A[i]%A[0] == 0: continue
    else: a.append(A[i]%A[0])
  A = sorted(a)
print(A[0])

Measured memory_bytes: 14252
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0

for i in range(n):
    a = n-1-i
    for j in range(n):
        b = n-1-j
        if s[a] == s[b]:
            dp[a][b] = dp[a+1][b+1] + 1
for i in range(n):
    for j in range(n):
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)

Measured memory_bytes: 232072
#include<stdio.h>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
string str[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
        sort(str[i].begin(),str[i].end());
    }
    sort(str,str+n);
    long long sum=0,sign=0,cnt=1;
    for(int i=0;i<n;i++)
    {
        if(str[i]==str[i+1])
        {
            cnt++;
        }
        else
        {
            sum+=cnt*(cnt-1)/2;
            cnt=1;
        }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 7296
#include <stdio.h>

int main()
{
  char s[101];
  scanf("%s",&s);
  char a[27];
  int i;
  i = 0;
  while (i < 26)
  {
    a[i] = 2;
    i++;
  }
  a[i] = 0;
  i = 0;
  while (s[i])
  {
    a[s[i]-'a']++;
    i++;
  }
  i = 0;
  while (a[i])
  {
    //printf("%d\n",a[i]);
    if (a[i] % 2 != 0)
    {
      printf("No\n");
      return (0);
    }
    i++;
  }
  printf("Yes\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    unordered_map<int,bool>ump;
    for(int i=0;i<n;i++)
    {
        if(ump.find(v[i])==ump.end()){
            ump[v[i]]=true;
        }
        else
        {
            ump[v[i]]=1-ump[v[i]];
        }
    }
    int count=0;
    for(auto it=ump.begin();it!=ump.end();it++)
    {
        if(it->second==true)
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 7668
#include<bits/stdc++.h>
char a[10010]; 
bool c, f; 
int main() {
    scanf("%s", a); 
    for(int i=0; i<strlen(a); i++) {
        if(a[i]=='C') c=true; 
        if(a[i]=='F'&&c==true) f=true;
    }
    if(f==true) printf("Yes\n"); 
    else printf("No\n"); 
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    vector<int> edge[N+1];
    rep(i, N-1){
        int A, B;
        cin >> A >> B;
        edge[A].push_back(B), edge[B].push_back(A);
    }
    bool used[N+1];
    fill_n(used, N+1, false);
    queue<int> que;
    que.push(1);
    vector<P> vec;
    used[1] = true;
    ll dep[N+1];
    fill_n(dep, N+1, 1);
    while(!que.empty()){
        int i = que.front();
        que.pop();
        rep(j, edge[i].size()){
            int k = edge[i][j];
            if(!used[k]){
                used[k] = true;
                que.push(k);
                vec.push_back(P(i, k));
            }
        }
    }
    rep3(i, N-2, 0){
        int j = vec[i].first, k = vec[i].second;
        dep[j] += dep[k];
    }
    vector<ll> num[N+1];
    ll sum[N+1];
    fill_n(sum, N+1, 0);
    rep(i, N-1){
        int j = vec[i].first, k = vec[i].second;
        num[j].push_back(dep[k]);
        sum[j] += dep[k];
    }
    rep2(i, 2, N) num[i].push_back(N-1-sum[i]);
    ll e[N+1], inv[N+1], p = (MOD+1)/2;
    e[0] = 1, inv[0] = 1;
    rep2(i, 1, N) e[i] = (e[i-1]*2)%MOD, inv[i] = (inv[i-1]*p)%MOD;
    ll y = 0;
    rep2(i, 1, N){
        y += e[N-1]-1;
        rep(j, num[i].size()){
            y += (MOD+1-e[num[i][j]]);
        }
        y %= MOD;
    }
    cout << (y*inv[N])%MOD << endl;
}

Measured memory_bytes: 33660
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int p, q, r;
  cin >> p >> q >> r;
  cout << (p + q + r - max(max(p, q), r));
}
#endif


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int N=0;
    int M=0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i]=='A')
        {   
            N=i;
            break;
        }
        
    }
    for (int i = s.size()-1; i >= 0; i--)   
    {
        if (s[i]=='Z')
        {
            M=i;
            break;
        }
        
    }
    cout<<M-N+1<<endl;
    
}

Measured memory_bytes: 640
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>


signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, c;
  cin >> n >> c;
  int d[c + 1][c + 1], a[n + 1][n + 1];
  for (int i = 1; i <= c; i++) {
    for (int j = 1; j <= c; j++) {
      cin >> d[i][j];
    }
  }

  vector<int> sep[3];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      sep[(i + j) % 3].push_back(a[i][j]);
    }
  }
  vector<vector<int>> after(3, vector<int>(31, 0));
  for (int i = 0; i < 3; i++) {
    for (int j = 1; j <= c; j++) {
      for (auto &el : sep[i]) {
        after[i][j] += d[el][j];
      }
    }
  }

  int ans = INT64_MAX;

  for (int i = 1; i <= c; i++) {
    for (int j = 1; j <= c; j++) {
      for (int k = 1; k <= c; k++) {
        if (i != j && j != k && k != i) {
          ans = min(ans, after[0][i] + after[1][j] + after[2][k]);
        }
      }
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 4260
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int MAXN = 1e5+2;
const int MAX = 1e9+5;
const int MOD = 1e9+7;

int main(){	
	int l, r,d; cin >> l >> r >> d;
	int ans = 0;
	for(int i = l; i <= r; ++i){
		if(i % d == 0){
			++ans;
		}
	}
	cout << ans << endl;


	return 0;
}	


Measured memory_bytes: 3604
n,m=map(int,input().split())
arr=[int(i) for i in input().split()]
hashmap=dict()
count=dict()
visited=dict()
for key in range(1,n+1):
  hashmap[key]=arr[key-1]
  count[key]=0
  visited[key]=0

for i in range(m):
  a,b=map(int,input().split())
  visited[a]+=1
  visited[b]+=1
  if hashmap[a]<hashmap[b]:
    count[a]+=1
  elif hashmap[b]<hashmap[a]:
    count[b]+=1  
  else:
    count[a]+=1
    count[b]+=1
result=0
for i in range(1,n+1):
  if visited[i]!=0 :
      if count[i]==0:
        result+=1
  else:
      result+=1      
    
print(result)    

Measured memory_bytes: 36088
#include<bits/stdc++.h>
using namespace std;
int main(){
	string str;
	getline(cin>>ws, str);
	sort(str.begin(), str.end());
	if (str[0] == str[1] && str[2] == str[3] && str[1] != str[2]){
		cout << "Yes" << endl;
	} else cout << "No" << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	char S[100010], T[100010];
	int N = 0;
	int M = 0;
	while ((S[N] = getchar_unlocked()) >= 'a') N++;
	while ((T[M] = getchar_unlocked()) >= 'a') M++;

	int n[100001][26];
	rep(i, 26) n[N - 1][i] = -1;
	for (int i = N - 1; i >= 0; i--) {
		n[N - 1][S[i] - 'a'] = i;
	}
	for (int i = N - 1; i >= 1; i--) {
		memcpy(n[i - 1], n[i], sizeof(n[i]));
		n[i - 1][S[i] - 'a'] = i;
	}

	int OK = 1;
	ll kotae = 0;
	int k = N - 1;
	rep(i, M) {
		int k2 = n[k][T[i] - 'a'];
		if (k2 == -1) {
			OK = 0;
			break;
		}

		if (k2 > k) kotae += k2 - k;
		else kotae += k2 - k + N;
		k = k2;
	}

	if (OK) printf("%lld", kotae);
	else printf("-1");

	Would you please return 0;
}

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

string s;
int a[11];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    a[i] = (int)(s[i] - '0');
  }
  for (int i = 0; i < (1 << 3); i++) {
    int sum = a[0];
    for (int j = 0; j < 3; j++) {
      if (i & (1 << j)) {
        sum += (a[j + 1]);
      } else {
        sum -= (a[j + 1]);
      }
    }
    if (sum == 7) {
      cout << a[0];
      for (int j = 0; j < 3; j++) {
        if (i & (1 << j)) cout << "+";
        else cout << "-";
        cout << a[j + 1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n, q = map(int,input().split())
Q = [0]*(n+1)
head = 0
tail = 0

def enqueue(x):
    global tail
    global Q

    Q[tail] = x
    tail += 1
    if tail == n+1:
        tail = 0

def dequeue():
    global Q
    global head

    X = Q[head]

    head += 1
    if head == n+1:
        head = 0

    return X

def main():
    global n
    global q
    global Q
    global tail
    global head

    time = 0
    cnt = 0

    que = [list(input().split()) for _ in range(n)]
    for i in range(n):
        enqueue(que[i])

    while True:
        temp = dequeue()
        if int(temp[1]) <= q:
            time += int(temp[1])
            print(temp[0] + ' ' + str(time))
            cnt += 1
        else:
            time += q
            temp[1] = str( int(temp[1]) - q )
            enqueue( temp )

        if cnt == n:
            break

main()



Measured memory_bytes: 15224
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      if ((a >= h) && (b >= w)) {
        ans++;
      }
    }

    System.out.println(ans);

  }
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,m;
  cin>>n>>m;
  vector<ll> h(n);
  cin>>h;
  vector<vector<int>> adj(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    adj[a].emplace_back(b);
    adj[b].emplace_back(a);
  }
  int ans = 0;
  rep(i,n){
    bool ok = true;
    for(auto v:adj[i]){
      if(h[i]<=h[v])ok=false;
    }
    ans += ok;
  }
  cout<<(ans)<<endl;

}

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

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

int main(){
    int data0,data1;
    int answer;
    while(cin>>data0>>data1){
        answer=gcd(data0,data1);
        cout<<answer<<" "<<data0/answer*data1<<endl;
    }
}

Measured memory_bytes: 3052
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef vector<vector<vector<char> > > vec3d;

int dxyz[26][3];

int main(){
    int n;
    int i,j,k;
    int cnt = 0;
    for(i=0;i<3;++i)
        for(j=0;j<3;++j)
            for(k=0;k<3;++k) {
                if(i==1&&j==1&&k==1) continue;
                dxyz[cnt][0] = i-1;
                dxyz[cnt][1] = j-1;
                dxyz[cnt][2] = k-1;
                cnt++;
            }

    cnt = 1;
    while(true){
        cin >> n;
        if(n == 0) break;
        vec3d cur(7, vector<vector<char> >( 7, vector<char>(7) ) );
        vec3d next(7, vector<vector<char> >( 7, vector<char>(7) ) );
        for(i=0;i<7;++i)
            for(j=0;j<7;++j)
                for(k=0;k<7;++k) { cur[i][j][k] = '0'; next[i][j][k] = '0'; }
        for(k=1;k<6;++k){
            for(j=1;j<6;++j){
                for(i=1;i<6;++i){
                    cin >> cur[i][j][k];
                }
            }
        }
        int m1, m2;
        int temp;
        set<int> a,b;
        cin >> m1;
        while(m1--) {
            cin >> temp;
            a.insert(temp);
        }
        cin >> m2;
        while(m2--) {
            cin >> temp;
            b.insert(temp);
        }
        while(n--){
            for(k=1;k<6;++k){
                for(j=1;j<6;++j){
                    for(i=1;i<6;++i){
                        int sum = 0;
                        for(int x=0;x<26;++x){
                            if( cur[i+dxyz[x][0]][j+dxyz[x][1]][k+dxyz[x][2]] == '1' ) sum++;
                        }
                        if(cur[i][j][k] == '0') {
                            if( a.find(sum) != a.end() ) next[i][j][k] = '1';
                            else next[i][j][k] = '0';
                        } else {
                            if( b.find(sum) == b.end() ) next[i][j][k] = '0';
                            else next[i][j][k] = '1';
                        }
                    }
                }
            }
            for(k=1;k<6;++k)
                for(j=1;j<6;++j)
                    for(i=1;i<6;++i)
                        cur[i][j][k] = next[i][j][k];
        }
        if(cnt > 1) cout << endl;
        cout << "Case " << (cnt++) << ":" << endl;
        for(k=1;k<6;++k){
            for(j=1;j<6;++j){
                for(i=1;i<6;++i){
                    cout << cur[i][j][k];
                }
                cout << endl;
            }
            if( k < 5 ) cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int a,n;
bool cmp(int a,int b){
	return a>b;
}
int main() {
	scanf("%d%d",&a,&n);
	printf("%d\n",a*a-n);
	return 0;
}

Measured memory_bytes: 256
def combination(n,r):
  n1,r = n+1, min(r,n-r)
  numer = denom = 1
  for i in range(1, r+1):
    numer = numer*(n1-i)
    denom = denom*i
  return numer // denom

n = int(input())
a = [int(i) for i in input().split()]

d = dict()
for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

total = 0
for i in d:
  if d[i] > 1:
    total += combination(d[i],2)

for i in a:
  ans = total - (d[i]-1)
  print(ans)

Measured memory_bytes: 26140
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var v = make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	max, min := maxAndMin(v)
	var lenOfCosts = max - min + 1
	var costs = make([]int, lenOfCosts, lenOfCosts)
	var costsIndex int = 0
	for i := min; i <= max; i++ {
		var sum int = 0
		for j := 0; j < n; j++ {
			diff := i - v[j]
			sum += (diff * diff)
		}
		costs[costsIndex] = sum
		costsIndex++
	}
	_, ans := maxAndMin(costs)
	fmt.Println(ans)
}

func maxAndMin(slice []int) (int, int) {
	var max int = 0
	var min int = slice[0]
	for _, v := range slice {
		if v > max {
			max = v
		}
		if min > v {
			min = v
		}
	}
	return max, min
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int dp[1010][1010][2];

int main() {
	int w,n,num=0;;
	while(w=in(),w){
		n=in();
		memset(dp,0,sizeof(dp));
		int a,b,i;
		for(i=0;i<n;i++){
			scanf("%d,%d",&a,&b);
			int k;
			for(k=0;k<b;k++){
				dp[i+1][k][0]=dp[i][k][0];
				dp[i+1][k][1]=dp[i][k][1];
			}
			for(k=b;k<=w;k++){
				if(dp[i][k][0]<dp[i][k-b][0]+a
				||dp[i][k][0]==dp[i][k-b][0]+a&&dp[i][k][1]>dp[i][k-b][1]+b){
					dp[i+1][k][0]=dp[i][k-b][0]+a;
					dp[i+1][k][1]=dp[i][k-b][1]+b;
				}else{
					dp[i+1][k][0]=dp[i][k][0];
					dp[i+1][k][1]=dp[i][k][1];
				}
			}
			//cout<<dp[w]<<endl;
		}
		cout<<"Case "<<++num<<":"<<endl;
		cout<<dp[n][w][0]<<endl;
		cout<<dp[n][w][1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
 
int N, K;
int dp[2010][2010];
 
int count(int y1, int x1, int y2, int x2) {
  if (y1 < 0 || y1 >= 2 * K || y2 < 0 || y2 >= 2 * K) {
    return 0;
  }
  if (x1 < 0 || x1 >= 2 * K || x2 < 0 || x2 >= 2 * K) {
    return 0;
  }
  if (y1 > y2 || x1 > x2) {
    return 0;
  }
  int res = dp[y2][x2];
  if (y1 > 0) {
    res -= dp[y1-1][x2];
  }
  if (x1 > 0) {
    res -= dp[y2][x1-1];
  }
  if (y1 > 0 && x1 > 0) {
    res += dp[y1-1][x1-1];
  }
  return res;
}
 
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x, y;
    char c;
    cin >> x >> y >> c; 
    if (c == 'W') {
      x += K;
    }
    x %= 2 * K;
    y %= 2 * K;
    dp[y][x] += 1;
  }
  for (int y = 0; y < 2 * K; y++) {
    for (int x = 0; x < 2 * K; x++) {
      if (y > 0) {
        dp[y][x] += dp[y-1][x];
      }
      if (x > 0) {
        dp[y][x] += dp[y][x-1];
      }
      if (y > 0 && x > 0) {
        dp[y][x] -= dp[y-1][x-1];
      }
    }
  }
  int res = 0;
  for (int y1 = 0; y1 + K - 1 < 2 * K; y1++) {
    for (int x1 = 0; x1 + K - 1 < 2 * K; x1++) {
      int y2 = y1 + K - 1, x2 = x1 + K - 1;
      int cnt = 0;
      cnt += count(y1, x1, y2, x2);
      cnt += count(0, 0, y1 - 1, x1 - 1);
      cnt += count(0, x2 + 1, y1 - 1, 2 * K - 1);
      cnt += count(y2 + 1, 0, 2 * K - 1, x1 - 1);
      cnt += count(y2 + 1, x2 + 1, 2 * K - 1, 2 * K - 1);
      res = max(res, cnt);
      res = max(res, N - cnt);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n; cin >> n;
    int dig = n%10;
    if(dig == 3){
        cout << "bon" << endl;
    }else if(dig == 0 || dig == 1 || dig == 6 || dig == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}

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

int main(){
    int n,m;
    vector<int> a(m,-1);

    cin>>n>>m;
    for(int i=0;i<m;i++){
      cin >> a[i];
    }
    int alldays=0;
    for(int i=0;i<m;i++){
      alldays+=a[i];
    }
    if(alldays>n){
      cout<<-1;
    }else{
      cout<<n-alldays;
    }
}

Measured memory_bytes: 3752