akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=2e5+10,mod=1e9+7;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,k;
long long fac[maxn],inv[maxn],finv[maxn];

void init()
{
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<=2e5;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

long long C(long long n,long long a)
{    
    return fac[n]*(finv[a]*finv[n-a]%mod)%mod;
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n>>k;
    init();
    long long ans=0;
    for(int i=0;i<=min(n-1,k);i++)
    {
        ans=(ans+C(n,i)*C(n-1,n-i-1))%mod;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 4992
// setのプログラム例
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<map>

using namespace std;

int main(void)
{

    int n;
    char str[10];
    string in_str;

    map<string, int> D;

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> str >> in_str;

        if( str[0] == 'i' )
        {
            D[in_str] = i;
        }
        else if( str[0] == 'f' )
        {
            if( D.find(in_str) != D.end() )
            {
                cout << "yes";
            }
            else
            {
                cout << "no";
            }

            cout << endl;
        }

    }

    return 0;
}



Measured memory_bytes: 36844
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
a = list(map(float, input().split()))
one = a.count(1)
two = a.count(2)
three = a.count(3)

#dp[i][j][k]は残1がi枚、残2がj枚、残3がk枚のときの残り回数の期待値
dp = [[[0.0 for _ in range(N+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 0.0

def rec(i, j, k):
    if dp[i][j][k] > -1:
        return dp[i][j][k]

    res = 0
    if i > 0:
        res += rec(i - 1, j, k) * i / (i + j + k)
    if j > 0:
        res += rec(i + 1, j - 1, k) * j / (i + j + k)
    if k > 0:
        res += rec(i, j + 1, k - 1) * k / (i + j + k)
    res += N / (i + j + k)
    dp[i][j][k] = res
    return dp[i][j][k]

for k in range(three + 1):
    for j in range(two + three + 1 - k):
        for i in range(one + two + three + 1 - k - j):
            if i + j + k == 0:
                continue

            res = 0
            if i > 0:
                res += dp[i - 1][j][k] * i / (i + j + k)
            if j > 0:
                res += dp[i + 1][j - 1][k] * j / (i + j + k)
            if k > 0:
                res += dp[i][j + 1][k - 1] * k / (i + j + k)
            res += N / (i + j + k)
            dp[i][j][k] = res

print(dp[one][two][three])

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

int main() {
	long long n,a=0;
	cin>>n;
	if(n%11!=0&&n%11<=6)a=1;
	else if(n%11!=0) a=2;
	cout<<(n/11)*2+a<<endl;
	//cout<<n%11<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;

	vb win(k+1);
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	FOR(j,0,k+1) for (ll x: a) if (j >= x && !win[j-x]) win[j] = true;
	
	cout << (win[k] ? "First" : "Second") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)
// vectorに対して[ ]でアクセスするとout of rangeのエラーが出ない

int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    vector<ll> h(n);
    rep(i,n){
        cin >> vec.at(i);
        h.at(i) = vec.at(i);
    }

    vector<ll> dp(n, INF);

    rep(i, dp.size()){
        if(i == 0){
            dp.at(i) = 0;
            continue;
        }

        if(i == 1){
            dp.at(i) = dp.at(i-1) + abs(vec.at(i) - vec.at(i-1));
            continue;
        }

        chmin(dp.at(i), dp.at(i-1) + abs(vec.at(i) - vec.at(i-1)));
        chmin(dp.at(i), dp.at(i-2) + abs(vec.at(i) - vec.at(i-2)));
    }

    cout << dp.at(dp.size() - 1) << endl;

}


Measured memory_bytes: 2560
N=int(input())
A=list(map(int,input().split()))
digit=[0 for i in range(0,61)]
for i in range(0,N):
    for j in range(0,60):
        digit[j+1]+=(A[i]>>j)&1
ans=((N-1)*sum(A))%(10**9+7)
X=[(digit[k]*(digit[k]-1)*2**(k-1))%(10**9+7) for k in range(1,61)]
print((ans-sum(X))%(10**9+7))


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

//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)
//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();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;

    cin >> s;

    int sum = 700;

    REP(i,3){
        if(s[i] == 'o'){
            sum += 100;
        }
    }

    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

const ll mod=998244353;

ll ruijou(ll a,ll b){
  ll s = 1;
  while(b > 0){
    if(b & 1)s=s*a%mod;
    a=a*a%mod;
    b >>=1;
  }
  return s;
}

int main(){
	ll n;
	cin >> n;
	bool an=1;
	ll d[100010];
	vector<ll> v;
	FOR(i,n){
		cin >> d[i];
		if(i!=0)v.push_back(d[i]);
		if(i!=0){
			if(d[i]==0 || d[i]>n-1){
				an=0;
			}
		}
	}
	if(d[0]!=0){
		an=0;
	}
	
	ll ans=0;
	sort(all(v));
	vector<ll> l=v;
	l.push_back(0ll);
	sort(all(l));
	FOR(i,l.size()-1){
		if(l[i+1]>l[i]+1)an=0;
	}
	ll cnt=1;
	vector<ll> k;
	FOR(i,v.size()-1){
		if(v[i]==v[i+1]){
			cnt++;
		}else{
			k.push_back(cnt);
			cnt=1;
		}
	}
	k.push_back(cnt);

	ans=1;
	FOR(i,k.size()-1){
		ans=ans*ruijou(k[i],k[i+1])%mod;
	}

	if(an)cout << ans << endl;
	else cout << 0 << endl;

}

Measured memory_bytes: 4452
k, x = map(int, input().split())
l = [i for i in range(x - k + 1, x + k)] 
ans = ''
for i in range(len(l)):
    if i == len(l) - 1:
        ans += str(l[i])

    else:
        ans += str(l[i]) + ' '
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt( str[0] );
      int y = Integer.parseInt( str[1] );

      if( x<y ){
        int tmp = x; x = y; y = tmp;
      }  

      System.out.println( gcd(x,y) );
    }
  }

  static int gcd(int x, int y) {
    if( (x%y) == 0 ) return y;
    else return gcd(y,x%y);
  }
}


Measured memory_bytes: 24440
def cal(a, op, b):

  if op == '+':
    r = a + b
  elif op == '-':
    r = a - b
  elif op == '*':
    r = a * b
  elif op == '/':
    r = a / b
  return r

while 1:
  a,op,b = raw_input().split()
  if op == '?':
    break
  else:
    print(cal(int(a), op, int(b)))

Measured memory_bytes: 4212
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int min = Integer.MAX_VALUE;
		for (int i = 0; i + k - 1 < n; i++) {
		    min = Math.min(min, arr[i + k - 1] - arr[i]);
		}
		System.out.println(min);
   }
}


