akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long ll;
struct edge{
  int from,to,cost;
};
typedef vector<vector<edge> > AdjList;
AdjList graph;
typedef pair<int , int> P;

//esに辺を入れる頂点数V,辺の数E
//クラスカル union-find必須
bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}
edge es[400001];
ll kruskal(ll E,ll V){
  sort(es,es+E,comp);
  init(V);
  int res = 0;
  for(int i=0;i<E;i++){
    edge e = es[i];
    if(!same(e.to,e.from)){
      unite(e.to,e.from);
      res += e.cost;
    }
  }
  return res;
}
//クラスカル終わり

int main()
{
  int N,x,y,cn=0;
  pair<P,int> p[100001];
  cin >> N;
  REP(i,N){
    cin >> x >> y;
    P d;
    d.first = x;
    d.second = y;
    p[i].first = d;
    p[i].second = i;
  }
  sort(p,p+N);
  REP(i,N-1){
    P d1 = p[i].first;
    P d2 = p[i+1].first;
    int pos1=p[i].second,pos2=p[i+1].second;
    es[cn++] = (edge){pos1,pos2,min(abs(d1.first-d2.first),abs(d1.second-d2.second))};
    es[cn++] = (edge){pos2,pos1,min(abs(d1.first-d2.first),abs(d1.second-d2.second))};
  }
  REP(i,N){
    swap(p[i].first.first,p[i].first.second);
  }
  sort(p,p+N);
  REP(i,N-1){
    P d1 = p[i].first;
    P d2 = p[i+1].first;
    int pos1=p[i].second,pos2=p[i+1].second;
    es[cn++] = (edge){pos1,pos2,min(abs(d1.first-d2.first),abs(d1.second-d2.second))};
    es[cn++] = (edge){pos2,pos1,min(abs(d1.first-d2.first),abs(d1.second-d2.second))};
  }
  cout << kruskal(cn,N) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 6912
#include<cstdio>
#include<vector>
#include<algorithm>
using std::vector;
using std::sort;
long long rnum[400500];
vector <long long> G[400500];
long long f[400500],col[400500];
long long find(long long x){
	if(f[x]==x) return x;
	return f[x]=find(f[x]);
}
long long num[400500];
long long n,m,a,b;
int main(){
	scanf("%lld%lld",&n,&m);
	int cnt=0;
	for(long long i=0;i<=n+5;i++) f[i]=i;
	for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
	for(int i=1;i<=m;i++){
		scanf("%lld%lld",&a,&b);
		a++; b++;
		a=find(a);b=find(b);
		if(a!=b){f[b]=a;++cnt;}
	}
	m=n-cnt;
	if(n<2*(m-1)){
		puts("Impossible");
		return 0;
	}
	cnt=0;
	if(m==1){puts("0");return 0;}
	for(int i=1;i<=n;i++){
		G[find(i)].push_back(num[i]);
		if(i==f[i]) col[++cnt]=i;
	}
	for(int i=1;i<=m;i++) sort(G[col[i]].begin(),G[col[i]].end());
	long long sum=0ll;
	long long siz=0;
	for(int i=1;i<=m;i++){
		sum+=G[col[i]][0];
		for(int j=1;j<G[col[i]].size();j++)
			rnum[++siz]=G[col[i]][j];
	}
	sort(rnum+1,rnum+siz+1);
	for(int i=1;i<=m-2;i++) sum+=rnum[i];
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 19456
#include <stdio.h>

int selectionSort(int A[], int N) {
    int i,j,minj,dummy;
    int count =0;

    for(i=0;i<N;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j] < A[minj]) minj = j;
        }
        
        if(minj != i) {
            dummy = A[i];
            A[i] = A[minj];
            A[minj] = dummy;

            count ++;
        }
    }
    return count;
}

int main(void) {
    int N,i,count;
    int A[100];

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    count = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 604
package main

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

// main is...
func main() {
	var n int
	fmt.Scanln(&n)

	var sc = bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		array := strings.Fields(sc.Text())[:n]
		fmt.Print(run(array))
	}
}

func calc(array []int) int {
	return array[2] - (array[0] - array[1])
}

// run is run
func run(array []string) float32 {
	// var arrayInt = make([]float32, len(array))
	var sum float32

	// for i := 0; i < len(array); i++ {
	for _, value := range array {
		valueInt, _ := strconv.Atoi(value)
		// arrayInt[idx] = 1 / float32(valueInt)
		sum += 1 / float32(valueInt)
	}

	// if ret := calc(arrayInt); ret > 0 {
	// 	return ret
	// }
	return 1 / sum
}



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

