akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define HASH 200003

typedef struct List {
	struct List *next;
	char *s;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = ((x << 5) + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(S[i]);
		d[i].s = S[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, m, dp[2][26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 32, HASH);
	for (k = 1, pow[0] = 32; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		for (j = l[i] - 1, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (T[0] - 'a') % HASH + HASH) % HASH;
		tmp = tmp * inv % HASH;
		h[i] = (h[i] - tmp * (T[1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[0][j] = 0;
		dp[0][S[i][0] - 'a'] = 1;
		dp[1][0] = S[i][0] - 'a';
		for (j = 1, m = 1; j < l[i]; j++) {
			if (dp[0][S[i][j] - 'a'] == 0) {
				dp[0][S[i][j] - 'a'] = 1;
				dp[1][m++] = S[i][j] - 'a';
			}
			for (k = 0; k < m; k++) {
				T[j] = 'a' + dp[1][k];
				h[0] = (tmp * dp[1][k] + h[i]) % HASH;
				for (p = hash[h[0]]; p != NULL; p = p->next) if (lex_smaller(p->s, &(T[j])) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (S[i][j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 15712
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

t = sorted(t)
cnt_bus = 0
i = 0
while i < n:
    cnt_rider = 0
    l, r = i, min(i + c - 1, n - 1)
    while l <= r:#適当なmidを求める
        mid = (l + r) // 2
        if t[mid] > t[i] + k:
            r = mid - 1
        else:
            #t[mid] <= t[i] + k
            p = mid#最後に乗車する人の番号（仮）
            l = mid + 1

    cnt_rider = p - i + 1
    i += cnt_rider
    cnt_bus += 1
    #print(p, cnt_rider)
print(cnt_bus)

Measured memory_bytes: 8280
from itertools import groupby

s = input()
s_rle = [len(list(g)) for k,g in groupby(s)]

people = [str(0)]*len(s)
sum_index = -1

it = iter(s_rle)
for i in it:
    sum_index += i

    r_even = i//2
    r_odd = i - r_even
    l = next(it)
    l_even = l//2
    l_odd = l - l_even

    people[sum_index] = str(r_odd+l_even)
    people[sum_index+1] = str(r_even+l_odd)

    sum_index += l

ans = " ".join(people)
print(ans)

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

// 最大公約数
ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}

// 最小公倍数
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
    int N;
    ll M;
    cin >> N >> M;
    ll a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll l = 1;
    for (int i = 0; i < N; i++) {
        l = lcm(l, a[i] / 2);
        if (l > M) {
            cout << "0\n";
            return 0;
        }
    }

    for (int i = 0; i < N; i++) {
        ll t = l / (a[i] / 2);
        if (t % 2 == 0) {
            cout << "0\n";
            return 0;
        }
    }
    cout << (M - l) / (2 * l) + 1<< "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define MAX std::numeric_limits<lld>::max();
#define MIN std::numeric_limits<lld>::min();
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
lld palm (string s, lld l, lld r){
	while (l <= r){
		if (s[l] != s[r]){
			return 0;
		}
		l+=1; r -= 1;
	}
			return 1;
}
int main (){
    FastIO
    string s;
    cin >> s;
    lld n, i;
    n = s.length();
    lld a =(n-1)/2;
    lld b =(n+3)/2;
    if (palm(s, 0, n-1) == 1 && palm(s, 0, a-1) == 1 && palm(s, b-1, n-1) == 1){
    	cout << "Yes\n";
    }
    else{
    	cout <<  "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define endl "\n"
using namespace std;

void solve()
{
	//Enter code here Tanmay::
	int n,sum=0;
	cin>>n;
	int a[n],b[n],c[n-1];
	
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		sum=sum+b[i];
		
	}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
void fastscan(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
  
    // extract current character from buffer 
    c = getchar(); 
    if (c=='-') 
    { 
        // number is negative 
        negative = true; 
  
        // extract the next character from the buffer 
        c = getchar(); 
    } 
  
    // Keep on extracting characters if they are integers 
    // i.e ASCII Value lies from '0'(48) to '9' (57) 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
  
    // if scanned input has a negative sign, negate the 
    // value of the input number 
    if (negative) 
        number *= -1; 
} 

Measured memory_bytes: 256
ARGF.each_line do |line|
  count = 0
  n = line.to_i
  10.times do |i|
    10.times do |j|
      10.times do |k|
        10.times do |l|
          if i + j + k + l == n
            count += 1
          end
        end
      end
    end
  end
  puts count
end

Measured memory_bytes: 8652
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools
import heapq


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(input):
    MAX = 110000
    X = int(input)
    eratosthenes = set(range(2, MAX+1))
    primes = []

    top = min(eratosthenes)
    while top <= math.sqrt(MAX):
        eratosthenes.remove(top)
        primes.append(top)

        multiple = top + top
        while multiple <= MAX:
            if multiple in eratosthenes:
                eratosthenes.remove(multiple)
            multiple += top
        top = min(eratosthenes)

    primes.extend(list(eratosthenes))
    primes.sort()

    for p in primes:
        if p >= X:
            return p


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(input())
    print(ret)


Measured memory_bytes: 48624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <ctime>
#define ll long long
#define debug cout << "debug" << endl
#define STOPSYNC ios::sync_with_stdio(false);cin.tie(nullptr)
#define MULTIKASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
template <typename T>
inline void w(T x) {
    if (x > 9) w(x / 10);
    putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x, char c) {
    w(x);
    putchar(c);
}
template <typename T>
inline void read(T &x) {
    x = 0;
    T f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
    for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
    x *= f;
}
template <typename T>
T MAX(T a, T b) {
    return a > b ? a : b;
}
template <typename T>
T MIN(T a, T b) {
    return a > b ? b : a;
}
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;
}
void solve(){
    
}
int main(){
    int n;
    cin >> n;
    printf("%s\n", n >= 30 ? "Yes" :"No");
    return 0;
}

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

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin>>t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()
    
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }


    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      vector<ll> a(n);
      forn(i,0,n){
        cin>>a[i];
      }
      sort(all(a));
      ll ans = a[n-1];
      int cnt = n-2;
      int idx = 2;
      while(cnt != 0){
        ans += a[n-idx];
        cnt--;
        if(cnt == 0)
          break;
        ans += a[n-idx];
        cnt--;
        idx++;
      }
      cout<<ans<<endl;
    } 
    

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];
    ll now = H[0]-1;
    REP(i, N){
    	if(i==0) continue;
    	if(H[i]-1 >= now) now = H[i]-1;
    	else if(H[i]==now){
    		now = H[i];
    	}else{
    		cout << "No" << endl;
    		return 0;
    	}
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define endl "\n"

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

void INVERSE(vector<int64_t> &fact, vector<int64_t> &mul, int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
    fact[0] = 1;
	for (int64_t i = 1; i <= nn; ++i) {
		fact[i] = (fact[i - 1] * i) % mo;
	}
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

vector<int64_t> fact(2001);
vector<int64_t> inv(2001);
int mod = 1e9 + 7;

int64_t C(int64_t n, int64_t k) {
	if (k > n) {
		return 0;
	}
	return (fact[n] % mod * inv[k] % mod * inv[n - k] % mod) % mod;
}

int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	int z = 2000;
	INVERSE(fact, inv, z, mod);
	int64_t R = n - k;
	int64_t B = k;
	for (int i = 1; i <= k; ++i) {
		 cout << (C(R + 1, i) % mod * C(B - 1, i - 1) % mod) % mod << endl;
	}
}















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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 10000000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

//#define DEBUG

int main_(){
  char b;
  cin>>b;
  if(b=='A')cout<<'T'<<endl;
  else if(b=='C')cout<<'G'<<endl;
  else if(b=='G')cout<<'C'<<endl;
  else if(b=='T')cout<<'A'<<endl;
  return 0;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  vector<string>test;
  /*
   * input for debug
   */
  for(int i=0;i<test.size();++i){
    stringbuf buf;
    streambuf*out=cout.rdbuf(&buf);
    cout<<test[i]<<flush;
    cout.rdbuf(out);
    streambuf*in=cin.rdbuf(&buf);
    main_();
    cin.rdbuf(in);
    cout<<endl;
  }
#else
  main_();
#endif

  return 0;
}


Measured memory_bytes: 256
h,w = [int(x) for x in input().split()];
s = [[0 for i in range(w)] for i in range(h)];
for i in range(h) :
    s[i] = input();

ans = 'Yes';
for i in range(h) :
    for j in range(w) :
        if s[i][j] == '.' :
            continue;
        elif i == 0 :
            if j == 0 :
                if s[i+1][j] == '.' and s[i][j+1] == '.' :
                    ans = 'No';
                    break;
            elif j == w-1 :
                if s[i+1][j] == '.' and s[i][j-1] == '.' :
                    ans = 'No';
                    break;
            else :
                if s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' :
                    ans = 'No';
                    break;
        elif i == h-1 :
            if j == 0 :
                if s[i-1][j] == '.' and s[i][j+1] == '.' :
                    ans = 'No';
                    break;
            elif j == w-1 :
                if s[i-1][j] == '.' and s[i][j-1] == '.' :
                    ans = 'No';
                    break;
            else :
                if s[i-1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' :
                    ans = 'No';
                    break;
        else :
            if j == 0 :
                if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j+1] == '.' :
                    ans = 'No';
                    break;
            elif j == w-1 :
                if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' :
                    ans = 'No';
                    break;
            else :
                if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' :
                    ans = 'No';
                    break;           


print(ans);

Measured memory_bytes: 9280
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    
    int ecount = 0;
    for (int i = 0; i < N; i++) {
      if (S.charAt(i) == 'E') {
        ecount++;
      }
    }
    
    int wcount = 0;
    int ans = Integer.MAX_VALUE;
    for (int i = 0; i < N; i++) {
      int count = 0;
      if (S.charAt(i) == 'W') {
        wcount++;
        count--;
      } else {
        ecount--;
      }
      count += wcount + ecount;
      ans = Math.min(count, ans);
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 28732
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 20, INF = 1e9;
int dp[N][2];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

    vector<int> v;

    while (n > 0) {
        v.push_back(n % 10);
        n /= 10;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            dp[i][j] = -INF;
        }
    }

    dp[v.size()][1] = 0;

    for (int i = v.size(); i > 0; i--) {
        int c = v[i - 1];
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= (j ? c : 9); k++) {
                int nj = (j && k == c);
                dp[i - 1][nj] = max(dp[i - 1][nj], dp[i][j] + k);
            }
        }
    }

    cout << max(dp[0][0], dp[0][1]) << "\n";

    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

ll next(string str){
  str = '0' + str;
  int n = (int)str.length();
  int i=0;
  for(i = n-1; i >= 1; --i){
    if(str[i] <= str[i-1]){
      if(str[i] == '9') continue;
      str[i] = char((int)str[i] + 1);
      break;
    }
  }
  if(i == 0){
    if(str[1] == '9'){
      str[i] = '1';
    } else {
      str[1] = char(int(str[1] + 1));
      i++;
    }
  }
  i++;
  while(i < n){
    str[i] = (str[i-1] == '0' ? '0' : char((int)str[i-1]-1));
    i++;
  }
  return stoll(str);
}

int main(){
  int k; cin >> k;
  ll ans = 0;
  for(int i = 0; i < k; ++i){
    ans = next(to_string(ans));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"

int main(int argc, char const *argv[]) {

  int A, B, C;

  std::cin >> A>>B>>C;

  if (A >= B && A >= C) {
    std::cout << A * 10 + B + C  << '\n';
  }else{
    if (B>=A && B >= C) {
      std::cout << A + B * 10 + C << '\n';
    }else{
      std::cout << A+B+C*10 << '\n';
    }
  }

  // std::cout << pow(2, 10) << '\n';
  // std::cout << 1e4 << '\n';


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	double x[]=new double[N];
	double y[]=new double[N];
	for(int i=0;i<N;i++) {
		x[i]=sc.nextDouble();
		y[i]=sc.nextDouble();
	}
	double ans=0;
	for(int i=0;i<N-1;i++) {
		for(int j=i+1;j<N;j++) {
			ans+=Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))*2;
		}
	}
	System.out.println(ans/N);
}
}

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

int main() {
  int N;

  cin >> N;
  vector<int> vec(N);
  vector<int> array(N);

  for(int i=0;i<N;++i){
    cin >> vec.at(i);
    array.at(i) = vec.at(i);
  }

  sort(vec.begin(),vec.end());
  for(int i=0;i<N;++i){
    if(array.at(i) == vec.at(N-1)){
      cout << vec.at(N-2) << endl;
    }else{
      cout << vec.at(N-1) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4792
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

using namespace std;

#define MAX_E 100000
#define MAX_V 100000

struct edge{
	int from, to;
	long long int cost;
};

edge es[MAX_E];
long long int d[MAX_V];
int V, E;// Vは頂点数、Eは辺数

// O(VE)、負の閉路がある場合 true を返す
bool shortest_path(int s){
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	bool update = false;
	for(int loop = 0; loop < V; loop++){
		update = false;
		for(int i = 0; i < E; i++){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update){
			break;
		}
	}
	return update;
}

int main(){
	
	int s;
	cin >> V >> E >> s;
	
	for(int i = 0; i < E; i++){
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	
	bool ret = shortest_path(s);
	
	if(ret){
		cout << "NEGATIVE CYCLE" << endl;
	}else{
		for(int i = 0; i < V; i++){
			if(d[i] == INF){
				cout << "INF" << endl;
			}else{
				cout << d[i] << endl;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int k;
        cin>>k;
        if(k%2==0){
            cout<<"-1\n";
            return 0;
        }
        ll ctr=0;
        ll val=7;
        ll val1=0;
        set <pair<int,int>> s;
        do{
            val=val%k;
            val1=(val1+val)%k;
            if(s.find(make_pair(val,val1))!=s.end()){
                ctr=-1;
                break;
            }
            else
                s.insert(make_pair(val,val1));
            ctr++;
            val*=10;
        }while((val1%k)!=0);
        cout<<ctr<<"\n";
    }
    return 0;
}

Measured memory_bytes: 50480
use proconio::{input, fastout, marker::Chars};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h],
    }
    let mut res = 0;

    for i in 0..((2 as usize).pow(h as u32)) {
        for j in 0..((2 as usize).pow(w as u32)) {
            let mut temp_c = c.clone();
            for ii in 0..h {
                if ((i+1) & (1 << ii)) > 0 {
                    for i_j in 0..w {
                        temp_c[ii][i_j] = 'r';
                    }
                }
            }
            for jj in 0..w {
                if ((j+1) & (1 << jj)) > 0 {
                    for j_i in 0..h {
                        temp_c[j_i][jj] = 'r';
                    }
                }
            }

            // cnt #
            let mut temp_cnt_k = 0;
            for cnt_i in 0..h {
                for cnt_j in 0..w {
                    if temp_c[cnt_i][cnt_j] == '#' {
                        temp_cnt_k += 1;
                    }
                }
            }
            if temp_cnt_k == k {
                res += 1;
            }
        }
    }

    println!("{:?}", res);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int cnt[N], a[N], h[N];
struct cmp {
	bool operator () (int i, int j) {
		return h[i] > h[j];
	}
};
int main() {
	priority_queue<int, vector<int>, cmp> q;
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; ++ i) {
		scanf("%d", &a[i]);
		cnt[a[i]] ++;
	}
	for (int i = 1; i <= n; ++ i) if (cnt[i] == 0) q.push(i);
	while(!q.empty()) {
		int p = q.top(); q.pop();
		h[a[p]] = max(h[p], h[a[p]]) + 1;
		cnt[a[p]] --;
		if (cnt[a[p]] == 0) q.push(a[p]);
	}
	printf("%d\n", h[1]);
}



Measured memory_bytes: 1788
#include <stdio.h>

int main() {
	int k,n;
	char s[100];

	scanf("%d %d",&n,&k);
	scanf("%s", s);
	
	if (s[k - 1] == 'A')
		s[k - 1] = 'a';
	if (s[k - 1] == 'B')
		s[k - 1] = 'b';
	if (s[k - 1] == 'C')
		s[k - 1] = 'c';

	printf("%s\n",s);

	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	pair<char,int> p;
	vector<pair<char,int> > list(n);
	vector<pair<char,int> > base(52);
	vector<bool> islost(52,true);
	for(int i=0;i<52;i++){
		switch(i/13){
			case 0:
				base[i].first='S';
				break;
			case 1:
				base[i].first='H';
				break;
			case 2:
				base[i].first='C';
				break;
			case 3:
				base[i].first='D';
				break;
		}
		base[i].second=i%13+1;
	}
	for(int i=0;i<n;i++){
		cin >> p.first >> p.second;
		for(int i=0;i<52;i++){
			if(p==base[i]){
				islost[i]=false;
				break;
			}
		}
	}
	for(int i=0;i<52;i++){
		if(islost[i])cout << base[i].first << " " << base[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1000000000 //1e9

bool graph[8][8] = {{}};
bool visited[8] = {};

int dfs(int x, int N) {
    bool all_visited = true;
    REP(i, N) if (!visited[i]) all_visited = false;
    if (all_visited) return 1;

    int ret = 0;
    REP(i, N) {
        if (!graph[x][i]) continue;
        if (visited[i]) continue;
        visited[i] = true;
        ret += dfs(i, N);
        visited[i] = false;
    }
    return ret;
}

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

    int N, M;
    cin >> N >> M;
    int a, b;
    REP(i, M) {
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }

    visited[0] = true;
    cout << dfs(0, N) << endl;
}

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

int main() {
  int s;
  
  cin >> s;
  
  int s3 = s % 2;
  int s2 = (s / 10) % 2;
  int s1 = (s / 100) % 2;
  
  cout << s1 + s2 + s3 << endl;
  
}


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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 2e5 + 100;

int N, A[Maxn], B[Maxn];
vector <pii> C;
vector <int> Pos[Maxn];
LL Sum[Maxn];

inline void Solve ()
{
	LL sum = 0, ans = LLONG_MAX;

	for (int i = 1; i <= N; ++i) sum += A[i];
	Chkmin (ans, sum);
	sum = 0;
	for (int i = 1; i <= N; ++i) sum += B[i];
	Chkmin (ans, sum);


	C.pb(mp (0, 0));
	for (int i = 1; i <= N; ++i) C.pb (mp (A[i], i)), C.pb (mp (B[i], i));
	sort (C.begin(), C.end());
	for (int i = 1; i <= 2 * N; ++i)
	{
		Pos[C[i].y].pb (i);
		Sum[i] = Sum[i - 1] + C[i].x;
	}

	for (int i = 1; i <= N; ++i)
	{
		sort (Pos[i].begin(), Pos[i].end());
		if (Pos[i][1] <= N)
		{
			Chkmin (ans, Sum[N]);
			cout << ans << endl;
			return ;
		}
	}

	for (int i = 1; i <= N; ++i)
	{
		if (Pos[i][1] == N + 1) Chkmin (ans, Sum[N + 2] - A[i] - B[i]);
		else Chkmin (ans, Sum[N + 1] - C[Pos[i][0]].x);
	}

	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>(), B[i] = read<int>();
}

int main()
{

#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}

ll mod(ll a, ll b) {return (a % b + b) % b;}

ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

using namespace std;
ll mods(string num, ll a) 
{ 
    // Initialize result 
    ll res = 0; 
    // One by one process all digits of 'num' 
    for (ll i = 0; i < num.length(); i++) 
         res = (res*10 + (ll)num[i] - '0') %a; 
    return res; 
} 
int main() 
{	
	fast;
	ll n; cin>>n;
	ll k; cin>>k;
	ll visited[n+3];
	memset(visited,0,sizeof(visited));
	ll arr[n+1]; 
	for(ll i = 1; i <= n; i++) cin>>arr[i];
	ll timer = 0;
	ll x = 1;
	while(visited[x] == 0)
	{
		visited[x] = timer;
		timer++;
		x = arr[x];
	}
	ll t = timer - visited[x];
	x = 1;
	memset(visited,0,sizeof(visited)); timer = 0;
	while(k--)
	{
		if(visited[x] != 0)
		{
			k = k % t;
		}
		visited[x] = timer;
		timer++;
		x = arr[x];
	}
	cout << x << endl;
 	return 0;
}

Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;


int main() {
    int N, M;
    cin >> N >> M;
    vector<int> S(M);
    vector<char> C(M);

    for(int i=0; i<M; i++) {
        cin >> S[i] >> C[i];
    }

    for(int i=0; i<1000; i++) {
        bool flg = true;
        string num_s = to_string(i);
        for(int j=0; j<M; j++) {
            if(num_s[S[j]-1] != C[j] || num_s.size() != N){
                flg = false;
            }
        }
        if(flg && num_s.size() == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu long long unsigned
int main()
{
        int x;
        string s="";
        int AC=0,WA=0,TLE=0,RE=0;
        scanf("%d",&x);
        for(int j=0;j<x;j++){
            string s2="";
            cin>>s2;
            if(s2=="AC") AC++;
            if(s2=="WA") WA++;
            if(s2=="TLE") TLE++;
            if(s2=="RE") RE++;
            s2.clear();
        }
        printf("AC x %d\n",AC);
        printf("WA x %d\n",WA);
        printf("TLE x %d\n",TLE);
        printf("RE x %d\n",RE);


    return 0;
}







Measured memory_bytes: 3788
#include <stdio.h>
#include <stdbool.h>

#define MAX 44

int Fib(unsigned int n);

int memo[MAX] = {1, 1};
bool in_memo[MAX] = {true, true};

int main(void) {
  unsigned int n;
  scanf("%d", &n);

  printf("%d\n", Fib(n));

  return 0;
}

int Fib(unsigned int n) {
  if(!in_memo[n]) {
    memo[n] = Fib(n-1) + Fib(n-2);
    in_memo[n] = true;
  }

  return memo[n];
}



Measured memory_bytes: 2140
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
#include <algorithm>
	#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
#include <map>
#include <cmath>

//#include <bits/stdc++.h>
using namespace std;


int main() {
	uint64_t a;
	cin >> a;
	vector<uint64_t> b(a);
	vector<uint64_t> c(a, 0);
	for (uint64_t i = 0; i < a; i++) {
		cin >> b[i];
		c[b[i]-1] += 1;
	}

	uint64_t total = 0;
	for (uint64_t i = 0; i < a; i++) {
		if (c[i] != 0) {
			total += c[i] * (c[i] - 1) / 2;
		}
	}
	//cout << total;

	uint64_t num=0;
	for (uint64_t i = 0; i < a; i++) {
		num = total - c[b[i]-1]+1;
		if (num < 0) {
			num = 0;
		}
		cout << num << endl;
	}


	return 0;

}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    ll n, mx=-inf, mn=inf;
    cin >> n;
    while(n--)
    {

        ll x;
        cin >> x;
        mx = max(mx,x);
        mn=min(x,mn);
    }
    cout << mx-mn;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define input(x) istream_iterator<x>(cin)
#define output(x, y) ostream_iterator<x>(cout, y)
const int N = 1e6;

int n;
int a[N];

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        a[x - 1]++;
    }
    copy_n(a, n, output(int, "\n"));
    return 0;
}





Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        long long int ans=0;
        long long int ansm=0,ansa=0,ansr=0,ansc=0,ansh=0;
        string s;
        for(int i=0;i<n;i++)
        {
            cin>>s;
            if(s[0]=='M') ansm++;
            else if(s[0]=='A') ansa++;
            else if(s[0]=='R') ansr++;
            else if(s[0]=='C') ansc++;
            else if(s[0]=='H') ansh++;
        }
        if(n<3)
        {
            ans=0;
        }
        else
        {
            ans+=ansm*ansa*ansr;
            ans+=ansm*ansa*ansc;
            ans+=ansm*ansa*ansh;

            ans+=ansm*ansr*ansc;
            ans+=ansm*ansr*ansh;

            ans+=ansm*ansc*ansh;

            ans+=ansa*ansr*ansc;
            ans+=ansa*ansr*ansh;

            ans+=ansa*ansc*ansh;
            ans+=ansr*ansc*ansh;
        }
        cout<<ans<<endl;

    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    double a;
    double high=0,low=0;
    while(scanf("%lf",&a)!=EOF){
        if(high==0&&low==0){
            high=a;
            low=a;
        }
        if(high<a){
            high=a;
        }
        else if(low>a){
            low=a;
        }
    }
    printf("%0.1f\n",high-low);
    return 0;
}

Measured memory_bytes: 652
#include <stdio.h>

int main(void)
{
	int a,b;
	int sum, ave;
	int i;

	i = 0;
	sum = 0;
	ave = 0;
	while (scanf("%d,%d", &a, &b) != EOF){
		sum += a * b;
		ave += b;
		i++;
	}

	printf("%d\n%d\n", sum, (int)((double)ave / i + 0.5));

	return (0);
}

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

using namespace std;

int f(ll a,ll b) {
  int d_a,d_b;
  _for(i,12) {
    if (a/((ll)pow(10,i))==0) {
      d_a = i;
      break;
    }
  }
  _for(i,12) {
    if (b/((ll)pow(10,i))==0) {
      d_b = i;
      break;
    }
  }
  return max(d_a,d_b);
}

int main() {
  ll n;
  cin >> n;
  int f_min = 12;
  for(ll i=1;i<=sqrt(n);i++) {
    if (n%i == 0) {
      f_min = min(f_min, f(i,n/i));
    }
  }
  cout << f_min << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<string>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll h, w;
	cin >> h >> w;
	for (ll i = 0; i < h; i++) {
		for (ll j = 0; j < w; j++) {
				string s;
				cin >> s;
				if (s == "snuke") {
				char c = 'A' + j;
				cout << c << i + 1<< endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
/// Created by Arsenii Kirillov
 
#ifdef DEBUG
#  define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#ifndef LOCAL
#  define cerr __get_ce
#endif
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;
 
/*
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
//*/
 
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }
 
 
void solve() {
	string s;
	cin >> s;
	int n = sz(s) + 1;
	vector<int> a(n, 0);
	for (int i = 0; i + 1 < n; i++)
		if (s[i] == '<')
			a[i + 1] = max(a[i + 1], a[i] + 1);
	for (int i = n - 2; i >= 0; i--)
		if (s[i] == '>')
			a[i] = max(a[i], a[i + 1] + 1);
	ll sum = 0;
	for (int i = 0; i < n; i++)
		sum += a[i];
	cout << sum << endl;
}
 
 
int main() {
#ifdef LOCAL
	clock_t start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int test_count = 1;
	//cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
 
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 2844
const main = (inputs) => {
  var N = inputs[0] - 0;
  var array2 = inputs[1].split(" ");
  var sum = new Array(N).fill(0);

  array2.forEach(i => {
    var num = i - 1;
    sum[num] = sum[num] + 1;
  });

  sum.forEach(j => {
    console.log(j);
  });

}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

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

string str;
int cnt;
int inf;

string solve(string x){
  int ret = INT_MIN;
  string a;
  string ans;

  // cout << x << " " << cnt << endl;
  if(x.size() == 1) return x;
  if(inf <= atoi(x.c_str()) && cnt != 0){
    cnt = -1;
    return 0;
  }
  for(int i = 0; i < (int)x.size(); i++){
    string b;
    a+=x[i];
    for(int j = i+1; j < (int)x.size(); j++){
      b += x[j];
    }
    int c = atoi(a.c_str())*atoi(b.c_str());
    if(ret < c){
      ret = max(ret,c);
    }
  }
  stringstream s;
  s << ret;
  s >> ans;
  cnt++;
  return solve(ans);

}

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

  for(int i = 0; i < q; i++){
    cnt = 0;
    cin >> str;
    inf = atoi(str.c_str());
    solve(str);
    cout << cnt << endl;
  }


}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int MAX = 1000005;
int c[MAX];

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

    int G = 0;
    rep(i, n) {
        int a;
        cin >> a;
        G = __gcd(G, a);
        c[a]++;
    }

    if (G > 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    for (int i = 2; i < MAX; i++) {
        int cnt = 0;
        for (int j = i; j < MAX; j += i) cnt += c[j];
        if (cnt > 1) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }

    cout << "pairwise coprime" << endl;
    return 0;
}


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

#define getn int n; cin >> n
#define fori(n) for (int i = 0; i < (n); i++)
#define forj(n) for (int j = 0; j < (n); j++)
#define forifill(n,x) for (int i = 0; i < (n); i++) cin >> x[i]
#define foriprint(n,x,sep) for (int i = 0; i < (n); i++) cout << x[i] << sep;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define unsync cin.sync_with_stdio(false), cin.tie(0)
#define inoutfile freopen("d:\\testcase.txt", "r", stdin);freopen("d:\\output.txt", "w", stdout)

typedef unsigned long long lng;


int main()
{
	unsync;

	int n, l;
	cin >> n >> l;
	string x[105];
	forifill(n, x);
	sort(x, x + n);
	foriprint(n, x, "");
	cout << "\n";
}


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

int main(){
    vector<int>x(5);
    for (int i = 0; i < 5; i++) {
        cin >> x.at(i);
        if (x.at(i) == 0) {
            cout << i+1;
            break;
        }
    }
} 

Measured memory_bytes: 3620
#include <stdio.h>
#define swap(type, x, y)  do{ type t = x; x = y; y = t; }while(0)

void quick(long array[], int left, int right){
  int pl = left, pr = right;
  long x = array[(left + right) / 2];
  do{
    while(array[pl] < x)  pl++;
    while(array[pr] > x)  pr--;
    if(pl <= pr){
      swap(long, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

int main(){
  int n;  scanf("%d", &n);
  long ans = 0;
  long a[100005];
  for(int i=0; i<n; i++)  scanf("%ld", a+i);
  quick(a, 0, n-1);
  int count = 1;
  for(int i=1; i<n; i++)
    if(a[i] == a[i-1]){
      count++;
    }else{
      ans = ans + count%2;
      count = 1;
    }
  ans = ans + count%2;
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int input[] = new int[n + 2];
		final int COLOR_MAX = 2_000_01;

		input[0] = COLOR_MAX;
		for(int i = 1; i <= n; i++){
			input[i] = sc.nextInt();
		}
		input[n + 1] = COLOR_MAX;

//		int appear[] = new int[2_00001];

//		Arrays.fill(appear, -1);

		long dp[] = new long[n + 1];
		dp[0] = 1;
//		appear[input[0]]++;
		int mod = 1_000_000_007;
		long sumOfEachColor[] = new long[COLOR_MAX + 1];
		sumOfEachColor[input[1]] = 1;
		for(int i = 1; i <= n; i++){
//			for(int j = 1; j <= i; j++){
//				if(input[i] == input[j] && input[i] != input[j - 1]){
//					dp[i] += dp[j - 1];
//				}
//			}
			dp[i] = sumOfEachColor[input[i]];


			if(input[i] != input[i + 1]){
				sumOfEachColor[input[i + 1]] += dp[i];
				sumOfEachColor[input[i + 1]] %= mod;
			}

//			dp[i] += sumOfEachColor[input[i - 1]];

//			System.out.println("i = "+i+" dp[i] = "+dp[i]);

//			for(int j = 0; j < 10; j++){
//				System.out.print(sumOfEachColor[j]+" ");
//			}
//			System.out.println();
		}

		System.out.println(dp[n]);
	}
}


Measured memory_bytes: 50768
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
  double n, s[1010], sd;
  while(cin>>n && n != 0){
    double sum = 0, double_sum = 0, m;
    for(int i=0;i<n;i++){
      cin>>s[i];
      sum += s[i];
      double_sum += pow(s[i], 2);
    }
    m = sum / n;
    sd = sqrt(double_sum / n - pow(m, 2));
    printf("%.5f\n", sd);
  }
  return 0;
}



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

using namespace std;

vector<vector<int> > list_to_mat(vector<vector<int> >& adj){

  const int mat_size = (int)adj.size();
  vector<vector<int> > ans(mat_size,vector<int>(mat_size,0));
  for(int i=0; i<mat_size; i++){
    for(int j=0; j<adj[i].size(); j++){
      ans[i][adj[i][j]-1] = 1;
    }
  }
  return ans;
}

void dump_mat( vector<vector<int> > mat){
  
  const int mat_size = (int)mat.size();
  for(int i=0; i<mat_size; i++){
    for(int j=0; j<mat[i].size(); j++){
      cout << mat[i][j];
      if(j!=mat[i].size()-1)
	cout << " ";
      else
	cout << "\n";
    }
  }

}

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

  vector<vector<int> > list;
  for(int i=1; i<=n; i++){
    int u,k; cin >> u >> k;
    vector<int> tmp(k);
    for(int j=0; j<k; j++) cin >> tmp[j];
    list.push_back(tmp);
  }
  vector<vector<int> > mat = list_to_mat(list);
  dump_mat(mat);
}

Measured memory_bytes: 1308
from sys import stdin
import numpy as np
import itertools
N,D = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()] + [_])

ans = 0
for j in list(itertools.product(data,repeat=2)):
    tot = 0
    #print(j)
    for k,l in zip(j[0][:D] , j[1][:D]):
        tot += abs(k-l)**2
        #print(tot)
    if j[0][-1] < j[1][-1]:
        if np.sqrt(tot).is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 13728
import sys

list_len = int(input())
l = list(map(int, input().split()))

sorted_l = sorted(l)

wrong = 0
for i in range(list_len):
    if l[i] != sorted_l[i]:
        wrong += 1
        if wrong > 2:
            print("NO")
            sys.exit(0)

print("YES")

Measured memory_bytes: 3060
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<unordered_map>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<complex>
#include<bitset>
#include<iostream>
using namespace std;

/**** Type Define ****/

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


int n,ans=0;
/**** main function ****/
int main(){
  scanf("%d",&n);
  vector<int> d(n);
  for(int i=0;i<n;i++){
    scanf("%d",&d[i]);
  }


  sort(d.begin(),d.end(),[](int& a,int& b) {return a<b;});
  if(n%2) ans=0;
  else ans =d[n/2]-d[n/2-1];
  printf("%d",ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

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

    cout << a * b - (a + b - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int D, N;
    cin >> D >> N;

    if(N==100){
        ll num = pow(100, D) * (N+1); // 10000に注意
        p(num);
    }else{
        ll num = pow(100, D) * N;
        p(num);
    }
    
    return 0;
}

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

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

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

  vector<ll> h(n);
  rep(i,n) cin >> h.at(i);

  int count=0;
  int maxc=0;

  rep(i,n-1){
    if(h.at(i)>=h.at(i+1))count++;
    else {maxc=max(maxc,count); count=0;}
  }
  maxc = max(maxc, count);
  cout << maxc;
}

Measured memory_bytes: 4052