akhauriyash/Code-Regression huggingface dataset:
S = input()

counts = []
count = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        count += 1
        if i == len(S) - 1:
            counts.append(count)
    else:
        counts.append(count)
        count = 0

print(max(counts))


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

int main() {
	int n;
  	string s;
  
  cin>>n>>s;
  
  string ans;
  
  for(int i=0;i<s.size();i++){
  	int x=s[i]-'A';//s.at(i)のほうがいいのかなあ
    ans.push_back('A'+(x+n)%26);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int n,m;
struct Node{
	int x,y,num;
}Edge[100005];
 
bool cmp(Node a,Node b){
	if(a.x == b.x){
		return a.y < b.y;
	}
	return a.x < b.x;
}
 
bool cmp1(Node a,Node b){
	return a.num < b.num;
}
 
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&Edge[i].x,&Edge[i].y);
		Edge[i].num = i;
	}
	sort(Edge,Edge+m,cmp);
	int num = 1;
	for(int i=0;i<m-1;i++){
		if(Edge[i].x == Edge[i+1].x){
			Edge[i].y = num++;
		}
		else{
			Edge[i].y = num;
			num = 1;
		}
	}
	if(Edge[m-2].x != Edge[m-1].x) Edge[m-1].y = num;
	else Edge[m-1].y = num++;
	sort(Edge,Edge+m,cmp1);
	for(int i=0;i<m;i++){
		printf("%06d%06d\n",Edge[i].x,Edge[i].y);
	}
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	string s;

	cin >> s;

	cout << ((s[0] == s[1] || s[0] == s[2] ||s[1] ==s[2]) ? "No" : "Yes") << endl;

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define eps (1e-10)
#define xx first
#define yy second
#define ln 17
#define off 2

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define log 20
#define mod 1000000007LL
#define maxn 2000005
#define INF 1000000000000000000LL

vector <i64> findBasis( vector <i64> b , i64 x )
{
    if(b.size()==0) return b ;
    vector <i64> idx , num ;
    for(int i=0 ; i<b.size() ; i++) idx.pb(i) , num.pb(b[i]) ;

    for(int i=x-1 , j=0 ; i>=0 ; i--,j++)
    {
        for(int k= j+1 ; k<idx.size() ; k++)
        {
            if( b[k] > b[j] )
            {
                swap(b[k],b[j]) ;
                swap(idx[k],idx[j]) ;
            }
        }
        for(int k=j+1 ; k<idx.size() ; k++)
        {
            if( (b[k]^b[j]) < b[k] ) b[k] ^= b[j] ;
        }

    }
    return b ;
    int i = (int)idx.size() - 1 ;
    while( i > 0 && b[i] == 0 )
    {
        b.pop_back() ;
        idx.pop_back() ;
        i-- ;
    }
    return b ;
    vector <i64> basis ;
    for(int i=0 ; i<idx.size() ; i++) basis.pb( num[idx[i]] ) ;
    return basis ;
}

char s[205] ;

