akhauriyash/Code-Regression huggingface dataset:
// ベクトル同じならコストかからない とするとベクトルっつーか同一直線上にあるものは同じ木に属するとして木の数を数える感じ（まずこの読解で天才みを感じる
// つっても実装がまったく浮かばない ベクトルはキメれるとして探索は？
// 1つの点に対して決め打ちしたベクトルで到達できるのはたかだか1つなのでそれがあったら0なければ1って感じか？？

package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	X, Y := make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&X[i], &Y[i])
	}
	ans := int(1e18)
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			vectorX, vectorY := X[i]-X[j], Y[i]-Y[j]
			// 今キメたベクトルでいくつ対応できるか
			tmp := 0
			for y := 0; y < N; y++ {
				flag := false
				for x := 0; x < N; x++ {
					if y == x {
						continue
					}
					if X[y]-X[x] == vectorX && Y[y]-Y[x] == vectorY {
						flag = true
						break
					}
				}
				// 対応できるのがなかったね これはコスト必須
				if !flag {
					tmp++
				}
			}
			ans = min(ans, tmp)
		}
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	char c[3][3];
	
	for(int i=0; i<3; i++)
		for(int j=0; j<3; j++)
			cin >> c[i][j];
	
	cout << c[0][0] << c[1][1] << c[2][2];
	
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for(auto v : s) {
        if(v == 'A' || v == 'C' || v == 'G' || v == 'T') {
            tmp++;
            ans = max(ans, tmp);
        }else {
            tmp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn gcd(x: i32, y: i32) -> i32 {
    if x < y {
        gcd(y, x)
    }
    else if y == 0 {
        x
    }
    else {
        gcd(y, x % y)
    }
}

fn main() {
    let n: usize = read();
    let a: Vec<i32> = read_vec();
    let mut b = vec![0; n+2];
    let mut c = vec![0; n+2];
    for i in 0..n {
        b[i + 1] = gcd(a[i], b[i]);
    }
    for i in (1..n+1).rev() {
        c[i] = gcd(a[i-1], c[i + 1]);
    }
    let mut ans = 1;
    for i in 1..n+1 {
        ans = std::cmp::max(ans, gcd(b[i-1], c[i+1]));
    }
    // println!("{:?}", b);
    // println!("{:?}", c);
    println!("{}", ans);
}

Measured memory_bytes: 6396
#include<string>
#include<cstdlib>
#include<iostream>

using namespace std;

int prior[128];

long long parse(string s)
{
	if(s[0]=='(' && s[s.length()-1]==')'){
		bool f=true;
		for(int i=1,d=1;i<s.length()-1;i++){
			if     (s[i]=='(')	d++;
			else if(s[i]==')')	d--;
			if(d==0){	f=false;	break;	}
		}
		if(f)	return parse(s.substr(1,s.length()-2));
	}

	int divprr=3,divpos=10000000;
	for(int i=s.length()-1,d=0;i>=1;i--){
		if     (s[i]==')')	d--;
		else if(s[i]=='(')	d++;

		else if(d==0 && prior[s[i]]!=0){
			if(divprr>prior[s[i]])
				divprr=prior[s[i]],divpos=i;
		}
	}

	if(divpos==10000000)	return atoll(s.c_str());

	switch(s[divpos]){
		case '+': return parse(s.substr(0,divpos)) + parse(s.substr(divpos+1));
		case '-': return parse(s.substr(0,divpos)) - parse(s.substr(divpos+1));
		case '*': return parse(s.substr(0,divpos)) * parse(s.substr(divpos+1));
		case '/': return parse(s.substr(0,divpos)) / parse(s.substr(divpos+1));
	}

	while(1);
}

int main()
{
	prior['+']=prior['-']=1;
	prior['*']=prior['/']=2;

	int n;	cin>>n;
	while(n--){
		string s;	cin>>s;
		s=s.substr(0,s.length()-1);
		cout<<parse(s)<<endl;
	}

	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  cout << min(a,b) +min(c, d) << "\n";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin>>l.at(i);
  }
  sort(l.begin(),l.end());
  
  int ans=0;
  
  for(int i=0;i<K;i++){
    ans+=l.at(N-1-i);
  }
  cout<<ans<<endl;
}


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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var N = long.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            long R = S.Where(_ => _ == 'R').Count();
            long G = S.Where(_ => _ == 'G').Count();
            long B = S.Where(_ => _ == 'B').Count();

            var ans = R * G * B;
            for(var i = 1;i<=N /2 ; i++) {
                for(var j = 0;j < N - (2 * i); j++) {
                    if(S[j] != S[j + i]&&S[j + i] != S[j + (2*i)]&&S[j]!= S[j + (2 * i)]) {
                        ans--;
                    }
                }
            }

            Console.Write(ans);
        }
    }
}

