akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int n;
int q[100010];
int dp[100010][2];
bool b[100010];

signed main() {
	cin >> n;
	rep (i, n) {
		cin >> q[i];
		b[i] = true;
		for (int j = 2; j * j <= q[i]; j++) b[i] = b[i] && (q[i] % j != 0 || q[i] == j);
	}
	rep (i, n) {
		// i 番目を q とする
		if (i == 0) {
			dp[i][0] = b[i];
			continue;
		}
		if (b[i]) {
			if (q[i - 1] < q[i]) dp[i][0] = (dp[i][0] + dp[i - 1][0]) % MOD;
			if (i > 1 && q[i - 2] < q[i]) dp[i][0] = (dp[i][0] + dp[i - 1][1]) % MOD;
		}
		// i 番目を e とする
		dp[i][1] = (dp[i][1] + dp[i - 1][0]) % MOD;
	}
	cout << (dp[n - 1][0] + dp[n - 1][1]) % MOD << endl;
	//rep (i, n + 1) cout << dp[i][0] << " " << dp[i][1] << endl;
	return 0;
}


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

int main(){
    ll h,a,ans;
    cin >> h >> a;
    if(h % a != 0){
        ans = h / a + 1;
    }else{
        ans = h / a;
    }
    cout << ans;
    return 0;
}


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

namespace ConsoleApp8
{
	class Program
	{
		static void Main(string[] args)
		{
			var str = Console.ReadLine().Split(' ');

			int n = int.Parse(str[0]);
			int total = int.Parse(str[1]);

			for (int i = 0; i <= n; i++)
			{
				for (int j = 0; j <= n - i; j++)
				{
					if (i * 10000 + j * 5000 + (n - i - j) * 1000 == total)
					{
						Console.WriteLine($"{i} {j} {n - i - j}");
						return;
					}
				}
			}
			Console.WriteLine($"-1 -1 -1");
		}
	}
}

Measured memory_bytes: 11220
import sys
input = sys.stdin.readline


def main():
    limit = 10**18
    N = int(input())
    A = list(map(int, input().split()))
    assert N == len(A)
    answer = 1
    if 0 in A:
        print(0)
        exit()
    for i in A:
        answer *= i
        if answer > limit:
            print("-1")
            exit()
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21920
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

bool cmp(P a, P b) { return a.second < b.second; }

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

	string s, t;
	cin >> s >> t;

	int n = s.length();
	int m = t.length();

	set<string> ans;
	for(int r = n; r >= m; r--) {
		int l = r - m;

		int ok = 1;
		for (int i = 0; i < m; i++) {
			if (s[l + i] != '?' && s[l + i] != t[i]) {
				ok = 0;
			}
		}
		if (ok) {
			string u = "";
			rep(i, n) u += s[i];
			rep(i, m) u[l + i] = t[i];
			rep(i, n) if (u[i] == '?') u[i] = 'a';
			ans.insert(u);
		}
	}

	if (sz(ans) == 0) out("UNRESTORABLE");
	else out(*(ans.begin()));

	return 0;
}

Measured memory_bytes: 256
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
int main() {
	int N;
	scanf("%d", &N);
	auto s = new string[N];
	for (int i = 0; i < N; i++) {
		char si[11];
		scanf("%s", si);
		s[i] = si;
	}
	std::sort(s, s + N);
	int res = 1;
	for (int i = 1; i < N; i++) {
		if (s[i] != s[i - 1])res++;
	}
	printf("%d", res);
	return 0;
}

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

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

string s;

ll s2n(const string& x){
    ll ret = 0;
    for(char c : x){
        ret *= 10;
        ret += c - '0';
    }
    return ret;
}

ll calc(ll left, ll total){
    ll ret = total + s2n(s.substr(left, s.size() - left));
    for(ll i = left + 1; i < s.size(); ++i){
        ll tmp = total + s2n(s.substr(left, i - left));
        ret += calc(i, tmp);
    }
    return ret;
}