int main()
{
    int tc , t=1 ;

    scanf("%d",&tc) ;

    while( t++ <= tc )
    {
        int n ;
        scanf("%d",&n) ;

        vector <i64> vec ;

        for(int i=1; i<=n ; i++)
        {
            i64 a ;
            scanf("%lld",&a) ;
            vec.pb(a) ;
        }

        scanf("%s",s) ;
        int fl = 0 ;

        for(int i=0 ; i<n ; i++)
        {
            if( s[i]=='1' )
            {
                vector <i64> v ;
                for(int j=i+1 ; j<n ; j++) if(s[j]=='0') v.pb( vec[j] ) ;

                vector <i64> bas = findBasis(v,61) ;

                sort(bas.begin(),bas.end()) ;
                for(int j=((int)bas.size()) -1 ; j>=0 ; j-- )
                {
                    if( (vec[i]^bas[j]) < vec[i] ) vec[i] ^= bas[j] ;
                }
                if(vec[i]!=0) fl = 1 ;
            }
        }

  //      printf("------ ") ;
        printf("%d\n",fl) ;
    }


    return 0 ;
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    const int k = 3;
    int a[k][k];
    for (int a_i = 0; a_i < k; a_i++) {
        for (int a_j = 0; a_j < k; a_j++) {
            cin >> a[a_i][a_j];
        }
    }

    int n;
    cin >> n;

    int b[n];
    for (int b_i = 0; b_i < n; b_i++) {
        cin >> b[b_i];
    }

    int table[3][3];
    for (int a_i = 0; a_i < k; a_i++) {
        for (int a_j = 0; a_j < k; a_j++) {
            table[a_i][a_j] = 0;
        }
    }

    for (int b_i = 0; b_i < n; b_i++) {
        for (int a_i = 0; a_i < k; a_i++) {
            for (int a_j = 0; a_j < k; a_j++) {
                if (b[b_i] == a[a_i][a_j]) {
                    table[a_i][a_j] = 1;
                }
            }
        }
    }

    int flag1 = 0;
    for (int a_i = 0; a_i < k; a_i++) {
        int temp = 1;
        for (int a_j = 0; a_j < k; a_j++) {
            temp *= table[a_i][a_j];
        }
        flag1 += temp;
    }

    int flag2 = 0;
    for (int a_j = 0; a_j < k; a_j++) {
        int temp = 1;
        for (int a_i = 0; a_i < k; a_i++) {
            temp *= table[a_i][a_j];
        }
        flag2 += temp;
    }

    int flag3 = 1;
    for (int i = 0; i < k; i++) {
        flag3 *= table[i][i];
    }

    int flag4 = 1;
    for (int i = 0; i < k; i++) {
        flag4 *= table[i][k-i-1];
    }

    int flag = flag1 + flag2 + flag3 + flag4;
    if (flag > 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  char s[n+1];
  scanf("%s",s);
  int min=0,count;
  for(i=1;i<n;i++)
    if(s[i]=='E')
      min++;
  count=min;
  for(i=1;i<n;i++){
    if(s[i-1]=='W' && s[i]=='W')
      count++;
    else if(s[i-1]=='E' && s[i]=='E')
      count--;
    if(count<min)
      min=count;
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 512
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        _n: usize, m: usize,
        ps_vec: [(usize, String); m]
    }

    let mut map: HashMap<usize, Vec::<String>> = HashMap::new();
    
    for (p, s) in ps_vec.iter() {
        map.entry(*p).or_insert(Vec::new()).push(s.to_string());
    }

    let mut penalty = 0;
    let mut ans = 0;

    for v in map.values() {
        let mut tmp_pena = 0;
        for vv in v.iter() {
            if vv == "WA" {
                tmp_pena += 1;
            } else {
                ans += 1;
                penalty += tmp_pena;
                break
            }
        }
    }

    println!("{} {}", ans, penalty);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 20828
#include<iostream>
#include<string>
using namespace std;
int main(){

	int n,answer=0;
	//unsigned int judge;
	string s,ring,ring2;
	cin >> s;
	cin >> n;

	for(int i=0;i<n;i++){
        cin >> ring;
        ring2 = ring + ring;
        //judge = ring2.find(s);
        if(ring2.find(s) != string::npos)answer++;
	}
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからbまで
#define print(x) cout<<x<<endl  //xを改行付きで出力
#define scan(x) cin>>x //xを入力
const int INF = 1e9 + 7;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
/
/
*/
string s;
cin>>s;
sort(s.begin(),s.end());
if(s == "abc")print("Yes");
else print("No");
return 0;
}


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

int main(){
    int k ;
    ll sum=0;
    cin>>k;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                sum +=__gcd(__gcd(a,b),c);
            }
        }
    }
    cout << sum;
}

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

class Program
{
    static void Main(string[] args)
    {
        var x = long.Parse(Console.ReadLine());

        long b = 0;
        long a = 0;

        for (a = -300; a < 300; a++)
        {
            for (b = -300; b < 300; b++)
            {
                if (Math.Pow(a, 5) - Math.Pow(b, 5) == x) goto ans;
            }
        }

    ans:
        Console.WriteLine($"{a} {b}");
    }
}