Measured memory_bytes: 28260
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n = int(input())
e = [[] for _ in range(n)]
for j in range(n - 1):
    a, b = [int(i)-1 for i in input().split()]
    e[a].append((b, j))
    e[b].append((a, j))

co = [0]*(n-1)


def dfs(i=0, r=-1, dis=-1):
    global co
    c = 1
    for j in e[i]:
        if j[0] == r:
            continue
        if c == dis:
            c += 1
        co[j[1]] = c
        dfs(j[0], i, c)
        c += 1


dfs()

print(max(co))
for i in co:
    print(i)


Measured memory_bytes: 96796
#include <stdio.h>
#include <stdlib.h>

int t8s_force_scan_int()
{
	int n;

	if (scanf("%d", &n) == EOF)
	{
		printf("expected int input but got EOF");
		exit(-1);
	}

	return n;
}

int t8s_force_read_int_array(size_t count, int** arr)
{
	*arr = (int*) malloc(count * sizeof(int));

	if (arr == NULL)
		return -1;

	for (int i=0; i<count;i++)
	{
		int n;
		scanf("%d ", &n);
		*(*arr+i) = n;
	}

	return 0;
}
void t8s_swap(int* l, int* r)
{
	int o = *l;
	*l = *r;
	*r = o;
}


int sort(int* arr, int count)
{
	int sw = 0;

	for (int i=0;i<count;i++)
	{
		int minimum = i;
		for (int j=i+1;j<count;j++)
		{
			if (arr[j] < arr[minimum])
				minimum = j;
		}

		if (arr[minimum] < arr[i]) {
			t8s_swap(&arr[minimum], &arr[i]);
			sw++;
		}
	}

	return sw;
}

void log(int* arr, int count)
{
	for (int i=0; i<count;i++)
	{
		printf("%d", arr[i]);
		if (i < count-1 )
			printf(" ");
	}
	printf("\n");
}

int main()
{
	size_t count = t8s_force_scan_int();

	int* arr;

	if (t8s_force_read_int_array(count, &arr) < 0)
		exit(-1);

	int swapCount = sort(arr, count);
	log(arr, count);
	printf("%d\n", swapCount);
	free(arr);

	return 0;
}


Measured memory_bytes: 2724
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1][1]>=l[1]:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):l=len(A);s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
n=int(input())
f=lambda x,y:(x,int(y))
A=[f(*input().split())for _ in[0]*n]
B=A[:]
k(A,0,n-1)
print(['Not s','S'][A==d(B)]+'table')
for e in A:print(*e)


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int k,s;
cin>>k>>s;
int cnt=0;

rep(x,k+1){
    rep(y,k+1){
        int z=s-x-y;
        if(0<=z &&z<=k)cnt++;
    }
}

cout<<cnt<<endl;
//system("pause");
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  long int N, a[1000000];
  long long int ans = 0;
  cin >> N;

  for (int i = 0; i < N*3; i++) cin >> a[i];
  sort(a, a + N*3, greater<int>());
  for (int i = 1; i < N*2; i += 2) ans += a[i];
  printf("%lld\n", ans);
}


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

