akhauriyash/Code-Regression huggingface dataset:
from queue import Queue

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

def movable(S,vy,vx):
    if 0 <= vy and vy < H and 0 <= vx and vx < W:
        if S[vy][vx] == ".":
            return True
    return False

def bfs(S):
    sy,sx,gy,gx = 0,0,H,W
    Dist = [[None for _ in range(W)] for _ in range(H)]
    vec = [(-1,0),(1,0),(0,-1),(0,1)]
    q = Queue()
    q.put((sy,sx))
    Dist[sy][sx] = 0
    while not q.empty():
        p = q.get()
        py,px = p[0],p[1]
        for vy,vx in vec:
            if movable(S,py+vy,px+vx):
                q.put((py+vy,px+vx))
                Dist[py+vy][px+vx] = Dist[py][px]+1
                S[py+vy][px+vx] = "#"
    return Dist[H-1][W-1]

def white_sum(S):
    count = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                count += 1
    return count

white_sum = white_sum(S)
d_H_W = bfs(S)
if d_H_W == None:
    print(-1)
else:
    print(white_sum - d_H_W - 1)


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long int mod=1e9+9;
const int N=100000;
int t,i,j,cs=0,n,m,a,b;
string s;

int main()
{
    ll cost=0,k=0;
    cin>>n>>m;
    ll ar[n];
    for(i=0;i<n;i++){
        cin>>ar[i];
        cost+=ar[i];
    }
    ll in=4*m;
    sort(ar,ar+n);
    for(i=n-1;i>=0;i--){
        if(ar[i]*in>=cost){
            k++;
          //  cout<<ar[i]<<" ";
        }

        else{
            break;
        }
    }
    if(k>=m)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<endl;

}





Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys

def main():
    N = int(input())
    H = list(map(int, input().split()))
    H = H[::-1]

    for i in range(N-1):
        if H[i + 1] - H[i] == 1:
            H[i + 1] -= 1
        elif H[i] >= H[i + 1]:
            continue
        else:
            print("No")
            return
    print("Yes")

if __name__ == '__main__':
    main()

    


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    ll c = 0;
    while (true) {
        bool can = true;
        REP(i, N) {
            if (A[i]%2 != 0) can = false;
            A[i] /= 2;
        }
        if (!can) {
            cout << c << "\n";
            return 0;
        }
        c++;
    }
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = readLn >>= print . solve'

solve :: Integer -> Integer
solve n = sum [ i | i <- [2..(n-1)], n `mod` i == n `div` i]

solve' n = if null ans then 0 else sum ans
  where
    ans = catMaybes . map calc $ [1..mx]
    mx = ceiling . sqrt $ fromIntegral n
    calc m 
      | x == 0 = Nothing
      | (n - m) `mod` m == 0 && n `mod` x == n `div` x = Just x
      | otherwise = Nothing
      where x = (n - m) `div` m

Measured memory_bytes: 1020
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int X, cnt = 1;
  while (cin >> X){
    if (X == 0) return 0;
    printf("Case %d: %d\n", cnt, X);
    cnt++;
  }

  return 0;
}



Measured memory_bytes: 3116
import java.util.*;

class Main {

    static int H;
    static int W;
    static int K;
    static char[][] A;
    static int[][] dist;
    static int min;
    static ArrayList<int[]> list;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        K = sc.nextInt();
        A = new char[H][W];
        dist = new int[H][W];
        for (int i=0;i<H;i++) {
            for (int j=0;j<W;j++) {
                dist[i][j] = 19191919;
            }
        }
        min = 19191919;
        list = new ArrayList<int[]>();
        int[] add_1 = {1, 0};int[] add_2 = {-1, 0};int[] add_3 = {0, 1};int[] add_4 = {0, -1};
        list.add(add_1);list.add(add_2);list.add(add_3);list.add(add_4);
        int sy = -1;
        int sx = -1;
        for (int i=0;i<H;i++) {
            String S = sc.next();
            for (int j=0;j<W;j++) {
                A[i][j] = S.charAt(j);
                if (A[i][j]=='S') {
                    A[i][j] = '.';
                    sy = i;
                    sx = j;
                }
            }
        }
        int[] first = {sy, sx, 0};
        ArrayDeque<int[]> q = new ArrayDeque<int[]>();
        q.add(first);
        while (!q.isEmpty()) {
            int[] rem = q.poll();
            int y = rem[0];
            int x = rem[1];
            int k = rem[2];
            if (dist[y][x]<=k) continue;
            dist[y][x] = k;
            min = Math.min(min, y);
            min = Math.min(min, H-1-y);
            min = Math.min(min, x);
            min = Math.min(min, W-1-x);

            if (k==K) continue;

            for (int[] arr : list) {
                if (0<=y+arr[0] && y+arr[0]<H && 0<=x+arr[1] && x+arr[1]<W && A[y+arr[0]][x+arr[1]]=='.') {
                    int[] add = {y+arr[0], x+arr[1], k+1};
                    q.add(add);
                }
            }

        }

