akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
const int MAX_A = 1e6+5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> dp(MAX_A, 0);
  for (int x : a) {
    if (dp[x] != 0) {
      dp[x] = 2;
      continue;
    }
    for (int i = x; i < MAX_A; i += x) ++dp[i];
  }
  int ans = 0;
  for (int x : a) {
    if (dp[x] == 1) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7912
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }//自身がparentのグループを作る

        bool same(int x, int y){
            return findSet(x) == findSet(y); //x,yが同じグループに属しているか判定
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }//xとyの属するsetを結合する

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if( rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }//rankが大きい方の下にrankが小さいものをくっつける

        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }//再帰的にxの親を見つけている
};

int main(){
    int n, m, ans = 0;
    bool flag = 0;
    cin >> n >> m;
    ans = n;
    int x, y ,z;
    DisjointSet ds = DisjointSet(n);
    for(int i = 0; i < m; i++){
        cin >> x >> y >> z;
        if(ds.same(x-1,y-1) == false){
            ds.unite(x-1,y-1);
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
int i;
int k=1;


/* while(1)ということで、特に何も条件はないが繰り返し処理を続けるということ。*/
while(1){
     scanf("%d",&i);
     if (i == 0)  /* 0が入力されたらbreakする。*/
       break ;

     printf("Case %d: %d\n",k,i) ;
     k++ ;
     }
return 0 ;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;
template <typename T>
T calc_gcd(T x, T y) {
  if (y == 0) return x;
  return calc_gcd(y, x % y);
}

template <typename T>
T calc_lcm(T x, T y) { return (x / calc_gcd(y, x % y)) * y; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
string s,t;
cin>>s>>t;
ll num=calc_lcm(s.size(),t.size());
map<int,char> x;
rep(i,n){
    int idx=1+i*(num/n);
    x[idx]=s[i];
}
rep(i,m){
    int idx=1+i*(num/m);
    if(x.count(idx)&&x[idx]!=t[i]){
        num=-1;
        break;
    }
    x[idx]=t[i];
}
cout<<num<<endl;
return 0;
}

Measured memory_bytes: 11472
#include<bits/stdc++.h>
using namespace std;
long long n[100005];
int i=0;
void f(long long m){
    if (m>3234566667) return;
    n[i]=m;i++;
    if(m%10==0){
        f(m*10+1);
        f(m*10);
    }
    else if(m%10==9){
        f(m*10+9);
        f(m*10+8);
    }
    else{
        f(m*10+m%10);f(m*10+m%10+1);f(m*10+m%10-1);
    }
}
int main(){
    f(1);f(2);f(3);f(4);f(5);f(6);f(7);f(8);f(9);
    int k;
    scanf("%d",&k);
    sort(n,n+100000);
    printf("%lld",n[k-1]);
    return 0;
}

Measured memory_bytes: 1024
import sys

#f = open("test.txt", "r")
f = sys.stdin

num_rank = 14
s_list = [False] * num_rank
h_list = [False] * num_rank
c_list = [False] * num_rank
d_list = [False] * num_rank

n = f.readline()

n = int(n)

for i in range(n):
	[suit, num] = f.readline().split()
	num = int(num)
	if suit == "S":
		s_list[num] = True
	elif suit == "H":
		h_list[num] = True
	elif suit == "C":
		c_list[num] = True
	else:
		d_list[num] = True

for i in range(1, num_rank):
	if not s_list[i]:
		print("S " + str(i))
for i in range(1, num_rank):
	if not h_list[i]:
		print("H " + str(i))
for i in range(1, num_rank):
	if not c_list[i]:
		print("C " + str(i))
for i in range(1, num_rank):
	if not d_list[i]:
		print("D " + str(i))

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#include <future>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

int main()
{
	ll n, k, ans = 0;
	cin >> n>>k;
	vi v(n);
	REP(i, n) cin >> v[i];
	REP(i, v.size())
	{
		ans += (min(abs(k - v[i]), v[i])) * 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

ll n, m, a;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	vector<vector<ll>> A;
	
	rep(i, 0, n){
		vector<ll> tmp;
		A.push_back(tmp);
		rep(j, 0, m){
			cin >> a;
			A[i].push_back(a-1);
		}
	}
	
	ll ans = n;
	set<ll> use;
	rep(j, 0, m){
		ll cnt[m];
		memset(cnt, 0, sizeof(cnt));
		
		rep(i, 0, n){
			while(use.find(A[i][0]) != use.end()){
				A[i].erase(A[i].begin());
			}
			cnt[A[i][0]]++;
		}
		
		ll at = -1;
		ll mx = 0;
		rep(i, 0, n){
			if(cnt[A[i][0]] > mx){
				at = A[i][0];
				mx = cnt[at];
			}
		}
		
		ans = min(mx, ans);
		use.insert(at);
	}
	
	print(ans)
	return 0;
}

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

using namespace std;
#define INF 999999999
int D[21][21];

void solve()
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < n; ++j)
		{
			i == j ? D[i][i] = 0 : D[i][j] = INF;
		}
	}
	for(int i = 0; i < m; ++i)
	{
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		--a; --b;
		D[a][b] = c;
		D[b][a] = d;
	}
	int start, end;
	int reward, pillar;
	scanf("%d,%d,%d,%d", &start, &end, &reward, &pillar);
	for(int k = 0; k < n; ++k)
	{
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
	cout << reward - pillar - D[start - 1][end - 1] - D[end - 1][start - 1] << endl;
}

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

Measured memory_bytes: 0
n=int(input())
prime=[2,3]
ans=[]
for i in range(4,55556):
  for j in range(2,int(i**0.5)+1):
    if i%j==0:
      break
  else:
    prime.append(i)
for i in prime:
  if i%5==1:
    ans.append(i)
print(*ans[:n])

Measured memory_bytes: 3444
import java.util.*;
public class Main {
	static int N, A[];
	static List X;
	static boolean mujun;
	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];

		X = new ArrayList<ArrayList<int[]>>();
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
			List tmp = new ArrayList<int[]>();
			for(int j=0;j<A[i];j++) {
				int x = sc.nextInt() - 1; //人だけ０スタートにする
				int y = sc.nextInt();
				int t[] = {x, y};
				tmp.add(t);
			}	
			X.add(tmp);
		}
		sc.close();
		int ans = 0;
		for(int bit=0;bit<(1<<N);bit++) {
			//0bbitが全員のフラグを表す
			mujun = false;
			for(int i=0;i<N;i++) {
				if(((bit>>i)&1)==1) {
					List tmp = (List)X.get(i);
					for(int j=0;j<A[i];j++) {
						int judge[] = (int[])tmp.get(j); 
						int toPerson = judge[0];
						int toHonest = judge[1];
						if(((bit>>toPerson)&1)!=toHonest) {
							mujun = true;
							break;
						}
					}
				}
			}
			if(mujun)continue;
			ans = Math.max(ans,Integer.bitCount(bit));
		}
		
		
		System.out.println(ans);
	}
	
	
}

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

