akhauriyash/Code-Regression huggingface dataset:
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var s = o.r(h,1);
  var x = xArray(0,h,w);
  var y = xArray(0,h,w);
  for(var i = 0; i < h; i++){
    var u = 0;
    for(var j = 0; j < w; j++){
      if(s[i][j] === "#"){
        for(var k = 1; k <= u; k++){
          x[i][j-k] = u;
        }
        u = 0;
      }else{
        u++;
      }
    }
    for(var k = 1; k <= u; k++){
      x[i][w-k] = u;
    }
  }
  for(var j = 0; j < w; j++){
    var u = 0;
    for(var i = 0; i < h; i++){
      if(s[i][j] === "#"){
        for(var k = 1; k <= u; k++){
          y[i-k][j] = u;
        }
        u = 0;
      }else{
        u++;
      }
    }
    for(var k = 1; k <= u; k++){
      y[h-k][j] = u;
    }
  }
  var ans = 0;
  for(var i = 0; i < h; i++){
    for(var j = 0; j < w; j++){
      var t = x[i][j] + y[i][j];
      if(ans < t)ans = t;
    }
  }
  return ans-1;
}

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

namespace AtCoder.Contest.E
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int n = cin.NextInt();
			var a = new int[n];
			var b = new int[n];
            for (int i = 0; i < n; i++)
            {
				a[i] = cin.NextInt();
				b[i] = cin.NextInt();
            }
			Array.Sort(a);
			Array.Sort(b);
			long ans = 0;
            if (n % 2 == 0)
            {
				double midmin = (double)(a[(n + 1) / 2 - 1] + a[(n + 1) / 2]) / 2;
				double midmax = (double)(b[(n + 1) / 2 - 1] + b[(n + 1) / 2]) / 2;
                ans = (long)((midmax - midmin) * 2) + 1;

            }
            else
            {
				long midmin = a[n / 2];
				long midmax = b[n / 2];
				ans = midmax - midmin + 1;
            }
            Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 42172
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"
 
char getDif(char a,char b){
    if('R'!=a && 'R'!=b)return 'R';
    if('G'!=a && 'G'!=b)return 'G';
    return 'B';
}
 
ll getInd(char c){
    if(c=='R')return 0;
    if(c=='G')return 1;
    return 2;
}
 
void solve(){
    ll n;
    string s;
    cin>>n>>s;
    unordered_map<char,unordered_set<int>> m;
    for(int i=0;i<n;i++){
        m[s[i]].insert(i);
    }
    vector<vector<ll>> v(n,vector<ll>(3));
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<3;j++)v[i][j]+=v[i+1][j];
        v[i][getInd(s[i+1])]++;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]!=s[j]){
                char c=getDif(s[i],s[j]);
                int di=j-i;
                ans+=v[j][getInd(c)];
                if(m[c].count(j+di))ans--;
            }
        }
    }
    cout<<ans;
}
 
int main()
{
 
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

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

vector<vector<int>> V;
vector<int> Map;
int ans=0, inf=1<<30;

void dfs (int prev, int now, int cnt) {
  for (auto i: V[now]) {
    if(Map[i]!=inf) continue;
    else {
      Map[i]=cnt;
      dfs(now, i, cnt);
    }
  }
}

int main() {
  int N, M; cin >> N >> M;
  V = vector<vector<int>>(N, vector<int>(0));
  Map = vector<int>(N, inf);
  for (int i=0;i<M;i++) {
    int x, y, z; cin >> x >> y >> z;
    V[x-1].push_back(y-1);
    V[y-1].push_back(x-1);
  }
  
  ans=0;
  for(int i=0; i<N; i++) {
    if(Map[i]==inf) {Map[i]=ans;dfs(-1,i,ans);ans++;}
  }
  cout << ans << "\n";
}

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

#define MAX_N 10

int main() {
    int N;
    int p[MAX_N];
    unsigned long int res=0;
    std::cin >> N;
    for (int i=0; i<N; ++i) std::cin >> p[i];
    std::sort(p, p+N);
    for (int i=0; i<N-1; ++i) res += p[i];
    res += p[N-1]/2;
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
	int n, t;
	int a[200000];
	cin >> n >> t;
	a[0] = 0;
	for (int i=1; i<=n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	for (int i=1; i<=n; i++) {
		ans += min(t, a[i]-a[i-1]);
	}
	cout << ans + t;
	return 0;
}

Measured memory_bytes: 4392
# CODE FESTIVAL 2016 qual C C - 二人のアルピニスト / Two Alpinists
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
T = [0] + T + [T[-1]]
A = [A[0]] + A + [0]

K = [0 for k in range(N+2)]
L = [0 for k in range(N+2)]
for k in range(1,N+2):
    if T[k-1] != T[k]:
        K[k] = T[k]
for k in range(1,N+2):
    if A[N-k+2] != A[N-k+1]:
        L[N-k+1] = A[N-k+1]

MOD = 10**9 + 7
ans = 1
for k in range(1,N+1):
    if K[k] == L[k] == 0:
        ans *= min(A[k],T[k])
        ans %= MOD
    elif (K[k]>0 and A[k]<K[k]) or (L[k]>0 and T[k]<L[k]):
        print(0)
        exit(0)
print(ans)


Measured memory_bytes: 18752
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        scanner.close();
        int sum = a+b+c;
        if(sum>=22){
            System.out.println("bust");
        }
        else{
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <stdio.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];
int color[MAX];
int s_timer[MAX], b_timer[MAX], pass;

void dfs_search(int u) {
    int v;
    color[u] = GRAY;
    s_timer[u] = ++pass;
    for (v = 0; v < n; v++) {
        if (M[u][v] == 0) continue;
        if (color[v] == WHITE) {
            dfs_search(v);
        }
    }
    color[u] = BLACK;
    b_timer[u] = ++pass;
}

void dfs() {
    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
    }
    pass = 0;
    
    for (int j = 0; j < n; j++) {
        if (color[j] == WHITE) dfs_search(j);
    }
    
    for (int t = 0; t < n; t++) {
        printf("%d %d %d\n", t+1, s_timer[t], b_timer[t]);
    }
}

int main() {
    int u, k, v;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) M[i][j] = 0;
    }
    
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        if (k == 0) continue;
        for (int j = 0; j < k; j++) {
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
    
    return 0;
}