        System.out.println((min+K-1)/K+1);
    }
}

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

int main() {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# coding:utf-8

N, K = (int(x) for x in input().split())
h = [int(x) for x in input().split()]

inf = 100000000000000
dp = [inf for x in range(N)]

dp[0] = 0
for i in range(0, N):
	for j in range(1, K+1):
		if i + j < N:
			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])

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

#define N_MAX 200002

using namespace std;

int n;

string s;

int dp[N_MAX][26];
int mic[N_MAX];

int step[N_MAX][26];

int main()
{
    cin >> s;
    n = s.size();
    for(int j = 0; j < 26; j++)
        dp[n][j] = 1;
    mic[n] = 0;
    for(int i = n - 1; i >= 0; i--)
    {
        mic[i] = -1;
        for(int j = 0; j < 26; j++)
        {
            if(s[i] - 'a' == j)
            {
                dp[i][j] = dp[i + 1][mic[i + 1]] + 1;
                step[i][j] = mic[i + 1];
            }
            else
            {
                dp[i][j] = dp[i + 1][j];
                step[i][j] = j;
            }
            if(mic[i] == -1 || dp[i][j] < dp[i][mic[i]])
                mic[i] = j;
        }
    }
    for(int i = 0, j = mic[0]; i <= n; i++)
    {
        if(i == n || s[i] - 'a' == j)
            cout << char(j + 'a');
        j = step[i][j];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 41988
#include <stdio.h>

int main(void)
{

    int w, h, x, y, r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if (w-r >= x && r <= x && h - r >= y && r <= y)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

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

    string s;
    cin>>s;
    int ans=0;
    int n=s.size();
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    cin>>s;
    int cnt=0;
    int ans=0;
    for(int i=0;i<s.size();i++){
        cnt=0;
        if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
           
            for(int j=i;j<s.size();j++){
            if(s[j]=='A' || s[j]=='T' || s[j]=='G' || s[j]=='C'){
                cnt++;
                ans=max(ans,cnt);
            }
            else {
                ans=max(ans,cnt);
                break;
            }
        }
        }
    }
        cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 2e5 + 10;

int a[N];

int main() {
	int n, k;
	cin >> n >> k;
	
	for (int i = 1; i <= n; ++i) cin >> a[i];
	
	int p = 1;
	for (int i = k + 1; i <= n; ++i, ++p) {
		if (a[i] > a[p]) {
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
	
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 1e3+5;

int main()
{
	init();
	int n, ans = 0, n1, n2, count = 0;
	cin >> n;
	cin >> n1;
	lpi(i, 1, n){
		cin >> n2;
		if(n2 <= n1)
			++count;
		else{
			ans = max(ans, count);
			count = 0;
		}
		n1 = n2;
	}
	ans = max(ans, count);
	cout << ans;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> h;
  for (int i = 0; i < n; i++) {
	int tmp;
	cin >> tmp;
	h.push_back(tmp);
  }
  
  int i = 0;
  int res = 0;
  while (i < n) {
	if (h[i] == 0) {
	  i++;
	  continue;
	}
	int min = h[i];
	int j;
	for (j = i + 1; j < n; j++) {
	  if (h[j] == 0)
		break;
	  min = std::min(min, h[j]);
	}
	for (int k = 0; k < j; k++)
	  h[k] -= min;
	res += min;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double res = 0;

		double kaku = Math.abs(H * 30 + (double) M / 2 - M * 6);
		double rad = Math.toRadians(kaku);
		res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(rad));
		System.out.println(res);
	}
}

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

using namespace std;

int main() {
    int N , L;

    cin >> N >> L;

    int R = L + N - 1;

    int eat;
    if (R <= 0)
        eat = R;
    else if (L >= 0)
        eat = L;
    else
        eat = 0;
    
    int ans = (L + R) * (R - L + 1)/2 - eat;
    cout << ans << "\n";
}

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

using namespace std;

int a,b;

void search(int t)
{
	int r;
	
	if(r==0)
		return;
	
	if(t==1)
	{
		r=a%b;
		a=r;
		search(t=0);
	}
	else
	{
		r=b%a;
		b=r;
		search(t=1);
	}
	
}

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

int main()
{
	int a2,b2;
	
	for(;cin >> a;)
	{
		cin >> b;
/*		a2=a;
		b2=b;
		
		a=max(a2,b2);
		b=min(a2,b2);
		
		search(1);
		
		a=max(a,b);
		
		cout << a << " " << a2*(b2/a) << endl;
*/
		int gcd = GCD( a, b );
		cout << gcd << " " << a/gcd * b << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,x;cin >> n >> x;
  vector<int> l(n);rep(i,n) cin >> l[i];
  int res=1;
  int d=0;
  rep(i,n){
    d += l[i];
    if(d<=x) res++;
    else break;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
s =list(map(int, list(input())))
INF = 1001001001001
dp1=[INF]*1001001
dp2=[INF]*1001001
n=len(s)
dp1[n-1]=s[n-1]
dp2[n-1]=10-s[n-1]
for i in reversed(range(n-1)):
    if s[i]<9:
        dp1[i] = min(dp1[i+1]+s[i],dp2[i+1]+s[i]+1)
    else:
        dp1[i] = dp1[i+1]+s[i]
    dp2[i] = min(dp1[i+1]+10-s[i], dp2[i+1]+10-s[i]-1)

dp2[0]+=1
print(min(dp1[0], dp2[0]))



Measured memory_bytes: 141628
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;



int main(){
	vector<int> weight;
	for(int i = 0; i < 10; i++){
		weight.push_back(pow((float)2, i));
	}

	int w;

	while(cin >> w){
		int use[10] = {0};
		for(int i = 9; i >= 0; i--){
			if(w >= weight[i]){
				w -= weight[i];
				use[i] = 1;
			}
		}

		bool f = true;
		for(int i = 0; i < 10; i++){
			if(use[i]){
				if(!f){
					cout << ' ';
				}
				cout << weight[i];
				f = false;
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
import numpy as np


def nearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]


n = int(input())
a = []
a = [int(i) for i in input().split()]

ans1 = max(a)  # 出力1
if n == 2:
    ans2 = min(a)
else:
    ans2 = nearestValue(a, ans1/2)

print('{0} {1}'.format(ans1, ans2))


Measured memory_bytes: 25368
#include <iostream>
#include <vector>
#include <string>
#include <stack>

void ParseStringToCharArray(const std::string s, std::vector<std::string>& v){
    std::string space_str = " ";
    std::size_t space = s.find(space_str);
    if(space == std::string::npos){
        v.push_back(s);
    }
    else {
        std::string value = s.substr(0, space);
        v.push_back(value);
        ParseStringToCharArray(s.substr(space+1), v);
    }
}

int main() {
    std::string s;
    std::vector<std::string> v;
    std::getline(std::cin, s);
    ParseStringToCharArray(s, v);
    std::stack<int> st;
    int i = 0;

    while(i < v.size()){
        if(v[i] == "+"){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a+b);
        }
        else if(v[i] == "-"){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(b-a);
        }
        else if(v[i] == "*"){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a*b);
        }
        else {
            int num = std::stoi(v[i]);
            st.push(num);
        }
        ++i;
    }

    std::cout << st.top() << std::endl;
    
}


Measured memory_bytes: 3224
#include<stdio.h>
#include<math.h>

int main()
{
	int n, s[1000], sum = 0;
	double m = 0, a2 = 0;
	while (1)
	{
		sum = a2 = 0;
		scanf("%d", &n);
		if (!n)
			break;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", s + i);
			sum += s[i];
		}
		m = (double)sum / n;
		for (int i = 0; i < n; i++)
		{
			a2 += pow(s[i] - m, 2);
		}
		printf("%lf\n", sqrt(a2 / n));
	}

	return 0;
}


Measured memory_bytes: 2036
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  int ans;
  if(a>=b && a>=c) {
    if((b+c)%2==0) ans=(2*a-b-c)/2;
    else ans=(2*a+3-b-c)/2;
  }
  else if(b>=c && b>=a) {
    if((c+a)%2==0) ans=(2*b-c-a)/2;
    else ans=(2*b+3-c-a)/2;  
  }
  else if(c>=a && c>=b) {
    if((a+b)%2==0) ans=(2*c-a-b)/2;
    else ans=(2*c+3-a-b)/2;   
  }
  
  cout << ans << endl; 
}


Measured memory_bytes: 256
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
c = tuple(map(int, input().split()))

ans = b[a[0]-1]
for i in range(1, n):
  ans += b[a[i]-1]
  if a[i] == a[i-1] + 1:
    ans += c[a[i-1]-1]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(13);
  rep(i,0,N){
    int X; cin>>X;
    A[X]++;
  }
  bool flag=1;
  if(A[0]>=1) flag=0;
  rep(i,1,12){
    if(A[i]>=3) flag=0;
  }
  if(A[12]>=2) flag=0;
  int ans=0;
  if(flag){
    rep(i,0,(1ll<<11)){
      bitset<11> B(i);
      vector<bool> F(24);
      F[0]=1;
      if(A[12]==1) F[12]=1;
      rep(j,0,11){
        if(A[j+1]==2){
          F[j+1]=1;
          F[23-j]=1;
        }
        else if(A[j+1]==1){
          if(B.test(j)) F[j+1]=1;
          else F[23-j]=1;
        }
      }
      int sum=12;
      rep(j,0,24){
        REP(k,j+1,24){
          if(F[j]&&F[k]){
            sum=min({sum,k-j,24-k+j});
          }
        }
      }
      ans=max(ans,sum);
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
program name
    implicit none
    integer(8),allocatable:: a(:)
    character(500000):: s
    integer(4):: n,i

    read*, s(:)
    n=len_trim(s)+1
    allocate(a(n))
    a(:) = 0
    do i=1,n-1
        if (s(i:i) == '<') a(i+1) = a(i)+1
    end do

    do i=n-1,1,-1
        if (s(i:i) == '>' .and. a(i) <= a(i+1)) a(i) = a(i+1)+1
    end do
    print*, sum(a)
end program name

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

using namespace std;

int main() {
  long long A, B, C;
  scanf("%lld %lld %lld", &A, &B, &C);
/*
  int try1 = ceil((double) A/2)*B*C - floor((double) A/2)*B*C;
  int try2 = ceil((double) B/2)*A*C - floor((double) B/2)*A*C;
  int try3 = ceil((double) C/2)*A*B - floor((double) C/2)*A*B;
  printf("%d\n", min(min(try1, try2), try3));
*/

  int ans;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
	ans = 0;
  } else {
	ans = min(min(A*B, B*C), A*C);	
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
m, d = gets.chomp.split.map(&:to_i)
cnt = 0
(4..m).each do |i|
  (2..[Math::sqrt(i).to_i, 9].min).each do |j|
    next if i % j != 0
    k = i / j
    next if k > 9 || k < 2
    cnt += 1 if 10 * j + k <= d
    cnt += 1 if 10 * k + j <= d && j != k
  end
end
puts cnt

Measured memory_bytes: 1788
#!/usr/local/gnu/bin/bash
function isP(){
    s=$1
    r=`echo $s | rev`
    [ $s == $r ] && echo 1 || echo 0
}

read s
n=${#s}
((`isP $s`&&`isP ${s:0:(n-1)/2}`&&`isP ${s:(n+1)/2}`)) && echo Yes || echo No


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

int main() {
 int  N,T;
 int V[50] = {0};
 int C[50] = {0};
 int co = 0;

 cin >> N;

for(int i = 0; i < N;i++){
  cin >> V[i];
}

for(int i = 0; i < N;i++){
  cin >> C[i];
}

for(int i = 0; i < N;i++){
  if(V[i] > C[i]){
    co = co + V[i] - C[i];
  }
}

cout << co << endl;
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;
ll fexp(ll a, ll b, ll p){ll ans = 1;while(b){if(b&1) ans = ans*a%p; b/=2;a=a*a%p;}return ans;}
const ll mod=1000000007;
const int N=1e5+5;
int main()
{
	fast;ll n;cin>>n;
	map<ll,ll> mp;ll a[n];for(ll i=0;i<n;i++){cin>>a[i];mp[a[i]]++;}
	sort(a,a+n);map<ll,ll> mp1;ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(mp[a[i]]==1&& mp1[a[i]]==0)ans++;
		for(ll j=a[i];j<=a[n-1];j+=a[i])mp1[j]++;
	}
	cout<<ans;

}

Measured memory_bytes: 76904
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void){
    int i,n,x[100],y[100];
    double p_1=0,p_2=0,p_3=0,p_0=0;
 
    scanf("%d",&n);
     
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
    for(i=0;i<n;i++)
        scanf("%d",&y[i]);
     
    for(i=0;i<n;i++){
         
    //p=1
        p_1 += abs(x[i]-y[i]);
     
    //p=2
        p_2 += pow(fabs((double)x[i]-y[i]),2.0);
     
    //p=3
        p_3 += pow(fabs((double)x[i]-y[i]),3.0);
     
    //p=endless
        if(p_0 < abs(x[i]-y[i])) p_0 = abs(x[i]-y[i]);
         
    }
     
    printf("%lf\n%lf\n%lf\n%lf\n", p_1, pow(p_2,1.0/2), pow(p_3,1.0/3), p_0);
     
     
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

struct res{
    string s;
    ll val;
    ll num;
    bool operator<(const res a)const{
        if(s<a.s)return true;
        if(s==a.s&&val>a.val)return true;
        return false;
    }
};

int main(){fastio
    ll n;cin>>n;
    res a[n];
    rep(i,0,n-1){
        cin>>a[i].s>>a[i].val;
        a[i].num=i;
    }
    sort(a,a+n);
    rep(i,0,n-1){
        cout<<a[i].num+1<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

def main():
    N,M = cin.mapInt()
    S = [[] for i in range(N)] 
    for i in range(M):
        s = cin.mapInt()
        k = s[0]
        for j in range(k):
            a = s[j + 1] - 1
            S[a].append(i)
    ans = 0
    P = cin.mapInt()
    for i in range(1 << N):
        tmp = [0] * M
        isOK = True
        for j in range(N):
            if i >> j & 1:
                for k in S[j]:
                    tmp[k] += 1
        for j in range(M):
            if P[j] % 2 != tmp[j] % 2:
                isOK = False
        if isOK:
            ans += 1
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 42480
n = int(input())
a = list(map(int,input().split()))

import math

s = []
m = a[0]

for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(m//(i+1))
s.sort()
s = reversed(s)

for i in s:
    for j in range(len(a)):
        if a[j]%i>0:
            break
    else:
        print(i)
        break

Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true){
			int money = 1000 - stdIn.nextInt();
			if(money==1000){
				return;
			}
			
			int coin = 0;
			if(money>=500){
				money-=500;
				coin++;
			}
			if(money>=100){
				int tmp = money/100;
				money-=tmp*100;
				coin+=tmp;
			}
			if(money>=50){
				money-=50;
				coin++;
			}
			if(money>=10){
				int tmp = money/10;
				money-=tmp*10;
				coin+=tmp;
			}
			if(money>=5){
				money-=5;
				coin++;
			}
			coin+=money;
			System.out.println(coin);
		}
	}
}

Measured memory_bytes: 12000
ret = []
while True:
    m, f, r = map(int, raw_input().split())
    if (m,f,r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        ret += 'F'
    elif 80 <= m + f:
        ret += ['A']
    elif 65 <= m + f < 80:
        ret += ['B']
    elif 50 <= m + f < 65:
        ret += ['C']
    elif 30 <= m + f < 50 and 50 <= r:
        ret += ['C']
    elif 30 <= m + f < 50 and r < 50:
        ret += ['D']
    elif m + f < 30:
        ret += ['F']

for i in ret:
    print i

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

#define endl "\n"
#define int long long
#define vec(x) vector<x>
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);
int power(int a,int b,int m=MOD)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}
int dir[]={-1, 0, 1, 0, -1};
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

const int N = 1e5+1;
vi h(N);
int dp[N];
int n,k;

int helper(int i)
{
	if(i==0)
	return 0;
	if(dp[i]!=-1)
	return dp[i];
	int ans=INF;
	for(int j=i-1;j>=i-k and j>=0;j--)
	ans=min(ans,abs(h[i]-h[j])+helper(j));
	return dp[i]=ans;
}

void solve()
{
	int i;
	cin>>n>>k;
	for(i=0;i<n;i++)
	cin>>h[i];
	mem(dp,-1);
	cout<<helper(n-1)<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	t=1;
	//cin>>t;
	while(t--)
		solve();
}

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

int main(){
    int N;
    cin >> N;
    __int128_t M = 1, INF = int64_t(1e18) + 1;
    while(N--){
        int64_t a;
        cin >> a;
        M = min(M*a, INF);
    }
    if(M == INF) M = -1;
    cout << int64_t(M) << endl;
    return 0;
}


Measured memory_bytes: 3636
n, m = map(int, input().split())
store = []
for _ in range(m):
    a, b = map(int, input().split())
    store.append([a, b])
store.sort(key = lambda x:x[0])
count = 0
ans = 0
while count < m:
    index = 1
    t = store[0][1]
    while index < len(store) and store[index][0] < t:
        t = min(t, store[index][1])
        index += 1
    count += index
    store = store[index:]
    ans += 1
print(ans)

Measured memory_bytes: 119000
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define N 55
using namespace std;
typedef long long ll;
int mod;
struct matrix
{
    int r,c;
    int data[N][N];
    matrix(){}
    matrix(int _r,int _c):r(_r),c(_c){}
    friend matrix operator * (const matrix A,const matrix B)
    {
        matrix res;
        res.r=A.r;res.c=B.c;
        memset(res.data,0,sizeof res.data);
        for(int i=0;i<A.r;i++)
        {
            for(int j=0;j<B.c;j++)
            {
                for(int k=0;k<A.c;k++)
                {
                    if(A.data[i][k] && B.data[k][j]){
                        res.data[i][j]+=A.data[i][k]*B.data[k][j];
                        res.data[i][j]%=mod;
                    }
                }
            }
        }
        return res;
    }
    friend matrix operator + (const matrix A,const matrix B)
    {
        matrix res;
        res.r=A.r;res.c=A.c;
        memset(res.data,0,sizeof res.data);
        for(int i=0;i<A.r;i++)
        {
            for(int j=0;j<A.c;j++)
            {
                res.data[i][j]=A.data[i][j]+B.data[i][j];
                res.data[i][j]%=mod;
            }
        }
        return res;
    }
    friend matrix operator - (const matrix A,const matrix B)
    {
        matrix res;
        res.r=A.r;res.c=A.c;
        memset(res.data,0,sizeof res.data);
        for(int i=0;i<A.r;i++)
        {
            for(int j=0;j<A.c;j++)
            {
                res.data[i][j]=A.data[i][j]-B.data[i][j];
                res.data[i][j]=(res.data[i][j]%mod+mod)%mod;
            }
        }
        return res;
    }
    friend matrix operator ^ (matrix A,int n)
    {
        matrix res;
        res.r=A.r;res.c=A.c;
        memset(res.data,0,sizeof res.data);
        for(int i=0;i<A.r;i++)res.data[i][i]=1;

        while(n)
        {
            if(n&1)res=res*A;
            A=A*A;
            n>>=1;
        }
        return res;
    }
    void print()
    {
        for(int i=0;i<r;i++)
        {
            for(int j=0;j<c;j++)
                printf("%d ",data[i][j]);
            puts("");
        }
    }
}E,zero;

int main()
{
    int n,a,b,c,t;
    while(scanf("%d%d%d%d%d%d",&n,&mod,&a,&b,&c,&t)!=EOF)
    {
        if(n==0 && mod==0 && a==0 && b==0 && c==0 && t==0)break;

        matrix origin=matrix(n,n);
        memset(origin.data,0,sizeof origin.data);

        matrix A=matrix(n,n);

        for(int i=0;i<n;i++)
            scanf("%d",&A.data[i][0]);

        origin.data[0][0]=b,origin.data[0][1]=c;
        for(int i=1;i<n-1;i++)
        {
            origin.data[i][i-1]=a;
            origin.data[i][i]=b;
            origin.data[i][i+1]=c;
        }
        origin.data[n-1][n-2]=a;
        origin.data[n-1][n-1]=b;

        origin=origin^t;
        origin=origin*A;

        for(int i=0;i<n;i++)
        {
            if(i==0)
            printf("%d",origin.data[i][0]);
            else printf(" %d",origin.data[i][0]);
        }
        puts("");
    }
    return 0;
}

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

using namespace std;

const int MX = 5005, md = 1000000007;

void calc(int h[MX], int b, int a, int n) {
	static int dp[MX][MX], add[MX][MX], zero[MX];
	
	memset(dp, 0, sizeof dp);
	memset(add, 0, sizeof add);
	memset(zero, 0, sizeof zero);
	
	for (int i = 1; i < b; i++) {
		dp[i][0] = 1;
	}
	
	for (int i = 0; i <= n; i++) {
		dp[i][0] += zero[i];
		
		zero[i + 1] += zero[i];
		zero[i + 1] %= md;
		
		for (int j = 0; j < a; j++) {
			dp[i][j] += add[i][j];
			dp[i][j] %= md;
			
			if (j + 1 == a) continue;
			
			add[i + 1][j + 1] += add[i][j];
			add[i + 1][j + 1] %= md;
			
			if (i + 1 + b <= n) {
				add[i + 1 + b][j + 1 + b] += dp[i][j];
				add[i + 1 + b][j + 1 + b] %= md;
			}
			
			dp[i + 1][j + 1] += dp[i][j];
			dp[i + 1][j + 1] %= md;
			
			zero[i + 2] += dp[i][j];
			zero[i + 2] %= md;
			
			if (i + 1 + b <= n) {
				zero[i + 1 + b] += md - dp[i][j];
				zero[i + 1 + b] %= md;
			}
		}
	}
	
	for (int i = 0; i <= n; i++) {
		h[i] = 0;
		for (int j = 0; j < a; j++) {
			h[i] += dp[i][j];
			h[i] %= md;
		}
	}
}

int f[MX], g[MX], h[MX];

int main() {
	int n, a, b;
	ignore = scanf("%d %d %d", &n, &a, &b);
	
	if (a < b) swap(a, b);
	
	f[0] = 1;
	for (int i = b; i <= n; i++) f[i] = 1;
	
	for (int i = 0; i < n; i++) {
		f[i + 1] += f[i];
		f[i + 1] %= md;
		
		for (int j = b; i + 1 + j <= n; j++) {
			f[i + 1 + j] += f[i];
			f[i + 1 + j] %= md;
		}
	}
	
	calc(g, b, a, n);
	calc(h, b, n + 1, n);
	
	int ans = f[n];
	
	// prefix
	for (int len = a - 1; len < n; len++) {
		ans = (ans + f[len] * 1LL * g[n - 1 - len]) % md;
	}
	
	// suffix
	for (int len = a - 1; len < n; len++) {
		ans = (ans + f[len] * 1LL * h[n - 1 - len]) % md;
	}
	
	// middle
	for (int len = a - 2; len + 2 <= n; len++)
		for (int L = 0; L + len + 2 <= n; L++) {
			ans = (ans + f[len] * 1LL * h[L] % md * g[n - L - len - 2]) % md;
		}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 199612
# Useful data structures

# For sys.std*, sys.argv etc...
import sys

# For cases when input tokens are spread unevenly over many lines.
# This provides methods for reading tokens of various types.
class BufferedTokenizer:
    pass

def read_ints():
    return [int(token) for token in input().split()]

def read_tokens():
    return input().split()

def main():
    read_ints()
    approved = all(any(n % d == r for (d, r) in [(2, 1), (3, 0), (5, 0)])
                    for n in read_ints())
    print("APPROVED" if approved else "DENIED")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ACB078A
{
    class Program
    {
        static void Main(string[] args)
        {
            char X, Y;
            int A, B, C, D, E, F;
            var word = Console.ReadLine().Split(' ');
            X = word[0][0];
            Y = word[1][0];
            A = 10;
            B = 11;
            C = 12;
            D = 13;
            E = 14;
            F = 15;
            if (X>Y)
            {
                Console.WriteLine(">");
            }
            else if (X < Y)
            {
                Console.WriteLine("<");
            }
            else if (X ==Y)
            {
                Console.WriteLine("=");
            }
            Console.ReadKey();
        }
    }
}


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

int n, m;

int min(int a, int b){
    return a > b ? b : a;
}

int main(void){
   
    cin >> n >> m;
    int C[m+1];
    int A[m+1][n+1];
    int i, j;
    
    for(i = 1; i <= m; i++){
        cin >> C[i];
    }
    
    for(i = 0; i <= m; i++){
        for(j = 0; j <= n; j++){
            if(j==0){
                A[i][j] = 0;
            } else{
                A[i][j] = 1 <<21;
            }
        }
    }
    
    
    for(i = 1; i <= m; i++){
        for(j = 1; j <= n; j++){
            if(j-C[i] >= 0){
                A[i][j] = min(A[i-1][j], A[i][j-C[i]] + 1);
            } else{
                A[i][j] = A[i-1][j];
            }
        }
    }
    
    cout << A[m][n] << endl;

    return 0;
}



Measured memory_bytes: 7180
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

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

using namespace std;


int main(){
	int K,X;
	cin >> K >> X;
	for(int i = X-K+1;i<X+K;i++)cout <<i<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int n = s.length();
    bool f = false;
    REP(i,n) REP(j,n+1){
        string t = s.substr(0, i);
        t = t+s.substr(j);
        if(t == "keyence") f = true;
    }
    if(f) cout << "YES" << std::endl;
    else cout << "NO" << std::endl;
    return 0;
}

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

using namespace std;
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	int k; cin >> k;
	cout << a[k-1];
	return 0;
}


Measured memory_bytes: 3572
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;
int n;
vector<pair<int, int> > xy;
double ans = 0;
long long num = 0;
void solve(int now, int visited, int prev, double sum) {
  // cout << "dump:" << now << "," << visited << "," << prev << "," << sum <<
  // endl;
  if (now == n) {
    ans += sum;
    num++;
    return;
  }
  for (int i = 0; i < n; i++) {
    if ((visited & (1 << i)) != 0) {
      continue;
    }

    solve(now + 1, (visited | 1 << i), i,
          sum + sqrt((xy[i].first - xy[prev].first) *
                         (xy[i].first - xy[prev].first) +
                     (xy[i].second - xy[prev].second) *
                         (xy[i].second - xy[prev].second)));
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    xy.push_back(make_pair(x, y));
  }
  for (int i = 0; i < n; i++) {
    solve(1, 1 << i, i, 0);
  }
  // cout << ans << "," << num << endl;
  printf("%.16f\n", ((double)ans / num));
  return 0;
}

Measured memory_bytes: 256
#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;
int a[125];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  int mincost = 830252521;
  REP(i,201){
    int x = i-100;
    int cost = 0;
    REP(j,n){
      cost += (a[j]-x)*(a[j]-x);
    }
    CHMIN(mincost,cost);
  }
  printf("%d\n",mincost);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    ll n;
    cin>>n;
    ll ans =0;
    for(ll i= 2; i<= n-1; i++)
    {
        ll k = (n-1)/i;
        // cout<<k<<" ";
        ans += k;
    }
    ans += (n-2) + 1;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3620
#include <cstdio>

int alp[26] = {0};

char s[101];

int main(){

  scanf("%s", s);

  int i = 0;

  while(s[i] != 0){
    int num = s[i] - 'a';
    alp[num]++;
    i++;
  }
  
  bool can = true;

  for(int i = 0; i < 26; i++){
    if(alp[i] % 2){
      can = false;
      break;
    }
  }

  printf("%s", can ? "Yes" : "No");

  return 0;

}


Measured memory_bytes: 128
import numpy as np
import collections
from sys import stdin


def get_result(data):
    N, X = data[0][0], data[1:][0]
    X = np.array(X)
    max_X = max(X)
    tmp = np.zeros(max_X + 1)
    for i in range(max_X + 1):
        tmp[i] = np.sum((X - i) ** 2)
    return int(min(tmp))

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 12432
#include <iostream>

int main()
{
    int a, b, N;
    std::cin >> a >> b >> N;
    bool dup = 0;
    for (int i = 0; i < N; i++) {
        int s, f;
        std::cin >> s >> f;
        for (int j = s; j < f; j++) {
            if (a <= j && j < b) {
                dup = 1;
            }
        }
    }
    std::cout << dup << std::endl;
    return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>                                                                                                                                                                                                                                                                                                                                                                                                                   [3/34]
#include <stdlib.h>
#include <errno.h>

static int *
read_arr(FILE *f, int size) {
  int *arr;
  int *tmp_arr;
  int n;

  arr = (int *) malloc(sizeof(int) * size);
  if (arr == NULL) return NULL;

  tmp_arr = arr;
  while (1) {
    n = fscanf(f, "%d", tmp_arr++);
    if (errno != 0) perror("fscanf");
    if (n == EOF) break;
  }

  return arr;
}

static void
print_arr(int *arr, int size) {
  int i;

  for (i = 0; i < size; ++i) {
    if (i > 0) fprintf(stdout, " ");
    fprintf(stdout, "%d", arr[i]);
  }
  fprintf(stdout, "\n");
}

// Bubble sort
static int
sort(int *a, int n) {
  int cnt, flag, i, v;

  cnt = 0;
  flag = 1;
  while (flag) {
    flag = 0;
    for (i = n - 1; i > 0; --i) {
      if (a[i - 1] > a[i]) {
        v = a[i];
        a[i] = a[i - 1];
        a[i - 1] = v;
        flag = 1;
        ++cnt;
      }
    }
  }

  return cnt;
}

int
main(int argc, char **argv) {
  int *arr;
  int n, ret, cnt;

  ret = fscanf(stdin, "%d", &n);
  if (errno != 0) perror("fscanf");
  if (ret < 1) exit(1);

  arr = read_arr(stdin, n);
  if (arr == NULL) exit(1);

  cnt = sort(arr, n);
  print_arr(arr, n);
  fprintf(stdout, "%d\n", cnt);

  free(arr);
  arr = NULL;
  exit(0);
}


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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int f(int x, int y, int z) {
    return (x * x + y * y + z * z + x * y + y * z + z * x);
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n; cin>>n;
    FOR(i, 1, n + 1) {
        int res = 0;
        FOR(x, 1, sqrt(i) + 1) {
            FOR(y, 1, sqrt(i) + 1) {
                if(f(x, y, 1) > i) break;
                FOR(z, 1, sqrt(i) + 1) {
                    int fval = f(x, y, z);
                    if(fval == i) {
                        res++;
                    } else if(fval > i) break;
                }
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=998244353;

int main()
{
    string str;
    cin>>str;
    ll a=0;
    for(int i=0;i<str.size();i++)
    {
        a+=str[i]-'0';
    }
    if(a%9)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3720