int main() {
    int n,sum=0;
    cin>>n;

    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l.at(i);
    }

    sort(l.begin(),l.end());

    for(int i=0;i<n-1;i++){
        sum+=l.at(i);
    }

    if(sum>l.at(n-1)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B; cin >> A >> B;
    if(A == B){
        cout << "Draw" << endl;
    }
    else if(A == 1){
        cout << "Alice"  << endl;
    }
    else if(B == 1){
        cout << "Bob" << endl;
    }
    else{
        if(A > B) cout << "Alice" << endl;
        else cout << "Bob" << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    String s = scanner.nextLine();
		    
		    System.out.println(s.substring(0, 1) + (s.length()-2) 
		    		+ s.substring(s.length()-1) );
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
from itertools import combinations
import collections


N = int(input())
L = list(map(int, input().split()))
L_s = set(L)

if N < 3:
    print(0)
    exit()

ans = list(combinations(L, 3))

cnt = 0
for i in range(len(ans)):
    a = ans[i][0]
    b = ans[i][1]
    c = ans[i][2]
    if len(collections.Counter(ans[i])) != 3:
        cnt += 1
    elif not (a + b > c and b + c > a and c + a > b):
        cnt += 1

print(len(ans) - cnt)


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

using namespace std;

int main() {

	long n;
	cin >> n;
	string s;
	cin >> s;

	if (n % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	else {
		for (long i = 0; i < n/2; i++) {
			if (s[i] != s[i + n / 2]) {
				cout << "No" << endl;
				return 0;

			}
		}
	}

	cout << "Yes" << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double Do(int x)
{
	double ans = 1;
	int c = 1;
	while(c<x)
	{
		c*=2;
		ans /= 2;
	}
	return ans;
}
int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	double ans = 0;
	for(int i=1; i<=N; ++i)
		ans += Do((K+i-1)/i);
	printf("%.12lf\n", ans/N);
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s, t;
  cin >> s;
  cin >> t;

  vector< set< int > > v(26);
  for(int i = 0; i < s.length(); i++){
    v[s[i] - 'a'].insert(i);
  }

  if(v[t[0] - 'a'].empty()){
    cout << -1 << endl;
    return 0;
  }

  int i = 0, p = *(v[t[0] - 'a'].begin());
  bool found = true;
  for(int j = 1; j < t.length(); j++){
    auto it = v[t[j] - 'a'].upper_bound(p);
    if(it != v[t[j] - 'a'].end()){
      p = *it;
    } else {
      it = v[t[j] - 'a'].begin();
      if(it == v[t[j] - 'a'].end()){
        found = false;
        break;
      }
      p = *it;
      ++i;
    }
  }

  ll ans = (ll)i * s.length() + p + 1;
  if(found) cout << ans << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<map>
#include<vector>
#include<queue>

using namespace std;

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

int main() {
  vector<vector<int> > goal(2);
  rep (i, 8) goal[i / 4].push_back(i);
  map<vector<vector<int> >, int> mp;
  queue<pair<int, vector<vector<int> > > > que;
  que.push(make_pair(0, goal));
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  while (!que.empty()) {
    pair<int, vector<vector<int> > > now = que.front();
    que.pop();
    if (mp.count(now.second) != 0) continue;
    mp[now.second] = now.first;
    rep (i, 2) rep (j, 4) if (now.second[i][j] == 0) {
      rep (k, 4) {
	if (i + dy[k] < 0 || 2 <= i + dy[k]) continue;
	if (j + dx[k] < 0 || 4 <= j + dx[k]) continue;
	pair<int, vector<vector<int> > > next = now;
	next.first++;
	swap(next.second[i][j], next.second[i + dy[k]][j + dx[k]]);
	que.push(next);
      }
    }
  }
  vector<vector<int> > input(2 ,vector<int>(4));
  while (cin >> input[0][0] >> input[0][1] >> input[0][2] >> input[0][3] >> input[1][0] >> input[1][1] >> input[1][2] >> input[1][3]) cout << mp[input] << endl;
  return 0;
}

Measured memory_bytes: 5556
import java.util.*;
import java.io.*;
 
public class Main {
    static char[] alps = "abcdefghijklmnopqrstuvwxyz".toCharArray();
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] s = sc.next().toCharArray();
        int len = s.length;
        int k = sc.nextInt();
        for(int i = 0; i < len; i++){
            int changeA = (26-(s[i] - 'a')) % 26;
            if(changeA <= k){
                s[i] = 'a';
                k -= changeA;
            }else{
                continue;
            }
        }
        k %= 26;
        s[len-1] = alps[k+(s[len-1] - 'a')];
        System.out.println(new String(s));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 26708
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n, mut a: [usize; n], mut b: [usize; n]);
    let mut bi: Vec<(usize, usize)> = b.iter().enumerate().map(|(i, x)| (*x, i)).collect();
    bi.sort();
    let mut ai = vec![];
    for i in 0..n {
        ai.push((a[bi[i].1], i));
    }
    ai.sort();

    for i in 0..n {
        if ai[i].0 > bi[i].0 {
            println!("No");
            return;
        }
    }
    for i in 0..(n - 1) {
        if ai[i + 1].0 <= bi[i].0 {
            println!("Yes");
            return;
        }
    }
    let mut count = 0;
    let mut cur = 0;
    loop {
        count += 1;
        cur = ai[cur].1;
        if cur == 0 {
            break;
        }
    }
    if count < n {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 8872
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a.at(a.size() - 1) - a.at(0) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product

# input = sys.stdin.readline

D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]
ans = 10**8
for p in product((0, 1), repeat=D):
    nmax = -1
    num = 0
    total = 0
    need = 0
    for i, pi in enumerate(p):
        if pi == 1:
            num += pc[i][0]
            total += pc[i][0]*(i+1)*100 + pc[i][1]
        else:
            nmax = i
#     print(p)
#     print(nmax, num, total)
    if total < G:
        if nmax < 0:
            continue
        if total + nmax * 100 * pc[nmax][0] + pc[nmax][1] < G:
            continue
        need = math.ceil((G-total) / ((nmax+1)*100))
    ans = min(ans, num+need)
#     print(nmax, num, total, need, ans)

print(ans)





Measured memory_bytes: 27256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();
		
		System.out.printf("%f\n",Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))) ;
	}
}