Measured memory_bytes: 3264
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll a[200010];

int main(void){
	          int i;

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

	      	  int N;
	      	  cin >> N;
	      	  for(i=1;i<=N;i++){
	      		  cin >> a[i];
	      		  a[i]+=a[i-1];
	      	  }

	      	  map<ll,ll> mp;
	      	  for(i=1;i<=N;i++){
	      		  mp[a[i]]++;
	      	  }

	      	  ll ans=0;
	      	  foreach(mp,itr){
	      		  ll c=(*itr).second;
	      		  if((*itr).first==0){
	      			  if(c==0) continue;
	      			  else ans+=c*(c+1)/2;
	      		  }else{
	      			  if(c<=1) continue;
	      			  else ans+=c*(c-1)/2;
	      		  }
	      	  }

	      	  cout <<ans << endl;

	          return 0;
}


Measured memory_bytes: 14336
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;


int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < W + 2; ++ i) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    for (int i = 0; i < W + 2; ++ i) {
        cout << "#";
    }
    cout << endl;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define getI(a) scanf("%d",&a)
int main(){
    char n[5];
    while(~scanf("%s",n)){
        F(i,0,3){
            if(n[i]=='9') n[i]='1';
            else if(n[i]=='1') n[i]='9';
        }
        printf("%s\n",n);
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int a[100000];
	int b[100000];
	int n;
	int s;
	int c;
	s = 0;
	c = 0;
	for (int i = 0; i < 100000; i++){
		a[i] = 0;
		b[i] = 0;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		b[a[i] - 1]++;
	}
	for (int i = 0; i < 100000; i++){
		if (b[i] > 1)s = s + b[i] - 1;
		if (b[i] > 0)c++;
	}
	if (s % 2 == 1)printf("%d\n", c - 1);
	else printf("%d\n", c);


	return 0;
}

Measured memory_bytes: 896
N, ex, ey = list(map(int, input().split()))
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
count = [0 for _ in range(N)]
for start_edge in range(1, N+1):
    for end_edge in range(start_edge, N+1):
        dist = min(abs(start_edge-ex)+abs(end_edge-ey)+1,abs(end_edge-start_edge))
        count[dist] += 1

for i in count[1:]:
    print(i)

Measured memory_bytes: 37492
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
	char str[2000];
	char *t, *s;
	int flag;
	
	scanf("%[^\n]s", str);
	scanf("%*c");
	
	flag = 0;
	s = str;
	while ((t = strtok(s, " .,")) != NULL){
		if (3 <= strlen(t) && strlen(t) <= 6){
			if (flag == 1) printf(" ");
			printf("%s", t);
			flag = 1;
		}
		s = NULL;
	}
	puts("");
	
	return (0);
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define VI vector<int>
#define VII vector<pair<int, int>>
#define PII pair<int, int>
#define MP make_pair
// #define log(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define log(fmt, ...)
// #define check(...) assert(##__VA_ARGS__)
#define check(...)

#define MODULO 998244353

int mul(int a, int b) {
    return ((ll)a * b) % MODULO;
}

int add(int a, int b) {
    return ((ll)a + b) % MODULO;
}

int n, a[3000];
int cache[3001][3001];

int count(int index, int s/*, VI as*/) {
    if (s < 0) {
        return 0;
    }
    if (s == 0 && index <= n) {
        // log("found at %d: ", index);
        // for (auto x : as) {
        //     log("%d ", x);
        // }
        // log("\n");
        return n - (index + 1) + 2;
    }
    if (index >= n) {
        return 0;
    }
    if (cache[index][s] >= 0) {
        return cache[index][s];
    }
    // as.push_back(a[index]);
    int ans1 = count(index + 1, s - a[index]/*, as*/);
    // as.pop_back();
    int ans2 = count(index + 1, s/*, as*/);
    return cache[index][s] = add(ans1, ans2);
}

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

    int s;
    cin >> n >> s;
    rep(i, 0, n) {
        cin >> a[i];
    }

    // log("add(1,100)=%d", add(1,100));

    // 先找x1,x2...xk，每找到一种，就给答案增加了(x1+1)*(n-(xk+1)+1)种。
    int ans = 0;
    rep(index, 0, n + 1) {
        fill_n(cache[index], s + 1, -1);
    }
    rep(left, 0, n) {
        // VI as;
        // as.push_back(a[left]);
        int ans1 = mul((left + 1), count(left + 1, s - a[left]/*, as*/));
        log("left+1=%d,ans1=%d\n", left + 1, ans1);
        ans = add(ans, ans1);
    }
    cout << ans;
}