Measured memory_bytes: 50840
n = int(input())
a = list(map(int,input().split()))
b = [i for i in range(1,n+1)]
if a == b:
    print("YES")
else:
    count = 0
    for i in range(n):
        if a[i] != b[i]:
            count += 1
    if count == 2:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 38376
fun main(args: Array<String>) {
    val (N, R) = readInputLine().split(" ").map { it.toInt() }

    if (N < 10) {
        println(R + 100 * (10 - N))
    } else {
        println(R)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37896
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double n,d,x;
    cin>>n>>d;
    std::vector<vector<double>> vec(n,vector<double>(d));
    for (double i=0;i<n;i++) {
        for (double j=0;j<d;j++) {
            cin>>x;
            vec.at(i).at(j)=x;
        }
    }
    int count=0;
    for (double k=0;k<n;k++) {
        for (double l=k+1;l<n;l++) {
            double tmp=0;
            for (double m=0;m<d;m++) {
                tmp+=(vec.at(k).at(m)-vec.at(l).at(m))*(vec.at(k).at(m)-vec.at(l).at(m));
            }
            tmp=sqrt(tmp);
            if (ceil(tmp)==float(tmp)) {
                count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = list(map(int, input().split()))
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;

const int MAX_SIZE = 1e5 + 10;

vector<int> graph[MAX_SIZE];
vector<bool> visited(MAX_SIZE);

ll dfs(int a)
{
	visited[a] = true;
	vector<ll> G;
	for(auto &u : graph[a])
	{
		if(!visited[u])
		{
			G.pb(dfs(u));
		}
	}
	if(G.size() == 1)
		return 1 + G[0];
	else if(G.size() == 0)
		return 0;
	ll s = 0;
	for(auto &g : G)
	{
		s ^= (g + 1);
	}
	return s;
}

int main()
{
	int N;
	cin >> N;
	int x, y;
	for(int i = 1; i < N; i++)
	{
		cin >> x >> y;
		graph[x].pb(y);
		graph[y].pb(x);
		visited[x] = false;
		visited[y] = false;
	}
	ll s = dfs(1);
	if(s == 0)
		cout << "Bob" << endl;
	else
		cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 13568
#include<iostream>
#include<string>
#include<map>
#include<algorithm>

int main(){
    std::map<std::string, long> s, t;
    size_t n;
    std::cin >> n;

    for(size_t i = 0; i < n; i++){
        std::string tmp;
        std::cin >> tmp;
        if(s.find(tmp) == s.end()){
            s.emplace(tmp, 1);
        }else{
            s.at(tmp)++;
        }
    }

    size_t m;
    std::cin >> m;

    for(size_t i = 0; i < m; i++){
        std::string tmp;
        std::cin >> tmp;
        if(t.find(tmp) == t.end()){
            t.emplace(tmp, 1);
        }else{
            t.at(tmp)++;
        }
    }

    long max = 0;

    for(auto it = s.begin(); it != s.end(); ++it){
        if(it == s.begin()){
            if(t.find(it->first) != t.end()){
                max = it->second - t.at(it->first);
            }else{
                max = it->second;
            }
        }else{
            if(t.find(it->first) != t.end()){
                max = std::max(max, it->second - t.at(it->first));
            }else{
                max = std::max(max, it->second);
            }
        }
    }

    if(max < 0){
        std::cout << 0 << std::endl;
    }else{
        std::cout << max << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int t = sc.nextInt();
		int x = sc.nextInt();

		BigDecimal bT = BigDecimal.valueOf(t);
		BigDecimal bX = BigDecimal.valueOf(x);

		BigDecimal b = bT.divide(bX, 10, BigDecimal.ROUND_HALF_UP);

		System.out.println(b);


	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[k];
    int b[10]={0};
    for(int i=0;i<k;i++)
    cin>>a[i],b[a[i]]++;
    bool d=true;
    while(1)
    {
        bool f=true;
        int o=n;
        while(o>0)
        {
            int rem=o%10;
            if(b[rem]>0)
            {
                f=false;
                break;
            }
            o=o/10;
        }
        if(f==false)
        n++;
        else
        break;
    }
    cout<<n;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int insertionSort();
int main(){
  int a,i,j,v,n,A[100];
  // N個の要素を含む0-オリジンの配列A
  scanf("%d",&n);
  //入力
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  //最初の並び
  for(i=0;i<n-1;i++)printf("%d ",A[i]);
  printf("%d",A[n-1]);
  printf("\n");
  //そーと
  for (i = 1;i < n;i++){
    v = A[i];
    j = i - 1;
    
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    //表示
  for(a=0;a<n-1;a++)printf("%d ",A[a]);
  printf("%d",A[n-1]);
  printf("\n");
  }
  
}





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

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

using namespace std;

typedef pair<int,int> ii;
const int IINF = INT_MAX;

vector<ii> G[100010];
int mincost[100010];
int V,E,r;

struct Data{
  int cur,cost;
  bool operator < (const Data& data) const{ return cost > data.cost; }
};

int main(){
  scanf("%d %d %d",&V,&E,&r);

  int s,t,d;
  rep(i,E){
    scanf("%d %d %d",&s,&t,&d);
    G[s].push_back(ii(t,d));
  }

  rep(i,V) mincost[i] = IINF;
  mincost[r] = 0;
  priority_queue<Data> Q;
  Q.push((Data){r,0});
  while(!Q.empty()){
    Data data = Q.top(); Q.pop();
    int cur = data.cur;
    rep(i,(int)G[cur].size()){
      int t = G[cur][i].first,c = G[cur][i].second;
      if( mincost[t] > mincost[cur] + c ){
        mincost[t] = mincost[cur] + c;
        Q.push((Data){t,mincost[t]});
      }
    }
  }

  /*

// Shortest Path Faster Algorithm 
// O(kE)

  rep(i,V) mincost[i] = IINF;
  mincost[r] = 0;
  deque<int> deq; deq.push_back(r);
  vector<int> in_queue(V,0); in_queue[r] = 1;

  while(!deq.empty()){
    int u = deq.front(); deq.pop_front(); in_queue[u] = 0;
    rep(i,(int)G[u].size()){
      int v = G[u][i].first, c = G[u][i].second;
      if( mincost[v] > mincost[u] + c ) {
        mincost[v] = mincost[u] + c;
        if( !in_queue[v] ) {
          deq.push_back(v);
          in_queue[v] = 1;
        }
      }
    }
  }
  */

  rep(i,V) {
    if( mincost[i] == IINF ) puts("INF");
    else printf("%d\n",mincost[i]);
  }

  return 0;
}

Measured memory_bytes: 11324
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
    int s;
    cin >> s;
    int a[100000];
    a[1]   = s;
    bool f = false;
    for (int i = 1; i < 100000; i++) {
        if (a[i] % 2 == 0)
            a[i + 1] = a[i] / 2;
        else
            a[i + 1] = 3 * a[i] + 1;
        for (int j = 1; j < i; j++) {
            if (a[j] == a[i]) {
                cout << i << endl;
                f = true;
                break;
            }
        }
        if (f)
            break;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		s += s.charAt(s.length() - 1) == 's' ? "es" : "s";
		System.out.println(s);
		
		sc.close();
	}
}



Measured memory_bytes: 27008
h,w = map(int,input().split())
count = 0
X = []
p = []
X.append(["@"]*(w+2))
for _ in range(h):
  p = []
  x = input()
  for i in range(w):
    p.append(x[i])
  X.append(["@"]+p+["@"])  
X.append(["@"]*(w+2))
for i in range(1,h+1):
  for j in range(1,w+1):
    count=0
    if X[i][j]==".":
      if X[i-1][j-1]=="#":count+=1
      if X[i-1][j]=="#":count+=1
      if X[i-1][j+1]=="#":count+=1
      if X[i][j-1]=="#":count+=1
      if X[i][j+1]=="#":count+=1
      if X[i+1][j-1]=="#":count+=1
      if X[i+1][j]=="#":count+=1
      if X[i+1][j+1]=="#":count+=1
      count=str(count)
      X[i][j]=count
for k in range(1,h+1):
  print(*X[k][1:w+1],sep="")

Measured memory_bytes: 3572
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

L, R = l_inpl()

if R-L>=2019:
    print(0)
else:
    ans = INF
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, i*j%2019)

    print(ans)


Measured memory_bytes: 3668
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int a, b, c;
  cin >> a >> b >> c;
  D(((a * b * c == 7 * 5 * 5 && a + b + c == 17) ? "YES" : "NO"));
  return 0;
}



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

#define int long long int
#define all(x) (x).begin(), (x).end()
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'

template<typename Type>
istream &operator>>(istream &in,vector<Type>&vec){
	int n=vec.size();	
	for(int i=0;i<n;i++)
		in>>vec[i];
	return in;
}
template<typename Type>
ostream &operator<<(ostream &out,vector<Type>&vec){
	for(auto val:vec)
		out<<val<<" ";
	out<<endl;
	return out;
}

void solve(){
	int n;
	cin>>n;
	vector<int>h(n);
	cin>>h;
	vector<int>dp(n+1);
	dp[1]=0;
	dp[2]=abs(h[1]-h[0]);
	for(int i=3;i<=n;i++){
		dp[i]=min(abs(h[i-1]-h[i-2])+dp[i-1],abs(h[i-1]-h[i-3])+dp[i-2]);
	}
	cout<<dp[n]<<endl;
}

int32_t main(){

	//remove for interactive problems
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	solve();
	cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

	return 0;
}

Measured memory_bytes: 4720
dbg = False

a, b = list(map(int, input().split()))

if a > b:
    x, y = a, b
else:
    x, y = b, a

divs = [1]
for i in range(1, int((y+1)/2)+1):
    gcd_tmp = int(y / i)
    if dbg: print('%d, %d' % (i, gcd_tmp))
    if i > gcd_tmp:
        break
    if y % i == 0:
        if x % gcd_tmp == 0:
            print(gcd_tmp)
            exit()
        elif x % i == 0:
            divs.append(i)

print(max(divs))

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

public class Main {
    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader();
        //InputStream inputStream = System.in;
        //Scanner in = new Scanner(inputStream);
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        long mod = (int)1e9+7;
        int n = in.ni();
        long[] arr = new long[n];
        for(int i=0;i<n;i++)
            arr[i] = in.ni();
        ArrayList<Long> al = new ArrayList<>();
        al.add(arr[0]);
        for(int i=1;i<n;i++){
            if(arr[i]!=arr[i-1])
                al.add(arr[i]);
        }
        int count = 1;
        int len = al.size();
        for(int i=1;i<len-1;i++){
            long temp = al.get(i)-al.get(i-1);
            long temp2 = al.get(i+1)-al.get(i);
            if(temp*temp2<0) {
                count++;
                i++;
            }
        }
        out.println(count);
        out.close();
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String n() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int ni() {
            return Integer.parseInt(n());
        }

        long nl() {
            return Long.parseLong(n());
        }

        double nd() {
            return Double.parseDouble(n());
        }

        String nli() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }
}


Measured memory_bytes: 44248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
    string s;
    cin >> s;
    vint count(3);
    rep(i,s.size()) count[s[i]-'a']++;
    int ab = abs(count[1]-count[0]);
    int ac = abs(count[2]-count[0]);
    int bc = abs(count[1]-count[2]);
    if(ab < 2 && ac < 2 && bc < 2) cout << "YES" << endl;
    else cout << "NO" << endl;
} 


Measured memory_bytes: 512
from collections import deque
n,k = map(int,input().split())
d = set(list(map(int,input().split())))
a = list({0,1,2,3,4,5,6,7,8,9} - d)
a.sort()
que = deque()
que.append(0)

while que:
    ans = que.popleft()
    if ans >= n:
        print(ans)
        exit()
    for i in a:
        que.append(ans*10 + i)

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll w, h;
    cin >> w >> h;
    vector<pair<ll, ll>> cost;
    REP(i, w){
        ll pi;
        cin >> pi;
        cost.emplace_back(pi, 0);
    }
    REP(i, h){
        ll qi;
        cin >> qi;
        cost.emplace_back(qi, 1);
    }

    sort(ALL(cost));

    ll ans = 0;
    for(auto p : cost){
        const ll ci = p.first;
        const ll flg = p.second;
        if(flg == 0){ // horizontal
            ans += (h + 1) * ci;
            w--;
        }else{ // vertical
            ans += (w + 1) * ci;
            h--;
        }
        if(w + h == 0){ break; }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < 0) continue;
    if (a[a[i]-1] == i+1) {
      cnt++;
      a[a[i]-1] = -1;
    }
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c;
    cin>>n>>m>>c;
    int  x[m+5];
    for(int  i=0;i<m;i++)
    {
        cin>>x[i];
    }
    int  l=0;
    for(int j=0;j<n;j++)
    {
        int sum=0;
    for(int  i=0;i<m;i++)
    {
       int d;
       cin>>d;
       sum+=(d*x[i]);
    }
    if((sum+c)>0)
    {
        l++;
    }
}
cout<<l<<endl;
return 0;
}


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

int abslength(int a , int b);
int notabslength(int a , int b);

signed main(){
    int n , k , x[100005] , ans = 1000000000;

    cin >> n >> k;
    ans = 3 * 100000000;

    for(int i=0 ;i<n ;i++ ){
        cin >> x[i];
        if(k == 1){
            ans = min(ans , abs(x[i]));
        }
    }

    if(k > 1){
        for(int i=k-1 ;i<n ;i++ ){
            if( (x[i] > 0 && x[i-k+1] > 0) || (x[i] < 0 && x[i-k+1] < 0) ){
                ans = min(ans , notabslength(x[i] , x[i-k+1]));
            } else {
                ans = min(ans , abslength(x[i] , x[i-k+1]));
            }
        }
    }
    cout << ans << endl;

    return(0);
}

int notabslength(int a , int b){
    return( max(abs(a) , abs(b)) );
}

int abslength(int a , int b){
    return( min(a * 2 - b , a - b * 2) );
}

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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint com(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;


modint solve(vector<ll> &v,int n){
    modint sum = 0;
    rep(i,n-1) sum += modint(v[i+1]-v[i]) * modint(i+1) * modint(n-i-1);
    return sum;
}

int main(void){
    int n,m;
    cin>>n>>m;
    vector<ll> x(n),y(m);
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];
    cout<<solve(x,n) * solve(y,m)<<endl;
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
ans=-1
c=[[0]*10for i in range(11)]
for i in range(n+1):c[int(str(i)[0])][int(str(i)[-1])]+=1
for i in range(10):
 for j in range(10):ans+=c[i][j]*c[j][i]
print(ans)

Measured memory_bytes: 3060
def gcd(x,y):
    if memo[x][y] != 0:
        return memo[x][y]
    tmp_x = x
    tmp_y = y
    while y != 0:
        x,y = y,x%y
    memo[tmp_x][tmp_y] = x
    memo[tmp_y][tmp_x] = x
    return x

K = int(input())
ans = 0
memo = [[0]*(K+1) for _ in range(K+1)]

for i in range(1,K+1):
    for j in range(1,K+1):
        gcd(i,j)

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += memo[memo[i][j]][k]

print(ans)

Measured memory_bytes: 68620
#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define int long long
#define sz(x) (ll)(x.size())
using namespace std;


const int mod = 1e9+7;

int expo_pow(int x,int y){
 if(y == 0) return 1;
  y=y%(mod-1);
  x%=mod;
  if(y==0) y=mod-1;
  int res=1;
  while(y){
    if(y&1) res=(res*x)%mod;
    x=(x*x)%mod;
    y>>=1; 
  }
  return res;
}

ll add()
{
    return 0;
}

template <typename T, typename... Types>
T add(T var1, Types... var2){
    return (((((ll)(var1)) % mod + (ll)(add(var2...))) % mod) + mod) % mod;
}

ll mul(){
    return 1;
}

template <typename T, typename... Types>
T mul(T var1, Types... var2){
    return (((ll)(var1)) % mod * (ll)(mul(var2...))) % mod;
}

const int mx = 3e5 + 10;
int tree[4*mx];

void update(int n,int st,int end,int idx,int val){
  if(st==end){
    tree[n] += val;
    return;
  }
  int mid = (st + end)/2;
  if(idx<=mid) update(2*n,st,mid,idx,val);
  else update(2*n+1,mid+1,end,idx,val);
  tree[n] = max(tree[2*n],tree[2*n+1]);
}


void solve(){
  int h,w,m;
  cin>>h>>w>>m;
  vector<int> row[h+1];
  int col[w+1];
  
  int ans = 0;

  for(int i=0;i<m;i++){
    int p,q;
    cin>>p>>q;
    update(1,0,w,q,1);
    row[p].pb(q);
  }
  for(int i=1;i<=h;i++){
    
    for(auto u:row[i]){
      update(1,0,w,u,-1);
    }
    ans = max(ans,(int)row[i].size() + tree[1]);
    for(auto u:row[i]){
      update(1,0,w,u,1);
    }
  }
  cout<<ans<<"\n";

}


signed main(){
  fast;
  int test = 1;
  int i=1;
  while(test--){
    solve();
  }
}





Measured memory_bytes: 28256
def main():
    n = int(input())
    b = [int(i) for i in input().split()]

    a = ([b[0]])
    for i in range(1,n-1):
        a.append(min(b[i-1],b[i]))
    a.append(b[-1])
    print(sum(a))
if __name__ == "__main__":
    main()

Measured memory_bytes: 38460
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>

int main()
{
	long long a[2];
	int k;
	scanf("%lld%lld%d", a, a + 1, &k);

	for (int i = 0; i < k; ++i)
	{
		int p = i % 2;
		if (a[p] & 1) a[p]--;
		a[p] /= 2;
		a[!p] += a[p];
	}

	printf("%lld %lld\n", a[0], a[1]);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define GOAL 2019

int main(void){
	int N, M, A;
	int X[100];
	int i;
	
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &X[i]);
	}
	scanf("%d", &M);
	for(i = 0; i < M; i++){
		scanf("%d", &A);
		
		if(A != N){
			if(X[A - 1] + 1 != X[A]){
				X[A - 1]++;
			}
		}else{
			if(X[A - 1] != GOAL){
				X[A - 1]++;
			}
		}
	}
	
	for(i = 0; i < N; i++){
		printf("%d\n", X[i]);
	}

	return 0;
}


Measured memory_bytes: 2108
N,M = list(map(int,input().split()))
L = list(map(int,input().split()))#len(L) == N

S = sum(L)
p = S/(4*M)

cnt = 0
for i in range(N):
    if L[i] >= p:
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
def show (nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else :
            print(nums[i])

n = int(input())
A = list(map(int,input().split()))

counter = 0

for i in range(0,n):
    minj = i
    for j in range(i+1,n):
        if A[j] < A[minj]:
            minj = j
    if i != minj:
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
        counter += 1

show(A)
print(counter)


Measured memory_bytes: 5612
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s;cin>>s;
    int cnt = 0;
    for(auto c:s)
    {
        if(c=='o') cnt++;
    }
    if(cnt + (15 - s.size())>=8)
    {
        cout<<"YES" << endl;
    }
    else
    {
        cout <<"NO"<<endl;
    }
}


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

long long INF=1e18;

int main()
{
    int n;
    cin>>n;
    int a[n+1];
    map<int,int> x;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        x[a[i]]=i;
    }
    for(int i=1; i<=n; i++)
        cout<<x[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 5888
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define N 2000000
#define pi M_PI

struct node{
    unsigned int key;
    struct node *next;
    struct node *prev;
};
typedef struct node * NodePointer;

NodePointer nil;

void init(){
    nil = malloc(sizeof(struct node));
    nil->next = nil;
    nil->prev=nil;
}
void deleteNode(NodePointer t){
    NodePointer pr = t->prev,nx=t->next;
    pr->next=nx;
    nx->prev=pr;
    free(t);
}
void deleteTop(){
    NodePointer t=nil->next;
    if(t==nil) return;
    deleteNode(t);
}
void deleteLast(){
    NodePointer tmp=nil->prev;
    nil->prev=tmp->prev;
    deleteNode(tmp);
}
void delete(int key){
    NodePointer cur = nil->next;
 
  while(1){
    if(cur==nil) break;
    if(cur->key == (unsigned int)key){
      deleteNode(cur);
      break;
    }
    cur = cur->next;
  }
}
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->prev = nil;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  if(nil->prev == nil) nil->prev = x;
}
 
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteTop();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++; 
      }
      size--;
    }
  }
  NodePointer cur = nil->next;
 int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 32940
