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 < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int k;
    cin >> k;
    vector<int> b(8), a(8, -1);
    rep(i, 8) b[i] = i;
    rep(i, k)
    {
        int y, x;
        cin >> y >> x;
        a[y] = x;
    }
    do
    {
        bool valid = true;
        rep(i, 8)
        {
            if (a[i] != -1 && a[i] != b[i])
            {
                valid = false;
            }
        }
        rep(i, 8)
        {
            rep(j, 8)
            {
                if (i == j)
                    continue;
                int x1 = b[i] + (j - i);
                int x2 = b[i] - (j - i);
                if (x1 > -1 && x1 < 8 && b[j] == x1)
                {
                    valid = false;
                }
                if (x2 > -1 && x2 < 8 && b[j] == x2)
                {
                    valid = false;
                }
            }
        }

        if (valid)
        {
            rep(i, 8)
            {
                rep(j, 8)
                {
                    if (j == b[i])
                    {
                        cout << "Q";
                    }
                    else
                    {
                        cout << ".";
                    }
                }
                cout << endl;
            }
        }

    } while (next_permutation(b.begin(), b.end()));

    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main(void)
{

        int a,b,c,d;

        scanf("%d%d%d",&a,&b,&c);
        if(a<1 || 100<a)
                printf("正しい値を入力してください\n");
        else if(b<1 || 100<b)
                printf("正しい値を入力してください\n");
        else if(c<1 || 100<c)
                printf("正しい値を入力してください\n");

        d = b / a;

        if(d==c)
                printf("%d\n",d);
        else if(d<c)
                printf("%d\n",d);
        else if(d>c)
                printf("%d\n",c);


        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;

int main(){
	string s;
	int n,k;
	cin>>n>>k>>s;
	if(s[k-1]>='A' && s[k-1]<='Z')	s[k-1] = s[k-1]-'A'+'a';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;
 
int main() {
  int D; cin >> D;
  rep(i, D) cout << i % 26 + 1 << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>


int main(){
        char S[100];
        long long int K, i;

        int ch;

        scanf("%s", S);
        scanf("%lld", &K);

        for(i = 0; i < K; i++){

                if(S[i] != '1'){
                        printf("%c\n", S[i]);
                        return 0;
                }
        }
        printf("1\n");
        return 0;
}

Measured memory_bytes: 128
#include <iostream>

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int A, B;
    cin >> A >> B;

    int cnt = 0;
    int num = 1;
    while(num < B) {
        num += A - 1;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[18]:


import heapq


# In[23]:


N,M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))


# In[24]:


heapq.heapify(A)
for m in range(M):
    tmp = heapq.heappop(A)
    heapq.heappush(A, -(-tmp//2))
print(-sum(A))



Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

constexpr int Nmax = 200000;

int main()
{
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    bitset<Nmax> st(0);
    REP(i, N) if (s[i] == 'B') st.set(i);

    int now = 0;
    bool inv = false;
    REP(_, K)
    {
        if (st[now] ^ inv)
        {
            now++, inv = !inv;
            if (now == N) now = 0;
        }
        else st[now] = !st[now];
    }
    REP(i, N) cout << (st[(i + now) % N] ^ inv ? 'B' : 'A');
    cout << endl;
}


Measured memory_bytes: 792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
//#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int x;cin>>x;
	int c=100,o=0;
	while(c<x)
	{
		c=((double)101/100)*c;
		o++;
	}
	cout<<o<<endl;
}

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


int main () {
  int n,m;
  cin>>n>>m;
  int Lmax,Rmin;
  Lmax = 0;
  Rmin = n;
  for (int i=0;i<m;i++){
    int L,R;
    cin>>L>>R;

    Lmax = max(Lmax ,L);
    Rmin = min(Rmin ,R);
  }
  if (Lmax > Rmin){
    cout <<0 <<endl;
  }else{
  cout<<Rmin - Lmax +1<<endl;
  }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && A == C){
    cout << 0 << endl;
  }
  else {
    cout << max({A,B,C})-min({A,B,C}) << endl;
  }
  
}


Measured memory_bytes: 256
n = gets.to_i
res = n

for i in 0..n
  cc = 0
  t = i
  while t>0
    cc += t%6
    t /= 6
  end
  t = n-i
  while t>0
    cc += t%9
    t /= 9
  end
  if res>cc
    res = cc
  end
end
puts res

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,k=1;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a==k) k++;
    }
    if(k==1) cout<<-1;
    else cout<<n-k+1;
}


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