int main()
{
  int n;
  int num[2000000];
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> num[i];
  }
  sort(num, num + n);
  for (int i = 0; i < n - 1; i++){
    cout << num[i] << ' ';
  }
  cout << num[n - 1] << endl;
  return (0);
}

Measured memory_bytes: 8972
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	for(int i=1;i<=n;i++)
	{
		int x=read();
		if(x%2==0)
		{
			if(x%3==0||x%5==0) continue;
			cout<<"DENIED\n";
			return 0;
		}
	}
	cout<<"APPROVED\n";
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 



int main (){
    int n; cin >> n;
    vector<vector<int>> to(n), cost(n);
    rep(i,n-1){
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        to[u].push_back(v);
        to[v].push_back(u);
        cost[u].push_back(w);
        cost[v].push_back(w);
    }
    
    vector<int> ans(n, -1); //-1で初期化
    
    ans[0] = 0;
    
    queue<int> q;
    q.push(0);
    
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i = 0; i<to[v].size(); i++){
            int u = to[v][i];
            int w = cost[v][i];
            if(ans[u] != -1) continue;
            if(w%2==0) {
                ans[u] = ans[v];
            }else{
                ans[u] = 1^ans[v];
            }
            q.push(u);
        }
    }
    
    rep(i,n){
        cout << ans[i] << endl;
    }



}


Measured memory_bytes: 11904
import java.util.Scanner;


public class Main{
 	
  	public static void main(String args[]){
     	Scanner sc=new Scanner(System.in);
      	String s=sc.next();
        String t=sc.next();
      int cnt=0;
      	for(int i=0;i<s.length();i++){
			if(s.charAt(i)!=t.charAt(i)){
              cnt++;
            }
        }
      System.out.println(cnt);
    }
 
}


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