Measured memory_bytes: 27868
#include <cstring>
#include <cstdio>
#include <algorithm>
const int MAXN = 105;
using namespace std;

int H, W, ER, EC;
int prefR[MAXN][MAXN], prefC[MAXN][MAXN], dp[MAXN][MAXN][MAXN][MAXN];
char str[2];

inline int sumR(int x, int l, int r) { if(l > r) return 0; return prefR[x][r] - prefR[x][l - 1]; }
inline int sumC(int x, int l, int r) { if(l > r) return 0; return prefC[r][x] - prefC[l - 1][x]; }
inline void update(int &x, int y) { x = (x > y) ? x : y; }

int main() {
	scanf("%d%d", &H, &W);
	for(int r = 1; r <= H; r++) for(int c = 1; c <= W; c++) {
		scanf("%1s", str);
		if(str[0] == 'o') prefR[r][c] = prefC[r][c] = 1;
		else if(str[0] == 'E') ER = r, EC = c;
	}

	for(int r = 1; r <= H; r++) for(int c = 1; c <= W; c++) prefR[r][c] += prefR[r][c - 1];
	for(int c = 1; c <= W; c++) for(int r = 1; r <= H; r++) prefC[r][c] += prefC[r - 1][c];

	int Ans = 0;
	for(int l = 0; EC - l >= 1; l++)
		for(int r = 0; EC + r <= W; r++)
			for(int u = 0; ER - u >= 1; u++)
				for(int d = 0; ER + d <= H; d++)
	{
		int RL = d + 1, RR = H - u, CL = r + 1, CR = W - l;

		update(dp[l + 1][r][u][d],
			dp[l][r][u][d] + ( (EC - (l + 1) >= CL) ? sumC( EC - (l + 1), max(RL, ER - u), min(RR, ER + d) ) : 0 ) );
		update(dp[l][r + 1][u][d],
			dp[l][r][u][d] + ( (EC + (r + 1) <= CR) ? sumC( EC + (r + 1), max(RL, ER - u), min(RR, ER + d) ) : 0 ) );
		update(dp[l][r][u + 1][d],
			dp[l][r][u][d] + ( (ER - (u + 1) >= RL) ? sumR( ER - (u + 1), max(CL, EC - l), min(CR, EC + r) ) : 0 ) );
		update(dp[l][r][u][d + 1],
			dp[l][r][u][d] + ( (ER + (d + 1) <= RR) ? sumR( ER + (d + 1), max(CL, EC - l), min(CR, EC + r) ) : 0 ) );

		update(Ans, dp[l][r][u][d]);
	}

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


Measured memory_bytes: 242816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1;i<100000; i++) {
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }


VV G;
V cl;

bool dfs(int u, int x = 0) {
  if (cl[u] == x) return true;
  if (cl[u] == (x^1)) return false;
  cl[u] = x;
  bool res = true;
  for (auto v : G[u]) res &= dfs(v, x^1);
  return res;
}


