akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n, m, x, a[100] = {}, t;
    cin >> n >> m >> x;
    for (int i = 0; i < m; ++i) {
        cin >> t;
        a[t] = 1;
    }

    int ans = 100, c = 0;
    for (int i = x; i < n; ++i) {
        if (a[i])
            c++;
    }
    ans = min(ans, c);

    c = 0;
    for (int i = x; i >= 0; --i) {
        if (a[i])
            c++;
    }
    ans = min(ans, c);

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


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 20:53:13 2019

@author: YudNK
"""

l = [i for i in input()]

k = len(set(l))

a = l[0]
c = 0
for i in l:
    if i == a:
        c = c + 1

if k == 2 and c == 2:
    print('Yes')
else:
    print('No')

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

int main(){
  int N,D,ans=0;
  cin >> N >> D;
  vector<vector<int>> V(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> V.at(i).at(j);
    }
  }
  
  int dis=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      for(int k=0;k<D;k++){
        dis+= (V.at(i).at(k) - V.at(j).at(k)) * (V.at(i).at(k) - V.at(j).at(k));
      }
      if(sqrt(dis) == floor(sqrt(dis))) ans++;
      dis=0;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int d[N];
    REP(i, N) cin >> d[i];

    sort(d, d + N);
    int abc = d[N / 2 - 1];
    int arc = d[N / 2];
    cout << arc - abc << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
using namespace std;

void boarder(int x) {
    for(int i = 0; i < x; ++i) {
        cout << '#';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string str;
    int h, w;
    cin >> h >> w;
    getline(cin, str);
    
    boarder(w+2);
    cout << endl;

    for(int i = 0; i < h; i++) {
        getline(cin, str);
        cout << '#' << str << '#' << endl;
    }
    
    boarder(w+2);
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 15:43:49 2019

@author: mac
"""
n = input()
n = int(n)

numbers = []
index = []

for i in range(12):
    index.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

for _ in range(n):
    string = input()
    numbers.append(list(map(int, string.split(' '))))

numbers.sort()

for i in range(12):
    for j in range(10):
        for k in range(n):
            if (numbers[k][0]-1)*3+(numbers[k][1]-1) == i and (numbers[k][2]-1) == j:
                index[i][j] += numbers[k][3]
                      
for i in range(12):
    for j in range(10):
        print(" ",end="")
        print(index[i][j],end="")
#        if j != 9:
#            print(' ',end="")
        if i == 12:
            break
        
    print()
        
    if i == 2 or i == 5 or i == 8:
        print("####################")
    


