akhauriyash/Code-Regression huggingface dataset:
import math

g = 9.8
ESP = 1e-6


def calc(vy, t):
    return vy * t - g * t * t / 2


def cmp(lb, ub, a):
    if a < lb + ESP:
        return -1
    elif ub - ESP < a:
        return 1
    else:
        return 0


def check(qx, qy):
    a = (g * g) / 4
    b = g * qy - V * V
    c = qx * qx + qy * qy
    D = b * b - 4 * a * c

    if D < 0 and -ESP < D:
        D = 0

    if D < 0:
        return False

    for d in range(-1, 2, 2):
        t2 = (-b + d * math.sqrt(D)) / (2 * a)
        if t2 <= 0:
            continue

        t = math.sqrt(t2)
        vx = qx / t
        vy = (qy + g * t * t / 2) / t

        yt = calc(vy, X / vx)
        if yt < Y - ESP:
            continue
        ok = True

        for i in range(0, N):
            if L[i] >= X:
                continue

            if R[i] == X and Y <= T[i] and B[i] <= yt:
                ok = False

            yL = cmp(B[i], T[i], calc(vy, L[i] / vx))
            yR = cmp(B[i], T[i], calc(vy, R[i] / vx))

            xH = cmp(L[i], R[i], vx * (vy / g))
            yH = cmp(B[i], T[i], calc(vy, vy / g))
            if xH == 0 and yH >= 0 and yL < 0:
                ok = False
            if yL * yR <= 0:
                ok = False
        if ok:
            return True
    return False


if __name__ == '__main__':
    N, V, X, Y = list(map(int, input().split()))
    L = []
    B = []
    R = []
    T = []
    for i in range(N):
        tmp_L, tmp_B, tmp_R, tmp_T = list(map(int, input().split()))
        L.append(tmp_L)
        B.append(tmp_B)
        R.append(tmp_R)
        T.append(tmp_T)

    for i in range(0, N):
        R[i] = min(R[i], X)

    ok = check(X, Y)
    for i in range(0, N):
        if L[i] == 0 and T[i] != 0:
            pass
        else:
            ok |= check(L[i], T[i])

        if R[i] == 0 and T[i] != 0:
            pass
        else:
            ok |= check(R[i], T[i])

    print("Yes" if ok else 'No')

Measured memory_bytes: 7992
import * as fs from "fs";

// inputで受け取り配列化する
const [a, b] = fs.readFileSync("/dev/stdin", "utf8").split(" ").map(Number);

const multi = a * b;

if (multi % 2 === 0) {
  console.log("Even");
} else {
  console.log("Odd");
}


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

int main() {
  int S;
  int h, m, s;

  cin >> S;

  h = S / 3600;
  m = (S - h * 3600) / 60;
  s = S - h * 3600 - m * 60;

  cout << h << ':'
       << m << ':'
       << s << endl;
}

Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main()
{
    long long a[1000],i,n,total=0,m,min=0,s,j,min2=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        total=total+a[i];
    }
    m=total/n;
    s=m+1;
    for(i=1;i<=n;i++)
    {
        min=min+((a[i]-m)*(a[i]-m));
        min2=min2+((a[i]-s)*(a[i]-s));
    }
    if(min<=min2)
    {
        cout<<min<<endl;
    }
    else
    {
        cout<<min2<<endl;
    }
    return 0;
}

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

int main() {
  int K,N;
  string S;
  cin>>N>>K>>S;
  if(S.at(K-1)=='A'){
    S.at(K-1)='a';
  }
  if(S.at(K-1)=='B'){
    S.at(K-1)='b';
  }
  if(S.at(K-1)=='C'){
    S.at(K-1)='c';
  }
  cout<<S<<endl;
}

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

typedef long long ll;

const ll INF = 2e18;

const int MAXN = 2.1e5;
int N;
ll K;
int A[MAXN];

const int MAXV = 2.1e5;
int nxtOcc[MAXV];

const int L = 60;
ll jumpDist[MAXN][L + 1];