int main() {
  ll n, m; cin >> n >> m;
  
  G.assign(n, V());
  cl.assign(n, -1);

  rep(i, m) {
    int u, v; cin >> u >> v;
    --u; --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  Vll cnt(3);

  rep(i, n) {
    if (cl[i] != -1) continue;
    if (sz(G[i]) == 0) {
      ++cnt[2];
      continue;
    }
    int p = dfs(i);
    ++cnt[p];
  }

  ll ans = 0;
  ans += n*n - (n-cnt[2]) * (n-cnt[2]);
  ans += (cnt[0]+cnt[1]) * (cnt[0]+cnt[1]);
  ans += cnt[1] * cnt[1];

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


Measured memory_bytes: 12924
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    string s; cin >> s;

    bool flag = false;

    for (int i = 0; i < s.length() - 1; i += 2) {
        if(s.length() % 2 != 0){
            flag = false;
            break;
        }
        if(s[i] == 'h' && s[i + 1] == 'i'){
            flag = true;
        }else{
            flag = false;
            break;
        }
    }
    if(flag)print("Yes");
    else print("No");
}

Measured memory_bytes: 256
A = [0]*3
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [0]*N
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0:
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	N := getStdinInt64()
	Nori := N
	arr := make([]bool, int(math.Sqrt(float64(N)))+1)

	// 初期化
	for i := 2; i < len(arr); i++ {
		arr[i] = true
	}
	// 素数を求める
	arr[0] = false
	arr[1] = false
	for i := 2; i < len(arr); i++ {
		if arr[i] {
			for j := i * 2; j < len(arr); j += i {
				arr[j] = false
			}
		}
	}
	// 割り切れるか判定（素因数分解）
	cnt := 0
	var i int64
	for i = 2; int(i) < len(arr); i++ {
		if arr[i] && (N%i) == 0 {
			mul := i
			pow := 1
			for {
				if N%mul == 0 {
					cnt++
					N /= mul
					pow++
					mul = 1
					for n := 0; n < pow; n++ {
						mul *= i
					}
				} else {
					break
				}
			}
			if N <= 1 {
				break
			}
		}
	}
	// 素因数分解のあまり
	if N > 1 && int(N) > len(arr) {
		cnt++
	}

	if cnt == 0 && (Nori == 0 || Nori == 1) {
		fmt.Printf("%d\n", 0)
	} else if cnt == 0 {
		fmt.Printf("1\n")
	} else {
		fmt.Printf("%d\n", cnt)
	}
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 3176
#include <stdio.h>

int main(void)
{
    int w, n, i, v[30];

    scanf("%d %d", &w, &n);

    for (i = 0; i < w; i++)
        v[i] = i + 1;

    for (i = 0; i < n; i++) {
        int a, b, t;

        scanf("%d,%d", &a, &b);

        t = v[a - 1];
        v[a - 1] = v[b - 1];
        v[b - 1] = t;
    }

    for (i = 0; i < w; i++)
        printf("%d\n", v[i]);

    return 0;
}

Measured memory_bytes: 596
n = input()
n = int(n)
str = input()
val = [0]
x = 0
for _ in range(n):
  o = str[:1]
  if o == 'D':
    x -= 1
  else:
    x += 1
  val.append(x)
  str = str[1:]
print(max(val))

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (a == 0 && b == 0) break;
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    if (j != b - 1) {
                        System.out.print("#");
                    } else {
                        System.out.println("#");
                    }
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    vector<ll >v[n+10];
    ll i,j,k;
    ll a,b;
    for(i=0; i<n; i++)
    {
        cin>>a>>b;
        j=a+b;
        v[0].push_back(j);
        j=a-b;
        v[1].push_back(j);
        j=-a+b;
        v[2].push_back(j);
    }
    for(i=0; i<3; i++)
    {
        sort(v[i].begin(),v[i].end());
    }
    ll res=0;
    for(i=0; i<3; i++)
    {
        n=v[i].size();
        res=max(res,(v[i][n-1]-v[i][0]));
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 12848
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	double ans = (W * H) / 2.0;
	printf("%.10lf %d", ans, (x == W / 2 && y == H / 2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



ll power(ll a, ll b) {
    ll ans = 1;
    ll t = a;
    while (b) {
        if (b % 2) {
            ans = (ans * t) % 998244353;
        }

        t = (t * t) % 998244353;
        b /= 2;
    }

    return ans;
}



int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    int n;
    cin >> n;
    pair<int, int> a[n];
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

    double ans = 0;
    int fact = 1;
    for (int i = 2; i < n; i++) fact *= i;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ll x = abs(a[i].first - a[j].first);
            ll y = abs(a[i].second - a[j].second);
            ans += fact * sqrt(x * x + y * y);
        }
    }

    cout << 2 * ans / (fact * n);
}


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

int main(){
    int x,y,n;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0)break;
        if(x > y){
            n=y; y=x; x=n;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
n = int(input())
import sys
sys.setrecursionlimit(1000000+1)
s = input()

ce = {}
#iより右に居て，東を向いている人の数
def counte(s,i):
    if i in ce:
        return ce[i]
    elif i == n-1:
        return 0
    else:
        ce[i] = counte(s,i+1) + s[i+1:i+2].count("E")
        return ce[i]

cw = {}
#iより←に居て，西を向いている人の数
def countw(s,i):
    if i in cw:
        return cw[i]
    elif i == 0:
        return 0
    else:
        cw[i] = countw(s,i-1) + s[i-1:i].count("W")
        return cw[i]

minew = n
for i in range(0,n):
    ew = counte(s,i)+countw(s,i)
    if ew < minew:
        minew = ew
print(minew)

Measured memory_bytes: 298272
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    L = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                a, b, c = L[i], L[j], L[k]
                if a == b or b == c or c == a: continue
                if a + b > c and b + c > a and c + a > b:
                    ans += 1
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 67936
import heapq
from numpy import ceil,sum
N,M = (int(x) for x in input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)
for i in range(M):
    t1 = heapq.heappop(A)
    t2 = t1 / 2
    heapq.heappush(A, t2)
B = ceil(A)
print(int(sum(B)*(-1)))

Measured memory_bytes: 23148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

int		main(void)
{
	int t_hp, t_at, a_hp, a_at;
	cin >> t_hp >> t_at >> a_hp >> a_at;
	bool turn = true;
	while (t_hp > 0 && a_hp > 0)
	{
		if (turn)
			a_hp -= t_at;
		else
			t_hp -= a_at;
		turn = !turn;
	}
	if (t_hp > 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3592
a = input()
def atcoder(p):
    count = 0
    if p[0]=='A':
        count += 1
    
    count_C=0
    for i in range(len(p)-2):
        if p[i+2]=='C':
            count_C += 1
    if count_C == 1:
        count += 1
    
    count_c = 0
    for i in range(len(p)-1):
        if p[i].upper() ==p[i]:
            count_c+=1
    if p[len(p)-1]==p[len(p)-1].upper():
        count_c+=2
    if len(p)==3:
        count_c+=2
    if count_c ==2:
        count += 1
    
    
    if count ==3:
        print('AC')
    else:
        print('WA')
         
atcoder(a)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

bool is_odd_digit(int x) {
	int digit = 0;
	while(x > 0) {
		x /= 10;
		digit++;
	}
	return digit % 2 == 1;
}

int main() {
	int N; cin >> N;
	int cnt = 0;
	repp(x, 1, N) {
		cnt += is_odd_digit(x);
	}
	cout << cnt << "\n";
}

Measured memory_bytes: 256
# ABC125C - GCD on Blackboard
from fractions import gcd


class SegmentTree:
    def __init__(
        self,
        init_val: "initial value: Array or str",
        segfunc: "operation unique in case",
        ide_ele: "identity element corresponding init_val" = 0,
    ):
        self.segfunc = segfunc
        self.size = 1 << (len(init_val) - 1).bit_length()
        self.ide_ele = ide_ele
        self.tree = self._build(init_val)

    def _build(self, init_val: "Array or str"):
        tree = [self.ide_ele] * (2 * self.size)

        for idx, val in enumerate(init_val):  # set
            # modify val if needed (e.g. str -> ord())
            tree[idx + self.size - 1] = val

        for idx in range(self.size - 2, -1, -1):  # build
            tree[idx] = self.segfunc(tree[2 * idx + 1], tree[2 * idx + 2])
        return tree

    def update(self, idx: int, val):
        idx += self.size - 1
        # modify val if needed as same as in _build()
        self.tree[idx] = val
        while idx > 0:
            idx = (idx - 1) // 2
            self.tree[idx] = self.segfunc(
                self.tree[2 * idx + 1], self.tree[2 * idx + 2]
            )

    def query(self, left: int, right: int):
        if left >= right:
            return self.ide_ele

        left += self.size
        right += self.size
        ret = self.ide_ele
        while left < right:
            if left & 1:
                ret = self.segfunc(ret, self.tree[left - 1])
                left += 1
            if right & 1:
                right -= 1
                ret = self.segfunc(ret, self.tree[right - 1])
            left >>= 1
            right >>= 1
        return ret


def main():
    N, *A = map(int, open(0).read().split())
    seg = SegmentTree(A, gcd)
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int check( string S )
{
    //A
    if( S[ 0 ] == '>' && S[ 1 ] == '\'' && S[ S.size() - 1 ] == '~' && S.size() >= 6 )
    {
        S = S.substr( 2, S.size() - 3 );
        if( S.find_first_not_of( "#=", 0 ) != string::npos ) return 0;
        return S.substr( 0, S.find('#') ).size() == S.substr( S.find( '#' ) + 1, S.size() - 1 ).size() ? 1 : 0;
    }
    //B
    if( S[ 0 ] == '>' && S[ 1 ] == '^' && S[ S.size() - 1 ] == '~' && S[ S.size() - 2 ] == '~' && S.size() >= 6 )
    {
        S = S.substr( 2, S.size() - 4 );
        if( S.find_first_not_of( "Q=", 0 ) != string::npos || S.size() % 2 != 0 ) return 0;
        for( int i = 0; i < S.size(); i += 2 )
        {
            if( S[ i ] != 'Q' && S[ i + 1 ] != '=' ) return 0;
        }
        return 2;
    }
    return 0;
}
int main()
{
    int N;
    cin >> N;
    
    vector<string> res{ "NA", "A", "B" };
    string S;
    
    while( cin >> S )
    {
        cout << res[ check( S ) ] << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a+b == c+d) {
    cout << "Balanced" << endl;
  }else if(a+b < c+d) {
    cout << "Right" << endl;
  }else{
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define inf 0x3f3f3f3f
using namespace std;

struct node
{
    int xi,ni;
    int omrk,nowm;
    int num;
}x[100005];
int cmp(node a,node b)
{
    if(a.xi==b.xi)
        return a.ni<b.ni;
    else
        return a.xi<b.xi;
}
int cmp1(node a,node b)
{
    return a.omrk<b.omrk;
}
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        for(int i=0;i<m;i++)
        {
            cin>>x[i].xi>>x[i].ni;
            x[i].omrk=i;
        }
        sort(x,x+m,cmp);
        int mmm=x[0].xi,fff=0;
        for(int i=0;i<m;i++)
        {
            x[i].nowm=i+1;
            if(x[i].xi==mmm)
            {
                x[i].num=++fff;
            }
            else
            {
                mmm=x[i].xi;
                fff=0;
                x[i].num=++fff;
            }
        }
        sort(x,x+m,cmp1);
        for(int i=0;i<m;i++)
        {
            printf("%06d%06d\n",x[i].xi,x[i].num);
        }
    }
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  vvi a(n,vi(m));
  rep(i,n)rep(j,m) a[i][j] = in()-1;
  int ans = INF;
  vi used(m);
  vi s(n);
  rep(mi,m) {
    vi cnt(m);
    rep(i,n) {
      while (used[a[i][s[i]]]) ++s[i];
      cnt[a[i][s[i]]]++;
    }
    P p(0,0);
    rep(i,m) maxs(p,P(cnt[i],i));
    mins(ans,p.fi);
    used[p.se] = 1;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 640
R,C = map(int,input().split())
graph = [[i for i in input()] for j in range(R)]
visited = [[False for i in range(C)] for j in range(R)]

def dfs(start_y,start_x):
  queue = [[start_y,start_x,0]]
  while queue:
    now = queue.pop(0)
    visited[now[0]][now[1]] = True
    for next in [[1,0],[-1,0],[0,1],[0,-1]]:
      if now[0]+next[0] < 0 or now[1]+next[1] < 0: continue
      if now[0]+next[0] > R-1 or now[1]+next[1] > C-1: continue
      if visited[now[0]+next[0]][now[1]+next[1]]: continue
      if graph[now[0]+next[0]][now[1]+next[1]]=='#': continue
      queue.append([now[0]+next[0],now[1]+next[1],now[2]+1])
      visited[now[0]+next[0]][now[1]+next[1]] = True
  return now[2]

ans = 0
for row_s in range(R):
  for column_s in range(C):
      if graph[row_s][column_s]=='#': continue
      visited = [[False for i in range(C)] for j in range(R)]
      ans = max(ans,dfs(row_s,column_s))
    
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
  
using namespace std;
  
const int mod = 1e9 + 7;
  
int N;
vector< int > tree[100000];
unordered_map< int, int > val;
long long ret;
  
int dfs(int idx, int par = -1)
{
  int hashed = 1;
  for(int to : tree[idx]) {
    if(to != par) (hashed += 1LL * dfs(to, idx) * 1003 % mod) %= mod;
  }
  ret += val[hashed]++;
  return(hashed);
}
  
int main()
{
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    --A, --B;
    tree[A].push_back(B);
    tree[B].push_back(A);
  }
  dfs(0, -1);
  cout << ret << endl;
}

Measured memory_bytes: 18744
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N;
int A, B;
int P[111];

int main(void) {
    cin >> N;
    cin >> A >> B;
    REP(i, N) cin >> P[i];
    sort(P, P + N);
    int ans = 0;
    int l1 = 0, l2 = 0, l3 = 0;
    REP(i, N) {
        if (P[i] <= A) l1++;
        else if (P[i] <= B) l2++;
        else l3++;
    }
    cout << min({l1, l2, l3}) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}



int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  int cnt=0;
  rep(i,n){
	  if(s[i] == 'R'){
		  cnt++;
	  }
  }
  if(cnt == 0||cnt == n){
	  cout << "0" << endl;
	  return 0;
  }
  int ans = 0;
  rep(i, cnt){
	  if(s[i] == 'W'){
		  ans++;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3720
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        Int ans = (N - 1) * N / 2;
        cout << ans << endl;
    }

};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	string S; cin >> S;
	bool flag = true;
	for (int i = 0; i < 3; i++) {
		if (S[i] == S[i + 1]) flag = false;
	}
	if (flag) cout << "Good" << endl;
	else cout << "Bad" << endl;

	return 0;
}

Measured memory_bytes: 256
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int n;
    public static int N = 100;
    public static int[][] M = new int[N][N];
    public static int INF = 10000007;
    public static int NIL = -1;
    public static int WHITE = 0;
    public static int GRAY = 1;
    public static int BLACK = 2;

    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                M[i][j] = INF;
            }
        }
        for(int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int k = sc.nextInt();
            for(int j = 0; j < k; j++) {
                int c = sc.nextInt();
                int d = sc.nextInt();;
                M[i][c] = d;
            }
        }

        //??????
        prim();
    }

    public static void prim() {
        int[] color = new int[n];
        int[] d = new int[n];
        int[] p = new int[n];
        for(int i = 0; i < n; i++) {
            color[i] = WHITE;
            d[i] = INF;
        }
        d[0] = 0;
        p[0] = NIL;

        while(true) {
            int mincost = INF;
            int u = 0;
            for(int i = 0; i < n; i++) {
                if(color[i] != BLACK && d[i] < mincost) {
                    mincost = d[i];
                    u = i;
                }
            }
            if(mincost == INF) break;
            color[u] = BLACK;
            for(int i = 0; i < n; i++) {
                if(color[i] != BLACK && M[u][i] + d[u] < d[i]) {
                    d[i] = M[u][i] + d[u];
                    color[i] = GRAY;
                    p[i] = u;
                }
            }
        }
        for(int i = 0; i < n; i++) {
            System.out.println(i + " " + d[i]);
        }

    }



}