Measured memory_bytes: 35584
import numpy as np
N = int(input())
A, B = map(int,input().split())
P = list(map(int,input().split()))
P_1 = [i for i in P if i <= A]
P_2 = [i for i in P if i >= A + 1 and i <= B]
P_3 = [i for i in P if i >= B + 1]
P_len = np.array([len(P_1),len(P_2),len(P_3)])
print(P_len.min())

Measured memory_bytes: 12452
import java.util.Scanner;
public class Main{

   public static void main(String[] args){
      new Main().solve();
   }

   public void solve(){
      // input data
      long sum = 0;
      long whiteCost = 0;
      long minWhiteCost = 0;
      long blackCost = 0;
      long minBlackCost = 0;
      long tmp = 0;
      Scanner scanner = new Scanner(System.in);
      int N = scanner.nextInt();
      int K = scanner.nextInt();
      long[] a = new long[N];
      for(int i=0; i<a.length; i++){
         a[i] = scanner.nextLong();
         if(a[i] > 0) sum += a[i];
      }
      for(int i=0; i<K; i++){
         if(a[i] > 0) whiteCost += a[i];
         else blackCost += Math.abs(a[i]);
         tmp += a[i];
      }
      minWhiteCost = whiteCost;
      minBlackCost = blackCost;
      if(N-K > 0){
         for(int i=K; i<N; i++){
            if(a[i] > 0) whiteCost += a[i];
            else blackCost += Math.abs(a[i]);
            if(a[i-K] > 0) whiteCost -= a[i-K];
            else blackCost -= Math.abs(a[i-K]);
            minWhiteCost = Math.min(minWhiteCost, whiteCost);
            minBlackCost = Math.min(minBlackCost, blackCost);
         }
         sum -= Math.min(minWhiteCost,minBlackCost);
      }else{
         if(tmp > 0) sum = tmp;
         else sum = 0;
      }
      System.out.println(sum);
   }

}


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

#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)

int main() {
	int n,x,o=0;
	cin>>n;
	rep (i,n) cin>>x, o+=x&1;
	if (o&1) log("NO");
	else log("YES");
}


Measured memory_bytes: 256
MOD = 2019

def solve(S):
    N = len(S)
    dp = [0 for _ in range(MOD)]
    tmp = 0
    ret = 0
    for i in range(N):
        m = (tmp + int(S[i]) * pow(10, N - i - 1, MOD)) % MOD
        ret += dp[m]
        dp[m] += 1
        tmp = m
    ret += dp[0]
    return ret

if __name__ == "__main__":
    S = input()
    print(solve(S))

Measured memory_bytes: 68520
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define N 5000000
#define INF 10000000

int h,i,A[N],size;

/*void maxHeapify(int);
void buildMaxHeap(void);
int heapExtractMax(int);
void maxHeapInsert(int,int);
void heapIncreseKey(int);*/

maxHeapInsert(int key){
 size=size+1;
  A[size]=-INF;
  heapIncreseKey(size,key);
}

int heapExtractMax(){
  int max;
  if(size<1){return;}
  max=A[1];
  A[1]=A[size];
  size-=1;
  maxHeapify(1);
  return max;
}


heapIncreseKey(int i,int key){
  int tmp;
   if (key<A[i]){return;}
  A[i]=key;
  while (i>1 && A[parent(i)] <A[i]){
	 tmp=A[i];
	 A[i]=A[parent(i)];
	 A[parent(i)]=tmp;
	 i=parent(i);
}
}

int parent(int i){

  return floor(i/2);

}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return 2*i+1;
}