int main(){
    cin >> s;
    cout << calc(0, 0) << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int d1, d2, d3, d4;
  d1 = n % 10;
  d2 = n / 10 % 10;
  d3 = n / 100 % 10;
  d4 = n / 1000;
  if (d2 == d3 && (d3 == d4 || d1 == d2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

const int N = 100 + 5; // Cantidad de elementos
const int V = 100000 + 5; // Suma máxima de valores (100*1000)

/*
	Idea: 
		- Para cada ganancia posible, guardaremos el peso mínimo con
		  
		  el que podemos formarla, si el peso es menor o igual a 

		  la capacidad, entonces es una ganancia válido


*/

int n; // Elementos
int w[N]; // Peso de cada elemento
int v[N]; // Ganancia de cada elemento
long long W; // Capacidad
bool vis[N][V]; // Marcamos si los estados estan visitados o no
long long memo[N][V]; // Respuesta de los estados

long long DP(int pos, int gain){
	if(pos == n){
		if(gain == 0){
			return 0LL; // Si se pudo obtener la ganancia, devolvemos 0 porque ya no hay nada más que tomar
		}
		else return W+1; // No se pudo obtener la ganancia, damos una respuesta no valida
	}
	if(vis[pos][gain]) return memo[pos][gain];
	long long ans = DP(pos+1,gain); // Inicializamos la respuesta con la accion de no tomar el elemento
	if(gain >= v[pos]){
		ans = min(ans,w[pos] + DP(pos+1,gain-v[pos])); // Tomamos el elemento, así que debemos formar gain-v[pos] ahora y ya agregamos w[pos]
	}
	vis[pos][gain] = true;
	return memo[pos][gain] = ans;
}

int main(){
	scanf("%d %lld",&n,&W);
	int suma_de_valores = 0; // Maximo valor que podría ser obtenido
	for(int i=0; i<n; i++){
		scanf("%d %d",w+i,v+i);
		suma_de_valores += v[i];
	}
	/* Observación importante:
	 * No necesitamos memsetear el vis, dado que los elementos no cambian,
	 * así que los posibles valores formados se mantienen, no se descartan
	*/ 
	for(int i=suma_de_valores; i>=0; i--){ // Vamos del mas grande al menor
		if(DP(0,i) <= W){ // El primero valido es la respuesta por ser mayor
			cout << i << endl; 
			return 0; // Aca nomas cortamos xD
		}
	}
	return 0;
}


Measured memory_bytes: 90112
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    bool a[500][500];
    vector<VI> ans;
    REP(i, h)REP(j, w) {
        int temp;
        cin >> temp;
        a[i][j] = (temp % 2 == 1) ? true : false;
    }

    bool valid_flag = false;
    int prev_i = 0;
    int prev_j = 0;
    if(a[0][0] == true) valid_flag = true;

    REP(i, h){
        if(i % 2 == 0) {
            REP(j, w) {
                if(i == 0 and j == 0) continue;
                if(valid_flag == true) ans.push_back({prev_i, prev_j, i, j});
                if(a[i][j] == true) valid_flag = !valid_flag;
                prev_i = i;
                prev_j = j;
            }
        } else {
            FORR(j, w - 1, 0) {
                if(valid_flag == true) ans.push_back({prev_i, prev_j, i, j});
                if(a[i][j] == true) valid_flag = !valid_flag;
                prev_i = i;
                prev_j = j;
            }
        }
    }

    cout << ans.size() << endl;
    REP(i, ans.size()) {
        REP(j, 4) cout << ans[i][j] + 1 << (j == 3 ? "" : " ");
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 10160
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second

const ll M = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= M;
	if(k%2 == 1){
		ret *= x; ret %= M;
	}
	return ret;
}

int N;
ll h[102];

ll dp1[102][102];
ll dp2[102][102];
void solve(int l,int r,int d){
	if(l == r){
		dp1[l][r] = 0;
		dp2[l][r] = modpow(2,h[l]-d);
		return;
	}
	int d_ = M;
	for(int i = l ; i <= r ; i ++)d_ = min( (ll)d_ , h[i] );
	vector<P> vec;
	int l_=l,r_=l-1;
	int cnt = 0;
	for(int i = l ; i <= r ; i ++){
		if(h[i] <= d_){
			cnt ++;
			if(l_ <= r_){
				vec.push_back(P(l_,r_));
				solve(l_,r_,d_);
			}
			l_ = i+1;
			r_ = i;
		}
		else {
			r_ = i;
		}
	}
	if(l_ <= r_){
		vec.push_back(P(l_,r_));
		solve(l_,r_,d_);
	}
	dp1[l][r] = 1;
	dp2[l][r] = 1;
	for(int i = 0 ; i < vec.size() ; i ++){
		P p = vec[i];
		dp1[l][r] *= (dp1[p.fr][p.sc]+dp2[p.fr][p.sc]*2);
		dp1[l][r] %= M;
		dp2[l][r] *= dp2[p.fr][p.sc];
		dp2[l][r] %= M;
	}
	dp1[l][r] *= modpow(2,cnt);
	dp1[l][r] %= M;
	dp2[l][r] *= 2;
	dp2[l][r] %= M;
	dp1[l][r] += M-dp2[l][r];
	dp1[l][r] %= M;
	dp2[l][r] *= modpow(2,d_-d-1);
	dp2[l][r] %= M;
}

int main(){
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&h[i]);
	}
	solve(1,N,0);
	//cout << dp1[1][N] << " " << dp2[1][N] << endl;
	cout << (dp1[1][N]+dp2[1][N])%M << endl;
}



Measured memory_bytes: 384
/* Author rumoisen */
/* created 2018/10/07 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main(void)
{
    int n,m;
    cin>>n>>m;
    int a[81],b[81];
    REP(i,n) cin>>a[i]>>b[i];
    int c[81],d[81];
    REP(i,m) cin>>c[i]>>d[i];
    for(int i=0;i<n;i++){
        int min_abs=abs(a[i]-c[0])+abs(b[i]-d[0]),tmp=1;
        for(int z=0;z<m;z++){
            const int mh=abs(a[i]-c[z])+abs(b[i]-d[z]);
            if(min_abs>mh){
                min_abs=mh;
                tmp=z+1;
            }
        }
        cout<<tmp<<endl;
    }
    return 0;
}

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

#define _LL long long

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
    int n;
    cin >> n;
    int *w = inputint(n);
    int ans = 100 * 100 * 100;
    for( int t = 1; t < n; t++ )
    {
        int s1 = 0;
        int s2 = 0;
        for(int i = 0; i < t; i++ ) s1 += w[i];
        for(int i = t; i < n; i++ ) s2 += w[i];
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
#define to_digit(c) c-'0';
int main()
{
string s; cin >> s;
ll sum = 0;
rep(0,s.size())
{
    sum += (s[i]-'0');
    sum %= 9;
}
if(!sum)
cout << "Yes" << endl;
else
{
    cout << "No" << endl;
}

return 0;
}

Measured memory_bytes: 3688
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N==1){
            System.out.println("Hello World");
        }
        else{
            int A = sc.nextInt();
            int B = sc.nextInt();
            System.out.println(A+B);
        }
    }
}


Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll r = in(), s = in(), p = in();
	vector<ll>manhattan(555555, 0);
	ll max_m = 0;
	REP(i, p) {
		ll y, x; scanf("%lld %lld", &y, &x); --y; --x;
		ll m = (r - y) + (x < s ? s - x : x - s + 1);
		max_m = max(max_m, m);
		++manhattan[m];
	}
	ll debt = 0;
	for (ll i = 2;; ++i) {
		if (manhattan[i] > 1)debt += manhattan[i] - 1;
		else if (manhattan[i] == 0)debt = max(debt - 1, 0LL);
		if (i >= max_m && debt == 0) {
			cout << i << endl;
			return 0;
		}
	}
}


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

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

struct Radix {
	string s;
	int a[128];
	Radix(string s = "0123456789ABCDEF") :s(s) {
		for (int i = 0; i < s.size(); i++)
			a[s[i]] = i;
	}
	//10???(long long) -> n???(string)
	string format(long long x, int n, int len = 1) {
		if (!x)return string(len, s[0]);
		string ret;
		for (; x || len > 0; x /= n, len--)
			ret += s[x%n];
		reverse(ret.begin(), ret.end());
		return ret;
	}
	using It = string::iterator;
	//m???(string) -> n???(string)
	string format(It l, It r, int m, int n, int len = 1) {
		return format(format(l, r, m), n, len);
	}
	//m???(string) -> 10???(long long)
	long long format(It l, It r, int m) {
		long long x = a[*l];
		for (l++; l != r; l++)
			x = x * m + a[*l];
		return x;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<string> S(N); rep(i, 0, N) { cin >> S[i]; }
	Radix r(" abcdefghijklmnopqrstuvwxyz");
	unordered_set<long long> st;
	rep(i, 0, N) {
		int n = S[i].size();
		rep(h, 1, 5) {
			rep(j, 0, n - h + 1) {
				st.emplace(r.format(S[i].begin() + j, S[i].begin() + j + h, 27));
			}
		}
	}
	rep(i, 0, pow(27, 4)) {
		if (st.count(i))continue;
		string s = r.format(i, 27);
		if (s.find(' ') != string::npos)continue;
		cout << s << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 20356
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define MOD 100000
int M, N;
char S[20][20];
int idx[1<<20];
int idx_r[1<<20];
int dp[2][20000][3];
int bf[20][20];

int f(char c) {
  if (c == 'J') return 0;
  if (c == 'O') return 1;
  if (c == 'I') return 2;
  exit(1);
}

int main() {
  cin >> M >> N;
  for (int i=0; i<M; i++) {
    for (int j=0; j<N; j++) {
      cin >> S[i][j];
    }
  }

  int ctr = 0;
  for (int i=0; i<(1<<N); i++) {
    bool f = true;
    for (int j=1; j<N; j++) {
      if ((i & (1 << (j-1))) != 0 && (i & (1 << j)) != 0) {
        f = false;
        break;
      }
    }
    if (!f) continue;
    idx[i] = ctr;
    idx_r[ctr] = i;
    ctr += 1;
  }

  for (int k=0; k<3; k++) {
    if (S[0][0] != '?' && f(S[0][0]) != k) continue;
    dp[0][0][k] = 1;
  }

  for (int y=0; y<M; y++) {
    for (int x=0; x<N; x++) {
      int p = y*N + x;
      if (p == 0) continue;
      for (int s=0; s<ctr; s++) {
        for (int k=0; k<3; k++) {
          for (int g=0; g<3; g++) {
            if (S[y][x] != '?' && f(S[y][x]) != g) continue;

            int ns = idx_r[s] >> 1;
            if (x != 0 && k == 0 && g == 1) ns |= 1<<(N-1);

            if (x != N-1 && (ns & 1) != 0 && g == 2) {
              bf[y][x] += dp[(p-1)%2][s][k];
              bf[y][x] %= MOD;
              continue;
            }
            dp[p%2][idx[ns]][g] += dp[(p-1)%2][s][k];
            dp[p%2][idx[ns]][g] %= MOD;
          }
        }
      }
      for (int s=0; s<ctr; s++) {
        for (int k=0; k<3; k++) {
          dp[(p-1)%2][s][k] = 0;
        }
      }
    }
  }

  long long ans = 0;
  long long t = 1;
  for (int y=M-1; y>=0; y--) {
    for (int x=N-1; x>=0; x--) {
      ans = (ans + (t*(long long)bf[y][x] % MOD)) % MOD;
      if (S[y][x] == '?') t = (t * 3) % MOD;
    }
  }

  cout << ans << "\n";
  return 0;
}

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

const int N = 100 * 1000 + 20;
int n, m, ans, pen, cnt[N];
bool mark[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  	cin >> n >> m;
  	for (int i = 0; i < m; i++) {
		int idx;
      	string s;
      	cin >> idx >> s;
      	if (s == "AC")
			mark[idx] = true;
      	else
          	if (!mark[idx])
              	cnt[idx]++;
    }
  	for (int i = 1; i <= n; i++) 
      	if (mark[i]) {
			ans++;
          	pen += cnt[i];
        }
  	cout << ans << " " << pen << "\n";
}

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

#define int long long
#define double long double

#define ii pair<int,int>
#define dd pair<double,double>
#define fi first
#define sc second

#define sqr(x) ((x)*(x))

double dist(dd a, dd b) {
  return sqrt(sqr(a.fi - b.fi) + sqr(a.sc - b.sc));
}

double fact(int n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  vector<dd> a(n);
  for (auto &i : a) cin >> i.fi >> i.sc;
  double ans = 0;
  for (int i = 0; i < n - 1; i++)
  for (int j = i + 1; j < n; j++) {
    ans += dist(a[i], a[j]) * fact(n - 1) * 2;
  }
  cout << fixed << setprecision(10) << ans / fact(n) << '\n';
  return 0;
}


Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    var nm = Console.ReadLine().Split();
    int n = int.Parse(nm[0]);
    int m = int.Parse(nm[1]);
    
    int[] a = new int[n];
    int[] b = new int[n];
    int[] c = new int[m];
    int[] d = new int[m];
    
    for(int i=0; i<n; i++){
      var ab = Console.ReadLine().Split();
      a[i] = int.Parse(ab[0]);
      b[i] = int.Parse(ab[1]);
    }
    for(int i=0; i<m; i++){
      var cd = Console.ReadLine().Split();
      c[i] = int.Parse(cd[0]);
      d[i] = int.Parse(cd[1]);
    }
    
    for(int i=0; i<n; i++){
      int min = Math.Abs(a[i]-c[0]) + Math.Abs(b[i]-d[0]);;
      int ans = 0;
      for(int j=1; j<m; j++){
        int l = Math.Abs(a[i]-c[j]) + Math.Abs(b[i]-d[j]);
        if(l < min){
          min = l;
          ans = j;
        }
      }
      Console.WriteLine(ans+1);
    }
  }
}

Measured memory_bytes: 11220
time_list = [input() for _ in range(5)]
min_time = 10
for time in time_list:
    if time[-1]=="0":
        continue
    min_time = min(int(time[-1]), min_time)
ans = 0
for time in time_list:
    if time[-1]=="0":
        ans += int(time)
    else:
        ans += (int(time)//10 + 1)* 10
if min_time == 10:
    print(ans)
else:
    print(ans - (10-min_time))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int main() {
  ll n;
  scanf("%lld", &n);

  vector<ll> p(n);
  for (ll i = 0; i < n; i++) {
    scanf("%lld", &p[i]);
  }

  ll r = 1;
  ll mi = p[0];
  for (ll i = 1; i < n; i++) {
    if (mi > p[i]) {
      r++;
    }
    mi = min(mi, p[i]);
  }

  cout << r << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int N;
  int D;
  int a;
  scanf("%d",&N);
  scanf("%d",&D);
  a=2*D+1;
  if(N%a==0)
    printf("%d\n",N/a);
  else
    printf("%d\n",N/a+1);
  return 0;
}

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

#define INF 1<<29
#define MAXV 100

int V;      //????????°
int cost[MAXV+10][MAXV+10];

vector<int> dijkstra(int s){
    vector<int> d(V,INF);
    bool used[MAXV+10];
    for(int i=0;i<MAXV+10;i++) used[i]=false;

    d[s]=0;
    while(true){
        //??????????????????????????????????????§s??????????????¢???????°?????????????v??¨??????
        int v=-1;
        for(int u=0;u<V;u++){
            if(!used[u] and (v==-1 or d[u]<d[v])) v=u;
        }

        if(v==-1) break;
        
        used[v]=true;
        for(int u=0;u<V;u++){
            d[u] = min(d[u],d[v]+cost[v][u]);
        }
    }
    return d;
}

int main(){
    // initialize
    for(int i=0;i<MAXV+10;i++) for(int j=0;j<MAXV+10;j++) cost[i][j]=INF;

    cin >> V;
    for(int i=0;i<V;i++){
        int u,k;cin>>u>>k;
        for(int j=0;j<k;j++){
            int v,c;cin>>v>>c;
            cost[i][v]=c;
//            cost[v][i]=c;
        }
    }

    vector<int> dis = dijkstra(0);
    for(int i=0;i<dis.size();i++){
        printf("%d %d\n",i,dis[i]);
    }
}

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

using namespace std;

vector<bool> seen;
vector<long long int> topo;
vector<vector<long long int> > E;

void dfs(long long s) {
    seen[s] = true;
    
    for(int ei=0; ei<E[s].size(); ei++) {
        long long int e=E[s][ei];
        if(seen[e]) {
            continue;
        } else {
            dfs(e);
        }
    }
    
    topo.push_back(s);
}

int main() {
    long long int N, Q;
    cin >> N >> Q;
    seen.assign(N, false);
    E.resize(N);
    
    for(int n=0; n<N-1; n++) {
        long long int a, b;
        cin >> a >> b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }
    
    dfs(0);
    reverse(topo.begin(), topo.end());
    
    vector<long long int> ans(N, 0);
    for(int q=0; q<Q; q++) {
        long long int p, x;
        cin >> p >> x;
        
        ans[p-1] += x;
    }
    
    for(int n=0; n<N; n++) {
        long long int cur_i=topo[n];
        
        for(int ei=0; ei<E[cur_i].size(); ei++) {
            long long int tar_i=E[cur_i][ei];
            ans[tar_i] += ans[cur_i];
            
            for(int eti=0; eti<E[tar_i].size(); eti++) {
                if(E[tar_i][eti]==cur_i) {
                    E[tar_i].erase(E[tar_i].begin()+eti);
                    break;
                }
            }
        }
    }
    
    for(int n=0; n<N; n++) {
        cout << ans[n] << " ";
    }
    cout << endl;
    
    return 0;
    
}

Measured memory_bytes: 25968
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const long double INF=1e30;
 
int cnt[(int)1e5+3];
bool possible[(int)1e5+3];

int main(){
    int N,M;
    cin>>N>>M;
    CLR(cnt);CLR(possible);
    REP(i,N)cnt[i]=1;
    possible[0]=true;
    REP(i,M){
        int x,y;
        cin>>x>>y;x--;y--;
        if(possible[x])possible[y]=true;
        if(cnt[x]==1){
            possible[x]=false;
        }
        cnt[x]--;cnt[y]++;
    }
    int res=0;
    REP(i,N)res+=possible[i];
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
    int P,Q,R,a,b,c;
    cin >> P >> Q >> R;
    if(P>Q){
        b=P;
        P=Q;
        Q=b;
    }
    if(P>R){
        c=P;
        P=R;
        R=c;
    }
    if(Q>R){
        a=Q;
        Q=R;
        R=a;
    }
    cout << P+Q;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    long double aa, bb;
    cin >> aa >> bb;
    long double ans = aa*bb;
    ll aans = ans;
    cout << aans << endl;
}

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

int main() {
    int n,r; cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + (100*(10-n)) << endl;
}

Measured memory_bytes: 3588
#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 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 mod=1234567;
 
int main(){
    ll n;
    cin >> n;
    vector<ll> x(n),y(n),h(n);
    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
    }
    ll ans_x,ans_y,ans_h;
    for(ll i=0;i<=100;i++){
        for(ll j=0;j<=100;j++){
            set<ll> s;
            rep(k,n){
                if(h[k]>0){
                    s.insert(h[k]+abs(x[k]-i)+abs(y[k]-j));
                }
            }
            if(s.size()==1){
                ll v=*s.begin();
                bool ok=true;
                rep(k,n){
                    if(h[k]==0 && v-abs(x[k]-i)-abs(y[k]-j)>0){
                        ok=false;
                    }
                }
                if(ok){
                    ans_x=i;
                    ans_y=j;
                    ans_h=v;
                }
            }
        }
    }
    cout << ans_x << " " << ans_y << " " << ans_h << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*ta = map(int, read().split())


v=w=1
mp = iter(ta)
for t,a in zip(mp,mp):
    x = max((v+t-1)//t,(w+a-1)//a)
    v = t*x
    w = a*x
    #print(v,w)
    
print(v+w)



Measured memory_bytes: 9288
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s;
  ll cnt=0;
  cin >> s;
  for(int i=1;i<s.size();i++){
    if(s[i-1]!=s[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s,t,z;
    cin>>n;
    cin>>s;
    cin>>t;
    z=s;
    reverse(z.begin(),z.end());

    int i,j,f=0,c=0;
    if(z==t)cout<<n<<endl;
    else if(s==t)cout<<n<<endl;
    else
    {


    for(i=n-1; i>=0;)
    {
        if(f==n)break;
        for(j=n-1; j>=0;)
        {
            f++;
            if(s[i]==t[j])
            {
                c++;
             i--;
             j--;
            }
            else
            {
                j--;
            }

        }

    }
    cout<<2*n-c<<endl;
    }
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		 InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);                    //?????????

        String str = br.readLine(); 
        int x = Integer.parseInt(str);
        x=x*x*x;
        System.out.println(x);
	}
}

Measured memory_bytes: 24284
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=112345;

int n,w,wi[112],w2;
ll v[112],v2,dp[nmax];

int main()
{
    scanf("%d %d",&n,&w);
    for(int i=0; i<n; ++i)
        scanf("%d %lld",&wi[i],&v[i]);
    for(int i=0; i<n; ++i)
    {
        for(int j=w-wi[i]; j>0; --j)
            if(dp[j]!=0)
            {
                w2=j+wi[i];
                v2=dp[j]+v[i];
                if(dp[w2]<v2)
                    dp[w2]=v2;
            }
        w2=wi[i];
        v2=v[i];
        if(dp[w2]<v2)
            dp[w2]=v2;
    }
    ll res=0;
    for(int i=w; i>0; --i)
        if(res<dp[i])
            res=dp[i];
    printf("%lld\n",res);
    return 0;
}


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

int main(){
  string a,b;
  cin >> a >> b;
  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
  
}


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

int main() {
  int n, m, x; cin >> n >> m >> x;
  vector<int> a(m);
  int cost0 = 0, costx = 0;
  for (auto& e: a) {
    cin >> e;
    if (e < x) cost0++;
    if (x < e) costx++;
  }
  cout << min(cost0, costx) << endl;
}

Measured memory_bytes: 256
#pragma region

#ifdef LOCAL
#define debug cout
#else
#define debug \
    if (0) cout
#endif

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
}

#pragma endregion

using pll = pair<ll, ll>;

// Query for minimum
// Decreasing slope additions
// General queries
struct convex_hull {
    deque<pll> lines;

    // Only requires that l1.first <= l2.first <= l3.first
    bool bad(pll l1, pll l2, pll l3) {
        return (l2.second - l3.second) * (l2.first - l1.first) >= (l1.second - l2.second) * (l3.first - l2.first);
    }

    // Add y=mx+b. Decreasing slope!
    void add_min_slope(ll m, ll b) {
        if (!lines.empty()) {
            assert(m <= lines.front().first);
        }
        pll cur = {m, b};
        while (lines.size() >= 2 && bad(cur, lines[0], lines[1])) {
            lines.pop_front();
        }
        lines.push_front(cur);
    }

    void add_max_slope(ll m, ll b) {
        if (!lines.empty()) {
            assert(m >= lines.back().first);
        }
        pll cur = {m, b};
        while (lines.size() >= 2 && bad(lines[lines.size() - 2], lines[lines.size() - 1], cur)) {
            lines.pop_back();
        }
        lines.push_back(cur);
    }

    ll query_min(ll x) {
        int lo = 0, hi = lines.size() - 1;
        while (lo < hi) {
            int mid = hi - (hi - lo) / 2;
            auto l2 = lines[mid], l1 = lines[mid - 1];
            if (l1.second - l2.second >= x * (l2.first - l1.first)) {
                lo = mid;
            } else {
                hi = mid - 1;
            }
        }
        return lines[lo].first * x + lines[lo].second;
    }
};

void solve() {
    int n;
    ll C;
    cin >> n >> C;
    vector<int> h(n);
    cin >> h;
    convex_hull hull;
    hull.add_min_slope(-2LL * h[0], 1LL * h[0] * h[0]);
    ll f;
    for (int i = 1; i < n; ++i) {
        f = 1LL * h[i] * h[i] + C + hull.query_min(h[i]);
        hull.add_min_slope(-2LL * h[i], f + 1LL * h[i] * h[i]);
    }
    cout << f << "\n";
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if(W>=V or (V-W)*T<abs(A-B))
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>

#define MAX 100000 
#define NIL -1

struct Node{ 
  int p, l, r;
};
struct Node type[MAX];

void print(int);
int rec(int, int);

int n, depth[MAX];

int main()
{
  int id, k, c;
  int i, j, tmp, tmp1;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ) type[i].p=type[i].l=type[i].r=NIL;

  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d", &id, &k);
    for( j = 0 ; j < k ; j++ ){
      scanf("%d", &c);
      if( j == 0 ) type[id].l = c;
      else type[tmp].r = c;
      tmp = c;
      type[c].p = id;
    }
  }
  
  for( i = 0 ; i < n ; i++ ){
    if( type[i].p == NIL ) tmp1 = i;
  }

  rec(tmp1, 0);

  for( i = 0 ; i < n ; i++ ) print(i);

  return 0;
}

void print(int node)
{
  int i, c;

  printf("node %d: parent = %d, depth = %d, ", node, type[node].p, depth[node]);
  
  if( type[node].p == NIL ) printf("root, ");
  else if( type[node].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for( i = 0 , c = type[node].l ; c != NIL ; i++, c = type[c].r){
    if( i ) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int rec(int u, int p)
{
  depth[u] = p;
  
  if( type[u].r != NIL ) rec(type[u].r, p);
  if( type[u].l != NIL ) rec(type[u].l, p+1);
}

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

int n[4];

int main(){
  int t1;
  char t2;
  string s;
  while(cin>>t1>>t2>>s){
    if(s=="A")n[0]++;
    if(s=="B")n[1]++;
    if(s=="AB")n[2]++;
    if(s=="O")n[3]++;
  }
  for(int i=0; i<4; i++)
    cout<<n[i]<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void)
{
	unsigned long long int a,b,x;
	scanf("%llu%llu%llu",&a,&b,&x);
	int i=0;

	if(a%x==0) i=1;
	printf("%llu\n",b/x-a/x+i);

	return 0;
}

Measured memory_bytes: 128
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n;

struct node{
    int x, y, i;
    node(int x = 0,int y = 0, int i = 0):x(x), y(y), i(i){}
};

int compx(node a, node b){
    return a.x < b.x;
}
int compy(node a, node b){
    return a.y < b.y;
}


node c[N];



class dsu {
public:
    vector<int> p;
    int n;
    
    dsu(int _n) : n(_n) {
        p.resize(n+1);
        iota(p.begin(), p.end(), 0);
    }
    
    inline void re_init(){
        iota(p.begin(), p.end(), 0);
    }
    
    inline int findset(int x) {
        return (x == p[x] ? x : (p[x] = findset(p[x])));
    }
    
    inline bool unite(int x, int y) {
        x = findset(x);
        y = findset(y);
        if (x != y) {
            p[x] = y;
            return true;
        }
        return false;
    }
    inline int num_of_componet(){
        int ans = 0;
        for (int i = 1; i <= n; i++){
            if(i == findset(i)) ans++;
        }
        return ans;
    }
};


struct edge {
    int u, v, cost;
    edge(int u, int v, int cost):u(u), v(v), cost(cost){}
    bool operator <(const edge& rhs) const{
        return cost< rhs.cost;
    }
};

vector<edge> edges;

int kruskal(){
    int ans = 0;
    dsu d(n);
    sort(edges.begin(), edges.end());
    int m = edges.size();
    for (int i = 0; i < m; i++){
        edge& e = edges[i];
        int x = d.findset(e.u);
        int y = d.findset(e.v);
        if(x!=y){
            ans += e.cost;
            d.unite(x, y);
        }
    }
    return ans;
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for (int i = 1; i <= n; i++){
        cin>>c[i].x>>c[i].y;
        c[i].i = i;
    }
    
    sort(c+1, c+1+n, compx);
    
    for (int i = 1; i <= n-1; i++){
        edges.push_back(edge(c[i].i, c[i+1].i, c[i+1].x - c[i].x));
    }
    
    
    sort(c+1, c+1+n, compy);
    
    for (int i = 1; i <= n-1; i++){
        edges.push_back(edge(c[i].i, c[i+1].i, c[i+1].y - c[i].y));
    }
    
    cout<<kruskal()<<endl;
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 6004
n, x = map(int, input().split())
def layer(n):
    return 2 ** (n+2) - 3
def full(n):
    return 2 ** (n+1) - 2
def solve(n, x):
    if x <= 0:
        return 0
    if n == 0:
        return 0
    if x >= layer(n):
        return full(n)
    if x <= layer(n-1) + 1:
        return 1 + solve(n-1, x-1)
    else:
        return full(n-1) + solve(n-1, x - layer(n-1) - 2) + 1
print(x - solve(n,x))


Measured memory_bytes: 3060
h,w = map(int,input().split())

al_l = []

for _ in range(h):
    al = list(input())
    al_l.append(al)


for al in al_l:
    for idx, a in enumerate(al):
        tmp = [i[idx] for i in al_l]
        if "#" not in al or "#" not in tmp:
            pass
        else:
            print(a, end="")
    print("")
    

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

int main(){
  string s; cin >> s;
  cout << s;
  if (s.at(s.length() -1) == 's')
  {
    
    cout << "es" << endl;
  }
  else
  {
    cout << 's' <<endl;
  }
  
  
}

Measured memory_bytes: 3624
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.Vector as V

main :: IO()
main = do
    n <- read <$> getLine
    xs <- map read . words <$> getLine
    forM_ (solve xs n) print

solve :: [Int] -> Int -> [Int]
solve xs n = map sub [0..(length xs - 1)]
    where
        v = V.fromList xs
        lm = largeMedian xs n
        sm = smallMedian xs n
        sub idx = if (v V.! idx) <= sm
            then lm
            else sm

largeMedian :: [Int] -> Int -> Int
largeMedian [] _ = error "error"
largeMedian xs n = (tail $ sort xs) !! (n `div` 2 - 1)

smallMedian :: [Int] -> Int -> Int
smallMedian [] _ = error "error"
smallMedian xs n = (init $ sort xs) !! (n `div` 2 - 1)


Measured memory_bytes: 148860
n = int(input())
ans = [0] * n

for x in range(1,int(n**0.5)):
    for y in range(1,int(n**0.5)):
        for z in range(1,int(n**0.5)):
            a = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if a <= n:
                ans[a-1] += 1
[print(x) for x in ans]

Measured memory_bytes: 75092
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;

signed main(){
    string s; cin >> s;
    cout << *s.begin() << s.size()-2 << *(s.end()-1) << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(M)]
s = []
g = []
for i in range(M):
    if 1 == L[i][0]:
        s.append(L[i][1])
    if 1 == L[i][1]:
        s.append(L[i][0])
        
for i in range(M):
    if N == L[i][0]:
        g.append(L[i][1])
    if N == L[i][1]:
        g.append(L[i][0])
        
if set(g)&set(s):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 54764
n,d=map(int,input().split())
lis=[list(map(int,input().split())) for i in range(n)]
cnt=0
x=0
for i in range(n-1):
  for j in range(i+1,n):
    for k in range(d):
      x+=(lis[i][k]-lis[j][k])**2
    if (x**0.5).is_integer():
      cnt+=1
    x=0
print(cnt)

Measured memory_bytes: 3188
N=int(input())
L=[]
for i in range(N):
    a,b=input().split()
    L.append((a,int(b),i+1))
L.sort(key=lambda x:x[1],reverse=True)
L.sort(key=lambda x:x[0])
for i in range(N):
    print(L[i][2])

Measured memory_bytes: 3060
import numpy as np
def _unique1d(ar, return_index=False, return_inverse=False,
              return_counts=False):
    """
    Find the unique elements of an array, ignoring shape.
    """
    ar = np.asanyarray(ar).flatten()

    optional_indices = return_index or return_inverse
    optional_returns = optional_indices or return_counts

    if ar.size == 0:
        if not optional_returns:
            ret = ar
        else:
            ret = (ar,)
            if return_index:
                ret += (np.empty(0, np.intp),)
            if return_inverse:
                ret += (np.empty(0, np.intp),)
            if return_counts:
                ret += (np.empty(0, np.intp),)
        return ret

    if optional_indices:
        perm = ar.argsort(kind='mergesort' if return_index else 'quicksort')
        aux = ar[perm]
    else:
        ar.sort()
        aux = ar
    flag = np.concatenate(([True], aux[1:] != aux[:-1]))

    if not optional_returns:
        ret = aux[flag]
    else:
        ret = (aux[flag],)
        if return_index:
            ret += (perm[flag],)
        if return_inverse:
            iflag = np.cumsum(flag) - 1
            inv_idx = np.empty(ar.shape, dtype=np.intp)
            inv_idx[perm] = iflag
            ret += (inv_idx,)
        if return_counts:
            idx = np.concatenate(np.nonzero(flag) + ([ar.size],))
            ret += (np.diff(idx),)
    return ret
N = int(input())
A = np.array(list(map(int, input().split())), dtype= int)
I = np.arange(1, N+1)
C = A - I
mincost = -1
P, M = _unique1d(C, return_counts=True)
n = -N
for p , m in zip(P, M):
    n1 = n + 2*m
    if n*n1<=0:
        b = p
        break
    n = n1
cost = np.abs(C - b).sum()
print(cost)

Measured memory_bytes: 34228
sen=input()
n=len(sen)
def func(arg):
  n=len(arg)
  if len(arg)%2==0:
    maemae=arg[:int(n/2)]
    usiusi=arg[int(n/2):]
    if maemae[::-1]!=usiusi:
      return False
    else:
      return True
  else:
    maemae=arg[:n//2]
    #aidaaida=arg[n//2]
    usiusi=arg[n//2+1:]
    if maemae[::-1]!=usiusi:
      return False
    else:
      return True


mae=sen[:n//2]
#aida=sen[n//2]
usiro=sen[n//2+1:]
if mae[::-1]!=usiro:
    print('No')
else:
  #if func(mae)+func(usiro)==2:
  if func(mae)==1:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
   int n,t;
   cin >> n >> t;
   ll a;
   ll mi=INF,no,b=0,ans=0;
   rep(i,n){
     cin >> a;
     if (b==a-mi && no!=mi) ans++;
     if (b<a-mi) {
       no=mi;
       ans=1;
       b=a-mi;
     }
     if (a<mi) {mi=a;}
   }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  double L;
  cin >> L;
  double e = L/3;
  cout << setprecision(16) << e*e*e << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    A,B = map(int,input().split())
    import fractions
    C = fractions.gcd(A,B)
    cnt = 0
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        return divisors
    def is_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    C_2 = make_divisors(C)
    
    for i in C_2:
        if is_prime(i):
            cnt += 1
    print(cnt)
    
    


    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5300
#include<stdio.h>
#include<stdlib.h>
typedef long long int lli;

int gcd(int a,int b){
  if(b>a){
    int tmp=a;
    a=b;
    b=tmp;
  }
  if(a%b==0)return b;
  else return gcd(b,a%b);
}

int main(void)
{
  int n;
  lli sum=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        sum+=(lli)gcd(gcd(i,j),k);
      }
    }
  }
  printf("%lld\n",sum);
  return 0;
}

Measured memory_bytes: 1732