Measured memory_bytes: 40456
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

// i, mx(i, n) diff -> highest
// then you need to reduce the highest or increse the lowest by 1
const int N = 100 * 1000 + 5; 
vector <int> v[N];
vector <bool> vis(N, false);
int ev = 0, od = 0;
void dfs(int s, int c) {
	vis[s] = true;
	ev += (c % 2 == 0);
	od += (c % 2 == 1);
	for (auto g: v[s]) {
		if (!vis[g]) {
			dfs(g, c + 1);
		}
	}
}
int main() {
	int n, t;
	cin >> n >> t;
	vector <int> A(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> A[i];
	}
	int mx = 0, mxPos = 0;
	int diff = 0;
	vector <int> nxt(n + 1);
	for (int i = n; i >= 1; i--) {
		if (mx < A[i]) {
			mx = A[i];
			mxPos = i;
		}
		nxt[i] = mxPos;
		diff = max(diff, mx - A[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (A[nxt[i]] - A[i] == diff) {
			v[i].push_back(nxt[i]);
			v[nxt[i]].push_back(i);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			ev = 0;
			od = 0;
			dfs(i, 0);
			ans += min(ev, od);
		}
	}
	cout << ans;
}


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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  
  double Z = 10000 * E / (100 + E);
  int noudo = 0;   
  int ansW = min(100 * A, 100 * B);
  int ansS = 0;
  int satou = 0;
  for (int i = 0; i <= F / 100; i++) {
    for (int j = 0; j <= (F - A * i * 100) / 100; j++) {
      for (int k = 0; k <= (F - (A * i + B * j) * 100) / C; k++) {
        for (int l = 0; l <= (F - (A * i + B * j) * 100 - C * k) / D; l++) {
          int W = 100 * (A * i + B * j) + C * k + D * l;
          satou = C * k + D * l;
          if (W == 0) continue;
          double M = 10000 * satou / W;
          if (M <= Z && noudo < M) {
            noudo = M;
            ansW = W;
            ansS = satou;
          }
        }
      }
    }
  }
  cout << ansW << " " << ansS << endl;
}

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

int main(){
    int n,k; cin >> n >> k;
    int ans = 1;
    for(int i=0;i<n;i++){
        if(ans*2 > ans + k){
            ans += k;
        }else{
            ans *= 2;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())

l = [list(map(int, input().split())) for i in range(M)]

r = np.zeros(3)
r -= 1

f = True
for i, j in l:
    i -= 1
    if N < i+1:
        f = False
        continue
    if N != 1 and i == 0 and j == 0:
        f = False
        continue
    if r[i] != -1 and r[i] != j:
        f = False
        continue
    if r[i] == -1:
        r[i] = j
if f:
    l = ['1' if i == 0 and j == -1 else str(int(max(j, 0))) for i, j in enumerate(r)]
    s = ''.join(l)
    if N == 3:
	    print(s)
    elif N == 2:
      	print(s[:2])
    elif N == 1 and M == 0:
        print(0)
    else:
        print(s[:1])
else:
    print(-1)


Measured memory_bytes: 12504
import           Control.Monad

main :: IO ()
main = do
  [n, m] <- readInts
  students <- replicateM n readInts
  checkpoints <- zipWith (:) [1..] <$> replicateM m readInts
  forM_ students $ print . solve checkpoints

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: [[Int]] -> [Int] -> Int
solve checkpoints [a, b]
  = minimum
  $ map head
  $ filter (\[i, dist] -> dist == dist_min) dists
    where
      dists = map (\[i, c, d] -> [i, abs (c - a) + abs (d - b)]) checkpoints
      dist_min = minimum [ dist | [_, dist] <- dists ]

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int ans = 0;
	if(a==b&&a!=c)
	{
		ans = 1;
	}
	else
	{
		if(a==c&&a!=b)
		{
			ans = 1;
		}
		else
		{
			if(b==c&&b!=a)
			{
				ans = 1;
			}
		}
	}
	if(ans==1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,maxx,now,i;char c[105];
int main(){
	scanf("%d%s",&n,c);
	for(i=0;i<n;i++){
		c[i]=='I'?now++:now--;
		if(now>maxx) maxx=now;
	}
	printf("%d\n",maxx);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 1048576
char s[N];

int main(){
	int n; scanf("%d%s", &n, s);
	REP(i, n) s[i] -= '1';
	bool all2 = true;
	REP(i, n) if(s[i] == 1) all2 = false;
	int ans = 0;
	REP(i, n){
		if((i & (n-1)) == i) {
			ans ^= s[i];
		}
	}
	if(!all2) ans &= 1;
	printf("%d\n", ans);
}


Measured memory_bytes: 1280
from collections import deque
S=input().strip()
N=len(S)

a=[0 if x == '0' else 1 for x in S]

q = deque()
for i in a:
    if q:
        if q[-1] != i:
            q.pop()
        else:
            q.append(i)
    else:
        q.append(i)

print(N-len(q))


Measured memory_bytes: 10624