class Program
{
    static void Main()
    {
        int R = int.Parse(Console.ReadLine());

        string ans = "";
        if (R < 1200)
        {
            ans = "ABC";

        }
        else if (R < 2800)
        {
            ans = "ARC";
        }
        else
        {
            ans = "AGC";
        }
        Console.WriteLine(ans);
    }
    
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if((a<=c&&c<=b)||(b<=c&&c<=a)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


int main(){
    int n;
    cin >> n;
    bool flag = 1;
    long long h0 = 0;
    for(int i=0; i<n && flag==1; i++){
        long long h1; cin >> h1;
        if(h1>h0) h1 --;
        else if(h1==h0);
        else if(h1<h0) flag = 0;
        h0 = h1;
    }
    cout << (flag?"Yes":"No") << endl;
}

Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
const ll mod = 1000000007;
const ll mod9 = 1000000009;

signed main(){
    ll a;
    string b;
    cin>>a>>b;
    ll bb = (b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
    ll ans = a*bb/100;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int INF = 1e5;
int H, W;
char maze[60][60];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int d[60][60];

int bfs(){
  queue<P> que;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      d[i][j] = INF;
    }
  }
  que.push(P(0, 0));
  d[0][0] = 0;
  while(que.size()){
    P p = que.front(); que.pop();
    if(p.first==H-1 && p.second==W-1) break;
    for(int i=0; i<4; i++){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  if(d[H-1][W-1]!=INF) return d[H-1][W-1] + 1;
  return -1;
}

int main(){
  cin >> H >> W;
  int bl;
  for(int i=0; i<H; i++){
    string s; cin >> s;
    for(int j=0; j<W; j++){
      maze[i][j] = s[j];
      if(maze[i][j]=='#') bl++;
    }
  }
  int paint = bfs();
  if(paint==-1){
    cout << paint << endl;
  }
  else{
    cout << H*W - paint - bl << endl;
  }
}

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

void solve(long long N, std::vector<long long> A){
    map<ll,ll> count;
    for (ll i=0;i<N;i++){
        count[A[i]]++;
    }
    ll whole_count = 0;
    for (auto const kv : count){
        whole_count += (kv.second * (kv.second-1))/2;
    }
    for (ll i=0;i<N;i++){
        ll orig_count = (count[A[i]]*(count[A[i]]-1) )/2;
        ll new_count = max(0LL, ((count[A[i]]-1 ) * (count[A[i]]-2)) /2 ) ;
        printf("%lld\n",whole_count - orig_count+ new_count  ) ;
    }


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  int ans = n / 2;
  char c = s[n / 2];
  for (int i = n / 2; i < n; i++) {
    if (s[i] == c && s[n - 1 - i] == c) {
      ans++;
    } else {
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;
const ll INFLL = 1001001001001001001LL;


template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }


int main() {


	
	int A,B;

	scanf("%d %d", &A,&B);
	
	--A;
	--B;

	printf("100 100\n");

	int h = 1;
	for (int i = 1; i <= 48; i++) {
		for (int j = 1; j <= 100; ++j) {
			if (i % 2 == 0 || j % 2 == 0) {
				printf("#");
			}
			else {
				if (A > 0) {
					--A;
					printf(".");
				}
				else {
					printf("#");
				}
			}
		}
		printf("\n");
		++h;
	}
	for (int j = 1; j <= 100; j++) {
		printf(".");
	}
	printf("\n");
	for (int j = 1; j <= 100; j++) {
		printf(".");
	}
	printf("\n");


	
	for (int i = 51; i <= 100; i++) {
		for (int j = 1; j <= 100; ++j) {
			if (i % 2 == 0 || j % 2 == 0) {
				printf(".");
			}
			else {
				if (B > 0) {
					--B;
					printf("#");
				}
				else {
					printf(".");
				}
			}
		}
		printf("\n");
		++h;
	}





	return 0;
}

Measured memory_bytes: 256
n = int(input())
heap = list(map(int, input().split()))
for i in range(len(heap)):
    out = 'node {}: key = {}, '.format(i + 1, heap[i])
    parent = (i - 1) // 2
    out += 'parent key = {}, '.format(heap[parent]) if parent >= 0 else ''
    left = 2 * i + 1
    out += 'left key = {}, '.format(heap[left]) if left < len(heap) else ''
    right = 2 * i +2
    out += 'right key = {}, '.format(heap[right]) if right < len(heap) else ''
    print(out)


Measured memory_bytes: 5612
#[test]
fn test_solve() {
    assert_eq!(solve("6\n0 1 2 3 4 5\n"), "3\n");
    assert_eq!(solve("3\n0 0 0\n"), "6\n");
    assert_eq!(solve("54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17\n"), "115295190\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    let mut x = 0;
    let mut y = 0;
    let mut z = 0;
    let mut ans = Finite(1);
    for &a in &a {
        ans *= [x, y, z].iter().filter(|&&x| x == a).count() as u64;

        if a == x {
            x += 1;
        } else if a == y {
            y += 1;
        } else if a == z {
            z += 1;
        } else {
            return "0\n".to_string();
        }
    }

    format!("{}\n", ans)
}

const MOD: u64 = 1_000_000_007;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct Finite(u64);
impl std::fmt::Display for Finite {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
impl std::ops::MulAssign<u64> for Finite {
    fn mul_assign(&mut self, rhs: u64) {
        self.0 *= rhs;
        self.0 %= MOD;
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >> B;
    
    for(int i=1;i<21;i++){
        if (B == 1){
          cout << 0 << endl;
          break;
        }
        else if (i * A - (i - 1) >= B){
            cout << i << endl;
            break;
        }
    }
    
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = 1
    if ans[x-1] == 0:
      ball[x-1] = 0
      
print(sum(ball))

Measured memory_bytes: 28836
import java.io.*;
import  java.util.*;
import static java.lang.System.in;

public class Main{
    static int n,m;
    static long[] head,pos;
    static long mod = 1000000000+7;
    static long[][][][][] dp;
    static HashSet<String> wrong = new HashSet<>();
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n==3){
            System.out.println(61);
            return;
        }
        dp = new long[115][4][4][4][4];
        for(int i=0;i<115;i++){
            for(int a=0;a<4;a++){
                for(int b=0;b<4;b++){
                    for(int c=0;c<4;c++) Arrays.fill(dp[i][a][b][c],-1);
                }
            }
        }
        wrong.add("012");
        wrong.add("021");
        wrong.add("201");
        for(int i=0;i<4;i++) {
            wrong.add(String.format("%d%d%d%d",0,i,2,1));
            wrong.add(String.format("%d%d%d%d",0,2,i,1));
        }
        long ans = 0;
        for(int a=0;a<4;a++){
            for(int b=0;b<4;b++){
                for(int c=0;c<4;c++) {
                    for(int d=0;d<4;d++) ans = (ans+dfs(n-3,a,b,c,d))%mod;
                }
            }
        }
        System.out.println(ans);
    }
    static long dfs(int idx, int a, int b, int c, int d){
        if(dp[idx][a][b][c][d]>=0) return dp[idx][a][b][c][d];
        if(!check(a,b,c,d)) return dp[idx][a][b][c][d] = 0;
        if(idx==1) return dp[idx][a][b][c][d]=1;
        long ans = 0;
        for(int i=0;i<4;i++) ans += dfs(idx-1,i,a,b,c);
        ans %= mod;
        return dp[idx][a][b][c][d] = ans;
    }
    static boolean check(int a, int b, int c, int d){
        String cur = String.format("%d%d%d%d",a,b,c,d);
        for(String w:wrong){
            int idx = cur.indexOf(w);
            if(idx>=0) return false;
        }
        return true;
    }
}


Measured memory_bytes: 51272
$N, $A, $B, $C = gets.split.map(&:to_i)
$l = []
$N.times do
  $l << gets.to_i
end
$INF = 10 ** 9


def dfs(cur, a, b, c)
  if cur == $N
    if [a, b, c].min > 0
      return (a - $A).abs + (b - $B).abs + (c - $C).abs - 30
    else
      return $INF
    end
  end

  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + $l[cur], b , c) + 10
  ret2 = dfs(cur + 1, a, b + $l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + $l[cur]) + 10

  [ret0, ret1, ret2, ret3].min
end

puts dfs(0, 0, 0, 0)

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<char, set<int>> pp;
  map<char, set<int>> sp;
  for (int i = 0; i < n; ++i) {
    sp[s[i]].insert(i);
  }
  int64_t ans = 0;
  auto calc = [&] (char c1, char c2, int i) {
    int res = 0;
    for (int it = 0; it < 2; it++) {
      for (int x : pp[c1]) {
        res += (int) sp[c2].size();
        if (sp[c2].count(i + (i - x))) {
          res--;
        }
      }
      swap(c1, c2);
    }
    return res;
  };
  for (int i = 0; i < n; ++i) {
    sp[s[i]].erase(i);
    if (s[i] == 'R') {
      ans += calc('G', 'B', i);
    }
    else if (s[i] == 'G') {
      ans += calc('R', 'B', i);
    }
    else {
      ans += calc('R', 'G', i);
    }
    pp[s[i]].insert(i);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[100010],len[100010];
ll root(ll n){
  if(par[n]==n)return n;
  return par[n]=root(par[n]);
}
int main(){
  ll n,m;cin>>n>>m;
  ll a[m],b[m];
  for(ll i=0;i<m;i++)cin>>a[i]>>b[i];
  for(ll i=1;i<=n;i++){
    par[i]=i;
    len[i]=1;
  }
  ll ans=(n*(n-1))/2;
  ll sum=0;
  vector<ll> v;
  ll ss=0;
  v.push_back(ans-sum);
  for(ll i=m-1;i>0;i--){
    ll ra=root(a[i]);
    ll rb=root(b[i]);
    
    if(ra==rb){
      v.push_back(ans-sum);
      continue;
    }
    ss++;
    if(ss==n-1){
      for(ll j=0;j<i;j++)v.push_back((ll)0);
      break;
    }
    if(len[ra]==1){
      if(len[rb]==1){
        sum++;
        par[ra]=rb;
        len[rb]++;
         v.push_back(ans-sum);
      }
      else{
        par[ra]=rb;
        ll u=len[rb];
        sum+=u;
        len[rb]++;
         v.push_back(ans-sum);
      }
    }
    else{
      if(len[rb]==1){
        par[rb]=ra;
        sum+=len[ra];
        len[ra]++;
         v.push_back(ans-sum);
      }
      else{
        ll p=len[ra],q=len[rb];
        if(p>q){
          par[rb]=ra;
          len[ra]+=q;
        }
        else{
          par[ra]=rb;
          len[rb]+=p;
        }
        sum+=((p+q)*(p+q-1))/2-(p*(p-1))/2-(q*(q-1))/2;
         v.push_back(ans-sum);
      }
    }
        
  }
  for(ll i=v.size()-1;i>=0;i--)cout<<v[i]<<endl;
}

Measured memory_bytes: 5364
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	double i,n,n1,c=0;
	long long nn;
	cin>>n;
	nn=100;
	while(1){
		nn=nn*1.01;
		c++;
		if(nn>=n){
			printf("%.0lf\n",c);
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if (A > B) swap(A, B);
    if (B > C) swap(B, C);
    if (A > B) swap(A, B);
    if (A % 2 == 1 && B % 2 == 1 && C % 2 == 1) {
        cout << A * B << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
 
using namespace std;
 
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)

int dp[50];

int f(int n) {
    if(n == 0 || n == 1) return 1;
    if(dp[n]) {
        return dp[n];
    } else {
        return dp[n] = f(n-1) + f(n-2);
    }
}

int main() {
    int n;
    cin >> n;
    cout << f(n) << endl;
}

Measured memory_bytes: 1164
N = int(input())
s = [int(input()) for i in range(N)]

S = sum(s)
if S % 10 != 0:
    print(S)
else:
    s.sort()
    ans = S
    flag = False
    for x in s:
        if x % 10 != 0:
            ans -= x
            flag = True
            break
        else:
            continue
    if flag:
        print(ans)
    else:
        print(0)


Measured memory_bytes: 3060
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
bool h = false;
ll reg1 = 0;
bool judge(ll x){
    cout << x << endl;
    string s;
    cin >> s;
    ll reg;
    if (s == "Vacant"){
        h = true;
        return 0;
    }else if(s=="Male"){
        reg = ((1 + (x) % 2) % 2);
    }else{
        reg = (( (x) % 2) % 2);
    }
    return reg == reg1;
}
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
ll combi(ll a, ll b)
{
    if (a < b)
        return 0;
    ll res = 1;
    for (ll i = a; i >= a - b + 1; i--)
    {
        res *= i;
        res %= MOD;
    }
    rep3(i, 1, b + 1)
    {
        res *= modinv(i, MOD);
        res %= MOD;
    }
    return res;
}
//a,m=MOD MOD逆元
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin>>k;
    cout << 50 << endl;
    V vec(50, 49);
    rep(i,50){
        vec[i] += k / 50;
    }
    rep(i,k%50){
        vec[i]++;
    }
    rep3(i,k%50,50){
        vec[i]-=(k%50);
    }
    rep(i,50){
        cout << vec[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

void dfs(int i, int j, vector< vector<int> >& a) {
	a[i][j] = false;
	for (int di = -1; di <= 1; di++)
		for (int dj = -1; dj <= 1; dj++)
			if (a[i + di][j + dj]) dfs(i + di, j + dj, a);
}

int main() {
	for (;;) {
		int w, h; cin >> w >> h;
		if (w == 0 && h == 0) break;
		vector< vector<int> > a(h + 2, vector<int>(w + 2));
		for (int i = 1; i <= h; i++)
			for (int j = 1; j <= w; j++)
				cin >> a[i][j];
		int cnt = 0;
		for (int i = 1; i <= h; i++)
			for (int j = 1; j <= w; j++)
				if (a[i][j]) {
					cnt++;
					dfs(i, j, a);
				}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1412
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i, total = 0, x, y;
    int n;
    scanf("%d", &n);

    x = n;
    while (x / 10 > 0)
    {
        y = x % 10;
        x = x / 10;
        total += y;
    }

    total += x;

    if (n % total == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

class Program
{
    static long mod = (long)1e9 + 7;

    static void Main()
    {
        int[] inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = inputs[0], M = inputs[1];

        if (N > M)
        {
            Console.WriteLine(0);
            return;
        }

        long[,,] dp = new long[M + 1, N, N];
        dp[0, 0, N - 1] = 1;
        for (int n = 0; n < M; n++)
        {
            for (int s = 1; s <= N; s++)
            {
                for (int l = Math.Max(N - n - 1, 0); l < N; l++)
                {
                    dp[n + 1, N - l - 1, l] += s * dp[n, s - 1, l] % mod;
                    dp[n + 1, N - l - 1, l] %= mod;
                    dp[n + 1, s - 1, l] += (N - s - l) * dp[n, s - 1, l] % mod;
                    dp[n + 1, s - 1, l] %= mod;
                    if (l > 0)
                    {
                        dp[n + 1, s - 1, l - 1] += l * dp[n, s - 1, l] % mod;
                        dp[n + 1, s - 1, l - 1] %= mod;
                    }
                }
            }
        }

        Console.WriteLine(dp[M, N - 1, 0]);
    }
}


Measured memory_bytes: 222048
#include <stdio.h>

int main(void)
{
	int i,total;
	int data[10];
	total=0;
	for(i=1;i<=5;i++){
		scanf("%d",&data[i-1]);
		if(data[i-1]<40){
			data[i-1]=40;
		}
		total+=data[i-1];
	}
	printf("%d\n",total/5);
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        long[] count = new long[26];
        for (char ch : s.toCharArray()) {
            count[ch - 'a']++;
        }

        long mod = 1000000007L;
        long[] dp = new long[27];
        dp[0] = 1L;
        for (int i = 0; i < 26; i++) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= mod;

            dp[i + 1] += dp[i] * count[i];
            dp[i + 1] %= mod;
        }
        System.out.println((dp[26] + mod - 1) % mod);
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n, m;
vl a, b;
vll G;
vl Gans;
vl toedge;
/******* define variable end *******/
int solve() {
	cin >> n >> m;
	RES(G, n);
	RES(toedge, n);
	RES(a, n-1+m);
	RES(b, n-1+m);
	RES(Gans, n);
	vector<bool> nem(n);
	REP(i, n-1+m){
		cin >> a[i] >> b[i];
		nem[b[i]-1] = true;
		G[a[i]-1].push_back(b[i]-1);
		toedge[b[i]-1]++;
	}
	ll ne = -1;
	REP(i, n){
		if(nem[i]){
			continue;
		}
		ne = i;
	}

    // BFS のためのデータ構造
    vector<ll> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<ll> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[ne] = 0;
    que.push(ne); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        ll v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (ll nv : G[v]) {
			if(toedge[nv] > 1){
				toedge[nv]--;
				continue;
			}else{
				Gans[nv] = v + 1;
				dist[nv] = dist[v] + 1;
				que.push(nv);
			}
        }
    }
	REP(i, n){
		if(i == ne){
			cout << 0 << endl;
		}else{
			cout << Gans[i] << endl;
		}
	}

	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 12708
#include<bits/stdc++.h>
#define REP(i,N) for (int i=0;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
    string str;
    cin >> str;
    if (str == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(str == "Cloudy"){
        cout << "Rainy" << endl;
    }else if(str == "Rainy"){
        cout << "Sunny" << endl;
    }   
}

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

int main() {

	std::string s, t;
	std::cin >> s >> t;

	std::vector<std::vector<int>>
		v( s.size() + 1,
			std::vector<int>(t.size() + 1, 0)
		);

	
	for (decltype(s.size()) i{ 1 }; i <= s.size(); ++i) {

		for (decltype(t.size()) j{ 1 }; j <= t.size(); ++j) {

			if (s[i - 1] == t[j - 1])
				v[i][j] = v[i - 1][j - 1] + 1;
			else
				v[i][j] = std::max(v[i][j - 1], v[i - 1][j]);
		}
	}

	/*
	for (auto&&e : v) {
		for (auto&&ee : e)
			std::cout << ee << " ";
		std::cout << "\n";
	}*/

	std::string ans;
	ans.reserve( std::min( s.size(), t.size() ) );
	const decltype(s.size()) size = v[s.size()][t.size()];
//	std::cout << size << "\n";
	auto si = s.size() ;
	auto ti = t.size() ;

	while ( ans.size()<size) {
		
		if (s[si-1] == t[ti-1]) {
//			std::cout << s[si-1] << " ";
			ans += s[si-1];
			--si; --ti;
		}
		else if (v[si][ti] == v[si][ti - 1])
			--ti;
		else if (v[si][ti] == v[si - 1][ti])
			--si;
	}

	std::copy(std::crbegin(ans), std::crend(ans)
		, std::ostream_iterator<std::string::value_type>{std::cout,""}
	);
	std::cout << "\n";

	return 0;
}

Measured memory_bytes: 35584
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		String str = sc.nextLine();
		
		int[] arr = new int[4];
		
		for(char c : str.toCharArray()){
			if(c == 'N') arr[0]++;
			else if(c == 'S') arr[1]++;
			else if(c == 'E') arr[2]++;
			else if(c == 'W') arr[3]++;
		}
		
		if(arr[0] == 0 && arr[1] !=0){
			System.out.println("No");
		}
		else if(arr[0] != 0 && arr[1] == 0){
			System.out.println("No");
		}
		else if(arr[2] != 0 && arr[3] == 0){
			System.out.println("No");
		}
		else if(arr[3] != 0 && arr[2] == 0){
			System.out.println("No");
		}
		else System.out.println("Yes");
		
//		if(arr[0] == arr[1] && arr[2] == arr[3]) System.out.println("Yes");
//		else System.out.println("No");
		
	}
}


Measured memory_bytes: 9812
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 2000005
#define maxk 10005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[maxn],c[maxk];
int main(){
	scanf("%d",&n);
	int maxval = 0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		maxval = max(maxval,a[i]);
		c[a[i]]++;
	}
	int k = 0;
	for(int i=0;i<=maxval;i++){
		for(int j=1;j<=c[i];j++){
			a[++k] = i;
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d%c",a[i],i==n?'\n':' ');
	}
	return 0;
}



Measured memory_bytes: 11024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1; i<=n; i++){
        if(i%3!=0&&i%5!=0) ans+=i;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void) {
	int k, n, ans, a1, a2;
	scanf("%d", &n);
	scanf("%d", &k);
	if (k > 1) {
		a1 = k - 1;
		a2 = n - a1;
		ans = a2 - 1;
		printf("%d", ans);
	}
	else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

ans = [0]*10002
for x in range(1,101):
	for y in range(1,101):
		for z in range(1,101):
			t = x*x+y*y+z*z+x*y+y*z+z*x
			if t>10000:
				break
			else:
				ans[t]+=1

for i in range(1,n+1):
	print(ans[i])

Measured memory_bytes: 9456
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

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

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


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


Measured memory_bytes: 3656
S = input()
T = input()
N = len(S)

dict_S = {}
dict_T = {}

for i in range(N):
    # print("dict_S: {}".format(dict_S))
    # print("dict_T: {}".format(dict_T))
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    dict_S[S[i]] = T[i]
    dict_T[T[i]] = S[i]
print("Yes")


Measured memory_bytes: 3760
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int n;
  cin>>n;
  vector<vector<int>>vec(n,vector<int>(2));
  rep(i,n){
    cin>>vec.at(i).at(0)>>vec.at(i).at(1);
  }
  double d=0;
  double sq=0;
  rep(i,n){
    rep(j,n){
      sq=0;
      if(i>=j){
        continue;
      }
      sq+=pow(vec.at(i).at(0),2);
      sq+=pow(vec.at(j).at(0),2);
      sq+=pow(vec.at(i).at(1),2);
      sq+=pow(vec.at(j).at(1),2);
      sq-=2*vec.at(i).at(0)*vec.at(j).at(0);
      sq-=2*vec.at(i).at(1)*vec.at(j).at(1);
      //cout<<(double)(sq)<<endl;
      d+=sqrt((double)(sq));
    }
  }
  d=d*2/n;
  cout<<fixed<<setprecision(20);
  cout<<d<<endl;

  }

Measured memory_bytes: 3804
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> vals = new ArrayList<Integer>();
		while (in.hasNext()) {
			int val = in.nextInt();
			int keta = in.nextInt();
			if (val == 0 && keta == 0)
				break;
			vals.clear();
			int[] array = new int[keta];
			// Arrays.fill(array, 0);
			while (!vals.contains(val)) {
				vals.add(val);
				for (int k = 0; k < keta; k++) {
					array[k] = val % 10;
					val /= 10;
				}
				Arrays.sort(array);
				// System.out.println(Arrays.toString(array));
				for (int k = 0; k < keta; k++) {
					val *= 10;
					val += array[keta - 1 - k] - array[k];
				}
			}
			int i = vals.indexOf(val);
			int j = vals.size() - i;
			System.out.print(i);
			System.out.print(" ");
			System.out.print(val);
			System.out.print(" ");
			System.out.println(j);
		}
	}
}

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

const int MAXN=20;

int n;
int ans;
int prod=1;
int a[MAXN];
std::vector<int> seq;

void DFS(int pos){
	if(pos==n){
		int prod=1;
		for(int i=0;i<n;i++){
			prod*=seq[i];
		}
		if(prod%2==0)
			ans++;
		return;
	}
	for(int i=a[pos]-1;i<=a[pos]+1;i++){
		seq.push_back(i);
		DFS(pos+1);
		seq.pop_back();
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	DFS(0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
PYP = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    PYP[i].append(i)
PY = sorted(PYP)
P = PY[0][0]
S = 0
for i in range(M):
    if PY[i][0] != P:
        P = PY[i][0]
        S = 0
    S += 1
    PY[i].append(("0"*(6-len(str(P)))+str(P)+"0"*(6-len(str(S)))+str(S)))
for i in PY:
    i[0] = i[2]
PY.sort()
for i in PY:
    print(i[3])


Measured memory_bytes: 39368
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n:i32 = read();
    let m:i32 = read();
    println!("{}", if m == n {"Yes"}else{"No"});
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int *num;
int *res;

int c[200000];
#define MAX 10000


void countingsort(int);

int main(){
  int i,j;
  int n;

  scanf("%d",&n);
  
  num=malloc(sizeof(int)*(n+1));
  res=malloc(sizeof(int)*(n+1));
  
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }

  countingsort(n);
  for(j=1;j<=n;j++){
    if(j!=n) printf("%d ",res[j]);
    else printf("%d\n",res[j]);
  }
  
  free(num);
  free(res);
  
  return 0;
}

void countingsort(int n){
  int i,j;

  for(i=0;i<MAX;i++){
    c[i]=0;
  }
 
  for(j=0;j<n;j++){
    c[num[j]]++;
  }

  for(i=0;i<MAX;i++){
    c[i]=c[i]+c[i-1];
  }

  for(j=n;j>=0;j--){
    res[c[num[j]]]=num[j];
  c[num[j]]--;
  }
}

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

int main(){
  int N,K; cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(i>=K){
      if(A[i-K]<A[i]) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.rbegin(), arr.rend());
  int sum_length = 0;
  for (int i = 0; i < k; ++i) {
    sum_length += arr[i];
  }
  cout << sum_length << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N =  INT()
s = ["".join(sorted(input())) for _ in range(N)]

s.sort()

ans = 0
count = 0
tmp = ""
for i in s:
	if tmp == i:
		count += 1
	else:
		ans += count*(count+1)//2
		count = 0
		tmp = i
ans += count*(count+1)//2
print(ans)


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n; cin >> n;
	vector<int> v;
	vector<string> s(n);
	rep(i,0,n){
		cin >> s[i];
		rep(j,0,n) if(s[i][j]=='o') v.push_back(i+1);
	}

	random_device rd;
	mt19937 eng(rd());
	vector<int> cnt(n);
	rep(i,0,200){
		cout << v[eng()%v.size()] << endl; //最初の200回は適当に良さそうな手を出しつつ相手の手のデータをとる
		int in; cin >> in;
		++cnt[--in];
	}

	vector<int> w;
	rep(i,0,n){
		rep(j,0,n){
			if(s[i][j]=='o') rep(k,0,cnt[j]*2) w.push_back(i+1); //相手が多く出した手に勝てる手は多めの確率で出すようにする
			if(s[i][j]=='-') rep(k,0,cnt[j]/2) w.push_back(i+1); //引き分けはとりあえず半分程度で
		}
	}

	rep(i,0,800){
		cout << w[eng()%w.size()] << endl;
		int in; cin >> in;
	}
}

int main(){
	//std::ios::sync_with_stdio(false);
	//std::cin.tie(0);
	Solve();
	return 0;
}

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

int main() {
  int64_t A,B;
  vector<int64_t> PF;
  cin >> A >>B;
  int add=1;
  
   for (int64_t i=2 ; (i*i <= A) || (i*i <= B)  ; i ++){
    if ( (A % i == 0) && (B % i ==0) ) {
      A /= i;
      B /= i;
      PF.push_back(i);
      }
     while (A % i == 0){
        A /= i;
      }
      while (B % i == 0){
        B /= i;
      }
  }
  if ( (A == B) && (A != 1) ){ add ++;}
    
  
  cout << PF.size() + add ;
}


Measured memory_bytes: 256