int main() {
	scanf("%d %lld", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	// cyclic
	for (int i = N-1; i >= 0; i--) {
		nxtOcc[A[i]] = i+N;
	}
	for (int i = N-1; i >= 0; i--) {
		jumpDist[i][0] = (nxtOcc[A[i]] - i) + 1;
		nxtOcc[A[i]] = i;
	}

	for (int l = 0; l < L; l++) {
		for (int i = 0; i < N; i++) {
			jumpDist[i][l+1] = min(INF, jumpDist[i][l] + jumpDist[(i + jumpDist[i][l]) % N][l]);
		}
	}

	ll curLoc = 0;
	for (int l = L; l >= 0; l--) {
		if (curLoc + jumpDist[curLoc % N][l] <= N * K) {
			curLoc += jumpDist[curLoc % N][l];
		}
	}

	vector<int> ans;
	while (curLoc < N * K) {
		ll nxtLoc = (curLoc + jumpDist[curLoc % N][0]);
		if (nxtLoc <= N * K) {
			curLoc = nxtLoc;
		} else {
			ans.push_back(A[curLoc % N]);
			curLoc++;
		}
	}

	for (int v : ans) {
		printf("%d ", v);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 102004
/*
 * ID: ITP2_1_C
 * Problem: List
 */

#include <stdio.h>
#include <stdlib.h>

struct _list {
    int value;
    struct _list* next;
    struct _list* prev;
};

typedef struct _list list_t;

int main(void)
{
    list_t *p;

    p = malloc(sizeof(list_t));
    p->value = 999;
    p->prev = NULL;
    p->next = NULL;

    int n_command;
    scanf("%d", &n_command);

    int n;
    for (n = 0; n < n_command; n++) {
        list_t *q, *r;
        int command;
        scanf("%d", &command);

        int v, move, i;
        switch (command) {
            case 0:
                scanf("%d", &v);

                q = malloc(sizeof(list_t));
                q->value = v;
                q->prev = p;
                q->next = p->next;
                if (p->next)
                    (p->next)->prev = q;
                p->next = q;
                p = q;
                break;
            case 1:
                scanf("%d", &move);

                if (move > 0)
                    for (i = 0; i < move; i++)
                        p = p -> prev;
                else
                    for (i = 0; i < -move; i++)
                        p = p -> next;
                break;
            case 2:
                q = p->next;
                r = p->prev;
                if (r)
                    r->next = q;
                if (q)
                    q->prev = r;
                free(p);
                p = r;
                break;
        }
    }

    for (; p -> next; p = p->next)
        ;
    for (; p -> prev; p = p->prev)
        printf("%d\n", p->value);

    return 0;
}



Measured memory_bytes: 17404
#include<bits/stdc++.h>
#define register rg
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
typedef long long ll;
int a[1000001];
int main() {
	//file("a");
	int n,x;
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	x=a[1];
	for(int i=2; i<=n; i++)
		x=__gcd(a[i],x);
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    string S, T;
    cin >> S >> T;
    S += S;
    REP (i, T.size()) {
        if (S.substr(i, T.size()) == T) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007,INF=1001001001;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


#define int ll

int n,b;
int a[100010];
int cnt=0,ans=0;

signed main(){
    cin>>n;
    rep(i,0,100010)a[i]=0;
    rep(i,0,n){
        cin>>b;b--;
        a[b]++;
    }
    rep(i,0,100010){
        if(a[i]==0 || a[i]==1)continue;
        if(a[i]%2==0)cnt++,ans--;
        ans+=a[i]/2;
    }
    ans+=(cnt+2-1)/2;
    cout<<n-ans*2<<endl;
    return 0;
}

Measured memory_bytes: 1024
n,q=gets.split.map(&:to_i)
s=gets.chomp
dp=[0,0]
(n-1).times{|i|
  v=s[i]==?A && s[i+1]==?C ? 1 : 0
  dp << dp.last+v
}
q.times{
  l,r=gets.split.map(&:to_i)
  puts dp[r]-dp[l]
}

Measured memory_bytes: 3452
n = input()
*l, = map(int,input().split())
cl = [0]*(10**5)
for i in l:
  cl[i]+=1
xl = [0]*(10**5)
for i in range(0,10**5-2):
  xl[i] = cl[i]+cl[i+1]+cl[i+2]
print(max(xl))

Measured memory_bytes: 13964
#include<bits/stdc++.h>
#define ll long long
#define F(i,a,b) for(i = a; i <= b; i ++)
#define RF(i,a,b) for(i = a; i >= b;i --)
#define sz(a) sizeof(a)
using namespace std;

typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef unordered_map<int,int> umii;
typedef unordered_map<char,int> umci;

void solve()
{
    int n,i;
    cin>>n;
    int *height_arr = new int[sz(int) * n], * sol = new int[sz(int) * n];
    F(i,0,n - 1)
        cin>>height_arr[i];
    sol[n - 1] = 0;
    sol[n - 2] = abs(height_arr[n - 1] - height_arr[n - 2]);
    RF(i, n - 3, 0)
    {
        sol[i] = min(abs(height_arr[i + 2] - height_arr[i]) + sol[i + 2]
                    ,abs(height_arr[i + 1] - height_arr[i]) + sol[i + 1]);
    }
    cout<<sol[0]<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#else
    //#endif
    solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	string s = "MARCH";
	map<char, ll> cnt;
	ll res = 0;
	void find(int p = 0, int l = 0, string prefix = "") {
		if (p == 3) {
			res += cnt[prefix[0]] * cnt[prefix[1]] * cnt[prefix[2]];
			return;
		}
		for (int i = l; i < s.size(); i++) {
			find(p + 1, i + 1, prefix + s[i]);
		}
	}

	void solve() {
		int n;
		cin >> n;
		for (int i = 0; i < n; i++) {
			string t;
			cin >> t;
			cnt[t[0]]++;
		}
		find();
		cout << res;
	}

	int main() {
		ios::sync_with_stdio(false);
		cin.tie(0);
		int t = 1;
		//cin >> t;
		for (int i = 1; i <= t; i++) {
			solve();
		}
	}

Measured memory_bytes: 3600
def main():
    X, Y, A, B, C = map(int, input().split())
    *p, = sorted(map(int, input().split()), reverse=True)
    *q, = sorted(map(int, input().split()), reverse=True)
    *r, = map(int, input().split())

    pool = p[:X] + q[:Y] + r
    pool.sort(reverse=True)
    ret = sum(pool[:X + Y])
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24240
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  int a;
  cin>>a;
  cout<<(a+(a*a)+(a*a*a));
    
}

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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;

ll x;

int main() {
  cin >> x;
  ll ans = 0;
  ans = (x/11) * 2;
  x %= 11;
  if (x>6) cout << ans+2 << endl;
  else if (x>0) cout << ans+1 << endl;
  else if (x==0) cout << ans << endl;
  return 0;
}


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

#define mx 1000000009
int main()
{


  ll n,W;
  cin>>n;
  cin>>W;
  ll v[n+1],w[n+1];
  ll sum=0;

  for(ll i=1;i<=n;i++)
    cin>>w[i]>>v[i];

  for(ll i=1;i<=n;i++)
    sum+=v[i];


  ll dp[sum+1];

  for(ll i=1;i<=sum;i++)
    dp[i]=mx;

  dp[0]=0;

//   cout<<sum<<endl;
  for(ll i=1;i<=n;i++)
  {

    
    for(ll j=sum;j>=v[i];j--)
    {
         
         dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }


  }

 for(ll j=sum;j>=0;j--)
 {
    //  cout<<dp[j]<<" ";
 if(dp[j]<=W)
  {
    cout<<j;
    break;
  }
 }
}

Measured memory_bytes: 1024
import collections

N = int(input())
A_s = list(map(int, input().split()))

CNT_A = collections.Counter(A_s).most_common()
sorted_A = sorted(CNT_A, reverse=True)


verticle = []
ans = 0


for i in range(len(CNT_A)):
    key = sorted_A[i][0]
    value = sorted_A[i][1]
    
    if (value > 1):
        verticle.append(key)
    

    if (len(verticle) == 1 and value > 3):
        ans = key * key
        break

    elif (len(verticle) >= 2):
        ans = verticle[0] * verticle[1]
        break


print(ans)

Measured memory_bytes: 21540
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

//??§?¨???§???
//v: ??§???????????§?¨??????? ????????????
template<typename T>
vector<int> compress(vector<T> v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	return v;
}

//??§???????????§?¨?
//index(??§???????????§?¨?, ??§???????????§?¨??????????(??????))
template<typename T>
int index(const vector<T> &v, T i) { return lower_bound(v.begin(), v.end(), i) - v.begin(); }

signed main() {
	int N; cin >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N);
	rep(i, 0, N) {
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	vector<int> x(x1);
	x.insert(x.end(), x2.begin(), x2.end());
	vector<int> y(y1);
	y.insert(y.end(), y2.begin(), y2.end());
	vector<int> zipx = compress(x), zipy = compress(y);
	dump(zipx);
	dump(zipy);
	vector<vector<int>> s(zipx.size() + 1, vector<int>(zipy.size() + 1, 0));
	rep(i, 0, N) {
		s[index(zipx, x1[i])][index(zipy, y1[i])]++;
		s[index(zipx, x2[i])][index(zipy, y2[i])]++;
		s[index(zipx, x1[i])][index(zipy, y2[i])]--;
		s[index(zipx, x2[i])][index(zipy, y1[i])]--;
	}
	rep(x, 0, zipx.size())rep(y, 0, zipy.size()) {
		s[x + 1][y] += s[x][y];
	}
	rep(y, 0, zipy.size())rep(x, 0, zipx.size()) {
		s[x][y + 1] += s[x][y];
	}
	int ans = 0;
	rep(x, 0, s.size() - 1) {
		rep(y, 0, s[x].size() - 1) {
			dump(x, y);
			if (s[x][y] == 0)continue;
			ans += (zipx[x + 1] - zipx[x])*(zipy[y + 1] - zipy[y]);
			dump(ans);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 128292
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	int A[N], ans = 0;
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	sort(A, A + N);
	for (int i = 0; i < K; ++i) ans += A[i];
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 1736
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	double sol;

	sol = (double)n / 3.0;

	printf("%.7lf", sol*sol*sol);

	return 0;
}

Measured memory_bytes: 128
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()


void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int32_t main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();
    int n;
    cin >> n;
    int w;
    cin >> w;

    
    vector<pair<int, int>> v;
    int s = 0;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        s += y;
        v.push_back({x, y});
    }
    //deb(s);
    int dp[n+1][s+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=s;j++){
            dp[i][j] = INT_MAX;
        }
    }
    dp[0][0] = 0;
    for(int i=1;i<=n;i++){
        dp[i][0] = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= s; j++)
        {
            if (v[i - 1].second <= j)
            {
                
                dp[i][j] = min(dp[i - 1][j], v[i - 1].first + dp[i - 1][j - v[i - 1].second]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= s; i++)
    {
        
        if (dp[n][i] <= w)
        {
            ans = i;
        }
    }
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 82424
#include <iostream>
#include <cstdio>
#define N 15
using namespace std;

int h, w, s, mn, a[N], c[N][N];
bool v[N];

void f(int p, int q) {
	int i;
	if (q >= mn) return;
	if (p == 1) {mn = q; return;}
	if (v[p]) return;
	v[p] = 1;
	for (i = 0; i <= 9; i++) f(i, q + c[p][i]);
	v[p] = 0;
}

int main()
{
	int i, j, t;
	cin >> h >> w;
	h *= w;
	for (i = 0; i <= 9; i++) for (j = 0; j <= 9; j++) scanf("%d", &c[i][j]);
	for (i = 0; i <= 9; i++) mn = 1e9, f(i, 0), a[i] = mn;
	while (h--) {
		scanf("%d", &t);
		if (t != -1) s += a[t];
	}
    cout << s << endl;
    return 0;
}

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

int main() {
  int count = 0, A, B;
  
  cin >> A >> B;
  for(int i = A; i <= B; i++) {
    if(i / 10000 == i % 10) {
      if(i % 10000 / 1000 == i % 100 / 10) {
        count = count + 1;
      }
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
sx, sy, tx, ty = tuple(int(x) for x in input().split())

ans = ''
ans += 'U' * abs(ty - sy)
ans += 'R' * abs(tx - sx)
ans += 'D' * abs(ty - sy)
ans += 'L' * abs(tx - sx)
ans += 'L'
ans += 'U' * (abs(ty - sy) + 1)
ans += 'R' * (abs(tx - sx) + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (abs(ty - sy) + 1)
ans += 'L' * (abs(tx - sx) + 1)
ans += 'U'

print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<long> a(N);
  vector<long> b(N);
  vector<long> d(N);
  long sum=0;
  long cold=0;
  int sat=0;
  for(int i=0;i<N;i++)cin >> a[i];
  for(int i=0;i<N;i++){
    cin >> b[i];
    d[i]=b[i]-a[i];
    cerr << d[i] << endl;
    cold+=d[i];
    if(d[i]>0){
      sum+=d[i];
      sat++;
    }
  }
  if(cold>0)cout << -1;
  else{
    sort(d.begin(),d.end());
  //	reverse(d.begin(),d.end());
    int ans=0;
    while(sum>0){
      sum+=d[ans];
      ans++;
    }
    cout << ans+sat;
  }
}








Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <algorithm>
#define llint long long
#define eps 1e-9

using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> S;

llint h, w, l;
char c[105][105];
string s = "NESW";
S succ[60][105][105][4];
llint dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};

int main(void)
{
	while(1){
		cin >> h >> w >> l;
		if(h == 0 && w == 0) break;
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				cin >> c[x][y];
			}
		}
		
		S p;
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				if(c[x][y] == '.' || c[x][y] == '#') continue;
				p.first.first = x, p.first.second = y;
				for(int i = 0; i < 4; i++){
					if(s[i] == c[x][y]) p.second = i;
				}
			}
		}
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				for(int d = 0; d < 4; d++){
					for(int i = 0; i < 4; i++){
						llint nd = (d+i)%4, nx = x + dx[nd], ny = y + dy[nd];
						if(nx <= 0 || nx > w || ny <= 0 || ny > h) continue;
						if(c[nx][ny] == '#') continue;
						succ[0][x][y][d] = S(P(nx, ny), nd);
						break;
					}
				}
			}
		}
		
		for(int i = 1; i < 60; i++){
			for(int y = 1; y <= h; y++){
				for(int x = 1; x <= w; x++){
					for(int d = 0; d < 4; d++){
						llint mx = succ[i-1][x][y][d].first.first, my = succ[i-1][x][y][d].first.second, md = succ[i-1][x][y][d].second;
						succ[i][x][y][d] = succ[i-1][mx][my][md];
					}
				}
			}
		}
		
		for(int i = 59; i >= 0; i--){
			if(l & (1LL<<i)){
				p = succ[i][p.first.first][p.first.second][p.second];
			}
		}
		cout << p.first.second << " " << p.first.first << " " << s[p.second] << endl;
	}
	return 0;
}


Measured memory_bytes: 65088
#include <iostream>
using namespace std;
int main(){
 int a,b,c;
 cin>>a>>b>>c;
 if(b>c) swap(b,c);
 if(a>b) swap(a,b);
 if(b>c) swap(b,c);
 cout<<a<<" "<<b<<" "<<c<<endl;
 return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n);
  vector<bool> v(1000010);
  map<int, int> cntmp;
  REP(i, n) {
    cin >> a[i];
    v[a[i]] = true;
    cntmp[a[i]]++;
  }

  vector<bool> sel(n, true);
  REP(i, n) {
    if(cntmp[a[i]] > 1) {
      sel[i] = false;
      continue;
    }
    if(a[i] == 1) continue;
    for(ll j=1;j*j <= a[i];++j) {
      if(a[i] % j == 0) {
        if(v[j]) {
          sel[i] = false;
          break;
        }
        if(j!=1 && v[a[i]/j]) {
          sel[i] = false;
          break;
        }
      }
    }
  }

  int cnt = 0;
  REP(i, n) cnt += sel[i];
  cout << cnt << endl;



}
























Measured memory_bytes: 13472
#include <iostream>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <stack>
using namespace std;

bool isop(const string &s) {
  return s == "+" || s == "*" || s == "-" || s == "/";
}

int main() {
  map<string, set<int> > idx;
  int n,m,lb,ub;
  string name;
  cin>>m;
  for (int i=0; i<m; ++i) {
    cin>>name>>lb>>ub;
    set<int> s;
    for (int j=lb; j<=ub; ++j) s.insert(j);
    idx[name] = s;
  }

  cin>>n;
  stack<set<int> > st;
  string exp;
  bool error = false;
  for (int i=0; i<n; ++i) {
    cin>>exp;
    if (error) continue;
    if (isop(exp)) {
      if (st.size() < 2) {
        error = true;
        continue;
      }
      set<int> right = st.top(); st.pop();
      set<int> left = st.top(); st.pop();
      set<int> v;
      for (set<int>::iterator l=left.begin(); l!=left.end(); ++l) {
        for (set<int>::iterator r=right.begin(); r!=right.end(); ++r) {
          if (exp == "+") v.insert((*l+*r)%256);
          if (exp == "-") v.insert((*l-*r+256)%256);
          if (exp == "*") v.insert(((*l) * (*r))%256);
          if (exp == "/") {
            if (*r == 0) error = true;
            else v.insert(((*l)/(*r))%256);
          }
        }
      }
      st.push(v);
    } else if (idx.find(exp) != idx.end()) {
      st.push(idx[exp]);
    } else {
      set<int> v; v.insert(atoi(exp.c_str()));
      st.push(v);
    }
  }
  if (error) cout<<"error"<<endl;
  else cout<<"correct"<<endl;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;

class Program
{
  static void Main(string[] args)
  {
    string str = Console.ReadLine();
    int n = int.Parse(str);

    Dictionary<int, bool> map = new Dictionary<int, bool>();
    for (int i=0; i<n; i++) {
      string t_str = Console.ReadLine();
      int t = int.Parse(t_str);
      if (map.ContainsKey(t)) {
        map.Remove(t);
      } else {
        map.Add(t, true);
      }
    }

    Console.WriteLine(map.Count);
    return;
  }
}


Measured memory_bytes: 21088
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2005;
int f[2][N],s[N],n,m,k,t,l,res;
inline int min(R int x,R int y){return x<y?x:y;}
int main(){
	scanf("%d%d%d",&n,&m,&k),l=(n+m-1)/(k-1),--m;
	f[0][0]=1,t=0;
	for(R int i=1;i<=l;++i,t^=1){
		s[0]=f[t][0];
		fp(j,1,n)s[j]=add(s[j-1],f[t][j]);
		fp(j,0,min(n,k-1))f[t^1][j]=s[j];
		fp(j,k,n)f[t^1][j]=dec(s[j],s[j-k]);
		fp(j,1,n)if(j%(k-1)==n%(k-1)&&i*(k-1)-j<=m&&(i*(k-1)-j)%(k-1)==m%(k-1))
			upd(res,dec(f[t^1][j],f[t][j]));
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    ANS = [ [0]*N for _ in range(N)]
    for i in range(11):
        if N <= pow(2,i):
            M = i
            break
    # for s in range(1, N, 2):
    #     for i in range(N-s):
    #         ANS[i][i+s] = 1
    for t in range(1,M+1):
        w = pow(2,t-1)
        for s in range(1,N+1, 2):
            if w*s >= N:
                break
            for i in range(N-s*w):
                if ANS[i][i+w*s] == 0:
                    ANS[i][i+w*s] = t
    for i in range(N-1):
        print( " ".join( map( str, ANS[i][i+1:])))
if __name__ == '__main__':
    main()


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

typedef tuple<string,int,int> tp;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<tp> a(n);
	for (int i=0; i<n; i++) {
		string s; int p; cin>>s>>p;
		a[i]=make_tuple(s,-p,i+1);
	}
	sort(a.begin(),a.end());
	for (int i=0; i<n; i++)
		cout<<get<2>(a[i])<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int y[51], t[51];
int n, r;

void set_yama(int n){
    for(int i=0; i<n; i++){
        y[i] = i + 1;
    }
}

void shuffle(int n, int r){
    for(int i=0; i<r; i++){
        int p,c;
        cin >> p >> c;

        for(int j=0; j<c; j++){
            t[c-1-j] = y[n-p-j];
        }

        for(int j=n-p+1; j<n; j++){
            y[j-c] = y[j];
        }

        for(int j=0; j<c; j++){
            y[n-c+j] = t[j];
        }
    }
}

int main(void){

    while(1){
        cin >> n >> r;
        if(n==0 || r==0){
            break;
        }
        
        set_yama(n);
        shuffle(n, r);
        cout << y[n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
n=int(input())
dic={}
ds=[int(s)for s in input().split(" ")]
for d in ds:
    if d in dic:dic[d]+=1
    else:dic[d]=1
m=int(input())
ts=sorted([int(s)for s in input().split(" ")])
f=True
for t in ts:
    if t not in dic or dic[t]==0:
        print("NO")
        f=False
        break
    else:dic[t]-=1
if f:print("YES")

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

ll n;
string ans;
int main(){
	cin>>n;
	while(n){
		n-=1;
		ans+=n%26+'a';
		n/=26;
	}
	for(int i=ans.size()-1;i>=0;i--) cout<<ans[i];
	return 0;
} 

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
const int inf=0x3f3f3f3f;
ll n;
ll dp[maxn][3];
ll a[maxn][3];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][1]>>a[i][2]>>a[i][3];
    }
    dp[1][1]=a[1][1];
    dp[1][2]=a[1][2];
    dp[1][3]=a[1][3];
    for(int i=2;i<=n;i++)
    {
        dp[i][1]=dp[i][2]=dp[i][3]=-inf;
    }
    for(int i=2;i<=n;i++)
    {
        dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i][1];
      	dp[i][2]=max(dp[i-1][1],dp[i-1][3])+a[i][2];
      	dp[i][3]=max(dp[i-1][1],dp[i-1][2])+a[i][3];
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 214748364700000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
   ll N;cin >> N;
   vector<ll> P(N),Q(N),A(N);
   rep(i,N) cin >> P[i];
   rep(i,N) cin >> Q[i];
   rep(i,N) A[i] = i+1;
   ll a = 0,b = 0,l = 0;
   do{
       bool p = 1,q = 1;
       rep(i,N){
           if(A[i] != P[i]) p = 0;
           if(A[i] != Q[i]) q = 0;
       }
       if(p) a = l;
       if(q) b = l;
       l++;
   }while(next_permutation(ALL(A)));
   cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int ans = 0;
    char s[4 + 1];
    scanf("%s", s);
    for(int i = 0; s[i] != '\0'; i++){
        if(s[i] == '+') ans++;
        else ans--;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
ac,wa = 0,0
was = [0]*(N+1)
acs = [0]*(N+1)
for i in range(M):
    p,S = input().split()
    p = int(p)
    if S=="AC":
        if acs[p]==0:
            ac+=1
            wa+=was[p]
            acs[p]=1
    else:
        was[p] += 1
print(ac,wa)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}



int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    ll mcnt=0;
    for (ll i = 0; i < S.length(); i++) {
        ll cnt=0;
        for (ll j = 0; j < T.length(); j++) {
            if(i+j>=S.length()) {
                cnt=0;
                continue;
            }
            if(i+j< S.length() && S[i+j]==T[j]) cnt++;
        }
        chmax(mcnt,cnt);
    }
    cout << T.length() - mcnt << endl;
    return 0;
}


Measured memory_bytes: 3624
n = int(input())
lst = []
count = 0
for i in range(3):
    lst.append(input())

for i in range(n):
    if not lst[0][i] == lst[1][i] == lst[2][i]:
        if (lst[0][i] == lst[1][i]) or (lst[1][i] == lst[2][i]) or (lst[0][i] == lst[2][i]):
            count += 1
        else:
            count += 2
print(count)

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
  const hoge = input.split(' ');
  const A = Number(hoge[0]);
  const B = Number(hoge[1]);
  const C = Number(hoge[2]);

  if (C >= A && C <= B) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

// let input = `6 5 4`;
// Main(input);
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    while(1){
        int n,x,cnt=0;
        cin >> n >> x;
        if(n==0 && x==0){
            return 0;
        }
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define maxn 4000010
#define P 1000000007
#define mod 1000000007
using namespace std;
typedef long long ll;
const int M = 2000100;
ll fact[maxn];
ll ifact[maxn];
ll x1,x2,x3,x4,x5,x6;
ll y1,y2,y3,y4,y5,y6;
ll qpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b&1) res=res*a%P;
		b>>=1;
		a=a*a%P;
	}
	return res;
}

ll C(ll n,ll m) {
	return m<=n?(long long)fact[n]*ifact[m]%P*ifact[n-m]%P:0;
}
ll cal(ll n,ll m) {
//	cout << C(n+m, n) << endl;
	return C(n+m, n);
}
struct node {
	int x, y, val;
	node(int x, int y, int val) : x(x), y(y), val(val) {}
	node() {}
} a[10], b[10];
ll solve(node a, node b) {
	ll res = 0;

	for(int x=x3; x<=x4; x++) {
		res += cal(x - a.x, y3 - a.y - 1)*cal(b.x - x, b.y - y3)%mod*(-x-y3)%mod*a.val*b.val;
		res %= mod;
		res+= mod;
		res%=mod;
	}
	for(int x=x3; x<=x4; x++) {
		res += cal(x - a.x, y4 - a.y)*cal(b.x - x, b.y - y4 - 1)%mod*(x+1+y4)%mod*a.val*b.val;
		res %= mod;
		res+= mod;
		res%=mod;
	}
	for(int y=y3; y<=y4; y++) {
		res += cal(x3 - 1 - a.x, y - a.y)*cal(b.x - x3, b.y - y)%mod*(-y-x3)%mod*a.val*b.val;
		res %= mod;
		res+= mod;
		res%=mod;
	}
	for(int y=y3; y<=y4; y++) {
		res += cal(x4 - a.x, y - a.y)*cal(b.x - x4 - 1, b.y - y)%mod*(y+x4+1)%mod*a.val*b.val;
		res %= mod;
		res+= mod;
		res%=mod;
	}
	return res;
}
int main() {
	fact[0]=1;
	for(int i=1; i<=M; ++i)
		fact[i]=fact[i-1]*i%P;
	ifact[M]=qpow(fact[M],P-2);
	for(int i=M-1; i>=0; --i)
		ifact[i]=ifact[i+1]*(i+1)%P;

	scanf("%lld%lld%lld%lld%lld%lld",&x1,&x2,&x3,&x4,&x5,&x6);
	scanf("%lld%lld%lld%lld%lld%lld",&y1,&y2,&y3,&y4,&y5,&y6);
	a[0] = node(x1-1, y1-1, 1);
	a[1] = node(x2, y1-1, -1);
	a[2] = node(x1-1, y2, -1);
	a[3] = node(x2, y2, 1);
	b[0] = node(x6+1, y6+1, 1);
	b[1] = node(x6+1, y5, -1);
	b[2] = node(x5, y6+1, -1);
	b[3] = node(x5, y5, 1);
	ll ans=0;
	for(int i=0; i<4; i++) {
		for(int j=0; j<4; j++) {
			ans+=solve(a[i], b[j]);
			ans%=mod;
		}
	}
	printf("%lld\n",(ans+mod)%mod);
}

Measured memory_bytes: 33024
#include <iostream>
#include <cmath>
#define R 6378.1
using namespace std;



int main(){
  while(1){
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a==-1 && b==-1 && c==-1 && d==-1) break;
    double ra, rb, rc, rd;
    ra=M_PI*a/180;
    rb=M_PI*b/180;
    rc=M_PI*c/180;
    rd=M_PI*d/180;
    double x1, y1, z1, x2, y2, z2, t1, t2;
    t1=R*cos(ra);
    x1=t1*cos(rb);
    y1=t1*sin(rb);
    z1=R*sin(ra);
    t2=R*cos(rc);
    x2=t2*cos(rd);
    y2=t2*sin(rd);
    z2=R*sin(rc);
    double nai;
    nai=x1*x2+y1*y2+z1*z2;
    double rad;
    rad=acos(nai/(R*R));
    double ans;
    ans=rad*R;
    printf("%.0f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

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

int main(){
    ll N; cin >> N;
    vector<vector<ll>> DP(N+1, vector<ll>(N+1));
    for(int i = 3; i <= N; i++) DP[0][i]++;
    ll c=3;
    for(int i = 0; i <= N; i++){
        bool flag = true;
        for(int j = c; j <= N; j++){
            flag = false;
            if(DP[i][j] != 0){
                for(int k = 3; k <= N; k++){
                    ll idx = j+k;
                    if(idx > N) break;
                    DP[i][idx] += DP[i][j];
                    DP[i][idx]%= MOD;
                }
            }
        }
        c*=2;
        if(flag) break;
    } 
    ll ans = 0;
    for(int i = 0; i <= N; i++) {
        ans+=DP[i][N];
        ans %= MOD;
    }
    cout << ans << endl;


}



Measured memory_bytes: 34580
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
        public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int ans = 0;

        String[] arr = br.readLine().split(" ");
        int N = Integer.parseInt(arr[0]);
        int D = Integer.parseInt(arr[1]);

        String[][] arr2 = new String[N][D];
        for (int i = 0; i < N; i++) {
            arr2[i] = br.readLine().split(" ");       
        }

        for (int i = 0; i < N - 1; i++) {
            String[] y = arr2[i];
            for (int j = i + 1; j < N; j++) {
                String[] z = arr2[j];
                ans += check(D, y, z);
            }
        }

        out.println(ans);
        out.close();
    }

    private static int check(int D, String[] arr1, String[] arr2) {
        int sum = 0;
        for (int i = 0; i < D; i++) {
            int y = Integer.parseInt(arr1[i]);
            int z = Integer.parseInt(arr2[i]);
            sum += Math.pow(y - z, 2);
        }
        double sqrt = Math.sqrt(sum);
        return sqrt % 1 == 0 ? 1 : 0;
    }
}


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

int n;
int x[8], y[8];

double sub(const vector<int>& v) {
  double sum = 0;
  for (int i = 1; i < n; ++i) {
    int a = v[i - 1];
    int b = v[i];
    int dx = x[b] - x[a];
    int dy = y[b] - y[a];
    sum += hypot(dx, dy);
  }
  return sum;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  
  vector<int> v;
  for (int i = 0; i < n; ++i) v.push_back(i);
  
  int cnt = 0;
  double sum = 0;
  do {
    sum += sub(v);
    ++cnt;
  } while(next_permutation(v.begin(), v.end()));
  cout << setprecision(16) << fixed << sum / cnt << endl;
}

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

public class Main {
    public static void main (String[] args) throws java.lang.Exception {
    
    BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
    String txt = input.readLine();
    String[] text = txt.split(" ");
    Arrays.sort(text);
    System.out.println(text[0] + " " + text[1] + " " + text[2]);
    }
}


Measured memory_bytes: 24180
n = int(input())
mod = 1000000007

def comb(n,k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n]*finv[k]%mod*finv[n-k]%mod

fac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(1,n+1):
    fac[i] = fac[i-1]*i%mod
    finv[i] = pow(fac[i],mod-2,mod)

ans = 0
for i in range(2,n+1):
    ans += comb(n,i)*((pow(2,i,mod)-2)%mod)%mod*pow(8,n-i,mod)%mod
    ans %= mod
    # print(ans)
print(ans)


Measured memory_bytes: 99284
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  int ans0 = 0, sum = 0;
  bool t = true;
  for (int i = 0; i < N; i++)
  {
    sum += A.at(i);
    if (t && sum >= 0)
    {
      ans0 += 1 + sum;
      sum = -1;
    }
    else if (!t && sum <= 0)
    {
      ans0 += 1 - sum;
      sum = 1;
    }
    t = !t;
  }

  int ans1 = 0; sum = 0;
  t = false;
  for (int i = 0; i < N; i++)
  {
    int s = sum;
    sum += A.at(i);
    if (t && sum >= 0)
    {
      ans1 += 1 + sum;
      sum = -1;
    }
    else if (!t && sum <= 0)
    {
      ans1 += 1 - sum;
      sum = 1;
    }
    t = !t;
  }

  cout << min(ans0, ans1) << endl;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, W; cin >> N >> W;
    vl w(N), v(N); REP(i, N) cin >> w[i] >> v[i];

    vector<vvl> dp(101, vvl(301, vl(101, 0)));

    REP(i, N)
    {
        REP(j, 301)
        {
            REP(k, N+1)
            {
                chmax(dp[i+1][j][k], dp[i][j][k]);
                if(j - w[i] + w[0] >= 0 && k <= N-1) chmax(dp[i+1][j][k+1], dp[i][j-w[i]+w[0]][k] + v[i]);
            }
        }
    }

    ll ans = 0;
    REP(j, 301)
    {
        REP(k, N+1)
        {
            if(W >= k*w[0] + j) chmax(ans, dp[N][j][k]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 28508
#include<cstdio>

using namespace std;

int main(){
    int n , k;
    scanf("%d %d", &n, &k);
    int ans = 0;
    for(int i = 0; i < n; i++){
        int h;
        scanf("%d", &h);
        if (h >= k) ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 504
n = int(input())
taro = hanako = 0
for i in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        taro += 3
    elif cards[0] < cards[1]:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)



Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  vector<P> ab(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    ab[i] = P(b, a);
  }
  sort(ab.begin(), ab.end());
  int count = 0;
  bool flag = true;
  rep(i, n){
    count += ab[i].second;
    if (ab[i].first < count){
      flag = false;
      break;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    ll N,K;
    cin >> N >> K;
    double ans = 0;
    for(int i = 1; i <= N; i++){
        int count = i;
        double res = 1.0/N;
        while(count < K){
            count *= 2;
            res /= 2;
        }
        ans += res;
    }
    cout << setprecision(12) << ans;
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<double> v(n+1);
    for(int i=1;i<=n;i++) {
    	cin>>v[i];
    }
    vector<vector<double>> dp(n+1, vector<double> (n+1));
    
    dp[1][0] = 1-v[1];
    dp[1][1] = v[1];
    
    for(int i=2;i<=n;i++) {
    	for(int j=0;j<=i;j++) {
    		if(j==0) {
    			dp[i][j] = (1-v[i])*dp[i-1][j];
    		} else if(j==i) {
    			dp[i][j] = v[i]*dp[i-1][j-1];
    		} else {
    			dp[i][j] = v[i]*dp[i-1][j-1] + (1-v[i])*dp[i-1][j];
    		}
    	}
    }
    
    double ans = 0;
    for(int i=n/2+1;i<=n;i++) {
    	ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans;
    
	return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>
#define mod 1000000007
typedef long long ll;

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

ll rev(ll a) {
  ll ans = 1, b = mod - 2;
  while(b) {
    if(b & 1) ans = mul(ans, a);
    a = mul(a, a), b >>= 1;
  }
  return ans;
}

ll sum(ll a) {
  return a * (a + 1) / 2;
}

int main(void) {
  ll i, j, n, m, k, ans = 0, c, now;
  scanf("%lld%lld%lld", &n, &m, &k);
  ll fact[n * m + 1];
  fact[0] = 1;
  for(i = 1; i <= n * m; ++i) fact[i] = mul(fact[i - 1], i);
  c = mul(fact[n * m - 2], mul(rev(fact[k - 2]), rev(fact[n * m - k])));
  for(i = 0; i < n; ++i) for(j = 0; j < m; ++j) {
    now = m * sum(i) + n * sum(j);
    now += sum(n - 1 - i) * m + sum(m - 1 - j) * n;
    now %= mod;
    now = mul(now, c);
    ans += now;
    ans %= mod;
  }
  ans = mul(ans, rev(2));
  printf("%lld", ans);
  return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<pair<int, int>> ff, ss;
  map<int, int> f, s;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    if (i&1) {
      s[x]++;
    } else {
      f[x]++;
    }
  }

  for (auto i : f) ff.push_back(i);
  for (auto i : s) ss.push_back(i);

  auto cmp = [&](auto a, auto b) {
    return a.second > b.second;
  };
  ff.push_back({0, 0});
  ss.push_back({0, 0});

  sort(ff.begin(), ff.end(), cmp);
  sort(ss.begin(), ss.end(), cmp);
  if (ff[0].first != ss[0].first) {
    n -= ff[0].second + ss[0].second;
  } else {
    n -= max(ff[0].second + ss[1].second, ff[1].second + ss[0].second);
  }

  cout << n << '\n';
}



Measured memory_bytes: 6140
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o D_Double_Dots.exe D_Double_Dots.cpp 
Execute: ./D_Double_Dots
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 
	// Inputs 
	int N, M;
	vector<int> graph_adj_list[100000]; // Representation of graph as adjacency list. 
	cin >> N >> M;
	
	int A_i, B_i; 
	for(int i = 0; i < M; i++) { // Input graph edges. 
		cin >> A_i >> B_i; 
		A_i--; B_i--; 
		graph_adj_list[A_i].push_back(B_i);
		graph_adj_list[B_i].push_back(A_i);
	}
	
	int depth[100000];
	int prev_node[100000]; 
	for(int i = 0; i < N; i++) {
		depth[i] = N + 2; // Initialize graph depth as "bigger than possible". 
		prev_node[i] = -2; // Initialize prev node as impossible value. 
	}
	depth[0] = 0; 
	queue<int> search_tree; 
	search_tree.push(0); 
	
	// cout << "------------------------------------------" << endl; 
	
	int front_node, current_node; 
	while(search_tree.size() > 0) {
		front_node = search_tree.front(); 
		for(int i = 0; i < graph_adj_list[front_node].size(); i++) {
			current_node = graph_adj_list[front_node].at(i); 
			// cout << front_node << " " << current_node << " " << depth[front_node] << " " << depth[current_node] << endl; 
			if(depth[current_node] > depth[front_node] + 1) {
				depth[current_node] = depth[front_node] + 1;
				prev_node[current_node] = front_node; 
				search_tree.push(current_node); 
			}
		}
		search_tree.pop(); 
	}
	
	// cout << "------------------------------------------" << endl; 
	cout << "Yes" << endl; 
	for(int i = 1; i < N; i++) {
		// cout << depth[i] << endl; 
		cout << prev_node[i] + 1 << endl; 
	}
	

	return 0; 
} 


Measured memory_bytes: 10800