akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations, permutations
from math import factorial
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    XY = [tuple(map(int, input().split())) for _ in [0] * N]

    n = list(range(N))
    dist = [[0] * N for _ in [0] * N]
    for i, j in combinations(n, 2):
        dist[i][j] = ((XY[i][0] - XY[j][0]) ** 2 + (XY[i][1] - XY[j][1]) ** 2) ** 0.5
        dist[j][i] = dist[i][j]

    ans = 0
    for r in permutations(n):
        for i in range(N - 1):
            ans += dist[r[i]][r[i+1]]
    print(ans / factorial(N))


main()


Measured memory_bytes: 3064
H,W=map(int,input().split())

A = [[0]*(W) for j in range(H+1)]

for i in range (H):
    A[i]=list(input()+".")

i=0
j=0
A[0][0]=0
while(True):
    if((i==(H-1))and(j==(W-1))):
        for k in range(H):
            if("#" in A[k]):
                print("Impossible")
                exit()
        print("Possible")
        exit()
    if(A[i+1][j]=="#"):
        A[i+1][j]=0
        i+=1
    elif(A[i][j+1]=="#"):
        A[i][j+1]=0
        j+=1
    else:
        print("Impossible")
        exit()






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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

const int N=1E5;
vi g[N];
int vis[3][N];

inline void add_edge(const int u,const int v){
    g[u].push_back(v);
}


void solve(int s,int t){
    priority_queue<ii,vii,greater<ii>> q;
    q.push(MP(0,s));
    vis[0][s]=0;
    while (!q.empty()){
        auto p=q.top(); q.pop();
        if (p.second==t && p.first%3==0) return;
        ++p.first;
        int d=p.first%3;
        for(int c:g[p.second]){
            if (vis[d][c]>p.first){
                vis[d][c]=p.first;
                q.push(MP(p.first,c));
            }
        }
    }
}

int main() {
    READ(0);
    int n,m;cin>>n>>m;
    while(m--){
        int u,v;cin>>u>>v;
        add_edge(u-1,v-1);
    }
    FOR(i,3)
        fill(vis[i],vis[i]+n,INF);
    int s,t;cin>>s>>t;
    solve(--s,--t);
    if (vis[0][t]==INF) cout << -1;
    else cout << vis[0][t]/3;
    return 0;
}



Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    if(x==2||y==2)
    {
        cout<<"No";
        return 0;
    }
    int a[7]={1,3,5,7,8,10,12};
    int b[4]={4,6,9,11};
    for(int i=0;i<4;i++)
    {
        for(int j=i+1;j<4;j++)
        {
            if(x==b[i]&&y==b[j])
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    for(int i=0;i<7;i++)
    {
        for(int j=i+1;j<7;j++)
        {
            if(x==a[i]&&y==a[j])
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}


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

using namespace std;

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

Measured memory_bytes: 256
#include <stdio.h>
int main (){
    long long a,b,c,k;
    scanf("%lld%lld%lld%ld",&a,&b,&c,&k);
    if(k%2==0){
        printf("%lld\n",a-b);
    }
    if(k%2==1){
        printf("%lld\n",b-a);
    }
}

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

static int cnt=-1;//cnt=stacktopの配列番号

void calculation(int *t,int check,int cnt)
{
	if(check == 0){
		t[cnt-1]=t[cnt-1]+t[cnt];
		t[cnt]=0;
	}else if(check == 1){
		t[cnt-1]=t[cnt-1]-t[cnt];
		t[cnt]=0;
	}else if(check == 2){
		t[cnt-1]=t[cnt-1]*t[cnt];
		t[cnt]=0;
	}
		
}

int main(void)
{
	int x,i,j;
	int check;//演算子の種類を関数に伝達
	char s[100];//空白毎に値もしくは演算子を格納
	int t[100];//stack
	for(i=0;scanf("%s",s)!=EOF;i++){
		if(s[0]>47) {
			cnt++;
			t[cnt]=atoi(s);
		}
		if(s[0] == '+'){
			check=0;
			calculation(t,check,cnt);
			cnt--;
		}else if(s[0] == '-'){
			check=1;
			calculation(t,check,cnt);
			cnt--;
		}else if(s[0] == '*'){
			check=2;
			calculation(t,check,cnt);
			cnt--;
		}
	}
	printf("%d\n",t[cnt]);
	
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){

    int K,X; cin>>K>>X;
    if(K*500>=X){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int n,t=1;
int a[N][N]={0},d[N]={0},f[N]={0};

void dfs(int u){
  int i;

  d[u]=t++;
  for(i=1;i<=n;i++){
    if(d[i]==0 && a[u][i]==1)
      dfs(i);
  }
  f[u]=t++;
}


int main(void){
  int i,j,u,k,v;

  scanf("%d", &n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    if(d[i]==0)
      dfs(i);
  }
  for(i=1;i<=n;i++){
    printf("%d %d %d\n", i, d[i], f[i]);
  }

  return 0;
}

Measured memory_bytes: 636
from collections import defaultdict

n, m = list(map(int, input().split()))
h = list(map(int, input().split()))

a = []
b = []
for j in range(m):
    data = list(map(int, input().split()))
    a.append(data[0])
    b.append(data[1])

conn = defaultdict(list)

for j in range(m):
    conn[a[j]-1].append(b[j]-1)
    conn[b[j]-1].append(a[j]-1)

good = 0

for a in range(n):
    if len(conn[a]) == 0:
        good += 1
    else:
        for b in conn[a]:
            if h[b] >= h[a]:
                break
        else:
            good += 1

print(good)

Measured memory_bytes: 42600
a, b, q = map(int, input().split())
S = [0] * a
T = [0] * b
X = [0] * q
for i in range(a):
  S[i] = int(input())
S = [-10**10*2-1] + S + [10**10*2+1]
for i in range(b):
  T[i] = int(input())
T = [-10**10*2-1] + T + [10**10*2+1]
for i in range(q):
  X[i] = int(input())
#print(S)  
#print(T)  
from bisect import bisect_right
for i in range(q):
  x = X[i]
  s_left = bisect_right(S, x) - 1
  s_right = bisect_right(S, x)
  t_left = bisect_right(T, x) - 1
  t_right = bisect_right(T, x)
  sl = S[s_left]
  sr = S[s_right]
  tl = T[t_left]
  tr = T[t_right]
  #print(X[i], S[s_left], S[s_right], T[t_right], T[t_left])
  l_rr = max(sr - x, tr - x)
  l_ll = max(x - sl, x - tl)
  l_rslt = (sr - x) + (sr - tl)
  l_rtls = (tr - x) + (tr - sl)
  l_lsrt = (x - sl) + (tr - sl)
  l_ltrs = (x - tl) + (sr - tl)
  print(min(l_rr, l_ll, l_rslt, l_rtls, l_lsrt, l_ltrs))
  

Measured memory_bytes: 125568
from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
 while t[x]>=0:x=t[x]
 return x
def u(x,y):
 x,y=r(x),r(y)
 if x!=y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=0
for v in a:d[r(i)]+=v,;i+=1
if len(d)<2:exit(print(0))
c,b,k=0,[],(n-m-1)*2
for r,p in d.items():p.sort();c+=p.pop(0);b+=p;k-=1
print(k>len(b)and'Impossible'or c+sum(sorted(b)[:k]))

Measured memory_bytes: 35516