n = int(input())
a = list(map(int,input().split()))
ans = 0
flag = False

while flag == False:
    for i in range(n):
        if a[i]%2 == 0:
            a[i] /= 2
        else:
            flag = True
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 9144
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace  std;

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }
  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }

  ~StPnt() { }
};

void fnInput(int &rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnKochCrv( const StPnt &cnroPnt1, const StPnt &cnroPnt2, vector<StPnt> &rvoRtnPnt)
{
  const double PI = 3.141592;

  StPnt aoPnt[5];
  aoPnt[0] = cnroPnt1;
  aoPnt[1].m_nx = (2 * cnroPnt1.m_nx + cnroPnt2.m_nx) / 3;
  aoPnt[1].m_ny = (2 * cnroPnt1.m_ny + cnroPnt2.m_ny) / 3;
  aoPnt[3].m_nx = (cnroPnt1.m_nx + 2 * cnroPnt2.m_nx) / 3;
  aoPnt[3].m_ny = (cnroPnt1.m_ny + 2 * cnroPnt2.m_ny) / 3;

  double nRad = 60 * PI / 180; 
  aoPnt[2].m_nx = (aoPnt[3].m_nx - aoPnt[1].m_nx) * cos(nRad) - (aoPnt[3].m_ny - aoPnt[1].m_ny) * sin(nRad);
  aoPnt[2].m_nx += aoPnt[1].m_nx;
  aoPnt[2].m_ny = (aoPnt[3].m_nx - aoPnt[1].m_nx) * sin(nRad) + (aoPnt[3].m_ny - aoPnt[1].m_ny) * cos(nRad);
  aoPnt[2].m_ny += aoPnt[1].m_ny;

  aoPnt[4] = cnroPnt2;

  for (int i = 0; i < 5; i++)
    rvoRtnPnt.push_back(aoPnt[i]);
}

void fnKochCtl(int nRcSiz, vector<vector<StPnt>> &rvvoPnt)
{
  StPnt oPntB(0.0, 0.0);
  StPnt oPntE(100.0, 0.0);

  rvvoPnt.resize(8);
  rvvoPnt[0].clear();
  rvvoPnt[0].push_back(oPntB);
  rvvoPnt[0].push_back(oPntE);

  for (int nRc = 0; nRc < nRcSiz; nRc++)
  {
    rvvoPnt[nRc + 1].clear();
    rvvoPnt[nRc + 1].push_back(oPntB);
    for (int i = 0; i < rvvoPnt[nRc].size() - 1; i++)
    {
      StPnt oPnt1 = rvvoPnt[nRc][i];
      StPnt oPnt2 = rvvoPnt[nRc][i + 1];
      vector<StPnt> voRtnPnt;

      fnKochCrv(oPnt1, oPnt2, voRtnPnt);
      for (int j = 1; j < 5; j++)
        rvvoPnt[nRc + 1].push_back(voRtnPnt[j]);
    }
  }
}

void fnResult(int nRcSiz, const vector<vector<StPnt>> &cnrvvoPnt)
{
  for (int i = 0; i < cnrvvoPnt[nRcSiz].size(); i++)
    cout << cnrvvoPnt[nRcSiz][i].m_nx << " " << cnrvvoPnt[nRcSiz][i].m_ny << endl;
}

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

  int nRcSiz;
  vector<vector<StPnt>> vvoPnt;

  fnInput(nRcSiz);
  fnKochCtl(nRcSiz, vvoPnt);

  fnResult(nRcSiz, vvoPnt);

  return 0;
}