using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector< vector<bool> > a(n);
    for(int i = 0;i < n;i++){
        a[i].resize(m);
        for(int j = 0;j < m;j++){
            a[i][j] = false;
        }

        int k;
        cin >> k;
        for(int j = 0;j < k;j++){
            int val;
            cin >> val;
            a[i][val-1] = true;
        }
    }

    int result = 0;
    for(int j = 0;j < m;j++){
        result++;
        for(int i = 0;i < n;i++){
            if(a[i][j] == false){
                result--;
                break;
            }
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
string str1;
string str2;
int n;
int taro,hanako;
int main()
{
  cin >>n;
  taro =hanako = 0;
  for(int i = 0;i <n;i++){
    cin >>str1;
    cin >>str2;
    if(str1 >str2){
      taro+=3;
    }else if(str1 <str2){
      hanako+=3;
    }else{
      taro++;
      hanako++;
    }
  }
  cout <<taro<<" "<<hanako<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(void){
  int a, b;
  char op;
  while(scanf("%d %c %d", &a, &op, &b) && op != '?'){
    if(op == '+') a += b;
    else if(op == '-') a -= b;
    else if(op == '*') a *= b;
    else if(op == '/') a /= b;
    printf("%d\n", a);
  }
  return 0;
}



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

int main() {
  int t=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i%2 == 0 && s.at(i)=='L'  ) t++;
    if(i%2 == 1 && s.at(i)=='R'  ) t++;
  
  } 
  if(t>0) cout << "No" <<endl;
  else  cout << "Yes" <<endl;
}

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

int main()
{
	int n, f=0;
	cin >> n;
	int d[n+1], d1[n+1];
	for (int i=1; i<=n; i++)
	{
		if (f==3)
		{
			cout << "Yes" << endl;
			return 0;
		}
		cin >> d[i] >> d1[i];
		if (d[i]==d1[i])
		{
			f++;
		}
		else
		{
			f=0;
		}
	}if (f==3)
		{
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
	return 0; 
}

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

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;   ll mod = 1e9+7;
    vector<vector<vector<vector<ll> > > > dp(n+1, vector<vector<vector<ll> > >(5, vector<vector<ll> >(5, vector<ll>(5, 0))));
    dp[0][0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            for (int k = 0; k < 5; k++) {
                for(int l = 1; l < 5; l++) {
                    for (int m = 0; m < 5; m++) {
                        if (j == 1 && k == 2 && l == 3) continue;
                        if (m == 1 && j == 2 && l == 3) continue;
                        if (m == 1 && k == 2 && l == 3) continue;
                        if (j == 2 && k == 1 && l == 3) continue;
                        if (j == 1 && k == 3 && l == 2) continue;
                        dp[i+1][j][k][l] = (dp[i+1][j][k][l] + dp[i][m][j][k]) % mod;
                    }
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i < 5; i++) {
        for (int j = 1; j < 5; j++) {
            for (int k = 1; k < 5; k++)
                ans = (ans + dp[n][i][j][k]) % mod;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	int N;
	long long sum = 0;

	cin >> N;

	int A[N];

	for(int i = 0; i < N ; i++){
		cin >> A[i];
		sum+= A[i];
	}

	float diff = 1000;
	int ans = 0;
	float ave = (float)sum / N;

	for(int i = 0; i < N; i++){
		if( diff > (abs(A[i] - ave)) ){
			diff = abs(A[i] - ave);
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        if(A>8 || B>8)
            System.out.println(":(");
        else
            System.out.println("Yay!");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int dp[100000];
int main(){
	int n, k;
	cin>>n>>k;
	int arr[n];
	for(int i = 0; i<n; i++){
	cin>>arr[i];
	dp[i] = INT_MAX;
}
	dp[0] = 0;
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<= i+k; j++){
			if(j<n)
			dp[j] = min(dp[j], dp[i]+ abs(arr[i]-arr[j]));
		}
	}
	cout<<dp[n-1];
	return 0;
}

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

int main()
{   
    int n;
    scanf("%d",&n);
    int a[50],b[50],c[50];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    for(int i=0;i<n-1;i++){
        scanf("%d",&c[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
    }
    for(int i=0;i<n-1;i++){
        if(a[i+1]==a[i]+1){
            ans+=c[a[i]-1];
        }
    }
   
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
N, T = map(int, input().split())
A = list(map(int, input().split()))
C = 0
L = 10 ** 9 + 5
S = 0
for a in A:
    if a < L:
        L = a
    elif a > L:
        St = a - L
        if St == S:
            C += 1
        elif St > S:
            C = 1
            S = St
print(C)

Measured memory_bytes: 20332
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;

vector<vector<int>> T(100000);
vector<int> rea(100000, -1);
vector<int> rea1(100000, -1);
vector<int> rea2(100000, -1);

int main() {
	int N, M;
	int a, b;
	int s, t, cnt = 0;
	cin >> N >> M;
	for (int i = 0;i < M;i++) {
		cin >> a >> b;
		a--;b--;
		T[a].push_back(b);
	}
	cin >> s >> t;
	s--;t--;
	rea[s] = 0;
	queue<int> Q;
	Q.push(-1);
	for (int i : T[s]) Q.push(i);
	while (Q.size()!=1) {
		a = Q.front();
		//cout << a << endl;
		Q.pop();
		if (a < 0) {
			Q.push(a);cnt++;continue;
		}
		if (cnt % 3 == 0) {
			if (rea[a] < 0) rea[a] = cnt / 3;
			else continue;
		}
		else if (cnt % 3 == 1) {
			if (rea1[a] < 0) rea1[a]++;
			else continue;
		}
		else if (cnt % 3 == 2) {
			if (rea2[a] < 0) rea2[a]++;
			else continue;
		}
		for (int i : T[a])
			Q.push(i);
	}
	cout << rea[t] << endl;
}

Measured memory_bytes: 6912
H, W = map(int, input().split())
S = [0]*(H+2)
S[0] = ''.join(['#']*(W+2))
S[-1] = ''.join(['#']*(W+2))
for i in range(1,H+1):
  S[i] = '#'+input()+'#'

maxd = 0
import queue
dy = [1,0,-1,0]
dx = [0,1,0,-1]
for h in range(1,H+1):
  for w in range(1,W+1):
    if S[h][w]=='.':
      visited = [[False]*(W+2) for _ in range(H+2)]
      q = queue.Queue()
      visited[h][w] = True
      q.put([h,w,0])
      while not q.empty():
        a,b,c = q.get()
        #print(a,b,c)
        for i in range(4):
          y,x = a+dy[i], b+dx[i]
          if S[y][x]=='.' and visited[y][x]==False:
            q.put([y,x,c+1])
            visited[y][x]=True
      maxd = max(maxd,c)
print(maxd)

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

// g++-9 c.cpp

int main(){
    int n;
    cin >> n;
    vector<int> ret(n);
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        ret[num-1] = i+1;
    }
    for(auto& x: ret) cout << x << " ";
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    map<pair<int, int>, int> mp;

    rep(i, n)
    {
        cin >> a[i] >> b[i];
        mp[{a[i], b[i]}]++;
    }
    vector<vector<int>> dp(n + 1, vector<int>(t, 0));
    rep(i, n)
    {
        rep(j, t)
        {
            //cerr << "change " << dp[i + 1][j] << "->" << dp[i][j] << endl;
            dp[i + 1][j] = dp[i][j];
        }
        rep(j, t)
        {
            if (a[i] + j < t)
            {
                if (dp[i + 1][j + a[i]] < dp[i][j] + b[i])
                {
                    dp[i + 1][j + a[i]] = dp[i][j] + b[i];
                }
            }
        }
    }
    int ans = 0;
    rep(j, t)
    {
        //cerr << dp[n][j] << endl;
        rep(i, n)
        {
            //cerr << mp[{n, j}][i] << " ";
            int tt = 0;
            bool ff = (j - a[i] < 0);
            int nn = mp[{a[i], b[i]}];
            rep(k, nn)
            {
                if (j - (k + 1) * a[i] < 0)
                {
                    ff = true;
                    break;
                }
                ff |= (dp[n][j] > dp[n][j - (k + 1) * a[i]] + (k + 1) * b[i]);
                if (k==100)break;
            }

            if (ff)
            {
                //  cerr << j << " " << i << " " << a[i] << " " << b[i] << endl;
                // cerr << dp[n][j] << " " << dp[n][j - a[i]] + b[i] << endl;
                tt = b[i];
            }
            ans = max(ans, dp[n][j] + tt);
        }
        //cerr << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35712
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
#n,k= (int(i) for i in input().split())      #入力整数横2つ
x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意

if y+z<x: c = 0
else:c = y+z-x

print(min(y,z),c)

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

  int s = S.size();
  vector<ll> R(s);
  vector<ll> L(s);
  vector<ll> child(s, 0);

  int check = 0;
  for (int i = 0; i < s; i++) {
    if (S[i] == 'R') {
      check++;
    } else if (S[i] == 'L') {
      if (check % 2 == 0) {
        child[i - 0] += check / 2;
        child[i - 1] += check / 2;
      } else {
        child[i - 0] += check / 2;
        child[i - 1] += check / 2 + 1;
      }
      check = 0;
    }
  }

  for (int i = s - 1; i >= 0; i--) {
    if (S[i] == 'L') {
      check++;
    } else if (S[i] == 'R') {
      if (check % 2 == 0) {
        child[i + 0] += check / 2;
        child[i + 1] += check / 2;
      } else {
        child[i + 0] += check / 2;
        child[i + 1] += check / 2 + 1;
      }
      check = 0;
    }
  }

  cout << child[0];
  for (int i = 1; i < s; i++) {
    cout << SP << child[i];
  }
  cout << BR;

  return 0;
}

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


int main(){
    int n;
    cin >> n;
    vector<vector<int>> open;
    rep(i, n){
        vector<int> tmp(10);
        rep(j, 10) cin >> tmp[j];
        open.push_back(tmp);
    }
    vector<vector<int>> profit;
    rep(i, n){
        vector<int> tmp(11);
        rep(j, 11) cin >> tmp[j];
        profit.push_back(tmp);
    }
    int ans = -1000000000;
    for (int bit = 0; bit < (1<<10); bit++){
        if (bit == 0) continue;
        int score = 0;
        rep(i, n){
            int cnt = 0;
            rep(j, 11) if (bit & (1<<j) && open[i][j]) cnt++;
            score += profit[i][cnt]; 
        }
        ans = max(ans, score);
    }
    cout << ans << endl;
}  


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

struct UF {
	vector<int> data;
	void init(int n)
	{
		data.resize(n);
		fill(begin(data), end(data), -1);
	}
	int root(int x)
	{
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	void unite(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (size(x) < size(y)) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
	int size(int x)
	{
		x = root(x);
		return -data[x];
	}
	bool is_root(int x)
	{
		return x == root(x);
	}
};

int N, M, K;
int counter[100010];

signed main()
{
	cin >> N >> M >> K;

	UF uf;
	uf.init(N);

	rep(i, M) {
		int a, b; cin >> a >> b;
		--a, --b;
		uf.unite(a, b);
		counter[a]++;
		counter[b]++;
	}

	rep(i, K) {
		int c, d; cin >> c >> d;
		--c, --d;

		if (uf.same(c, d)) {
			counter[c]++;
			counter[d]++;
		}
	}

	rep(i, N) {
		printf("%lld%c", uf.size(i) - 1 - counter[i], i == N - 1 ? '\n' : ' ');
	}
}


Measured memory_bytes: 2432
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, K) = read_tuple::<i64>();
    let ans = if K % 2 == 1 {
        (N / K).pow(3)
    } else {
        let e = N / K;
        let o = N * 2 / K - e;
        e.pow(3) + o.pow(3)
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N,M;
    cin >> N >> M;
    string A[N],B[M];
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    bool exist=false;
    for(int i=0;i<M;++i){
        cin >> B[i];
    }
    bool right=true;
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            right=true;
                    if(i+M-1>=N || j+M-1>=N){
                        continue;
                    }
            for(int k=0;k<M;++k){
                for(int l=0;l<M;++l){
                    if(A[i+k][j+l]!=B[k][l]){
                        right=false;
                    }
                    }
            }
            if(right==true){
                exist=true;
            }
        }
    }
    if(exist){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    }

Measured memory_bytes: 256
#!/usr/bin/env python3
# 入力
s = input()
num = len(s)-1
ret = 0

for i in range(2**num):
    st = 0
    for j in range(num):
        if (i >> j) & 1:
            ret += int(s[st:j+1])
            st = j+1
    ret += int(s[st:])

print(ret)





Measured memory_bytes: 8924
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int n;
ll cnt[10][10]{};

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	fore(z,1,n){
		int i=z;
		int a,b;
		b=i%10;
		while(i>=10) i/=10;
		a=i;
		cnt[a][b]++;
	}
	
	ll ans=0;
	forn(i,0,10){
		ans+=cnt[i][i]*cnt[i][i];
		forn(j,i+1,10){
			ans+=cnt[i][j]*cnt[j][i]*2;
		}
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    long n; cin >> n;
    vector<int> a(n, 0); REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    int ans = a.size();
    if (ans % 2 == 0) ans--;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  ll a,b,n;cin>>a>>b>>n;
  print(a*min(n,b-1)/b);
  return 0; 
}


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

const int N = 200 * 1000 + 20;
double ans, n, k, a[N], ps[N];

int main() {
  	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  	cin >> n >> k;
  	for (int i = 0; i < n; i++)
		cin >> a[i];
 	for (int i = 0; i < n; i++)
      	a[i] = (a[i] + 1) / 2;
    for (int i = 1; i <= n; i++)
        ps[i] = ps[i - 1] + a[i - 1];
 	for (int i = k; i <= n; i++)
 	    ans = max(ans, ps[i] - ps[i - (int)k]);
 	cout << setprecision(10) << fixed;
 	return cout << ans << "\n", 0;
}


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

// not-so-diverse.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2017 Seong Yong-ju

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  int n, k;
  cin >> n >> k;

  int as[n];
  map<int, int> kinds_map;

  REP(i, n) {
    int a;
    cin >> a;

    as[i] = a;
    kinds_map[a] = 0;
  }
  REP(i, n) {
    int a = as[i];

    ++kinds_map[a];
  }

  size_t kind_counts = kinds_map.size();
  vector<int> counts;

  for (auto &pair:kinds_map) {
    counts.push_back(pair.second);
  }

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

  int ans =
    k < kind_counts ? accumulate(counts.begin(), counts.begin() + (kind_counts - k), 0, [](int sum, int count) -> int {
      return sum + count;
    }) : 0;
  cout << ans << endl;
}


Measured memory_bytes: 11512
using System;
using System.Text;
 
class AtCoder
{
    static void Main(){
      Int32 a = Int32.Parse( Console.ReadLine());
		string s = Console.ReadLine();
      	for(int cnt=0;cnt < s.Length;cnt++){
          Console.Write((char)(((s[cnt]+a)-65)%26+65));
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    int max = 0;
    int sum = 0;
    int temp;
    for (int i = 0; i < N; i++) {
        scanf("%d", &temp);
        sum += temp;
        if (max < temp) {
            max = temp;
        }
    }
    printf("%s\n", max < (sum - max) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

const int inf = 2e9;

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

	vector<int> w(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}

	int V = 1000 * N;
	VVI dp(N + 1, VI(V+1, inf));

	dp[0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < V; j++) {
			if (dp[i][j] >= W) {
				continue;
			}

			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

			int nv = j + v[i];
			dp[i+1][nv] = min(dp[i+1][nv], dp[i][j] + w[i]);
		}
	}

	int ans = 0;
	for (int i = V; i >= 0; i--) {
		if (dp[N][i] <= W) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 40192
num=raw_input()
tmp=map(int, raw_input().split(" "))
tmp.sort()
tmp.reverse()
oldnum=0
arr=[]
flag=0
out=0
for i in range(len(tmp)-1):
    if tmp[i]==tmp[i+1] and flag==0:
            arr.append(tmp[i])
            flag=1
    else:
        flag=0
    if len(arr)==2:
        out=arr[0]*arr[1]
        break
    try:
        if tmp[i]==tmp[i+1] and tmp[i]==tmp[i+2] and tmp[i]==tmp[i+3]:
            out=tmp[i]**2
            break
    except:
        pass
print out

Measured memory_bytes: 11336
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
 
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
 

 
int main(void){
	ll X;
	cin>>X;
	for(int i=0;i<1000000;i++){
		if(i*(i+1)/2>=X){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
<?php
$haveTrampNum = trim(fgets(STDIN));
$trampCheckList = createTrampCheckList();

for ($i = 0; $i < $haveTrampNum; $i++) {
    list($mark, $num) = getSpacesByExplodeTrimInput();
    $trampCheckList[$mark][$num] = 'check';
}

foreach ($trampCheckList as $key => $value) {
    for ($trampNum = 1; $trampNum <= 13; $trampNum++) {
        if (! isset($trampCheckList[$key][$trampNum])) {
            echo $key.' '.$trampNum, PHP_EOL;
        }
    }
}

function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

function createTrampCheckList()
{
    return array(
        "S" => array_fill(1, 13, null),
        "H" => array_fill(1, 13, null),
        "C" => array_fill(1, 13, null),
        "D" => array_fill(1, 13, null)
    );
}

Measured memory_bytes: 15428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = pow(10LL,9LL) + 7LL;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
  ll n; cin >> n;
  ll x[n];
  FOR(i,0,n-1) cin >> x[i];

  ll porb = 0;
  ll ans = 0;

  FOR(i,0,n-2){
    porb += modinv(i+1,MOD);
    porb %= MOD;
    ans += (x[i+1]-x[i]) * porb;
    ans %= MOD;
  }
  FOR(i,1,n-1){
    ans *= i;
    ans %= MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n);
    vector<ll> b(m);
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<m;i++)
    cin>>b[i];
    vector<ll> dp1(n,0);
    dp1[0]=a[0];
    vector<ll> dp2(m,0);
    dp2[0]=b[0];
    for(ll i=1;i<n;i++)
    dp1[i]=dp1[i-1]+a[i];
    for(ll i=1;i<m;i++)
    dp2[i]=dp2[i-1]+b[i];
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ll val=k-dp1[i];
        
        if(val<0)
        break;
        ll p=upper_bound(begin(dp2),end(dp2),val)-begin(dp2);
        // cout<<i<<" "<<p<<endl;
        ans=max(ans,i+p+1);

    }
    for(ll i=0;i<m;i++)
    {
        ll val=k-dp2[i];
        if(val<0)
        break;
        ll p=upper_bound(begin(dp1),end(dp1),val)-begin(dp1);
        ans=max(ans,i+p+1);
    }
    cout<<ans<<endl;

}

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

int INF = 1000000007;

int main(void){
    int n, k;
    long long int cnt = 0;
    std::cin >> n >> k;
    for(long long int i = k; i <= n+1; i++){
        //long long int tmp = (i * (n - i + 1) + 1);

        long long int l = i * (i-1) / 2;
        long long int r = i * (2 * n - i + 1) / 2;
        //long long int l = sum(0,i-1), r = sum(n-i+1,n);
        cnt += r - l + 1;
        //sum = sum % INF;
        //std::cout << "---" << std::endl;

    }

    std::cout << cnt % INF << std::endl;

    return 0;
}

//long long int tmp = (i * (n - i + 1) + 1);

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

int main(void){
    char temp;

    scanf("%c", &temp);

    if( 'a' <= temp && temp <= 'z' ){
        temp = 'a';
//        temp = temp - ('a' - 'A');
    }else{
        temp = 'A';
//        temp += 32;
//        temp += ('a' - 'A');
    }

    printf("%c\n", temp);

    return 0;

} 


Measured memory_bytes: 3660
import java.io.PrintWriter

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (N, M) = reader.readLine()!!.split(" ").map { Integer.parseInt(it) }
    val pw = PrintWriter(System.out)

    var p = mutableMapOf<Int, Int>()
    var y = mutableMapOf<Int, Int>()
    var yd = mutableMapOf<Int, MutableList<Int>>()

    for (i in 1..M) {
        val (Pi, Yi) = reader.readLine()!!.split(" ").map { Integer.parseInt(it) }
        p[i] = Pi
        y[i] = Yi
        if (yd.containsKey(Pi)) {
            yd[Pi]!!.add(Yi)
        } else {
            yd[Pi] = mutableListOf(Yi)
        }
    }

    var ydid = mutableMapOf<Int, Int>()
    for (i in yd.keys) {
        var num = 1
        for (j in yd[i]!!.sorted()) {
            ydid[j] = num
            num = num.inc()
        }
    }
//    var res = mutableListOf<String>()
    for (i in 1..M) {
//        res.add(p[i].toString().padStart(6, '0') + ydid[y[i]].toString().padStart(6, '0'))
//        val pid = "%06d".format(p[i])
//        val yid = "%06d".format(ydid[y[i]])
//        pw.println("%s%s".format(pid, yid))
        pw.println(p[i].toString().padStart(6, '0') + ydid[y[i]].toString().padStart(6, '0'))
    }
    pw.flush()
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=17;

int n;
ll a[N][N];
ll dp[N][(1<<N)];
ll s[(1<<N)];

int bts[N],cnt=0;

int cur;

void bkt(int strat,int mask)
{
    if(strat==cnt)
    {
        s[cur]=max(s[cur],s[mask]+dp[n-1][cur-mask]);
    }
    else
    {
        bkt(strat+1,mask);
        bkt(strat+1,mask+(1<<bts[strat]));
    }
}

int main()
{
    ///ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<(1<<N);j++)
        {
            dp[i][j]=-(1LL<<60);
        }
        dp[i][0]=0;
    }
    for(int i=0;i<n;i++)
    {
        for(int now=0;now<(1<<n);now++)
        {
            if(i-1>=0)
            {
                dp[i][now]=dp[i-1][now];
            }
            if(now&(1<<i))
            {
                bool ok=1;
                ll add=0LL;
                for(int j=0;j<n;j++)
                {
                    if(now&(1<<j) && j!=i)
                    {
                        if(j>i)
                        {
                            ok=0;
                            break;
                        }
                        add+=a[i][j];
                    }
                }
                if(ok)
                {
                    if(i==0)
                    {
                        dp[i][now]=max(dp[i][now],add);
                    }
                    else
                    {
                        dp[i][now]=max(dp[i][now],dp[i-1][now-(1<<i)]+add);
                    }
             ///       if(i>0)
                 ///   cout<<i<<" , "<<now<<" : "<<dp[i][now]<<"\n";
                }
            }
        }
    }
    for(int now=0;now<(1<<n);now++)
    {
        s[now]=dp[n-1][now];
    }
    for(int now=0;now<(1<<n);now++)
    {
        cnt=0;
        for(int i=0;i<n;i++)
        {
            if(now&(1<<i))
            {
                bts[cnt++]=i;
            }
        }
        cur=now;
        bkt(0,0);
    }
    cout<<s[(1<<n)-1]<<"\n";
    return 0;
}



Measured memory_bytes: 18176
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a[5];
	REP(i,3){
		cin>>a[i];
	}
	sort(a,a+3);
	cout<<a[2]-a[1]+a[1]-a[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
S=input()
T=input()

def isOK(s):
    res=[]
    if len(s)<len(T):
        return res
    for i in range(len(s)-len(T)+1):
        ns=s[i:i+len(T)]
        for j in range(len(T)):
            if ns[j]!='?' and not ns[j]==T[j]:
                break
        else:
            res.append(s[:i]+T+s[i+len(T):])
    return res

OK_list=isOK(S)
if OK_list:
    OK_list.sort()
    print(OK_list[0].replace('?','a'))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 62052
from itertools import permutations
from math import factorial

N = int(input())
coord = []
for _ in range(N):
   x,y = map(int, input().split())
   coord.append((x,y))

def dist(a, b):
   x1, y1 = a
   x2, y2 = b
   return pow((x1-x2) ** 2 + (y1-y2) ** 2, 1/2)

res = 0
for i in range(N):
   for j in range(i+1, N):
      res += dist(coord[i], coord[j]) * 2 / N

print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i=0; i<n; i++) cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (n&1) {
		cout << b[n/2] - a[n/2] + 1;
	}
	else {
		cout << b[n/2-1] + b[n/2] - a[n/2-1] - a[n/2] + 1;
	}
}

Measured memory_bytes: 4768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	ll d,t,s;
	while(cin>>d>>t>>s)
	{
		if(t*s>=d)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	
	return 0;
}

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

int main() {
  int n;cin>>n;
  pair<int, int> an[n];
  rep(i,n) {
    cin>>an[i].first>>an[i].second;
  }
  sort(an, an+n, [](auto const& left, auto const& right) {
    return (left.first+left.second) > (right.first + right.second);
  });
  
  ll sum=0;
  rep(i,n) {
    if (i%2==0) sum += an[i].first;
    else sum -= an[i].second;
  }
  cout<<sum<<endl;
}


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

int main()
{
  int n, k; cin >> n >> k;
  vector<int> v(n); 
  for(int i = 0; i < n; ++i) cin >> v[i];
  sort(v.begin(), v.end());
  cout << accumulate(v.begin(), v.begin()+k, 0);
  return 0;
}

Measured memory_bytes: 3568
N, X = list(map(int, input().split()))
m = []
for i in range(N):
    m.append(int(input()))

def solve():
    money = X
    ans = len(m)
    money -= sum(m)
    ans += money//min(m)
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
import sys, re
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    s = readline().strip()
    ans = []
    for w in re.split("[ .,]", s):
        if 3 <= len(w) <= 6:
            ans.append(w)
    write(" ".join(ans))
    write("\n")
solve()


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

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()

#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;

ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}

void solve()
{
	ll k;
	cin>>k;

	ll ans=0;
	For(i,1,k+1)
	{
		For(j,1,k+1)
		{
			For(l,1,k+1)
			{
				ans+=__gcd(i,__gcd(j,l));
			}
		}
	}
	cout<<ans<<endl;
}

signed main() 
{
    fast_cin();
    // #ifndef ONLINE_JUDGE
    // freopen("C:/IO/in.txt", "r", stdin);
    // freopen("C:/IO/out.txt", "w", stdout);
    // #endif
    
    int t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 3660