int main(void){
  int flg[200]={0};
  int n, k, ans;
  
  cin >> n >> k;
  for (int i=0; i<k; i++){
    int d; cin >> d;
    for (int j=0; j<d; j++){
      int a; cin >> a;
      flg[a-1] = 1;
    }
  }
  ans=0;
  for (int i=0; i<n; i++){
    ans += 1-flg[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

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

		while(stdIn.hasNext()){
			long numA = stdIn.nextLong();
			long numB = stdIn.nextLong();
			long GCD = getGCD(numA,numB);				//最大公約数
			long LCM = getLCM(numA,numB);				//最小公倍数
			System.out.println(GCD + " " + LCM);
		}
	}

	//++++++++++++++++++++++++++++++++++++++++++++++++++
	//最大公約数(GCD)取得メソッド
	//++++++++++++++++++++++++++++++++++++++++++++++++++
	public static long getGCD(long numA,long numB){
		//以下、ユークリッドの互除法
		if(numA > numB){
			long temp = numA;
			numA = numB;
			numB = temp;
		}
		long r;
		while(0 != numB){
			r = numA % numB;
			numA = numB;
			numB = r;
		}
		long GCD = numA;

		return GCD;
	}

	//++++++++++++++++++++++++++++++++++++++++++++++++++
	//最小公倍数(LCM)取得メソッド
	//++++++++++++++++++++++++++++++++++++++++++++++++++
	public static long getLCM(long numA,long numB){
		long LCM = 0L;
		LCM = numA / getGCD(numA,numB) * numB;
		return LCM;
	}
}

Measured memory_bytes: 11000
N, M = map(int, input().split())
l = list(map(int, input().split()))

if (N>= M) or (M == 1):
    print(0)
else:
    l.sort()
    l_dist =[]

    for i in range(1, M):
        l_dist.append(abs(l[i]-l[i-1]))

    l_dist.sort()

    ans = sum(l_dist[:len(l_dist) - (N-1)])

    print(ans)

Measured memory_bytes: 13968
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=1000000000
s=[]
for j in range(a[0],a[-1]+1):
  k=0
  for i in range(n):
    k+=(a[i]-j)**2
  s.append(k)
print(min(s))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    const int H, N;
    scanf("%d %d", &H, &N);
    int total = 0;
    for(int i = 0; i < N; i++){
        int a;
        scanf("%d", &a);
        total += a;
    }
    printf(total < H ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a = 0, b = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (auto ch : s) {
        if (ch == 'R') {
            a++;
        } else {
            b++;
        }
    }
    if (a > b) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
import javax.smartcardio.CommandAPDU;
import java.io.* ;
import java.lang.reflect.Array;
import java.util.* ;
import java.math.* ;
public class Main
{
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input)
    {
        reader = new BufferedReader(new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException
    {
        while (!tokenizer.hasMoreTokens())
        {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static long nextInt() throws IOException
    {
        return Long.parseLong(next());
    }

    public static int ri() throws IOException
    {
        return (int) nextInt();
    }

    public static long rl() throws IOException
    {
        return nextInt();
    }

    public static double rd() throws NumberFormatException, IOException
    {
        return Double.parseDouble(next());
    }

    static void print_a(int[] arr)
    {
        for (int i = 0; i < arr.length; i++)
        {
            print(arr[i] + " ");
        }
        println();
    }

    public static int[] ria(int n) throws IOException
    {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = ri();
        }
        return a;
    }

    public static long[] rla(int n) throws IOException
    {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = rl();
        }
        return a;
    }

    public static int p(int i)
    {
        return (int) Math.pow(2, i);
    }

    static PrintWriter writer;

    static void outit(OutputStream outputStream)
    {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    static void print(Object... objects)
    {
        for (int i = 0; i < objects.length; i++)
        {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }
    static void println(Object... objects)
    {
        print(objects);
        writer.println();
        flush();
    }
    static void close()
    {
        writer.close();
    }

    static void flush()
    {
        writer.flush();
    }

    public static void main(String[] args) throws IOException
    {
        init(System.in);
        outit(System.out);
//        int t = (int) nextInt();
//        for (int i = 0; i < t; i++)
        output();
        flush();
        close();
    }
    static int n ;
    static long mod = 1000000007 ;
    static long [] pre ;
    public static void output() throws IOException
    {
        long [] ctr = new long[26];
        String s = next() ;
        long ans = 0 ;
        for (int i = s.length()-1; i>=0 ; i--)
        {
            int c = s.charAt(i)-'a' ;
            for (int j = 0; j <26 ; j++)
            {
                if(c!=j)
                {
                    ans+=ctr[j] ;
                }
            }
            ctr[c]++ ;
        }
        println((ans+1)) ;
    }
}

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

int main() {
	int n;
	cin >> n;
	int x[110], y[110]; long long h[110];
	long long H;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	bool flag;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			flag = true;
			for (int k = 0; k < n; k++) {
				if (h[k] >= 1) {
					H = h[k] + abs(x[k] - i) + abs(y[k] - j);
					break;
				}
			}
			for (int k = 0; k < n; k++) {
				if (max(0LL ,H - abs(x[k] - i) - abs(y[k] - j)) != h[k] ) {
					flag = false;
					break;
				}
			}
			if (flag == true) {
				cout << i << ' ' << j << ' ' << H << endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,a,n,b,ara[50],c;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
    }
    long long int s=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            c=ara[i]*ara[j];
            s=s+c;
        }
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int H, N,sum=0;
	cin >> H >> N;
	int A[999999];
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	for (int k = 0;k< N; k++){
		sum += A[k];
	}
	if (sum >= H){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<double>x(N);
	vector<string>y(N);
	double out = 0;
	REP(i, N) {
		cin >> x[i] >> y[i];
		if (y[i][0] == 'J') {
			out += x[i];
		}
		else {
			out += x[i] * 380000;
		}
	}
	print(out);
	


	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];

    ll ret = INF;
    REP(i, 101) {
        ll sum = 0;
        REP(j, n) sum += (x[j]-i)*(x[j]-i);
        chmin(ret, sum);
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int n,m;
    cin>>n>>m;
    int sum=0;
    rep(i,m){
        int a;
        cin>>a;
        sum+=a;
    }
    if(n-sum<0)fin(-1);
    else cout<<n-sum<<endl;
}


Measured memory_bytes: 3624
while True:
  n,x = map(int,input().split())
  if (n,x) ==(0,0):
    break
  c=0
  for i in range(1,n+1):
    for j in range(i+1,n+1):
      for k in range(j+1,n+1):
        if i+j+k==x:
          c+=1
  print(c)  


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

string s,t;

string INF = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
string ans = INF;

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

  for(int i = 0;i + t.size() <= s.size();i++){
    bool ok = true;
    for(int j = 0;j < t.size();j++){
      ok &= (s[i + j] == '?' || s[i + j] == t[j]);
    }
    if(ok){
      string res = s;
      for(int j = 0;j < t.size();j++){
        res[i + j] = t[j];
      }
      for(char& c : res){
        if(c == '?') c = 'a';
      }

      ans = min(ans,res);
    }
  }

  if(ans == INF){
    ans = "UNRESTORABLE";
  }

  cout << ans << endl;
}


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

int main(){
    int n;
    cin >>n;
    int a[10][10]={0};
    for(int i=1;i<=n;i++){
        int si=i%10,ue=i;
        while(ue/10>0){
            ue/=10;
        }
        if(ue*si>0) a[ue][si]++;
    }
    int ans=0;
    rep(i,10) {
        rep(j,10){
            ans+=a[i][j]*a[j][i];
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    string s,t;
    int a,b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(s==u) a--;
    else b--;
    cout << a << ' ' << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k;
int a[50];
unordered_map<int,int> memo[50];
int dp(int id, int sum){
    if (id == n) return (sum == 0);
    if (memo[id][sum] != -1) return memo[id][sum];
    return memo[id][sum] = dp(id+1,sum-a[id]) + dp(id+1,sum);
}
main(){
    scanf("%lld%lld",&n,&k);
    for (int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
        a[i] -= k;
    }
    for (int i = 0; i < n; i++){
        for (int j = -500; j <= 500; j++){
            memo[i][j] = -1;
        }
    }
    printf("%lld",dp(0,0)-1);
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1e9;

typedef long long ll;

#define MAX_V 10000

struct edge {
    int to;
    int cost;
};


int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int f[MAX_V];
bool mem[MAX_V];
int DFS(int u,int time){
  mem[u] = true;
  d[u] = time;
  REP(i,G[u].size()){
    
    if(!mem[G[u][i].to]){
      time++;
      time = DFS(G[u][i].to,time);
    }
  }
  time++;
  f[u] = time;
  return time;
}


int main(){
  int E,r;
  cin >> V;
 
  REP(i,MAX_V){
    mem[i] = false;
  }
  REP(i,V){
    int k,u;
    cin >> u;
    cin >> k;
    for(int j = 1;j <= k;j++){
      int f,t,c;
      cin >> t;
      c = 1;
      edge e = {t,c};
      G[u].pb(e);
    }
  }
  int t = 1;
  for(int i = 1;i <= V;i++){
    if(!mem[i]){
      t = DFS(i,t);
      t++;
    }
  }
  for(int i = 1;i <= V;i++){
    cout << i << " " << d[i] << " " << f[i] << endl;;
  }
  
  return 0;
}



Measured memory_bytes: 3408
import java.util.Scanner;

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

  int l = 0;
  int[] ansans = new int[10000];
    while (true) {
      int n, x, ans = 0;

      n = stdInt.nextInt();
      x = stdInt.nextInt();
      if (n == 0 && x == 0) break;

      for (int i = n; i > 0; i--) {
        for (int j = i-1; j > 0; j--) {
          for (int k = j-1; k > 0; k--) {
            if (i + j + k == x) 
            ans++;
          }
        }
      }
      ansans[l++] = ans;
    }

    for (int i = 0; i < l; i++) {
      System.out.println(ansans[i]);
    }
  }
}


Measured memory_bytes: 26400
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  int n,l;
  cin>>n>>l;
  //////
  int ans=0;
  rep(i,n){
   ans+=l+i; 
  }
  //cout<<ans<<endl;
  if(l>0) ans-=l;
  else if(n+l>0); 
  else ans-=l+n-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(K*2)]

indexs = []
for i in range(len(L)):
    if i%2 != 0:
        indexs.append(L[i])

uniq_list = []
for li in indexs:
    for e in li:
        if e not in uniq_list:
            uniq_list.append(e)

print(N - len(uniq_list))


Measured memory_bytes: 9232
def resolve():
    a,v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())

    if v <= w:
        print("NO")
    else:
        time = abs(b-a) / (v-w)
        if time <= t:
            print("YES")
        else:
            print("NO")
resolve()

Measured memory_bytes: 61680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
const int inf=1e9;
const int N=2e5+20;
const int M=2e3+20;
int a[N];// a[i] 编号i的左右人数之差绝对值为a[i] 求满足条件的排列个数 
map<int,int> mp;
int main()
{
	ll ans=1;
	bool flag=true;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]]++;
		
		if(a[i]&1==n&1)
		{
			//人数为偶数 左右之差肯定也为偶数 (左边如果是偶数 右边则为奇数+自己后总人数为偶数) 
			flag=false; 
		}
	} 
	if(mp[0]>1)
	{
		//左右人数之差为0 只能在中间  
		cout<<0<<endl;
	}
	else
	{

		for(int i=1;i<=n;i++)
		{
			if(mp[i])
			{
				//相同的最多只能有两个 
				if(mp[i]>2)
				{
					flag=false;
					break;
				}
				
				//这两个人的位置可以互换 位置(x,y)有两种选法  
				if(mp[i]==2)
				ans=(ans*2)%mod;
				
			}
		}
		if(!flag)
		cout<<0<<endl;
		else
		cout<<ans<<endl;
	}
	
	return 0;	
} 

Measured memory_bytes: 5376
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int a, b;

signed main(){
	scanf("%ld %ld", &a, &b);
	if(b%a == 0){
		printf("%ld\n", a+b);
	}else{
		printf("%ld\n", b-a);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> p(4); for (auto&& e : p) cin >> e;
  V<> t(4); for (auto&& e : t) cin >> e;
  V<> dp(200, 1e9);
  dp[0] = 0;
  for (int i = 1; i < 200; ++i) {
    for (int j = 0; j < 4; ++j) if (i >= t[j]) {
      dp[i] = min(dp[i], dp[i - t[j]] + p[j]);
    }
  }
  int res = *min_element(begin(dp) + n, end(dp));
  cout << res << '\n';
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int GCD(int a, int b)
{
	if (b == 0)
	{
		return(a);
	}
	return(GCD(b, a % b));
}

void solve()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	if (A[0] < A[1])
	{
		int temp = A[0];
		A[0] = A[1];
		A[1] = temp;
	}
	int ans = A[0];
	for (int i = 1; i < N; ++i)
	{
		ans = GCD(ans, A[i]);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 640
argN = int(input())
argColor = list(input())

cntR = 0
cntB = 0

for i in range(argN):
  if argColor[i] == "R":
    cntR += 1
  else:
    cntB += 1
    
if cntR > cntB:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,l,t;
    cin >> n >> l >> t;
    int arr[n],w[n];
    for (int i = 0; i < n; i++) cin >> arr[i] >> w[i];
    int finpos[n];
    for (int i = 0; i < n; i++){
        if (w[i] == 1) finpos[i] = (arr[i]+t)%l;
        else finpos[i] = (arr[i]+l-t%l)%l;
    }
    int start = 0;
    for (int i = 1; i < n; i++){
        if (w[i] != w[0]){
            int loop = t/l;
            int change = 2*loop;
            int timeleft = t-loop*l;
            if (w[0] == 1){
                int rem = arr[i]-arr[0];
                if (rem/2 < timeleft) change++;
                if ((rem+l)/2 < timeleft) change++;
                start = (start+change%n)%n;
            }
            else{
                int rem = l-arr[i]+arr[0];
                if (rem/2 < timeleft) change++;
                if ((rem+l)/2 < timeleft) change++;
                start = (start+n-change%n)%n;
            }

        }
    }
    int actpos[n];
    actpos[start] = finpos[0];
    sort(finpos,finpos+n);
    int newpos = 0;
    for (int i = 0; i < n; i++){
        if (finpos[i] == actpos[start]) {
            if (w[0] == 1)newpos = i;
            else if (i != n-1 && finpos[i+1] == actpos[start]) newpos = i+1;
            else newpos = i;
            break;
        }
    }
    for (int i = 1; i < n; i++) actpos[(start+i)%n] = finpos[(newpos+i)%n];
    for (int i = 0; i < n; i++) cout << actpos[i] << "\n";
}



Measured memory_bytes: 5192
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    vector<pair<long, long>> pos(N);
    long x,y;
    for(size_t i=0;i<N; i++)
    {
        cin >> x >> y;
        pos[i] = make_pair(x, y);
    }
    long count = 0;
    double total_distance;
    for(size_t i=0;i<N; i++)
    {
        for(size_t j=i+1;j<N; j++)
        {
            total_distance += sqrt(pow(pos[i].first-pos[j].first, 2) + pow(pos[i].second-pos[j].second, 2));
            count++;
        }
    }
    cerr << count << endl;
    cout << fixed << setprecision(10) << total_distance * (N-1)  / count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<vint> s(m);
    rep(i,m){
        cin >> k[i];
        s[i].resize(k[i]);
        rep(j,k[i]){
            cin >> s[i][j];
        }
    }
    vint p(m);
    rep(i,m) cin >> p[i];

    int ans = 0;
    for(int bit=0; bit<(1<<n); bit++){
        bool flag = 1;
        rep(i, m){
            int tmp=0;
            rep(j, k[i]){
                if( (bit >> (s[i][j]-1) )& 1 ) tmp++;
            }
            if(tmp%2 != p[i]){
                flag = 0;
            }
        }
        if(flag){
            ans++;
            // printf("%d\n", bit);
        }
    }
    cout << ans << endl;
}


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

int b[1000000];
int r[1000],c[1000];

int main(){
  int h,w;
  scanf("%d%d",&h,&w);

  for(int i=0;i<h*w;i++){
    scanf("%d",b+i);
    if(!b[i])r[i/w]++, c[i%w]++;
  }

  for(int i=0;i<h*w;i++){
    printf("%d%c",(r[i/w]+c[i%w]+1-b[i])&1,i%w==w-1?'\n':' ');
  }
}

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

int main() {

  while( true ) {

    long long int w, d;
    cin >> w >> d;
    if ( w == 0 ) break;

    vector< long long int > hw, hd;

    for ( long long int i = 0; i < w; i++ ) {
      long long int in;
      cin >> in;
      hw.push_back( in );
    }
    for ( long long int i = 0; i < d; i++ ) {
      long long int in;
      cin >> in;
      hd.push_back( in );
    }
    hw.push_back( 0 );
    hd.push_back( 0 );
    sort( hw.begin(), hw.end() );
    sort( hd.begin(), hd.end() );

    long long int sw = hw.size() - 1;
    long long int sd = hd.size() - 1;

    long long int ans = 0;

    while( sw > 0 || sd > 0 ) {

      if ( hw[sw] == hd[sd] ) {
	ans += hw[sw];
	sw--;
	sd--;
      }else if ( hw[sw] < hd[sd] ) {
	ans += hd[sd];
	sd--;
      }else {
	ans += hw[sw];
	sw--;
      }

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1216
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
using namespace std;
// #define endl '\n'
#define br cout<<endl
#define mem(a) memset(a,0,sizeof(a))
const double pi=3.141592653589793238;
#define d(x) cout<<x<<endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define rev(a) reverse(a.begin(),a.end())
const int inf = 100000000000000000;
#define maxn 1000005
#define mod 998244353
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x) x.begin(),x.end()
#define f(i,n) for(int i=1;i<=n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i+=1)
#define fn(i,k,n) for(int i=k;i>=n;i-=1)
void pv(vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<endl;}
void pa(int a[],int n,int p){for (int i = p; i < n+p; ++i){cout<<a[i]<<" ";}cout<<endl;}
int modexp(int x,int y) {
   int res = 1;
   x = x % mod;
   while (y > 0){
       if (y & 1LL)
           res = (res*x) % mod;
       y = y>>1;
       x = (x*x) % mod;  
   }
   return res;
}
int invmod(int a) {
    return modexp(a,mod-2);
}
vector<int> edge[maxn];
void ipgraph(int n,int m) {
    fp(i,1,n) edge[i].clear();
    if(m==0) return;
   fp(i,1,m) {
       int a,b;
       cin>>a>>b;
       edge[a].pb(b);
       edge[b].pb(a);
   } 
}
/*
void dfs(int node,int p)
{
    for(int u : edge[node]) 
    {
        if(u!=p)
        {
            dfs(u,node);
        }
    }
}
*/
///////////////////////////////////////////////////////////////////////////////////
void solve()
{
    int x;
    cin>>x;
    d(!x)
}
int32_t main()
{
   IOS;
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
    #endif
   int t=1;
    //cin>>t;
   fp(i,1,t)
   {
       //cout<<"Case "<<i<<": ";
       solve();
   }
}


Measured memory_bytes: 27084
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<< a*b/2<<endl;

}

Measured memory_bytes: 256
def solve():
    n = int(input())
    hs = list(map(int, input().split(' ')))
    left = len(list(filter(lambda x: x != 0, hs)))
    count = 0
    while left != 0:
        start, length = tops(hs)
        for i in range(start, start+length):
            hs[i] -= 1
            if hs[i] == 0:
                left -= 1
        count += 1
    print(count)

def tops(hs):
    start = 0
    length = 1
    prev = hs[0]
    for i, h in list(enumerate(hs))[1::]:
        if prev < h:
            start = i
            length = 1
        elif prev == h:
            length += 1
        else:
            break
        prev = h
    return (start, length)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
n, m, c = map(int, input().split())

b = list(map(int, input().split()))

a = [[] for _ in range(n)]

ans = 0

for i in range(n):
    a[i] = list(map(int, input().split()))
    

for i in range(n):
    ac = 0
    for j in range(m):
        ac += a[i][j] * b[j]

    ac += c

    if ac > 0:
        ans += 1


print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vp xy(N);
  rep(i,N) {
    int x,y;
    cin >> x >> y;
    xy[i] = P(x,y);
  }
  sort(rng(xy));
  ll ans = 1ll<<62;
  rep(i,N) {
    int x1 = xy[i].first;
    rep(j,N) {
      int x2 = xy[j].first;
      rep(k,N) {
        int y1 = xy[k].second;
        rep(l,N) {
          int y2 = xy[l].second;
          int cnt = 0;
          rep(a,N) {
            int x = xy[a].first;
            int y = xy[a].second;
            if(x1 <= x && x <= x2 && y1 <= y && y <= y2) {
              cnt++;
            }
          }
          if(cnt >= K) {
            ans = min(ans,1ll*(y2-y1)*(x2-x1));
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    ll H;cin>>H;
    ll m=1,ans=0;
    while(H>0){
        ans+=m;
        H/=2;
        m*=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int gcd(Int x, Int y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}
Int lcm(Int x, Int y) {
    return x / gcd(x, y) * y;
}
Int solve(Int N, Int M, const vector<int> A) {
    vector<char> B(N);
    for (int a : A) {
        for (int k = a; k < N; k += M) {
            B[k] = 1;
        }
    }
    auto dfs = [&](auto&& dfs, int n) {
        if (B[n] == 1) return;
        B[n] = 1;
        if (0 <= n - 7) dfs(dfs, n - 7);
        if ((n % 7) != 0) dfs(dfs, n - 1);
        if ((n % 7) != 6) dfs(dfs, n + 1);
        if (n + 7 < N) dfs(dfs, n + 7);
    };
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        if (B[i] == 0) {
            ans++;
            dfs(dfs, i);
        }
    }
    return ans;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    Int N, M, Q; cin >> N >> M >> Q;
    vector<int> A(Q); for (auto &a : A) cin >> a;
    Int x = lcm(M, 7);
    Int k = 7 * N / x;
    if (k == 1) {
        Int cnt1 = solve(x, M, A);
        cout << cnt1 << endl;
    } else {
        Int cnt2 = solve(2*x, M, A);
        Int cnt3 = solve(3*x, M, A);
        cout << cnt2 + (cnt3 - cnt2) * (k - 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 17004
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n;
    var t;
    var v;
    var i;
    var j;
    var l;
    var r;
    var x;
    var minV;
    var distance;

    n = parseInt(input[0], 10);
    tvals = input[1].split(' ');
    vvals = input[2].split(' ');

    v = new Array(n + 2);
    l = new Array(n + 2);
    r = new Array(n + 2);

    v[0] = 0;
    l[0] = 0;
    r[0] = 0;

    for (i = 0; i < n; i++) {
        t = parseInt(tvals[i], 10);
        v[i + 1] = parseInt(vvals[i], 10);

        l[i + 1] = r[i];
        r[i + 1] = l[i + 1] + t;
    }

    v[n + 1] = 0;
    l[n + 1] = r[n];
    r[n + 1] = r[n];

    minV = new Array(r[n + 1] * 2 + 1);
    for (i = 0; i < r[n + 1] * 2 + 1; i++) {
        minV[i] = 100;
        x = i * 0.5;
        for (j = 0; j < n + 2; j++) {
            minV[i] = Math.min(minV[i], f(x, l[j], r[j], v[j]));
        }
    }

    distance = 0;
    for (i = 0; i < r[n + 1] * 2; i++) {
        distance += (minV[i] + minV[i + 1]) * 0.25;
    }

    console.log(distance);

    return 0;
}

function f(x, l, r, v) {

    if (x < l) {
        return -x + v + l;
    }
    else if (x > r) {
        return x + v - r;
    }
    else {
        return v;
    }
}


Measured memory_bytes: 11724
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,k,a[10010];
ll ans = 1e18;

inline int max(int a, int b)
{
	if(a < b) return b;
	return a;
}

int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i ++) scanf("%d", a + i);
	for(int i = 0; i < (1 << n); i ++)
	{
		int cnt = 0;
		for(int j = 0; j < n; j ++)
			cnt += bool(i & (1 << j));
		if(cnt != k) continue;
		int ls = -1;
		ll cst = 0;
		for(int j = 0; j < n; j ++)
		{
			if(i & (1 << j));
			else
			{
				ls = max(ls, a[j]);
				continue;
			}
			int nx = max(a[j], ls + 1);
			cst += nx - a[j];
			ls = nx;
		}
		ans = min(ans, cst);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>

using namespace std;

int main(){
    int N;
    map<string, bool> T;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s,t;
        cin>>s>>t;

        if (s == "insert") {
            T[t] = true;
        }else{
            if (T[t]) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 52432
#include<bits/stdc++.h>
using namespace std;
main(){
  long n,m=20;
  cin>>n;
  for(long a=1;a<=sqrt((double)n)+1;a++)
    if(a*(n/a)==n)m=min(m,(long)max((log((double)a)/log(10.0)+1.0),(log((double)n/a)/log(10.0)+1.0)));
  cout<<m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (ll i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (ll i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

struct edge{
    int to, color;
};

ll n, colornum;

vector<map<int,int>> G(100008);

void dfs(int now, int from){
    int prevcolor = -1;
    if (from != -1)
    {
        prevcolor = G[from][now];
    }
    ll nowcolor = 1;
    for (auto elem : G[now])
    {
        if (elem.FI != from)
        {
            if (nowcolor == prevcolor){
                nowcolor++;
            }
            G[now][elem.FI] = nowcolor;
            dfs(elem.FI, now);
            colornum = max(colornum, nowcolor);
            ++nowcolor;
        }
    }
}

int main()
{
    cin >> n;
    colornum = -1;
    vint avec(n - 1), bvec(n - 1);
    REP(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge e;
        e.to = b;
        e.color = 0;
        G[a][b] = 0;
        G[b][a] = 0;
        avec[i] = a;
        bvec[i] = b;
    }
    dfs(0, -1);
    cout << colornum << endl;
    REP(i,n-1){
        int a = avec[i], b = bvec[i];
        if (G[a][b] != 0){
            cout << G[a][b] << endl;
        }else
        {
            cout << G[b][a] << endl;
        }
    }
}

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


using namespace std;
#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 repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }

int n;
int d[100005];
void solve() {
    cin >> n;

    reps(i, n) {
        int a; cin >> a;
        d[a] = i;
    }

    reps(i, n)cout << d[i] << " ";
    cout << endn;
}

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


Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#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 FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

#define N 100000

int n;
vector<vector<int> > e(N);
vector<int> a(N) , p(N) , d(N);


void dfs(int now, int from, int depth){
    p[now] = from;
    d[now] = depth;
    if (e[now].size()==0){
        a[now] = 2;
    }
    REP(k,e[now].size()){
        dfs(e[now][k],now,depth+1);
    }
}

int main(void) {
    cin >> n;
    REP(i,n){
        int id , k;
        cin >> id >> k;
        REP(i,k){
            int c;
            cin >> c;
            e[id].push_back(c);
            a[c]=1;
        }
    }
    REP(i,n){
        if (a[i]==0){
            p[i]=-1;
            d[i]=0;
            REP(k,e[i].size()){
                dfs(e[i][k],i,1);
            }
        }
    }

    REP(i,n){
        printf("node %d: parent = %d, depth = %d, ",i,p[i],d[i]);
        if (a[i]==0)
            cout << "root";
        if (a[i]==1)
            cout << "internal node";
        if (a[i]==2)
            cout << "leaf";
        printf(", [");
        REP(k,e[i].size()){
            printf("%d",e[i][k]);
            if (k<e[i].size()-1){
                cout << ", ";
            }
        }
        cout << "]" << endl;
    }

    return 0;
}

Measured memory_bytes: 5496
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	int c=(a*25+1)/2,d=b*10;
	if(a<=b){
		if(c>d){
			if(c/10==b)
				cout<<c;
			else
				cout<<-1;
		}else{
			if(d*2/25==a)
				cout<<d;
			else
				cout<<-1;
		}
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
l = len(S)
ideal1 = '10' * (l // 2)
ideal2 = '01' * (l // 2)
if l % 2 == 1:
    ideal1 += '1'
    ideal2 += '0'
cnt1 = 0
cnt2 = 0

for i in range(l):
    if ideal1[i] != S[i]:
        cnt1 += 1
    if ideal2[i] != S[i]:
        cnt2 += 1
print(min(cnt1,cnt2))


Measured memory_bytes: 41072