Measured memory_bytes: 28152
n, k = map(int,input().split())

q = []
for i in range(n):
    q.append(list(map(int, input().split())))

q = sorted(q, key=lambda x:x[0])
cnt = 0
i = 0
while cnt < k:
    a, b = q[i]
    cnt += b
    i += 1
print(a)

Measured memory_bytes: 29420
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
  	/**
    *
    *
    */
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int inputNum = Integer.parseInt(line);
		int Num_1 = Num_reverse(inputNum - (inputNum/10)*10);
		int Num_10 = Num_reverse(inputNum/10 - (inputNum/100)*10);
		int Num_100 = Num_reverse(inputNum/100);
		
		System.out.println(Num_1 + 10*Num_10 + 100*Num_100);
	}
	public static int Num_reverse(int num) {
		if(num == 1) {
			num = 9;
		} else if (num == 9) {
			num = 1;
		}
		return num;
	}
}

Measured memory_bytes: 24532
from collections import deque
from math import ceil
 
n,d,a = map(int,input().split())
M = [list(map(int,input().split())) for i in range(n)]
M = sorted([(x,ceil(h/a)) for x,h in M])
 
que = deque()
 
ans = 0
atack = 0
for x,h in M:
  while len(que) > 0 and que[0][0] < x:
    tx,ta = que.popleft()
    atack -= ta      
  
  bomb_num = max(0, h-atack)
  atack += bomb_num
  ans += bomb_num
  
  if bomb_num > 0:
    que.append([x+d*2,bomb_num])
 
print(ans)  