maxHeapify(int i){
  int l,r,largest,tmp;

  l=left(i);
  r=right(i);

  if(l<=size && A[l]>A[i]) largest=l;

  else largest=i;

  if (r<=size && A[r]>A[largest]){
 
   largest=r;

  }

  if (largest!=i){

    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;

    maxHeapify(largest);
  }
}

  int main()
  {
    int x;
    char com[20];
    size=0;

    while(com[2]!='d'){

    scanf("%s",com);

    if(com[0]=='i'){
      scanf("%d",&x);
      maxHeapInsert(x);
    }

    else if(com[1]=='x'){printf("%d\n",heapExtractMax());}

    }

    return 0;
  }

Measured memory_bytes: 4692
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 100001
#define MAX_M 1000000001
#define INF   1000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll a[MAX_N];

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}  

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

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

    ll N, M;
    cin >> N >> M;

    for(ll i = 0; i < N; i++) cin >> a[i];

    ll lcm_a = 1;
    for(ll i = 0; i < N; i++) lcm_a = lcm(lcm_a, a[i]);

    for(ll i = 0; i < N; i++) {
      ll mul = (long long)(lcm_a / a[i]);
      if (mul % 2 == 0) {
	cout << 0 << endl;
	return 0;
      }
    }

    ll n = 0;
    ll num = lcm_a;
    
    while(num <= 2*M) {
      n++;
      num = lcm_a * (2*n + 1);
    }
    cout << n << endl;
   
    return 0;
}



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

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    long long int answer = 0;
    if (k < n) {
        answer = x * k + (n - k) * y;
    } else {
        answer = x * n;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long a[100010];
int main()
{
	long long n,sma=999999999,index=1;	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1 , a+1+n);
	for(;;)
	{
		for(int i=index+1;i<=n;i++)
			a[i]%=a[index];
		sort(a+index , a+1+n);
		for(int i=1;i<=n;i++)
			if(a[i]!=0){
				index=i;
				break;
			}
		/*for(int i=1;i<=n;i++)
			cout<<a[i]<<" ";
		cout<<endl;*/
		if(index==n){
			cout<<a[index];
			return 0;
		}
		sma=min(sma , a[index]);
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b;
  cin>>a>>b;
  if(a+b==15) co('+');
  else if(a*b==15) co('*');
  else co('x');
  return 0;
}

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


int main () {
    int N;
    cin >> N;
    int X[N];
    double sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        sum += X[i];
    }  

    int ave = round(sum / N);
    sum = 0;
    for (int i = 0; i < N; i++) {
        sum += pow(X[i] - ave, 2);
    }

    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void pk()
{
    string s;
    cin>>s;
    vector <ll> c;
    ll flag;
    ll cn=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        {
            cn++;
            flag=1;
        }
        if(s[i]=='S')
        {
            flag=0;
        }
        if(flag==0&&cn!=0)
        {
            c.push_back(cn);
            cn=0;
        }
    }
    c.push_back(cn);
    sort(c.begin(),c.end());
    ll n=c.size();
    cout<<c[n-1];
}
int main() 
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
	ll t=1;
    //cin>>t;
    while(t--)
    {
        pk();
    }
    return 0;
} 

Measured memory_bytes: 3652
a, b, c, d = map(int, input().split())

num_t = c // b
if c % b != 0:
    num_t += 1

num_a = a // d
if a % d != 0:
    num_a += 1