Measured memory_bytes: 1388
import itertools
import math
n = int(input())
lis = [x for x in range(n)]
permutations_lis = itertools.permutations(lis)
xy = [list(map(int,input().split())) for i in range(n)]
judge = []
for i in permutations_lis:
  count = 0
  first = i[0]
  for p in i:
    count += math.sqrt((xy[p][0]-xy[first][0])**2+(xy[p][1]-xy[first][1])**2)
    first = p
  else:
    judge.append(count)
print(sum(judge)/len(judge))

Measured memory_bytes: 4400
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[2000000];
		int k = sc.nextInt();
		int n = sc.nextInt();
		for(int i=0;n>i;i++) {
			int a=sc.nextInt();
			list.add(a);
		}
		Collections.sort(list);
		int count=0;
		List<Integer> list_check=new ArrayList<Integer>();
		for(int i=0;n-1>i;i++) {
			count=count+list.get(i+1)-list.get(i);
			list_check.add(list.get(i+1)-list.get(i));
		}
		count=count+k+list.get(0)-list.get(n-1);
		list_check.add(k+list.get(0)-list.get(n-1));
		int max = Collections.max(list_check);
		System.out.println(count-max);

	}
}

Measured memory_bytes: 86492
from collections import deque


def bfs():
    d = [[float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx and nx < h and 0 <= ny and ny < w and\
                    maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]


h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1

# 白いマスを数える
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()
if 0 < res < float("inf"):
    # 白いマスの数から最短経路でかかるコスト分を引く
    # ゴールを黒いマスに変えることはできないためその分も引く
    print(white - res - 1)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

set<int> s;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    int n; cin >> n;
    rep(i, 0, n) {
        int x;
        cin >> x;
        s.insert(x);
    }
    cout << s.size() << endl;
    return 0;
}


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