Measured memory_bytes: 68384
#include <iostream>
#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    int n;
    string s1;
    string s2;
    LL ans=1;
    vector<int> pat;

    cin >> n;
    cin >> s1;
    cin >> s2;

    int i=0;
    while(i<n){
        if(s1[i]==s2[i]){
            pat.push_back(1);
            i++;
        }else{
            pat.push_back(0);
            i+=2;
        }
    }

    if(pat[0]==0){
        ans=ans*3*2;
    }else{
        ans=ans*3;
    }

    //for(int i=0; i<pat.size(); i++){
    //    cout << pat[i];
    //}
    //cout << endl;

    for(int i=1; i<pat.size(); i++){
        if(pat[i-1]==0){
            if(pat[i]==0){
                ans=(ans*3)%MOD;
            }else{
                ans=ans%MOD;
            }
        }else{
            ans=(ans*2)%MOD;
        }
        //cout << i << " " << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int x = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                x += array[i];
            } else {
                x -= array[i];
            }
        }
        
        x /= 2;
        
        int[] ans = new int[n];
        ans[0] = x;
        for (int i = 1; i < n; i++) {
            ans[i] = array[i-1] - ans[i-1];
        }
        
        for (int i = 0; i < n; i++) {
            ans[i] *= 2;
            if (i != n - 1) {
                System.out.print(ans[i] + " ");
            } else {
                System.out.println(ans[i]);
            }
        }
    }
}


Measured memory_bytes: 64520
#include <iostream>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