if num_t <= num_a:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9160
#include <stdlib.h>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  uint64_t N;
  cin >> N;
  vector<uint64_t> k;

  for (uint64_t i = 1; i * i < N; ++i) {
    if (N % i == 0) {
      k.push_back(i);
    }
  }

  uint64_t res = 0;
  uint64_t m;
  for (uint64_t i = 0; i < k.size(); ++i) {
    m = (N / k[i]) - 1;
    if (N / m == N % m) {
      res += m;
    }
  }

  if (N == 2) {
    cout << 0 << endl;
  } else {
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 256
A,B=input().split()
a=int(A)
b=int(B)
 
c=min(a,b)
 
def sosu(x):
    sum=0
    for i in range(x):
        if x%(i+1)==0:
            sum+=1
    if sum==2:
        return True
    else:
        return False

j=2  
kobai=[]
while j<=c:
  if a%j==0 and b%j==0 and sosu(j):
    c=int(c/j)
    kobai.append(j)
    #print(j)
    a=int(a/j)
    b=int(b/j)
    j=2
   
  else:
    j+=1
#print(kobai) 
answer=int(A)*int(B)
for i in range(len(kobai)):
  answer=int(answer/kobai[i])

print(answer)


Measured memory_bytes: 3064
/*There's a possibility*/
/*but stop sucking first*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;
 
int n,k,ar[105],dp[100005][2],mn;

int main()
{
    fast;
    int i,j;
    cin>>n>>k;
    f(i,0,n)
        cin>>ar[i];

    mn=*min_element(ar,ar+n);

    f(i,0,mn)
        dp[i][0]=1,dp[i][1]=0;

    f(i,mn,k+1)
    {
        dp[i][0]=1, dp[i][1]=0;
        f(j,0,n)
            if(i-ar[j]>=0)
            {
                dp[i][0]=min(dp[i][0],dp[i-ar[j]][1]);
                dp[i][1]=max(dp[i][1],dp[i-ar[j]][0]);
            }
    }

    (dp[k][1])?cout<<"First":cout<<"Second";
    // db(dp,0,k,0,2);
}

Measured memory_bytes: 4408
module WeightedDirectedGraph
: sig
  (* 配列を用いたダイクストラ法の実装
     単純な速さでは一番だが，インターフェースが不便 *)
  module ByArray : sig
    module Make :
      functor (Weight : sig
        type t
        val inf : t
        val zero : t
        val ( + ) : t -> t -> t
        val compare : t -> t -> int
      end) ->
      sig
        (* 頂点を[0, n)の自然数に限定したグラフに対してのダイクストラ法
           時間計算量O(V^2)なので，密なグラフなら速い *)
        val dijkstra_dense : 
        (* 頂点数n *)
        int ->
        (* 隣接リスト *)
        (int -> (int * Weight.t) list) ->
        (* 始点 *)
        int ->
        (* 始点から辿り着けなければinfを返す関数
           この関数を覚えておけば，呼び出しごとの途中までの計算結果がシェアされる *)
        (int -> Weight.t)
      end
  end
end
= struct
  module type Weight = sig
    type t
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end

  module ByArray = struct
    module Make (W : sig include Weight val inf : t end) = struct
      let dijkstra_dense n e s =
        let d = Array.make n W.inf in
        d.(s) <- W.zero;
        let rec dijkstra_dense_aux = function
          | [] -> ()
          | v :: vs ->
              let u, us = List.fold_left (fun (u, us) v ->
                if W.compare d.(u) d.(v) < 0
                then (u, v :: us)
                else (v, u :: us)) (v, []) vs in
              List.iter (fun (v, c) ->
                let open W in
                if 0 < W.compare d.(v) (d.(u) + c) then
                  d.(v) <- d.(u) + c) (e u);
              dijkstra_dense_aux us in
        dijkstra_dense_aux (Array.to_list @@ Array.init n @@ fun v -> v);
        Array.get d
      end
  end
end

module G = WeightedDirectedGraph.ByArray.Make (struct
  type t = float
  let inf = infinity
  let zero = 0.
  let ( + ) = ( +. )
  let compare = compare
end)

let () = Scanf.scanf "%d %d %d %d\n%d\n" @@ fun xs ys xt yt n ->
  let xyrs = Array.init (n + 2) @@ function
    | 0 -> (float_of_int xs, float_of_int ys, 0.)
    | 1 -> (float_of_int xt, float_of_int yt, 0.)
    | _ -> Scanf.scanf "%d %d %d\n" @@ fun x y r ->
        float_of_int x, float_of_int y, float_of_int r in
  Printf.printf "%.16f" @@
  G.dijkstra_dense (n + 2) (fun v ->
      let (x, y, r) = xyrs.(v) in
      List.mapi (fun u (x', y', r') ->
        (u, max 0. (sqrt ((x -. x') ** 2. +. (y -. y') ** 2.) -. r -. r'))) @@
      Array.to_list xyrs) 0 1


  


Measured memory_bytes: 5632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int n;
vector<string> num[1<<10];
string z[1 << 10];
bool numgreat(string a, string b) {
	if (a.length() != b.length()) {
		return a.length() < b.length();
	}
	return a < b;
}
bool great(int a, int b) {
	int now = 0;
	int s = z[a].length(), t = z[b].length();
	int ca = 0, cb = 0;
	while (true) {
		if (s == now && t == now)return true;
		else if (s == now)return true;
		else if (t == now)return false;
		if (z[a][now] != '?'&&z[b][now] != '?') {
			if (z[a][now] != z[b][now]) {
				return z[a][now] < z[b][now];
			}
		}
		else if (z[a][now] == '?'&&z[b][now] != '?') {
			return true;
		}
		else if (z[a][now] != '?'&&z[b][now] == '?') {
			return false;
		}
		else if (z[a][now] == '?'&&z[b][now] == '?') {
			if (num[a][ca] != num[b][cb]) {
				return numgreat(num[a][ca], num[b][cb]);
			}
			ca++; cb++;
		}
		now++;
	}
	return true;
}
int main() {
	cin >> n;
	rep(i, n+1) {
		string s; cin >> s;
		int le = 0;
		int len = s.length();
		rep(j, len) {
			if ('0' <= s[j]&& s[j] <= '9') {
				if(j!=le)z[i]+=s.substr(le, j - le);
				int memo = j;
				while (j + 1 < len&&'0' <= s[j + 1] && s[j + 1] <= '9') {
					j++;
				}
				num[i].push_back(s.substr(memo, j - memo + 1));
				z[i].push_back('?');
				le = j + 1;
			}
		}
			if (le != len) {
				z[i]+=s.substr(le, len - le);
			}
	}
	rep(i, n) {
		if (great(0, i + 1))cout << "+" << endl;
		else cout << "-" << endl;
	}
	//cout << num[2][0] << endl;
	//cout << z[2] << endl;
	return 0;
}


Measured memory_bytes: 3288
W, H, x, y = map(int, input().split())

# 面積の半分
area_half = W * H / 2
# 点 x,y が中心なら分割方法は複数
if x == W/2 and y == H/2:
  print(area_half, 1)
else:
  print(area_half, 0)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int ans=0;
	string s;
	cin>> s;

	if(s=="RSR"){
		cout<< 1 <<endl;
		return 0;
	}

	rep(i, 3){
		if(s[i]=='R') ans++;
	}

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

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

int main(){
    long long N,K;
    cin >> N >> K;
    long long A[N+1];
    long long i;
    for(i=1; i<=N; i++){
        cin >> A[i];
    }
    for(i=K+1; i<=N; i++){
        if(A[i-K]<A[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 5256
def main():
    all_s = input()
    k = int(input())
    substr = set()
    for i in range(len(all_s)):
        for j in range(1, k + 1):
            substr.add(all_s[i:i + j])
    substr = list(substr)
    substr.sort()
    print(substr[k - 1])


if __name__ == '__main__':
    main()



Measured memory_bytes: 4464
#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

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

int main()
{
    string s, t;
    string alp = "abcdefghijklmnopqrstuvwxyz";
    map<char, char> mp1, mp2;
    cin >> s >> t;

    REP(i, 26)
    {
        mp1[alp[i]] = '0';
        mp2[alp[i]] = '0';
    }

    REP(i, s.size())
    {
        if (mp1[s[i]] == '0')
        {
            mp1[s[i]] = t[i];
        }
        else if (mp1[s[i]] != t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    REP(i, s.size())
    {
        if (mp2[t[i]] == '0')
        {
            mp2[t[i]] = s[i];
        }
        else if (mp2[t[i]] != s[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
N = int(input())
L=list(map(int, input().split()))


import itertools
A=list(itertools.combinations(L,3))
ans=0
for a in A:
	if max(a)*2<sum(a) and len(a)==len(set(a)):
		ans+=1

print(ans)

# 2darray [[0] * 4 for i in range(3)]
# import itertools

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int X, Y;
    cin >> X >> Y;
    int ok = 0;
    for(int i = 0; i <= X; i++){
    	for(int j = 0; j <= Y; j++){
    		int num = i + j;
    		int foot = 2*i + 4*j;
    		if(num==X && foot==Y) ok = 1;
    	}
    }
    if(ok==0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005];

void Main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    rep(i, N + 10) dp[i] = INF;
    dp[0] = 0;
    rep(i, N) {
        rep2(j, 1, K + 1) {
            if (i + j <= N - 1) dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]));
        }
    }
    cout << dp[N - 1] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1408
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var a = new List<int>();
        var n = int.Parse(Console.ReadLine().Trim());
        var imax = (int)Math.Pow(2, n - 1);
        for (int i = 0; i < imax; i++)
        {
            var w = int.Parse(Console.ReadLine().Trim());
            var w2 = int.Parse(Console.ReadLine().Trim());
            if (w == w2) a.Add(w);
            else a.Add(Math.Abs(w - w2));
        }
        var ret = getAns(a);
        Console.WriteLine(ret[0]);
    }
    public static  List<int>  getAns (List<int> w)
    {
        var wc = w.Count();
        if (wc == 1) return w;
        var ret = new List<int>();
        for (int i = 0; i < wc/2; i++)
        {
            var t = w[2 * i];
            var t2 = w[2 * i + 1];
            if (t == t2) ret.Add(t);
            else ret.Add(Math.Abs(t - t2));
        }
        return getAns(ret);
    }
}


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

using namespace std;

int main() {
  char c = 0;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	vector<int> a(10);
	int n,sort;
	while(cin>>n){
		if(n==0) break;
		else{
		fill(a.begin(),a.end(),0);
		for(int i=0;i<n;i++){
			cin>>sort;
			a[sort]++;
		}
		for(int i=0;i<10;i++){
		if(a[i]==0){
		cout<<"-";
		}else{
		for(int j=0;j<a[i];j++){
			cout<<"*";
			}
	}
		cout<<endl;
}
}
}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main(){
    vector<int> c(9);
    for(int i=0;i<9;i++){
        cin>>c[i];
    }
    int sum=0;
    for(int i=0;i<9;i++){
        sum+=c[i];
    }
    int sum1=c[0]+c[4]+c[8];
    if(3*sum1==sum){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

lint count_multiple2(lint l, lint r, lint x)
{
    //l以上r以下の整数に含まれるxの倍数の数を返す
    lint ans;
    ans = r / x - (l - 1) / x;
    //cout << ans << "\n";
    return ans;
}

lint count_multiple(lint l, lint r, lint x)
{
    //l以上r以下の整数に含まれるxの倍数の数を返す
    lint n, ans;
    n = r - l + 1;
    ans = n / x;
    if (n % x + l % x > x)
    {
        ans += 1;
    }
    //cout << ans << "\n";
    return ans;
}

lint gcd(lint m, lint n)
{
    // 引数に０がある場合は０を返す
    if ((0 == m) || (0 == n))
        return 0;

    // ユークリッドの方法
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
} //gcd

lint lcm(lint m, lint n)
{
    // 引数に０がある場合は０を返す
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
} //lcm

int main()
{

    lint a, b, c, d;
    cin >> a >> b >> c >> d;
    lint n, ans;
    n = b - a + 1;
    lint cd;
    cd = lcm(c, d);
    lint tmp = count_multiple(a, b, c) + count_multiple(a, b, d) - count_multiple(a, b, cd);
    ans = n - tmp;
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;

int main(){
	string st;
	map<string, int> cnt;
	string len_max, freq_max;
	int len = 0;
	while( cin >> st ){
		cnt[st]++;
		if(len < st.size()){
			len = st.size();
			len_max = st;
		}
		freq_max = (cnt[freq_max] < cnt[st]) ? st : freq_max;
	}
	cout << freq_max << " " << len_max << endl;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    ll N;
    cin >> N;
    ll res = 0;
    ll a = 1;
    while(a * a <= N){
        if(N % a == 0) res = a;
        a++;
    }
    ll ans = res + N / res - 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <fstream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstring>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <bitset>
#define MOD 8192
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define NMAX 1705

using namespace std;

typedef pair<int, int> pii;


int main() {
	int i,j,t,a,b,c;

	cin>>a>>b>>c;

	if(a+b==c || a+c==b || b+c==a) cout<<"Yes";
	else cout<<"No";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C));

        sc.close();
    }

    static int solve(int A, int B, int C) {
        return A ^ B ^ C;
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;

vector<int> to[100005];
int n;

vector<int> calcDist(int s){
    vector<int> dist(n);
    rep(i,n) dist[i]=-1;
    queue<int> q;
    //マスiを値xで埋める。埋められたらqにマスiを追加。
    auto update = [&](int i, int x){
        if(dist[i]==-1){
            dist[i]=x;
            q.push(i);
        }
    };
    update(s,0);
    while(!q.empty()){
        int now = q.front(); q.pop();
        rep(i, to[now].size()){
            update(to[now][i],dist[now]+1);
        }
    }
    return dist;
}
int main(){
    cin >> n;
    int s,t; cin >> s >> t;
    s--; t--;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    vector<int> distS = calcDist(s);
    vector<int> distT = calcDist(t);

    int mx = 0;
    rep(i,n){
        if (distS[i]<distT[i] && distT[i]>mx){
            mx = distT[i];
        }
    }
    int ans = mx - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,K,a,count=0;cin>>N>>M;
  vector<int> menu(M);
  for(int i=0;i<N;i++){
    cin>>K;
    for(int j=0;j<K;j++){
      cin>>a;
      menu.at(a-1)++;
    }
  }
  
  for(int i=0;i<M;i++)
    if(menu.at(i)==N)count++;
  cout<<count<<endl;
}

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

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

    int n;
    cin >> n;

    map<ll, int> a;
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        a[tmp]++;
    }

    ll w = 0;
    ll h = 0;
    for (auto itr = a.rbegin(); itr != a.rend(); itr++) {
        if (itr->second >= 2 && h == 0) {
            h = itr->first;
            if (itr->second - 2 >= 2) {
                w = itr->first;
                break ;
            }
        } else if (h != 0 && itr->second >= 2) {
            w = itr->first;
            break ;
        }
    }

    cout << w * h << '\n';
    return 0;
}


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

int main(void) {
    while (true) {
        string card;cin>>card;
        if (card == "-") break;
        int shuffle;cin>>shuffle;
        for (int i = 0; i < shuffle; i++) {
            int h;cin>>h;
            string new_card = card.substr(h, card.size() - h) + card.substr(0, h);
            card = new_card;
        }
        cout << card << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
# cpding: utf-8
n_s, n_c = map(int, input().split())
scc_from_s = 0
scc_from_c = 0

if n_s >= 1 and n_c >=2:
	if n_s <= (n_c // 2):
		scc_from_s = n_s
		n_c -= (n_s * 2)
		scc_from_c = n_c // 4
	else:
		scc_from_s = (n_c // 2)
		scc_from_c = 0

scc_sum = scc_from_s + scc_from_c

print(scc_sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 2e5+3;
ll n,a[N],s1[N],s2[N],ans=LLONG_MAX;

int main(){
    scanf("%lld",&n);
    rep(i,1,n) scanf("%lld",&a[i]);
    rep(i,1,n) s1[i]=s1[i-1]+a[i];
    per(i,n,1) s2[i]=s2[i+1]+a[i];
    rep(i,1,n-1){
        ans=min(ans,abs(s1[i]-s2[i+1]));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4992
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
typedef long long ll;
using namespace std;

const int INF = 10e8;
void OneCardPoker(){

	int a, b;
	cin >> a >> b;
	
	if (a == b) {
		cout << "Draw" << endl;
		return;
	}
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	if (a > b) {
		cout << "Alice" << endl;
	}else if (b > a) {
		cout << "Bob" << endl;
	}
}

int main() {
	OneCardPoker();
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define mod 1000000007
#define ln "\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve(){
    ll n,i,m,j,x;
    cin>>n;
    if(n%1000==0)
    cout<<0;
    else 
        cout<<1000-(n%1000);
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    solve();
    return 0; 
} 

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, k int
	fmt.Fscan(read, &n, &k)

	ans := 0.0
	p0 := 1.0 / float64(n)
	p := 0.0
	for i := 1; i <= n; i++ {
		p = p0
		for j := i; j < k; j *= 2 {
			p /= 2.0
		}
		ans += p
	}
	fmt.Fprintln(write, ans)
}


Measured memory_bytes: 640
n=int(input())
lis=[]
for i in range(n):
  lis.append(list(map(int,input().split())))

summ=0
for i in range(0,n-1):
  for j in range(i+1,n):
    dis=((lis[i][0]-lis[j][0])**2+(lis[i][1]-lis[j][1])**2)**(1/2)
    summ+=dis
print(summ*2/n)


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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


void solve(int N, int M, vi& a, vi& b, int Q, vi& v, vi& d, vi& c){
    vi masks(11, 0);
    rep(d,11) {
        masks[d] = (1 << (d+1))-1;
    }

    vvi ne(N);
    rep(i,M) {
        int ai = a[i], bi = b[i];
        ne[ai].pb(bi);
        ne[bi].pb(ai);
    }

    vi visited(N, 0);
    vi colors(N, 0);

    queue<ii> q;
    for (int i=Q-1; i>=0; --i) {
        int v0 = v[i], d0 = d[i], c0 = c[i];

        if (visited[v0] & (1 << d0)) continue;

        if (visited[v0] == 0) colors[v0] = c0;
        visited[v0] |= masks[d0];

        if (d0 == 0) continue;
        --d0;

        for (int u: ne[v0]) {
            q.emplace( u, d0 );
        }
        while (!q.empty()) {
            int u=q.front().first, d=q.front().second;
            q.pop();

            if (visited[u] & (1 << d)) continue;
            if (visited[u] == 0) colors[u] = c0;
            visited[u] |= masks[d];
            if (d == 0) continue;
            --d;

            for (int v: ne[u]) {
                if (visited[v] & (1 << d)) continue;
                q.emplace( v, d );
            }

        }
    }

    rep(i,N) {
        printf("%d\n", colors[i]);
    }
}

int main() {
    int N, M; scanf("%d %d", &N, &M);
    vi a(M), b(M);
    rep(i,M){
        scanf("%d %d", &a[i], &b[i]);
        --a[i]; --b[i];
    }
    int Q; scanf("%d", &Q);
    vi v(Q),d(Q),c(Q);
    rep(i,Q){
        scanf("%d %d %d", &v[i], &d[i], &c[i]);
        --v[i];
    }
    solve(N,M,a,b, Q,v,d,c);
    return 0;
}


Measured memory_bytes: 9768
open System


[<EntryPoint>]
let main argv =
    let s =stdin.ReadLine()
    let l =String.length s
    let t =stdin.ReadLine()
    [|for i in [1..(l-1)] do yield (s.Substring(i)+s.Substring(0,i));yield s|]
    |>Seq.sumBy(fun c -> (if c=t then 1 else 0))
    |>fun c -> (if c>0 then "Yes" else "No")
    |>stdout.WriteLine
    0

Measured memory_bytes: 13396
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    val a = IntArray(N)
    for (i in 0 until a.size) {
        a[i] = sc.nextInt()
    }
    println(calc(a))
}

fun calc(a: IntArray): Int {
    var j = 1
    for (i in 1..a.size) {
        j = a[j - 1]
        if (j == 2) {
            return i
        }
    }
    return -1
}


Measured memory_bytes: 50068