akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 +7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    REP(i, n){
        int a, b;
        cin >> a >> b;
        if(a > m) continue;
        jobs[m - a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for(int i = m - 1; i >= 0; i--){
        for(int b : jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
n,time = map(int,input().split())
p=[]
p.append(['p0','0'])
for i in range(n):
  p.append(input().split())
  
head = 1
tail = 0

def enque(x):
  global tail
  p[tail] = x;
  tail = (tail+1) % len(p)

def dequeue():
  global head
  x = p[head]
  head = (head+1) % len(p)
  return x;

checkTime = 0
while(head != tail):
  u = dequeue()
  c = min(time,int(u[1]))
  u[1] = int(u[1]) - c
  checkTime += c
  if int(u[1]) > 0:
    enque(u)
  else:
    print(u[0], checkTime)
    


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

namespace Volume0011
{
    class Program
    {
        static void Main(string[] args)
        {
            int NumOfverticalLine = int.Parse(Console.ReadLine());
            int[] verticalLines = new int[NumOfverticalLine];
            DrawingLots.MaleInitialLines(verticalLines);
            int NumOfSideLine = int.Parse(Console.ReadLine());
            int[][] swapOrders = new int[NumOfSideLine][];
            for (int i = 0; i < NumOfSideLine; ++i)
            {
                swapOrders[i] = new int[2];
                swapOrders[i] = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
            }
            DrawingLots.Swaping(verticalLines, swapOrders);
            OutputCurrentLineUp(verticalLines);
        }

        private static void OutputCurrentLineUp(int[] verticalLines)
        {
            foreach (int lineNum in verticalLines)
            {
                Console.WriteLine(lineNum);
            }
        }
    }
    class DrawingLots
    {
        internal static void MaleInitialLines(int[] verticalLines)
        {
            for (int i = 0; i < verticalLines.Length; ++i)
            {
                verticalLines[i] = i + 1;
            }
        }
        internal static void Swaping(int[] verticalLines, int[][] swapOrders)
        {
            for (int i = 0; i < swapOrders.Length; ++i)
            {
                int tmp = 0;
                tmp = verticalLines[swapOrders[i][0] - 1];
                verticalLines[swapOrders[i][0] - 1] = verticalLines[swapOrders[i][1] - 1];
                verticalLines[swapOrders[i][1] - 1] = tmp;
            }
        }
    }
}



Measured memory_bytes: 16136
#include <stdio.h>

const int N = 10000;

int main()
{
	int a[N], n, maxn = -1000005, minn = 1000005;
	long long sum = 0;
	scanf("%d",&n);
	
	int i;
	for(i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
		if(a[i] > maxn)
		{
			maxn = a[i];
		}
		if(a[i] < minn)
		{
			minn = a[i];
		}
		sum += a[i];
		
		
	}
	printf("%d %d %lld\n",minn, maxn, sum);
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
using namespace std;

int sum(int x)
{
    if (x < 10) return x;
    return (x % 10) + sum(x / 10);
}

int main()
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int x = sum(i);
        if (x >= a && x <= b) ans += i;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N, M;
vector<int> G[1010];
vector<int> X[1010];

int calc(int a){
	vector<int> d(N);
	fill(d.begin(), d.end(), INF);
	queue<int> que;
	d[a] = 0;
	que.push(a);
	while(que.size()){
		int x = que.front(); que.pop();
		for(int i=0; i<G[x].size(); i++){
			int next = G[x][i];
			if(next == a) return d[x] + 1;
			if(d[next] == INF){
				d[next] = d[x] + 1;
				que.push(next);
			}
		}
	}
	return -1;
}

int main(){
	cin >> N >> M;
	int ans[N+1];
	for(int i=1; i<=N; i++) ans[i] = INF;
	for(int i=0; i<M; i++){
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		X[b].push_back(a);
	}
	int mi = INF, mi_index = -1;
	for(int i=0; i<N; i++){
		int len = calc(i);
		if(len != -1 && len < mi){
			mi = len;
			mi_index = i;
		}
	}
	if(mi == INF) cout << -1 << endl;
	else{
		vector<int> d(N);
		vector<int> prev(N);
		fill(d.begin(), d.end(), INF);
		queue<int> que;
		d[mi_index] = 0;
		que.push(mi_index);
		int f = 0;
		while(que.size()){
			int x = que.front(); que.pop();
			for(int i=0; i<G[x].size(); i++){
				int next = G[x][i];
				if(next == mi_index){
					prev[next] = x;
					f = 1;
					break;
				}
				if(d[next] == INF){
					d[next] = d[x] + 1;
					prev[next] = x;
					que.push(next);
				}
			}
			if(f) break;
		}
		int now = mi_index;
		cout << mi << endl;
		for(int i=0; i<mi; i++){
			cout << prev[now] + 1 << endl;
			now = prev[now];
		}
	}
	return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint c(int n, int k) {
  mint a = 1, b = 1;
  rep(i,k) {
    a *= n-i;
    b *= i+1;
  }
  return a/b;
}

void solve() {
  int n;
  cin >> n;
  n -= 5;
  mint ans;
  for (int o = 0; o <= 11; o++) {
    int m = n-o;
    if (m < 0 || m%2 != 0) continue;
    ans += c(m/2+15,15)*c(11,o);
  }
  cout << ans << endl;
}

int main() {
  int ts;
  cin >> ts;
  rep(ti,ts) solve();
  return 0;
}


Measured memory_bytes: 3600
// ABC 088 A- Infinite Coins

#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, A;

  cin >> N >> A;
  if ((N % 500) <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3520
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int p[N];
  int i;
  for(i=0;i<N;i++){
   cin >> p[i]; 
  }
  int count=0;
  for(i=1;i<N-1;i++){
   if(p[i]<p[i-1] && p[i]>p[i+1]) count++;
    else if(p[i]>p[i-1] && p[i]<p[i+1]) count++;
  }
  cout << count << endl;
return 0;
} 

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

using namespace std;
#define ll long long

int main()
{
     ll w , a , b;
     cin >> w >> a >> b;
     ll ar = a+w ;
     ll br = b+w ;
     if(ar<=b)
     {
         cout << b - ar << endl;
     }
     else if(ar>=b && ar<=br || a>=b && a<=br)
     {
         cout << 0 << endl;
     }
     else if(a>=br)
     {
         cout << a-br << endl;
     }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int e;
    while(cin >> e, e){
        int i,j,k,ans = 1000000;
        for(i = sqrt(1000000); i >= 0; i--){
            if(i * i * i > e) continue;
            for(j = sqrt(1000000 - i * i * i) ; j >= 0; j--){
                if(i * i * i + j * j > e) continue;
                k = e - i * i * i - j * j;
                ans = min(ans, i + j + k);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000000
#define PI 3.14159265358979323846
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x, n;
	cin >> x >> n;
	set<int>s;
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		s.insert(a);
	}
	int cu1=x, cu2=x;
	while(s.count(cu1) && s.count(cu2))
	{
		cu1--;
		cu2++;
	}
	if(!s.count(cu1))
		cout << cu1 << '\n';
	else
		cout << cu2 << '\n';
}

Measured memory_bytes: 3660
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int N, X;


int main(void) {
    scanf("%d %d", &N, &X);
    int m_min = 10000;
    ans += N;

    REP(i, 0, N) {
    	int m;
    	scanf("%d", &m);
    	X -= m;
    	m_min = min(m_min, m);
    }

    ans += (X / m_min);
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
// AtCoder ABC104: D - AtCoder Express 2
// 2019.9.11 bal4u

#include <stdio.h>

#if 1
int getchar_unlocked(void);
int putchar_unlocked(int c);
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif


int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int a[505][505];
int s[505][505];
int N, M;

int main()
{
	int i, l, r, Q, ans;
	
	N = in(), M = in(), Q = in();
	while (M--) {
		l = in(), r = in();
		a[l][r]++;
	}
	for (l = 1; l <= N; l++) {
		for (r = 1; r <= N; r++) s[l][r] = s[l][r-1]+a[l][r];
	}
	while (Q--) {
		l = in(), r = in();
		ans = 0;
		for (i = l; i <= r; i++) ans += s[i][r];
		out(ans);
	}
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;
int edge[103][103];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;
	REP(i,n){
		int v,t;cin>>v>>t;
		v--;
		while(t--){
			int u;
			cin>>u;
			u--;
			edge[v][u] = 1;
		}
	}
	REP(i,n){
		REP(j,n){
		if(j)cout << ' ';
			cout << edge[i][j];
		}
		cout << endl;
	}
  return 0;
}

Measured memory_bytes: 3168
import heapq
t = int(input())
for _ in range(t):
    n = int(input())
    klr = [tuple(map(int, input().split())) for _ in range(n)]
    klr.sort()
    
    left = [[]for _ in range(n)]
    right = [[]for _ in range(n)]
    score = 0
    for K,L,R in klr:
        if K!=n:
            if L<R:
                score+=L
                right[n-K-1].append(R-L)
            elif R<L:
                score+=R
                left[K-1].append(L-R)
            else:
                score+=L
        else:
            score+=L
    
    def calc(ls):
        n = len(ls)
        use = []
        retval = 0
        for i in reversed(range(n)):
            for x in ls[i]:
                heapq.heappush(use, -x)
            if use:
                retval-=heapq.heappop(use)
        return retval
    score+=calc(left)
    score+=calc(right)
    print(score)


Measured memory_bytes: 78312
function Main (input) {
  input = input.split("\n")[0].split(" ").map(Number);
  var a = input[0], b = input[1], c = input[2];
  if (b - a == c - b) {
    console.log("YES");
  }
  else {
    console.log("NO");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<algorithm>
#include <vector>
#include <cmath>
#define endl "\n"
using namespace std;


int main()
{
    long long N,AC=0,WA=0,TLE=0,RE=0;
    cin >> N;
    string S;
    while (N--)
    {
        cin >> S;
        if (S == "AC")
        {
            AC++;
        }
        else if (S == "WA")
        {
            WA++;
        }
        else if (S == "TLE")
        {
            TLE++;
        }
        else if (S == "RE")
        {
            RE++;
        }
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}


Measured memory_bytes: 3624
from collections import Counter

N=int(input())
A=[int(i) for i in input().split()]
A=Counter(A)
e1=0
e2=0
for key,value in A.items():
    if value<2:
        continue
    elif value>=4:
        e1=max(e1,key)
        e2=max(e2,key)
    else:
        if key>e1:
            e2=e1
            e1=key
        else:
            e2=max(e2,key)
print(e1*e2)

Measured memory_bytes: 21952
import scala.io.StdIn.readInt
import scala.io.Source.stdin
 
object Main {
  def main(args: Array[String]) = {
    val list = stdin.getLines().map { _.toInt }
    val n = list.next()
    val r0 = list.next()
    val r1 = list.next()
    var max = r1 - r0
    var min = if(r0 > r1) r1 else r0
    for( m <- list ) {
      if( max < m - min) {
        max = m - min
        if( min > m )
          min = m
      }
      else if( min > m ) {
        min = m
      }
    }
    println(max)
  }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> r(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    r[a-1] += 1;
    r[b-1] += 1;
  }

  for (int i = 0; i < n; i++) {
    cout << r[i] << endl;
  }
  
}


Measured memory_bytes: 3624
program echo
  implicit none
  integer :: n
  character(100) :: s
  read(*,*) n
  read(*,*) s
  if (mod(n,2) == 0 .and. s(1:n/2) == s(n/2+1:n)) then
    write(*,'(a)') "Yes"
  else
    write(*,'(a)') "No"
  end if
end program echo

Measured memory_bytes: 256
import sys
from collections import deque
readline = sys.stdin.readline

N = int(readline())
P = list(map(int, readline().split()))

geta = N+2
G = [0]*(geta*geta)

for v in range(-1-(-N//2), -1, -1):
    l = v+1
    r = N-v
    for i in range(geta):
        G[i*geta+l] = v
        G[i*geta+r] = v
        G[l*geta+i] = v
        G[r*geta+i] = v

for i in range(geta):
    G[i*geta] = -1
    G[i*geta + geta-1] = -1
    G[i] = -1
    G[geta*(geta-1)+i] = -1

Pn = []

for p in P:
    a, b = divmod(p-1, N)
    Pn.append((1+a)*geta+1+b)

DIREC = (1, -1, geta, -geta)
ans = 0
used = [False]*(geta*geta)
for p in Pn:
    ans += G[p]
    res = G[p]
    for d in DIREC:
        res = min(res, G[p+d])
    if G[p] != res:
        G[p] = res
        Q = [p]
        while Q:
            vn = Q.pop()
            for d in DIREC:
                vf = vn + d
                if not used[vf]:
                    if G[vf] > G[vn] + 1:
                        G[vf] = G[vn] + 1
                        Q.append(vf)
                else:
                    if G[vf] > G[vn]:
                        G[vf] = G[vn]
                        Q.append(vf)
                    
    used[p] = True
print(ans)

Measured memory_bytes: 134148
#include <bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
int main()
{
	int a,b,h,m; cin>>a>>b>>h>>m;
	double t=fabs((h+m/60.)*PI/6-m*PI/30);
	printf("%.10f\n", sqrt(a*a+b*b-2*a*b*cos(t)));
	return 0;
}

Measured memory_bytes: 4216
function Main(input){
	var args = input.split(' ');
	var N = parseInt(args[0],10);
  	var K = parseInt(args[1],10);
if(N%K===0){
  console.log('0');
}else{
 console.log('1');
}
  
}
Main(require('fs').readFileSync('/dev/stdin','utf8')); 

Measured memory_bytes: 7372
n = gets.to_i
hs = gets.split(" ").map(&:to_i)

move = 0
max = 0

for i in 1..hs.count-1
  if hs[i-1] >= hs[i]
    move += 1
    max = move if max < move
  else
    move = 0
  end
end
p max

Measured memory_bytes: 8580
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

const int maxn = 300 * 1000;

const ll mod = 1000 * 1000 * 1000 + 7;

ll Pow(ll x, ll n) {
  ll result = 1;
  while (n > 0) {
    if (n % 2) {
      n--;
      result = result * x % mod;
    } else {
      n /= 2;
      x = x * x % mod;
    }
  }
  return result;
}

ll Inv(ll x) {
  return Pow(x, mod - 2);
}

ll fact[maxn];
ll invFact[maxn];

int n;
vector<int> g[maxn];
ll subtreeSize[maxn];
ll cutSize[maxn];

bool used[maxn];

void DFS1(int v) {
  used[v] = true;

  int sz = 1;
  vector<int> child;
  for (int id = 0; id < g[v].size(); ++id) {
    int to = g[v][id];
    if (used[to]) continue;
    child.push_back(to);
    DFS1(to);
    sz += subtreeSize[to];
    cutSize[to] = n - subtreeSize[to];
  }

  subtreeSize[v] = sz;
}

ll subtreeAns[maxn];
ll cutAns[maxn];
ll ans[maxn];

void DFS2(int v) {
  used[v] = true;

  vector<ll> n, c, child;
  for (int to : g[v]) {
    if (used[to]) continue;
    DFS2(to);

    n.push_back(subtreeSize[to]);
    c.push_back(subtreeAns[to]);
    child.push_back(to);
  }

  int N = accumulate(n.begin(), n.end(), 0);
  ll result = 1;
  for (ll x : c) result = result * x % mod;
  result = result * fact[N] % mod;
  for (ll x : n) result = result * invFact[x] % mod;
  subtreeAns[v] = result;
}

void DFS3(int v) {
  used[v] = true;

  vector<ll> n, c, child;
  for (int to : g[v]) {
    if (used[to]) continue;

    n.push_back(subtreeSize[to]);
    c.push_back(subtreeAns[to]);
    child.push_back(to);
  }

  int N = accumulate(n.begin(), n.end(), 0) + cutSize[v];
  ll result = 1;
  for (ll x : c) result = result * x % mod;
  result = result * cutAns[v] % mod;
  for (ll x : n) result = result * invFact[x] % mod;
  result = result * invFact[cutSize[v]] % mod;

  ans[v] = (result * fact[N]) % mod;

  for (int i = 0; i < child.size(); ++i) {
    int to = child[i];
    ll curResult = result;
    curResult = curResult * Inv(c[i]) % mod;
    curResult = curResult * fact[n[i]] % mod;

    curResult = curResult * fact[N - n[i]] % mod;
    
    cutAns[to] = curResult;
    DFS3(to);
  }
}

int main()
{
  fact[0] = 1;
  for (ll i = 1; i < maxn; ++i) fact[i] = fact[i - 1] * i % mod;
  for (int i = 0; i < maxn; ++i) invFact[i] = Inv(fact[i]);

  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  memset(used, false, sizeof(used));
  DFS1(0);

  memset(used, false, sizeof(used));
  DFS2(0);

  memset(used, false, sizeof(used));
  cutAns[0] = 1;
  DFS3(0);

  for (int i = 0; i < n; ++i) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 38672
N = int(input())
a = list(map(int,input().split()))
if N % 3:
  for i in range(N):
    if a[i] != 0:
      print('No')
      break
  else:
    print('Yes')
else:
  a.sort()
  M = N//3
  if a[0]^a[M]^a[2*M] != 0:
    print('No')
  else:
    for i in range(N):
      if a[i] != a[(i//M)*M]:
        print('No')
        break
    else:
      print('Yes')


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

int main() {
int ans = 0;
int N;
cin >> N;
int Min = N+1;
int P;
for (int i = 0; i < N; i++)
{
    cin >> P;
    if(P < Min){
        ans += 1;
        Min = P;
    }
}

cout << ans << endl;
}

Measured memory_bytes: 256
let N =
    stdin.ReadLine()
    |> int
let xy =
    [|1..N|]
    |> Array.map (fun _ ->
        stdin.ReadLine().Split()
        |> Array.map int
        |> fun [|x;y|] -> (x,y))

let z = Array.map (fun (x,y) -> x+y) xy
let maxZ = Array.max z
let minZ = Array.min z

let w = Array.map (fun (x,y) -> x-y) xy
let maxW = Array.max w
let minW = Array.min w

max (maxZ-minZ) (maxW-minW)
|> stdout.WriteLine

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

string s;
int op[3];

bool dfs(int i, int res) {
  if (i == 3) {
    if (res == 7) return true;
    else return false;
  }

  if (dfs(i + 1, res + s[i + 1] - '0')) {
    op[i] = 1;
  } else if (dfs(i + 1, res - (s[i + 1] - '0'))) {
    op[i] = 0;
  }
}

void Main() {
  cin >> s;

  dfs(0, s[0] - '0');
  for (int i = 0; i < 3; i++) {
    cout << s[i];
    if (op[i]) cout << "+";
    else cout << "-";
  }
  cout << s[3] << "=7" << endl;
}

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

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n;
	t = 1;
	while(t--) {
	 cin >> n;
	 cout << "Christmas ";
	 while(n < 25) {
	  cout << "Eve ";
	  n++;
	 }
	 cout << endl;
	}
	return 0;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

left = []
right = []
left[0] = 0
right[n-1] = 0

(1..(n-1)).each do |i|
  left[i] = left[i-1].gcd(a[i-1])
  right[(n-1)-i] = right[n-i].gcd(a[n-i])
end

max = 1
n.times do |i|
  gcd = left[i].gcd(right[i])
  max = gcd if max < gcd
end

puts(max)

Measured memory_bytes: 11340
use std::io::{BufRead, Write};
use std::io;
use std::iter;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    s.clear();
    input.read_line(&mut s).unwrap();
    let mut cnt: usize = 0;
    let mut insufficient: usize = 0;
    for c in s.trim().chars() {
        if c == '(' {
            cnt += 1;
        } else if c == ')' {
            if cnt > 0 {
                cnt -= 1;
            } else {
                insufficient += 1;
            }
        } else {
            panic!();
        }
    }
    let result: String = iter::repeat('(')
        .take(insufficient)
        .chain(s.trim().chars())
        .chain(iter::repeat(')').take(cnt))
        .collect();
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("3
())\n",
             "(())\n");
    }
    #[test]
    fn case2() {
        test("6
)))())\n",
             "(((()))())\n");
    }
    #[test]
    fn case3() {
        test("8
))))((((\n",
             "(((())))(((())))\n");
    }
}



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

using namespace std;

using Weight=int;

struct Edge{
    int src,dst;
    Edge(int src,int dst):
    src(src),dst(dst){}
};

using Edges=vector<Edge>;
using Graph=vector<Edges>;

int memo[100001];

pair<vector<int>, Edges> bridge(const Graph& g) {
	const int n = g.size();
	int idx = 0, s = 0, t = 0, k = 0;
	vector<int>ord(n, -1), onS(n), stk(n), roots(n), cmp(n);
	Edges brdg;
	function<void(int, int)> dfs = [&](int v, int u) {
		ord[v] = idx++;
		stk[s++] = v;
		onS[v] = true;
		roots[t++] = v;
		for (auto& e : g[v]) {
			int w = e.dst;
			if (ord[w] == -1)dfs(w, v);
			else if (u != w && onS[w])
				while (ord[roots[t - 1]]>ord[w])--t;
		}
		if (v == roots[t - 1]) {
			brdg.emplace_back(u, v);
			while (true) {
				int w = stk[--s];
				onS[w] = false;
				cmp[w] = k;
				if (v == w)break;
			}
			--t;
			++k;
		}
	};
	for (int u = 0; u<n; ++u) {
		if (ord[u] == -1) {
			dfs(u, n);
			brdg.pop_back();
		}
	}
	return make_pair(cmp, brdg);
}

bool dfs0(const Graph &g,int p,int v,vector<bool> &elect,
vector<int>&elements,vector<int>&cycle){
    for(auto e:g[v]){
        if(e.dst==p)continue;
        if(elements[cycle[e.dst]]>1 || elect[e.dst])return elect[v]=1;
        if(dfs0(g,v,e.dst,elect,elements,cycle))return elect[v]=1;
    }
    return 0;
}

int dfs1(const Graph &g,int p,int v,vector<bool> &elect,
vector<int>&elements,vector<int>&cycle,vector<Weight>&node){
    if(memo[v])return memo[v];
    int res=0;
    for(auto e:g[v]){
        if(elect[e.dst]){
            return memo[v]=node[v];
        }
        if(e.dst!=p && elements[cycle[e.dst]]==1){
            res=dfs1(g,v,e.dst,elect,elements,cycle,node);
            if(res){
                return memo[v]=res+node[v];
            }
        }
    }
    return 0;
}

int main(){
    int n,m;
    cin>>n>>m;
    Graph g(n);
    vector<Weight>node(n);
    for(int i=0;i<n;++i){
        cin>>node[i];
    }
    for(int i=0;i<m;++i){
        int s,t;
        cin>>s>>t;
        --s;--t;
        g[s].emplace_back(s,t);
        g[t].emplace_back(t,s);
    }
    vector<int>cycle = bridge(g).first;
    vector<int>elements(n,0);
    for(int i=0;i<n;++i){
        elements[cycle[i]]++;
    }
    vector<bool>elect(n,false);
    elect[0]=true;
    for(int i=1;i<n;++i){
        if(elements[cycle[i]]>1){
            dfs0(g,-1,i,elect,elements,cycle);
        }
    }
    int buf=0;
    for(int i=1;i<n;++i){
        if(g[i].size()==1){
            buf=max(buf,dfs1(g,-1,g[i][0].src,elect,elements,cycle,node));
        }
    }
    int ans=0;
    for(int i=0;i<n;++i){
        if(elect[i]){
            ans+=node[i];
        }
    }
    ans+=buf;
    cout<<ans<<endl;
    return 0;
}

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

int n;
int a[200000];
long L[200001];
long R[200001];

void sub(long* P) {
  stack<int> gap;
  for (int i = 0; i < n; ++i) {
    gap.push(0);
  }
  
  long sum = 0;
  for (int i = 1; i < n; ++i) {
    long s = a[i - 1];
    long t = a[i];
    while (s < t) {
      sum += i - gap.top(); gap.pop();
      s *= 4;
    }
    
    while (s >= t * 4) {
      gap.push(i);
      t *= 4;
    }
    P[i + 1] = 2 * sum;
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  sub(L);
  reverse(a, a + n);
  sub(R);
  
  long mn = 1e18;
  for (int i = 0; i <= n; ++i) {
    mn = min(mn, L[i] + R[n - i] + i);
  }
  cout << mn << endl;
}

Measured memory_bytes: 4936
N = int(input())
Nlist = [[] for _ in range(N)]
for i in range(N):
    C, P = input().split()
    P = int(P)
    Nlist[i].append(i+1)
    Nlist[i].append(C)
    Nlist[i].append(P)

Nlist.sort(key=lambda x: x[1])
Nlist.sort(key=lambda x: x[2],reverse=True)
Nlist.sort(key=lambda x: x[1])
for i in range(N):
    print(Nlist[i][0])


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

using namespace std;

int main() {
  int n;
  cin >> n;
  float sum = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    sum += 1.0 / x;
  }
  sum = 1.0 / sum;
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main() {
  int N = readln.chomp.to!int;
  auto A = readln.chomp.split.map!(to!int);

  int ans = (1e9).to!int;

  foreach(a; A) {
    int tmp;
    while (a % 2 == 0 && a > 0) {
      tmp++;
      a /= 2;
    }

    ans = min(ans, tmp);
  }

  ans.writeln;
}

Measured memory_bytes: 256
use proconio::{fastout, input, marker::Usize1};
use std::cmp::Ordering;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        mut ab: [(Usize1, Usize1); m],
    }
    ab.sort_by(|x, y| {
        if x.1 < y.1 {
            Ordering::Less
        } else if x.1 > y.1 || x.0 > y.0 {
            Ordering::Greater
        } else if x.0 < y.0 {
            Ordering::Less
        } else {
            Ordering::Equal
        }
    });

    let mut res = 1;
    let mut now = ab[0].1;
    for i in 1..ab.len() {
        if now <= ab[i].0 {
            res += 1;
            now = ab[i].1;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 5492
from collections import deque
import sys
input = sys.stdin.readline

f_inf = float("inf")

n, m = map(int, input().split())
to = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

que = deque([])
que.append(0)

dist = [f_inf for _ in range(n)]
dist[0] = 0

guide = [-1 for _ in range(n)]

while que:
    v = que.popleft()
    for u in to[v]:
        if dist[u] != f_inf: continue
        dist[u] = dist[v]+1
        guide[u] = v
        que.append(u)

print("Yes")
for i in range(1, n):
    ans = guide[i] + 1
    print(ans)
    

Measured memory_bytes: 34904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    vector<string> cand;
    if (s.size() < t.size())
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for (ll i = 0; i <= s.size() - t.size(); i++)
    {
        bool candans = true;
        for (ll j = 0; j < t.size(); j++)
        {
            if (s[j + i] != '?' && t[j] != s[i + j])
                candans = false;
        }
        if (candans)
        {
            string S = s;
            for (ll j = 0; j < t.size(); j++)
            {
                S[i + j] = t[j];
            }
            cand.emplace_back(S);
        }
    }
    for (ll i = 0; i < cand.size(); i++)
    {
        for (ll j = 0; j < cand[i].size(); j++)
        {
            if (cand[i][j] == '?')
                cand[i][j] = 'a';
        }
    }
    sort(cand.begin(), cand.end());
    if (cand.size() == 0)
    {
        cout << "UNRESTORABLE" << endl;
    }
    else
    {
        cout << cand[0] << endl;
    }
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

n.times do |i|
  a[i] -= i + 1
end

a.sort!
m = a[a.size/2]

ans = 0
a.each do |aa|
  ans += (aa - m).abs
end
p ans


Measured memory_bytes: 19456
program main
implicit None
integer(8)::a,b,c,k
read *,a,b,c,k

if(abs(b-a) > 10e18)then 
	print 102,"Unfair"
	else if(mod(k,2) == 1)then
		print 101,b-a
	else
		print 101,a-b
endif

101 format(i0)
102 format(a)
end program main

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

int main () {
    int a, b;
    cin >> a >> b;
    
    if (a < b) {
        cout << "a < b" << endl;
    }
    
    if (a > b) {
        cout << "a > b" << endl;
    }
    
    if (a == b) {
        cout << "a == b" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define len(x) (int)(x).size()
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fast_io ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
    int mas[3];
    for(auto &i : mas)cin>>i;
    sort(mas , mas + 3);
    if(mas[0] == mas[1] && mas[1] != mas[2]){
        cout << "Yes";
    }else if(mas[0] != mas[1] && mas[1] == mas[2])cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N := sc.i()
	f := func(x, y, z int) int {
		return x*x + y*y + z*z + x*y + y*z + z*x
	}
	ans := make([]int, 100000)

	for x := 1; x*x < N; x++ {
		for y := 1; y*y < N; y++ {
			for z := 1; z*z < N; z++ {
				a := f(x, y, z)
				ans[a]++
			}
		}
	}
	for i := 1; i <= N; i++ {
		fmt.Println(ans[i])
	}

}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//------------------------------

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

// a^{-1} (mod) を計算
func Inv(a int) int {
	return Pow(a, mod-2)
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 2392
def solve(a, b)
  r = 60
  until r==0
    break unless a[r]==b[r]
    a ^= (1<<r) if a[r]==1
    b ^= (1<<r) if b[r]==1
    r -= 1
  end
  return 1 if b==0
  sum = 2**r - a
  if b==2**r
    sum += 2**r - a + 1
    sum -= 1 if a==0
  else
    k = r-1
    k -= 1 until b[k]==1
    if a <= 2**(k+1)
      sum += 2**r
    else
      sum += 2**(k+1)
      sum += 2**r - a
    end
  end
  sum
end

p solve(gets.to_i, gets.to_i)


Measured memory_bytes: 1788
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    a = LI()
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1
    lis = list(d.items())
    ans = []
    for i,j in lis:
        for _ in range(j // 2):
            ans.append(i)
    ans.sort(reverse=True)
    if len(ans) < 2:
        print(0)
    else:
        print(ans[0]*ans[1])

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 66712
N, mod = list(map(int, input().split()))
A = [ int(i)%mod for i in input().split()]

cnt = {}
cnt[0] = 0;
s = 0

for i in range(N):
    s = (s + A[i])%mod
    if s in cnt:
        cnt[s] = cnt[s] + 1
    else:
        cnt[s] = 1
        
ans = cnt[0]
s = 0
for i in range(N):
    s = (s + A[i])%mod
    cnt[s] = cnt[s] - 1
    if s in cnt:
        ans = ans + cnt[s]
        
print (ans)
    


Measured memory_bytes: 13928
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

/* 最大公約数を返す */
int gcd(int a, int b) {
	int r;
	while (b != 0) { r = a % b; a = b; b = r; }
	return (a < 0) ? -a : a;
}

/* 値を入れ換える */
void swap(int *a, int *b) {
	int c = *a; *a = *b; *b = c;
}

int main(void) {
	int a, b, c; /* 与えられる値 */
	int p, q, r, s;
	int f; /* 解が存在するか */

	/* データセット毎の処理 */
	while (scanf("%d%d%d", &a, &b, &c) == 3 && a > 0) {
		int d = b * b - 4 * a * c; /* 二次方程式の判別式D */
		f = 0;

		if (d == 0) {
			int g;
			/* 重解 -b / 2a */
			f = 1;
			p = 2 * a;
			q = b; /* 符号に注意 */
			/* 約分 */
			g = gcd(p, q);
			p /= g;
			q /= g;

			r = p;
			s = q;
		} else if (d > 0) {
			/* 異なる二つの実数解 (-b +- √d) / 2a */
			int i;
			for (i = 1; i * i < d; i++); /* D の正整数平方根を求める */

			/* Dの平方根が整数であるなら整数 p, q, r, s が存在する */
			if (i * i == d) {
				int g;
				f = 1;

				p = 2 * a;
				r = 2 * a;
				q = -(-b - i);
				s = -(-b + i);

				/* 約分 */
				g = gcd(p, q);
				p /= g;
				q /= g;
				g = gcd(r, s);
				r /= g;
				s /= g;

				/* 問題の条件に合わせて解の順番を入れ換える */
				if (!(p > r || (p == r && q >= s))) {
					swap(&p, &r);
					swap(&q, &s);
				}
			}
		}

		/* 結果を出力する */
		if (f) printf("%d %d %d %d\n", p, q, r, s);
		else printf("Impossible\n");
	}

	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> x(n),y(n);
	rep(i,n) cin >> x.at(i) >> y.at(i);
	vector<int> c(n);
	rep(i,n) c.at(i) = i;
	double sum = 0;
	do{
		rep(i,n - 1){
			sum += sqrt((x.at(c.at(i + 1)) - x.at(c.at(i))) * (x.at(c.at(i + 1)) - x.at(c.at(i))) + (y.at(c.at(i + 1)) - y.at(c.at(i))) * (y.at(c.at(i + 1)) - y.at(c.at(i))));
		}
	}while(next_permutation(all(c)));
	double div = 1;
	rep(i,n) div *= i + 1;
	cout << setprecision(20) << fixed << sum / div << endl;
}


Measured memory_bytes: 256
S = input()
S_list = list(S)
S_ex = ''.join((['1' if (k == 'A' or k == 'C' or k == 'G' or k == 'T') else '0' for k in S_list]))
S_ans = [len(k) for k in S_ex.split('0')]
print(max(S_ans))

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

template <int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return is;
    }

    static int get_mod() { return mod; }
};

int main() {
    const int mod = 1000000007;
    ModInt<mod> m;
    int n;
    cin >> m >> n;
    cout << m.pow(n) << endl;
}


Measured memory_bytes: 3112
let counting_sort a b k n =
  let c = Array.make (k + 1) 0 in
  Array.iter (fun e -> c.(e) <- c.(e) + 1) a;
  for i = 1 to k do
    c.(i) <- c.(i) + c.(i-1)
  done;
  for i = n - 1 downto 0 do
    b.(c.( a.(i) ) - 1) <- a.(i);
    c.( a.(i) ) <- c.( a.(i) ) - 1;
  done

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  let b = Array.make n 0 in
  counting_sort a b 10000 n;
  print_int b.(0);
  for i = 1 to n - 1 do
    print_string " "; print_int b.(i);
  done;
  print_newline ()

Measured memory_bytes: 36096
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		
		int ans = 0;
		int cnt = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'I') {
				cnt++;
			} else {
				cnt--;
			}
			
			ans = Math.max(ans, cnt);
		}
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 21588
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
		int y=sc.nextInt();

		int sum=0;

		if(x==1){
		sum+=300000;
		}
		else if(x==2){
		sum+=200000;
		}
		else if(x==3){
		sum+=100000;
		}
		else{
		sum+=0;
		}

		if(y==1){
		sum+=300000;
		}
		else if(y==2){
		sum+=200000;
		}
		else if(y==3){
		sum+=100000;
		}
		else{
		sum+=0;
		}

		if(x==1 && y==1){
		sum+=400000;
		}
		
		System.out.println(sum);
	}
}

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

using namespace std;

const int maxi=1e6+6;
int n,m;
int a[maxi];
int h[200][200];
int main()
{
    cin>>n>>m;

   int r;
   cin>>r;
   for (int i=1;i<=r;i++)
    cin>>a[i];

    int cur=1;

    for (int i=1;i<=n;i++)
    {
        if (i%2==1)
        {
            for (int j=1;j<=m;j++)
                if (a[cur]>0) {a[cur]--; h[i][j]=cur;} else
                    {
                        cur++;
                        a[cur]--;
                        h[i][j]=cur;
                    }
        } else
        {
            for (int j=m;j>0;j--)
                if (a[cur]>0) {a[cur]--; h[i][j]=cur;} else
                    {
                        cur++;
                        a[cur]--;
                        h[i][j]=cur;
                    }
        }

    }

    for (int i=1;i<=n;i++){
    for (int j=1;j<=m;j++)
        printf("%d ",h[i][j]);
    printf("\n");
}

    return 0;
}


Measured memory_bytes: 384
function MainD(input){
    const [A, B, N] = input.split(' ');
    const x = Math.min(B-1, N);
    const answer = Math.floor((A * x)/B) - A *  Math.floor(x/B);
    console.log(answer);
}
MainD(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 29612
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    int a,b,c,p=0;
	    cin>>a>>b>>c;
	   for (int i = a; i <= b; ++i)
	   {
	   	
	   	if(i%c == 0){
	   		p++;
	   	}
	   }
	    cout<<p<<endl;
	    return 0;
	  }


Measured memory_bytes: 3648
import collections

num = int(input())

num_list = []
count_list = []
ans = []

for i in range(0,num):
  num_list.append(input())

num_list_2 =collections.Counter(num_list).most_common()

for i in range(0,len(num_list_2)):
  if num_list_2[0][1] > num_list_2[i][1]:
    break
  
  ans.append(num_list_2[i][0])

ans.sort()

for i in range(0,len(ans)):
  print(ans[i])

Measured memory_bytes: 45036
if __name__ == '__main__':
    values = list(map(int, input().split()))
    k = int(input())

    max_index = 0
    max_value = values[0]
    for i in range(1, len(values)):
        if max_value < values[i]:
            max_index = i
            max_value = values[i]

    del values[max_index]
    answer = sum(values) + max_value * (2 ** k)
    print(answer)


Measured memory_bytes: 3060
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s, t = LS()
a, b = LI()
x = S()
if s == x:
    a -= 1
else:
    b -= 1


print(a, b)

Measured memory_bytes: 39664