int main()
{
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    if (a[0] == a[1] && a[1] != a[2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (a[0] != a[1] && a[1] == a[2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
def readinput():
    n=int(input())
    a=[]
    for i in range(1,n+1):
        a.append((int(input()),i))
    return n,a

def main(n,a):
    sa=sorted(a,key=lambda x:x[0], reverse=True)
    for i in range(1,n+1):
        if sa[0][1]!=i:
            print(sa[0][0])
        else:
            print(sa[1][0])            

if __name__=='__main__':
    n,a=readinput()
    main(n,a)


Measured memory_bytes: 40468
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)


int main()
{
    int n;cin>>n;
    vector<pair<int, int>> p(n);
    for(int i = 0; i<n; i++)cin>>p[i].first>>p[i].second;
    sort(p.begin(),p.end());
    cout << p[n-1].first+p[n-1].second << endl;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#else
#define db(...) true
#endif
template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c; return o;
}
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

int N;
vvi ans;

void solve(int st, int en, int dep) {
	if (st >= en)
		return;
	int mid = st + (en - st) / 2;
	db(st, en, mid);
	for (int i = st; i <= mid; ++i) {
		for (int j = mid + 1; j <= en; ++j) {
			ans[i][j] = dep;
		}
	}
	solve(st, mid, dep + 1);
	solve(mid + 1, en, dep + 1);
}

int main() {
	#ifdef LOCAL
	auto stTime = clock();
	#endif
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N;
	ans.assign(N + 1, vi(N + 1));
	solve(1, N, 1);

	for (int i = 1; i <= N - 1; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			cout << ans[i][j] << " \n"[j == N];
		}
	}

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


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

int main(){
    int defalt = 100;
    long long X;
    cin >> X;

    long long ans = 0;
    long long dep = defalt;
    while (dep < X)
    {
        dep *= 1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

int main() {
    int n;
    cin >> n;
    vector<int> as(n), bs(n), cs(n - 1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as[i] = a - 1;
    }
    for (int i = 0; i < n; i++) {
        cin >> bs[i];
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> cs[i];
    }

    int ans = bs[as[0]];
    for (int i = 1; i < n; i++) {
        ans += bs[as[i]];
        if (as[i - 1] + 1 == as[i]) {
            ans += cs[as[i - 1]];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
strings = input()
c = 1
res = 'Yes'
for i in strings:
    if ((c % 2 == 0 and i == 'L') or (c % 2 == 1 and i == 'R')) or i == "U" or i == 'D':
        pass
    else:
        res = 'No'
        break
    c += 1
print(res)

Measured memory_bytes: 3060