//aのn乗をMODで割った余りを求める関数
ll mypow(ll a, ll n){
    ll ans = 1;
    for(ll i = 0; i < n; i++){
        ans *= a;
        ans %= MOD;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    ll ans = mypow(10, n) - mypow(9, n) - mypow(9, n) + mypow(8, n);
    //ansが負の数になっている可能性を考慮し　正の数になるよう適当な数を足す
    ans += MOD*2;
    //改めてMODで割った余りを求める
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 10000000000000


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

template<class T>
bool inline ChangeMinimum( T &a, T b )
{
	if( a > b ){
		a = b;
		return true;
	}
	return false;
}

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

template<class T>
class Vec3
{
	public:
		T act[3];
};

int main(void) {


	string S;
	string T;
	INPUT(S);
	INPUT(T);
	int ans = 0;
	REPEAT(i,3){
		if( S[i] == T[i] ) ans++;
	}





	OUTPUT(ans);
		
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/


int main(void) {
	

	int a, b;
	sca(a);
	sca(b);
	if (a >= b) {
		rep(i, a) {
			printf("%d", b);
		}
	}
	else {
		rep(i, b) {
			printf("%d", a);
		}
	}




	return 0;
}

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

int main() {
	string s;
	cin >> s;

	if (s[0] != s[1] && s[0] != s[2] && s[1] != s[2]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int r,c,sum,total_sum = 0;
    scanf("%d %d",&r,&c);
    int table[r+1][c+1];
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            table[i][j] = 0;
        }
    }
 
    for(int i = 0; i < r; i++){
        sum = 0;
        for(int j = 0; j < c; j++){
            scanf("%d",&table[i][j]);
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        total_sum += sum;
    }
    table[r][c] = total_sum;
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            printf("%d ",table[i][j]);
        }
        printf("%d\n",table[i][c]);
    }
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,q,x,y,l,r,flag = 0,h,m,n,k;
    cin>>x>>y;
    cout<<x*y;
}

Measured memory_bytes: 3588
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
std::vector<ll> v[100002];
ll visited[100002];
void dfs(ll x)
{
	visited[x]=1;
	for (int i = 0; i < v[x].size(); ++i)
	{
		if(visited[v[x][i]]==0)
		{
			dfs(v[x][i]);
		}
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    ll x=0;
    for (int i =1; i <=n; ++i)
    {
    	if(visited[i]==0)
    	{
    		dfs(i);
    		x++;
    	}
    }
    cout<<x<<'\n';

}


Measured memory_bytes: 9600
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def dfs(graph, edgs, now, ret):
    edgs[now] = True
    if all(edgs): ret += 1

    for next in graph[now]:
        if edgs[next]: continue
        ret = dfs(graph, edgs, next, ret)
    edgs[now] = False
    return ret


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    g = {n: [] for n in range(N)}
    for m in range(M):
        a, b = il()
        g[a - 1].append(b - 1)
        g[b - 1].append(a - 1)

    ret = 0
    edgs = [False] * N
    edgs[0] = True
    ret = dfs(g, edgs, 0, ret)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
const ll maxi =20000;
#define ip pair<ll,ll>
#define mp make_pair
int main()
{ 
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

int n;
cin>>n;


string s;
cin>>s;


ll lastred=-1;
ll firstwhite=-1;

for(ll i=0;i<n;i++)
{
  if(firstwhite==-1&&s[i]=='W'){firstwhite=i;}
  if(s[i]=='R'){lastred=i;}

}
ll op=0;
ll i=firstwhite;
ll j=lastred;

while(i<j)
{
  if(s[i]=='W'&&s[j]=='R'){op++;
    j--;i++;}

  if(s[i]!='W'){i++;}
  if(s[j]!='R'){j--;}  
}
cout<<op<<endl;

}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 100000;
int n, k, s[M], t[M], c[M];
int d[30][M + 1];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> s[i] >> t[i] >> c[i]; s[i]--; c[i]--; }
	
	inc(i, n) {
		d[c[i]][s[i]]++;
		d[c[i]][t[i]]--;
	}
	inc(i, k) {
		inc1(j, M) { d[i][j] += d[i][j - 1]; }
		incII(j, 0, M) { setmin(d[i][j], 1); }
	}
	
	int ans = 0;
	incII(j, 0, M) {
		int m = 0;
		inc(i, k) { m += d[i][j]; }
		setmax(ans, m);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 13184
class Node():
    def __init__(self,num,next=None,prev=None):
        self.num=num
        self.next=next
        self.prev=prev
class Doubly():
    def __init__(self):
        self.start=self.end=None
    def insert(self,x):
        it=Node(x)
        if self.end is None:
            self.end=self.start=it
        else:
            it.next=self.start
            self.start.prev=it
            self.start=it
    def delete(self,x):
        poin=self.start
        while(poin is not None):
            if poin.num==x:
                if poin.prev is None and poin.next is None:
                    self.start = self.end = None
                elif poin is self.start:#先頭
                    self.start.next.prev=None
                    self.start=poin.next
                elif poin is self.end:#末尾
                    poin.prev.next =None
                    self.end=poin.prev
                else:
                    poin.prev.next=poin.next
                    poin.next.prev=poin.prev
                break
            poin=poin.next
    # def deleteFirst(self):
    #     self.start=self.start.next
    # def deleteLast(self):
    #     self.end.prev.next =None
    #     self.end=self.end.prev
    def deleteFirst(self):
        if self.start is self.end:
            self.start = self.end = None
        else:
            self.start.next.prev = None
            self.start = self.start.next
    def deleteLast(self):
        if self.start is self.end:
            self.start = self.end = None
        else:
            self.end.prev.next = None
            self.end = self.end.prev
    def print(self):
        var=self.start
        lis=[]
        while var is not None:
            lis.append(var.num)
            var = var.next
        return ' '.join(lis)
from sys import stdin
N=int(input())
DB=Doubly()
# code=[input().split() for k in range(N)]
# for _ in range(N):
#     c=input().split()
#     if len(c)==1:
#         eval('DB.'+c[0]+'()')
#     else:
#         eval('DB.'+c[0]+'(c[1])')
for _ in range(N):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            DB.insert(cmd[1])
        elif cmd[0] == 'delete':
            DB.delete(cmd[1])
        elif cmd[0] == 'deleteFirst':
            DB.deleteFirst()
        elif cmd[0] == 'deleteLast':
            DB.deleteLast()
print(DB.print())


Measured memory_bytes: 227796
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    string s[N];
    for(ll i = 0; i < N; i++) cin >>s[i];
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        string t[N];
        bool ok = 1;
        for(ll j = 0; j < N; j++) t[j] = (s[j] + s[j]).substr(i, N);
        for(ll j = 0; j < N; j++) for(ll k = 0; k < N; k++) if(t[k][j] != t[j][k]) ok = 0;
        if(ok) ans += N;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<complex>
#include<vector>
#include<cstdio>
#include<string>
#include<bitset>
#include<ctime>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define Cpy(x,y) memcpy(x,y,sizeof(x))
#define Set(x,y) memset(x,y,sizeof(x))
#define FILE "a"
#define mp make_pair
#define pb push_back
#define RG register
#define il inline
using namespace std;
typedef unsigned long long ull;
typedef vector<int>VI;
typedef long long ll;
typedef double dd;
const int N=1<<17;
const int mod=998244353;
const int base=26;
const dd eps=1e-6;
const int inf=2147483647;
const ll INF=1ll<<60;
const ll P=100000;
il ll read(){
  RG ll data=0,w=1;RG char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}

il void file(){
  srand(time(NULL)+rand());
  freopen(FILE".in","r",stdin);
  freopen(FILE".out","w",stdout);
}

int n,m;ll sz[N],o[N];
struct node{ll d,id;}t[N];
bool cmp_d(node a,node b){return a.d<b.d;}
bool cmp_id(node a,node b){return a.id<b.id;}
il void er(){puts("-1");exit(0);}
struct edge{int u,v;}E[N];

int head[N],nxt[N<<1],to[N<<1],cnt;
il void add(int u,int v){to[++cnt]=v;nxt[cnt]=head[u];head[u]=cnt;}
ll up[N],down[N],w[N];
void dfs1(int u,int ff){
  sz[u]=1;
  for(RG int i=head[u];i;i=nxt[i]){
    RG int v=to[i];if(v==ff)continue;
    dfs1(v,u);sz[u]+=sz[v];
    up[u]+=up[v]+sz[v];
  }
}
void dfs2(int u,int ff){
  for(RG int i=head[u];i;i=nxt[i]){
    RG int v=to[i];if(v==ff)continue;
    down[v]=down[u]+up[u]-(up[v]+sz[v])+(n-sz[v]);
    dfs2(v,u);
  }
}

int main()
{
  n=read();
  for(RG int i=1;i<=n;i++){t[i].d=read();t[i].id=i;}
  sort(t+1,t+n+1,cmp_d);
  for(RG int i=1;i<=n;i++)o[i]=t[i].d,sz[i]=1;
  for(RG int i=n,p;i!=1;i--){
    p=lower_bound(o+1,o+n+1,t[i].d-n+2ll*sz[i])-o;
    if(o[p]!=t[i].d-n+2ll*sz[i]||p>=i)er();
    E[++m]=(edge){t[p].id,t[i].id};sz[p]+=sz[i];
  }
  for(RG int i=1;i<=m;i++)add(E[i].u,E[i].v),add(E[i].v,E[i].u);
  dfs1(1,0);dfs2(1,0);sort(t+1,t+n+1,cmp_id);
  for(RG int i=1;i<=n;i++)w[i]=down[i]+up[i];
  for(RG int i=1;i<=n;i++)if(w[i]!=t[i].d)er();
  for(RG int i=1;i<=m;i++)printf("%d %d\n",E[i].u,E[i].v);
  return 0;
}


Measured memory_bytes: 16000
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<char>al(26);
	al = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	string S;
	cin >> S;
	int Z = S.size();
	if (S[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	int cnt = 0;
	for (int i = 2; i <= Z - 2; i++) {
		if (S[i] == 'C') {
			cnt++;
		}
	}
	if (cnt != 1) {
		cout << "WA" << endl;
		return 0;
	}
	cnt = 0;
	rep(i, Z) {
		rep(j, 26) {
			if (S[i] == al[j]) {
				cnt++;
			}
		}
	}
	if (cnt != Z - 2) {
		cout << "WA" << endl;
		return 0;
	}
	cout << "AC" << endl;
}

Measured memory_bytes: 256
from math import *
a, b, h, m = map(int, input().split())
h = (30*h + 0.5*m) * pi/180 #rad
m = 6*m * pi/180
theta = min(abs(h-m), 360-abs(h-m))
ans = sqrt(a**2 + b**2 - 2*a*b*cos(theta))
print(ans)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }


int main() {
  long long n; cin>>n;
  vector<long long> a(n);
  rep(i, n) cin>>a[i];
  vector<long long> s(200010, 0);
  rep(i, n) ++s[a[i]];
  long long ans = 0;
  rep(i, 200010) {
    ans += s[i]*(s[i]-1)/2;
  }

  rep(i, n) {
    long long k = a[i];
    long long t = (s[k]-1)*(s[k]-2)/2;
    print(ans-(s[k]*(s[k]-1)/2)+t);
  }

  return 0;
}

Measured memory_bytes: 5760
n,d = gets.split.map(&:to_i)
xs = []
n.times do
  xs << gets.split.map(&:to_i)
end
ans = 0

xs.each.with_index do |x,i|
  (i+1..n-1).each do |j|
    x2 = xs[j]
    total = 0
    x.each.with_index do |d,k|
      total += (d-x2[k]).abs ** 2
    end
    if Math.sqrt(total) % 1 == 0
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>

int main(){
    using namespace std;
    
    vector<size_t> G{2391484, 797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1};
    
    // input
    size_t n;
    cin >> n;
    vector<unsigned long> A(n);
    for(auto& i : A)cin >> i;
    if(n == 1)return 0 & puts("1\n1\n0\n1");
    
    // process
    unsigned long cnt{0};
    cout << lower_bound(G.rbegin(), G.rend(), n) - G.rbegin() << endl;
    for(const auto& g : G)if(g < n){
        cout << g << " \n"[g == 1];
        for(size_t i = g; i < n; ++i)for(size_t j = i; j >= g && A[j - g] > A[j]; j -= g, ++cnt)swap(A[j], A[j - g]);
    }
    cout << cnt << endl;
    for(const auto& a : A)cout << a << endl;
}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B;
  cin >> A >> B;
  if(A + B >= 10){
    cout << "error" << endl;
  }
  else{
    cout << A + B << endl;
  }
}

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

int main(){
  int n,a = 0;
  cin >> n;
  int max,max_n = 0;
  int sum = 0; 
  for(int i=0;i<n;++i){
    cin >> a;
    sum += a;
    if(max < a) max = a;
  }
  sum -= max/2;
  cout << sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	string N;
	cin >> N;
	if(N[0] == '9' || N[1] == '9'){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
i64 N, A, B;
int main()
{
    scanf("%lld%lld%lld", &N, &A, &B);
    printf("%lld\n", (B-A)&1?min(A, N+1-B)+(B-A-1)/2:(B-A)/2);
    return 0;
}

Measured memory_bytes: 3796
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

H, W = getNM()
maze = [input() for i in range(H)]

dict = defaultdict(int)
for i in range(H):
    for s in maze[i]:
        dict[s] += 1

one_cnt = 0
two_cnt = 0
for i in dict.items():
    opt = i[1] % 4
    if opt == 1:
        one_cnt += 1
    elif opt == 2:
        two_cnt += 1
    elif opt == 3:
        one_cnt += 1
        two_cnt += 1

# 両方奇数
if H % 2 != 0 and W % 2 != 0:
    if one_cnt > 1 or two_cnt > H // 2 + W // 2:
        print('No')
        exit()
# Hが奇数
elif H % 2 != 0 and W % 2 == 0:
    if one_cnt > 0 or two_cnt > W // 2:
        print('No')
        exit()
# Wが奇数
elif H % 2 == 0 and W % 2 != 0:
    if one_cnt > 0 or two_cnt > H // 2:
        print('No')
        exit()
# 両方偶数
else:
    if one_cnt > 0 or two_cnt > 0:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 10812