Measured memory_bytes: 5644
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  ll A[N+1]; FOR(i,0,N+1) cin >> A[i];
  ll B[N]; FOR(i,0,N) cin >> B[i];
  ll ans = 0;
  FOR(i,0,N) {
    ll a = min(A[i], B[i]);
    ans += a;
    A[i] -= a;
    B[i] -= a;
    a = min(A[i+1], B[i]);
    ans += a;
    A[i+1] -= a;
    B[i] -= a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
// ------------------------------------
// Date:2018/ 3/20
// Problem:A- Getting Difference a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

int N, K;

ll gcdd(ll x, ll y)
{
  ll r0, r1, a0, a1, b0, b1, q0, q1, tmp;
  r0 = x; r1 = y;
  a0 = 1; a1 = 0;
  b0 = 0; b1 = 1;
 
  while(r1 > 0) {
    q1 = r0 / r1;
 
    // a2 = a0 - q1 * a1
    tmp = a1;
    // a1 := a2
    a1 = a0 - q1 * a1;
    a0 = tmp;
 
    // b2 = b0 - q1 * b1
    tmp = b1;
    // b1 := b2
    b1 = b0 - q1 * b1;
    b0 = tmp;
 
    // r2 = r0 - q1 * r1
    tmp = r1;
    // r1 := r2
    r1 = r0 - q1 * r1;
    r0 = tmp;
  }
  return r0;
}

bool solve(vector< int > s)
{
  if (K > s[s.size() - 1]) return false;
  ll m_gcd = s[0];
  FOR(i, 1, N) {
    m_gcd = gcdd(m_gcd, s[i]);
  }
  if (K % m_gcd == 0) return true;
  return false;
}

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

  cin >> N >> K;
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }
  sort(ALL(a));

  bool ok = solve(a);

  OK(ok);

  return 0;
}



Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		int[] num = new int[2];
		for(int i = 0; i < N; i++)
			num[GetInt() % 2]++;
		Console.WriteLine((num[1] % 2 == 0) ? "YES" : "NO");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.length() <= k)
    cout << s << endl;
  else {
    for(int i = 0; i < k; i++) cout << s[i];
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int x,y;
  cin >> x >> y;
  int ans = false;

  // i=つる
  for(int i = 0; i<=x; i++) {
    int tot = i*4 + (x - i)*2;
    if (tot == y) ans = true;
  }

  Yes(ans);

  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <cmath>

long double nth_root(long double val, long double num)
{
  long double inverse = std::pow(num, -1);
  long double ln = std::log(val);
  return std::exp(inverse * ln);
}

int main()
{
  long long N, P;
  scanf("%lld%lld", &N, &P);

  long long ans = 1;
  long long loop = nth_root(P, N) + 0.5;
  for (long long i = loop; i > 1; i--) {
    long long temp = P;
    bool flag = true;
    for (int j = 0; j < N; j++) {
      if (temp % i != 0) {
        flag = false;
        break;
      }
      temp /= i;
    }
    if (flag) {
      ans = i;
      break;
    }
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=int(1e5+5);
int n,p;
int a[MAXN];
int ans[MAXN];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n-1;i++)
        p=a[i]-p;
    ans[1]=(a[n]-p)/2;
    for(int i=2;i<=n;i++)
        ans[i]=a[i-1]-ans[i-1];
    for(int i=1;i<=n;i++)
        printf("%d ",ans[i]*2);
}


Measured memory_bytes: 2048
import * as fs from 'fs';

const main = (inp: string) => {
    const antennas: number[] = inp.split('\n').map(Number);
    const k: number = antennas[5];
    antennas.pop();
    if (antennas[4] - antennas[0] <= k) {
        console.log('Yay!');
    } else {
        console.log(':(');
    }
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vector<string> s(1000);
int visited[1010][1010];
int h, w, ch, cw, dh, dw;
vector<P> moves = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };

bool is_range(int y, int x) {
  return 0 <= y && 0 <= x && y < h && x < w;
}
bool is_wall(int y, int x) {
  return s[y][x] == '#';
}
bool already_visited(int y, int x, int dist) {
  return visited[y][x] <= dist;
}
bool is_goal(int y, int x) {
  return y == dh && x == dw;
}

// 0-1 BFS
void bfs() {
  deque<P> d;
  d.push_back({ ch, cw });

  while(!d.empty()) {
    auto v = d.front(); d.pop_front();
    int y = v.first, x = v.second;
    int nd = visited[y][x];
    int ndd = nd+1;
    for(auto move:  moves) {
      int ny = y + move.first;
      int nx = x + move.second;

      if (!is_range(ny, nx)) continue;
      if (already_visited(ny,nx,nd)) continue;

      if (!is_wall(ny,nx)) {
        visited[ny][nx] = nd;
        d.push_front({ ny, nx });
      } else {
        for (int i = -2; i <= 2; i++) {
          for (int j = -2; j <= 2; j++) {
            if (i==0 && j==0) continue;
            int ni = i+y;
            int nj = j+x;

            if (!is_range(ni,nj)) continue;
            if (is_wall(ni,nj)) continue;
            if (already_visited(ni,nj,ndd)) continue;

            visited[ni][nj] = ndd;
            d.push_back({ ni, nj });
          }
        }
      }
    }
  }
}

int main() {
  IOS;
  cin >> h >> w;
  cin >> ch >> cw;
  cin >> dh >> dw;
  REP(i,h) cin >> s[i];
  ch--; cw--; dh--; dw--;
  REP(i,1010) REP(j,1010) visited[i][j] = INF;
  visited[ch][cw] = 0;

  bfs();

  if (visited[dh][dw] != INF) {
    COUT(visited[dh][dw]);
    return 0;
  }

  COUT(-1);
  return 0;
}

Measured memory_bytes: 8756
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;


int main() {
	map<int, int> mp;
	long long int a, b, c,sum;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) { cout << 0; }
	else {
		sum = a + b + c - max(max(a, b), c) - min(min(a, b), c);
		cout << sum * min(min(a, b), c);
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

void ch(int);
void print(void);

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

int main(){
  int i,j,k,r,c;

  for(i = 0; i < N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i = 0; i < 2*N-1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      X[i][j] = 0;
    }
  }

  scanf("%d",&k);

  for(i = 0; i < k; i++){
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
  }

  ch(0);

  return 0;
}

void ch(int i){
  int j;
  
  if(i == N){
    print();
    return;
  }

  for(j = 0; j < N; j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = NOT_FREE;
    dpos[i+j] = NOT_FREE;
    dneg[i-j+N-1] = NOT_FREE;
    ch(i+1);
    row[i] = FREE;
    col[j] = FREE;
    dpos[i+j] = FREE;
    dneg[i-j+N-1] = FREE;
  }
}

void print(void){
  int i,j;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(X[i][j]){
	if(row[i] != j) return;
      }
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(j == row[i]) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long

int sum(int N){
    int ans = 0;
    while(N > 0){
        ans += N % 10;
        N = N / 10;
    }

    return ans;
}

int main(void){
    int i;
    int N, A, B;
    scanf("%d""%d""%d",&N,&A,&B);

    int total = 0;
    REP(i,N+1){
        int Sum = sum(i);
        if(Sum >= A && Sum <= B) total += i;
    }

    printf("%d",total);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
double solve(int n, double d, double x) {
	if (n == 0) return 0;
	double res = d + (2 * n - 1) * x / 2;
	double dd = ((2 * n + 2) * d + 5 * x) / 2 / n;
	double xx = (n + 2) * x / n;
	return res + solve(n - 1, dd, xx);
}
int main() {
	int n, d, x;
	scanf("%d%d%d", &n, &d, &x);
	double ans = solve(n, d, x);
	printf("%.10f\n", ans);
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int cnt[35];

int main(){
  cin>>n>>m;
  REP(_,n){
    int k;
    cin>>k;
    while(k--){
      int a;
      cin>>a;
      cnt[a]++;
    }
  }
  cout << count(cnt,cnt+31,n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int num;
  rep(i,n) num+=i;
  num-=k;
  if(num<n-1){cout<<-1<<endl;return 0;}
  vector< pair<int,int> > ans;
  repi(i,1,n){
    repi(j,i+1,n+1){
      if(num!=0){
	ans.push_back(make_pair(i,j) );
	num--;
      }
    }
  }
  cout<<ans.size()<<endl;
  rep(i,ans.size() ){
    cout<<ans[i].fst<<" "<<ans[i].scd<<endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int dist(int a, int b, int c, int d) {
	return abs(a-c)+abs(b-d);
}
int main () {
	long long n, m;
	cin >> n >> m;
	int a[100];
	int b[100];
	int c[100];
	int d[100];
	for (int i=0; i<n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i=0; i<m; i++) {
		cin >> c[i] >> d[i];
	}
	int luu;
	for (int i=0; i<n; i++) {
		int mi = 1e9;
		for (int j=0; j<m; j++) {
			int x = dist(a[i], b[i], c[j], d[j]);
			if (x<mi) {
				mi = x;
				luu = j;
			}
		}
		cout << luu+1 << "\n";
	}
}

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

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

ll gcd(ll a,ll b)
{
	return b? gcd(b,a%b):a;
}

ll pow(ll a, ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

int ugabuga()
{

	int n;
	cin>>n;

	int a,b,c;
	cin>>a>>b>>c;

	for(int i=1;i<n;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		x+=max(b,c);
		y+=max(a,c);
		z+=max(a,b);
		a=x;
		b=y;
		c=z;
	}

	cout<<max({a,b,c});

	return 0;
}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int t=1;
    //cin>>t;
    while(t--)
    {
        ugabuga();
    }

}

Measured memory_bytes: 256
import sys

def solve():
    n = int(sys.stdin.readline())
    ans = 0

    for i in range(n):
        num = int(sys.stdin.readline())

        ans += is_prime(num)

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and n & 1 == 0):
        return False

    p = 3

    while p*p <= n:
        if n % p == 0:
            return False

        p += 2

    return True

if __name__ == '__main__':
    solve()

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

#define INF (1<<31)-1
#define LINF (1LL<<63)-1LL
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin>>n>>m;
    vector<int> od;
    rep(i,n)od.eb(i);

    int adj[n][n] = {};
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a;--b;

        adj[a][b] = 1;
        adj[b][a] = 1;
    }

    do{
        if(od[0] == 1)break;

        bool ok = true;
        rep(i,n-1){
            if(adj[ od[i] ][ od[i+1] ] != 1){ok=false;break;}
        }
        if(ok)++ans;

    }while( next_permutation(all(od)) );

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

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

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

  int S1, S2;
  int diff = 100;
  for (int T = 0; T < N; T++)
  {
    S1 = S2 = 0;
    for (int i = 0; i <= T; i++)
    {
      S1 += W.at(i);
    }
    for (int i = T + 1; i < N; i++)
    {
      S2 += W.at(i);
    }
    diff = min(abs(S1 - S2), diff);
  }
  cout << diff << endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            double T = int.Parse(input[0]);
            int X = int.Parse(input[1]);
            double answer = T / X;
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    char x,y;
    scanf("%c %c",&x,&y);
        if(x<y)
        {
            printf("<\n");
        }
        else if(x>y)
        {
             printf(">\n");
        }
        else if(x==y)
        {
             printf("=\n");
        }
}


Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r+1):
        if A[j] <= x:
            i = i + 1
            A[i], A[j] = A[j], A[i]

    return i


n = int(input())
A = [int(x) for x in input().split()]

p = partition(A, 0, n-1)

for i in range(n):
    if i:
        print(" ", end = "")
    if i == p:
        print("[", end="")
    print(A[i], end="")
    if i == p:
        print("]", end="")
print()

    



Measured memory_bytes: 16364
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N; SCD(N);
	vector<int>L;
	
	REP(i,2*N){
		int x; SCD(x);
		L.PB(x);
	}
	
	sort(L.begin(),L.end(),greater<int>() );
	
	int ans = 0;
	
	REP(i,N){
		ans += L[2*i + 1];
	}
	
	PRINTD(ans);
	
	return 0;
}


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

using namespace std;
#define int long long


signed main(){
    string A,B,C;
    cin >> A >> B >> C;
    
    A += "W";
    B += "W";
    C += "W";
    
    int a=0,b=0,c=0;
    string turn = "A";
    string ba = " ";
    for(int i=0;i<300;i++){
        
        if(turn == "A"){
            ba = A[a];
            a++;
        }else if(turn == "B"){
            ba = B[b];
            b++;
        }else if(turn == "C"){
            ba = C[c];
            c++;
        }
        if(A[a-1] == 'W'){
            cout << "A" << endl;
            return 0;
        }
        if(B[b-1] == 'W'){
            cout << "B" << endl;
            return 0;
        }
        if(C[c-1] == 'W'){
            cout << "C" << endl;
            return 0;
        }
        
        if(ba == "a") turn = "A";
        else if(ba == "b") turn = "B";
        else if(ba == "c") turn = "C";
        
    }
    return 0;
}


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

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

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

    int n;
    std::map<char, char> dict;
    while (std::cin >> n && n) {
        rep(i, n) {
            char src, dist;
            std::cin >> src >> dist;
            dict[src] = dist;
        }

        int m;
        std::cin >> m;
        rep(i, m) {
            char ch;
            std::cin >> ch;
            if (dict.count(ch))
                std::cout << dict[ch];
            else
                std::cout << ch;
        }
        std::cout << std::endl;
        dict.clear();
    }
}

Measured memory_bytes: 3056
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int h;
int w;
int ban[100][100];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
queue<int> q;

int main(){
  string ans = "Yes";
  cin >> h;
  cin >> w;
  int f = 0;
  FOR(i,h){
    FOR(j,w){
      char t;
      cin >> t;
      if(t=='#'){
        ban[i][j]=1;
        f=1;
      }
    }
  }
  FOR(i,h){
    FOR(j,w){
      if(ban[i][j]==1){
        int f2 = 0;
        REP(k,4){
          if(ban[i+dx[k]][j+dy[k]]==1)f2 = 1;
        }
        if(f2==0) ans = "No";
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int n;
long long s[111111];
map<pair<long long, long long>, int> mp;
int pr[2555];
vector<int> pp;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%lld",&s[i]);
	for(int i = 2; i <= 2500; ++i){
		if (!pr[i]){
			pp.push_back(i);
			for(int j = i; i * j <= 2500; ++j){
				pr[i * j] = 1;
			}
		}
	}
	for(int i = 1; i <= n; ++i){
		long long tmp = s[i], dn = 1, up = 1;
		for(int j = 0; j < pp.size(); ++j){
			if (tmp % pp[j]) continue;
			int x = 0;
			while (tmp % pp[j] == 0) tmp /= pp[j], ++x;
			x %= 3;
			if (x == 1){
				dn *= pp[j];
				up *= pp[j] * pp[j];
			}
			else if (x == 2){
				dn *= pp[j] * pp[j];
				up *= pp[j];
			}
		}
		if (tmp > 1){
			long long ss = sqrt(tmp);
			if (ss * ss == tmp){
				dn *= tmp;
				up *= ss;
			}
			else{
				dn *= tmp;
				up *= tmp * tmp;
			}
		}
		++mp[make_pair(dn, up)];
	}
	int an = 0;
	while (!mp.empty()){
		pair<long long, long long> cu = mp.begin()->first;
		if (cu.first == 1){
			++an;
		}
		else{
			pair<long long, long long> cuu = make_pair(cu.second, cu.first);
			an += max(mp[cu], mp[cuu]);
			mp.erase(cuu);
		}
		mp.erase(mp.begin());
	}
	printf("%d",an);
	return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<vector<ll>> A(N,vector<ll>(3,0));
    rep(i,N) {
        ll a,b;
        cin >> a >> b;
        A[i][0] = a+b;
        A[i][1] = a;
        A[i][2] = b;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    
    ll a,b;
    a = b = 0;

    rep(i,N) {
        if (i%2==0) {
            a += A[i][1];
        }
        else b += A[i][2];
    }
    ll ans = a-b;
    cout << ans << endl;
}


Measured memory_bytes: 8744
N = int(input())
dic = dict()
m = 0

for _ in range(N):
	S = str(input())
	if S in dic:
		dic[S] += 1
	else:
		dic[S] = 1
	m = max(m, dic[S])
		
a = list(dic.keys())
a.sort()

for t in a:
	if dic[t] == m:
		print(t)

Measured memory_bytes: 85592
// Ref ABC 172 B
using System;
// using System.Collections.Generic;
using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        var z = S.Zip(T, (first, second) => new char[] { first, second });
        int ans = 0;
        foreach (var v in z) if (v[0] == v[1]) ans++;
        Console.WriteLine(ans);
        return;
    }
}

Measured memory_bytes: 26292
N = int(input())
X,Y = [0]*N,[0]*N
U,V = [0]*N,[0]*N
mod = [0] * N
for i in range(N):
    X[i],Y[i] = map(int,input().split(" "))
    mod[i] = (X[i] + Y[i]) % 2
    U[i],V[i] = (X[i]+Y[i]),(X[i]-Y[i])

l = len(list(filter(lambda x: x == 1,mod)))

if l != 0 and l != N:
    print(-1)
    exit(0)

# 偶数
if l == 0:
    d = [ 1 << i for i in range(38,-1,-1) ] + [1]

else:
    d = [ 1 << i for i in range(39,-1,-1) ]

ans = []
for i in range(N):
    move = []
    curU,curV = 0,0
    for step in d:
        if curU <= U[i] and curV <= V[i]:
            curU += step
            curV += step
            move.append('R')

        elif curU > U[i] and curV <= V[i]:
            curU -= step
            curV += step
            move.append('D')

        elif curU <= U[i] and curV > V[i]:
            curU += step
            curV -= step
            move.append('U')

        elif curU > U[i] and curV > V[i]:
            curU -= step
            curV -= step
            move.append('L')

    ans.append(move)

print(len(d))
print(*d)
for i in range(N):
    print("".join(ans[i]))

Measured memory_bytes: 43376
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

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

struct node{
    vector<int> rank0;
    vector<int> rank1;
    node *l=nullptr;
    node *r=nullptr;
};

node *build(vector<int> a, int h){
    if(h==-1) return nullptr;
    vector<int> b[2];
    for(int x:a){
        b[(x>>h) & 1].push_back(x); //hビット目が0のものと1のもので振り分け
    }
    node *res=new node();
    res->l = build(b[0],h-1);
    res->r = build(b[1],h-1);
    const int n=a.size();
    res->rank0.resize(n+1);
    res->rank1.resize(n+1);
    for(int i=0;i<n;i++){
        res->rank0[i+1]=res->rank0[i]+((a[i]>>h & 1)==0);
        res->rank1[i+1]=res->rank1[i]+((a[i]>>h & 1)==1);
    }
    return res;
}

int countGE(node *x, int l,int r,int v,int h){
    if(h==-1) return r-l;
    int res=0;
    if(((v>>h) & 1)==0){
        res+=x->rank1[r]-x->rank1[l];
        res+=countGE(x->l, x->rank0[l], x->rank0[r], v, h-1);
    } else {
        res+=countGE(x->r, x->rank1[l], x->rank1[r], v, h-1);
    }
    return res;
}

int main(){
    ios;
    //元問題は、「区間[l,r)の中の数字の種類数はいくつか」という問題。
    //これは、各項aiについて、biを「aj=aiとなるようなi<jを満たす最小のj」と定義すれば、
    //[l,r)におけるr以上のbiの個数を求める問題に置き換えることができる。
    int n,q; cin >> n >> q;
    vector<int> c(n); rep(i,n) cin >> c[i];
    vector<int> next(n); //補助データ
    map<int,int> mp;
    for(int i=n-1;i>=0;i--){
        if(mp.count(c[i])){
            next[i]=mp[c[i]];
        } else {
            next[i]=n;
        }
        mp[c[i]]=i;
    }
    node *t=build(next,20);
    while(q--){
        int l,r; cin >> l >> r;
        l--;
        cout << countGE(t,l,r,r,20) << endl;
    }
}


Measured memory_bytes: 411384
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b, c, d = map(int, input().split())
    if abs(a - b) <= d and abs(b - c) <= d: print("Yes")
    elif abs(a - c) <= d: print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 61936
# -*- coding: utf-8 -*-


def main():
    mod = 1000000007
    N, M = map(int, input().split())
    # 計算用にidx=-1を追加する
    a = [0 for i in range(0, N+2)]

    for i in range(M):
        a[int(input())+1] = -1

    a[1] = 1
    for i in range(2, N+2):
        if a[i] == -1:
            continue

        if a[i-1] != -1:
            a[i] += a[i-1]

        if a[i-2] != -1:
            a[i] += a[i-2]

        a[i] %= mod

    print(a[-1])


if __name__ == "__main__":
    main()


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

int main(){
    long long n;
    long long r=0,g=0,b=0;
    string s;
    cin>>n>>s;
    long long cnt;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r++;
        }else if(s[i]=='G'){
            g++;
        }else if(s[i]=='B'){
            b++;
        }
    }
    cnt=r*g*b;
    //例外削除
    long long gap=1;
    long long i;
    while(1+gap*2<=n){
        i=0;
        while(gap*2+i<=n-1){
            if(s[i]!=s[gap+i]&&s[i]!=s[gap*2+i]){
                if(s[gap+i]!=s[gap*2+i]){
                    cnt--;
                }
            }
            i++;
        }
        gap++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

const int N=500005;

struct E{
	int to,next;
}mem[N<<1];
int n,num,x,y,ans;
int f[N],g[N],head[N],cnt[N],p[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void dfs1(int k,int pre){
	int u,j;
	g[k]=1; f[k]=0;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		dfs1(u,k);
		f[k]|=g[u]; g[k]&=f[u];
		if (g[u]) cnt[k]++,p[k]=u;
	}
}

void dfs2(int k,int pre){
	int u,j;
	if (g[k]) ans=1;
	if (ans) return;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		if (cnt[k]>1||(cnt[k]==1&&p[k]!=u)) g[u]&=1;
		else g[u]&=0;
		dfs2(u,k);
	}
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	dfs1(1,0);
	dfs2(1,0);
	if (ans) printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
 
int main() {
    char c;
    cin >> c;
    string s;
    s = "abcdefghijklmnopqrstuvwxyz";
    rep(i,s.size()) {
        if (s[i] == 'z') {
            cout << s[0] << "\n";
            return 0;
        }
        if (s[i] == c) {
            cout << s[i+1] << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    string s;
    cin>>s;
    if(s=="ABC")
      cout<<"ARC"<<endl;
    else
      cout<<"ABC"<<endl;
    }


Measured memory_bytes: 3640
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())


P = (A1-B1)*T1
Q = (A2-B2)*T2

if(P > 0):
  P *= -1
  Q *= -1
  
if(P+Q<0):
  print(0)
elif(P+Q==0):
  print('infinity')
else:
  if((-P)%(P+Q)==0):
    print((-P)//(P+Q)*2)
  else:
    print((-P)//(P+Q)*2+1)

Measured memory_bytes: 38384
# -*- coding: utf-8 -*-


def main():
    x, y = map(int, input().split())

    # KeyInsight
    # 最短の操作方法は，ボタンBを0回か1回押す，ボタンAを0回以上押す，ボタンBを0回か1回押す
    # 4通りを試す
    # y >= xが成り立てば，y - x回で目標を達成できる
    # 4通りの最小値が答え
    xy = [(x, y, 0), (x, -y, 1), (-x, y, 1), (-x, -y, 2)]
    ans = float('inf')

    for xi, yi, count in xy:
        if yi >= xi:
            ans = min(ans, yi - xi + count)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
X,Y,A,B,C = LI()
p = LI()
q = LI()
r = LI()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pa =  [0] + list(itertools.accumulate(p))
qa =  [0] + list(itertools.accumulate(q))
p = [INF] + p
q = [INF] + q
red = X
green = Y
t = 0
pl = 0
while p[red] < r[t] or q[green] < r[t]:
    pl += r[t]
    t += 1
    if red == 0:
        green -= 1
    elif green == 0:
        red -= 1

    elif p[red] < q[green] :
        red -= 1
    else:
        green -= 1
    if t >=C or (green ==0 and red ==0): break
print (pa[red] + qa[green] + pl)

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

typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(_VA_ARGS_, geti4, geti3, geti2, geti1) (_VA_ARGS_)

#define INF 987654321
#define IINF 987654321987654321

char st[100100];


int main(){
    scanf("%s",st);
    int len = strlen(st);
    if(len%2 == 0 ){
        if(st[0] == st[len-1]) printf("First\n");
        else printf("Second\n");
    }
    else{
        if(st[0] == st[len-1]) printf("Second\n");
        else printf("First");
    }

    

    return 0;
}















Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector <int > x,y;

int Ne(int k);

int main()
{

	cin >> N;
	x.resize(N);
	y.resize(N);
	REP(i,N){
		cin >> x[i];
		cin >> y[i];
	}
	double ans = 0;
	REP(i,N-1){
		FOR(j,i+1,N){
			ans += sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
		}
	}
	cout <<  setprecision(15) << ans * 2.0 / N;


}


int Ne(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<string>
#define fi first
#define se second
#define ll long long
#define INF 0x3f3f3f
using namespace std;
int main (void)
{
    int n,k,a[200001],i,j;
    ll sum;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    sum=(ll)0;
    for(i=0;i<n-k;i++)
    {
        sum+=(ll)a[i];
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
void solve()
{
	ll n;
	cin>>n;
	ll minPos = 1000000000008;
	for(ll i = 1; i*i<=n; i++)
	{
		if(n%i==0)
		{
			minPos = min(minPos, n/i + i -2);
		}
	}
	cout<<minPos<<"\n";
}
int main()
{
//	ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int x;
  cin>>x;
  bitset<32> bit(x);

  cout<<bit<<endl;
  cout<<~bit<<endl;
  cout<<(bit<<1)<<endl;
  cout<<(bit>>1)<<endl;


}


Measured memory_bytes: 3224
import sys

data= sys.stdin.readline().split(" ")
a = int(data[0])
b = int(data[1])
k = int(data[2])

if a == 1 or b == 1:
    print(a)

else:
    t = a
    if a < b:
        t = b
    t += 1
    count = 0
    for i in reversed(range(1, t)):
        if a % i == 0 and b % i == 0:
            count += 1   
    
        if count == k:
            print(i)
            break

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;
int a,b;

int main(){
    string op;
    cin >> a >> b;
    op = (a > b)? ">" : (a < b)? "<" : "==";
    cout << "a " << op << " b" << endl;
    

    
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	char arr[101]={};
	scanf("%s",arr);
	int a=0;
	while(1){
		if(arr[a]=='\0'){
			break;
		}
		a++;
	}
	//cout<<a;
	int b=0;
	int x=0;
	for(int i=0;i<a;i++){
		if(arr[i]=='C'){
			b=i;
			x=1;
			break;
		}
	}
	if(x==0){
		printf("No");
		return 0;
	}
	for(int i=b;i<a;i++){
		if(arr[i]=='F'){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    S = input()[:-1]
    if "RRR" in S:
        print(3)
    elif "RR" in S:
        print(2)
    elif "R" in S:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
map<int,ll> mp;
ll dp [100001];
const ll MOD = 1e9 + 7;

int main()
{
	scanf("%d",&N);
	vector<int> A(N);
	FOR(i,0,N){
		scanf("%d",&A [i]);
		mp [A [i]]++;
	}

	dp [0] = 1;
	FOR(i,0,N){
		int t = abs((N - i - 1) - i);
		dp [i + 1] = dp [i] * max(0ll,mp [t]) % MOD;
		mp [t]--;
	}

	printf("%lld\n",dp [N]);

	return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

ll n;

int main(){
  cin >> n;
  ll ans;
  rrep(i, (int)sqrt(n)) if(n % i == 0) ans = n / i;
  int digit = 0;
  while(ans > 0){
    ans /= 10;
    digit++;
  }
  cout << digit << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

unsigned GetDigit(unsigned num)
{
    return std::to_string(num).length();
}

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f)
{
    if (rest == 0)
    {
        f(indexes);
    }
    else
    {
        if (s < 0)
            return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f)
{
    int indexes[k];
    recursive_comb(indexes, n - 1, k, f);
}

priority_queue<int> que;
string s;

int main()
{
    int n, ans = 0;
    cin >> n >> s;
    rep(i, 1000)
    {
        int x1 = i / 100;
        int x2 = (i - x1 * 100) / 10;
        int x3 = i % 10;
        int tmp1 = false, tmp2 = false;
        rep(j, n)
        {
            if (!tmp1 && ctoi(s[j]) == x1)
            {
                tmp1 = true;
                continue;
            }
            if (tmp1 && !tmp2 && ctoi(s[j]) == x2)
            {
                tmp2 = true;
                continue;
            }
            if (tmp1 && tmp2 && ctoi(s[j]) == x3)
            {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        Console.WriteLine(NextDouble() / NextDouble());
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
int n,a[111111],b[111111],ans=1;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n;i++){
		if((a[i]>a[i-1]&&b[i]<a[i])||(b[i]>b[i+1]&&b[i]>a[i]))ans=0;
		else if(a[i]==a[i-1]&&b[i]==b[i+1]){
			ans*=min(a[i],b[i]);
			ans%=mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792