akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









class unionfind {
private:
    vector<int> par;
    vector<int> rank;
    vector<int> counter;
public:
    unionfind(int n) : rank(n), counter(n, 1){
        for(int i = 0; i < n; i++){
            par.push_back(i);
        }
    }
    
    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 (rank[x] < rank[y]) {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[x] = y;
        }
        else {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
    
    ll count(int x){
        return counter[find(x)];
    }
};





int main(){
    ll n;
    int m;
    scanf("%lld %d", &n, &m);
    vector<int> a(m), b(m);
    for(int i = 0; i < m; i++){
        scanf("%d %d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
    }
    unionfind uni(n);
    vector<ll> ans(m);
    ll res = n * (n - 1) / 2;
    for(int i = m - 1; i >= 0; i--){
        ans[i] = res;
        if(uni.same(a[i], b[i])) continue;
        ll c1 = uni.count(a[i]), c2 = uni.count(b[i]);
        uni.unite(a[i], b[i]);
        res -= c1 * c2;
    }
    for(ll &v : ans){
        printf("%lld\n", v);
    }
}

Measured memory_bytes: 4216
H,W=map(int,input().split())
C=[list(map(int,input().split()))for _ in range(10)]
A=[list(map(int,input().split()))for _ in range(H)]

for k in range(10):#経由する頂点
    for i in range(10):#始点
        for j in range(10):#終点
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
ans=0
for aa in A:
    for a in aa:
        if a==-1:
            ans+=0
        else:
            ans+=C[a][1]
print(ans)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

vector<string> split(const string &s,char c=' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}

int main(){
	string s;
	while(getline(cin,s)){
		if(s=="END OF INPUT") break;
		vector<string> ss=split(s,' ');
		string ans="";
		//rep(i,0,ss.size()) cout<<ss[i].size();
		//cout<<endl;
		rep(i,0,ss.size()){
			stringstream stream;
			stream<<ss[i].size();
			ans+=stream.str();
		}
		o(ans);
	}
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int a, b, c;
	std::cin >> a >> b >> c;
	std::cout << c - std::min(c, a - b) << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
    cin >> a >> b;
 
    if (a < b)
        cout << string(b, a + '0') << "\n";
    else
        cout << string(a, b + '0') << "\n";
 
    return 0;
      
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    int w, h;
    cin >> h >> w;
    char s[105][105];
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cin >> s[i][j];
        }
    }

    for(int i = 1; i <= 2 * h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cout << s[(i + 1) / 2][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace test
{

    class Program
    {
        static int[] primeArray = new int[1000000];

        static void Main(string[] args)
        {
            SetPrime();

            List<int> list = new List<int>();
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }

                list.Add(primeArray[n]);

            }

            foreach (int a in list)
            {
                Console.WriteLine(a);
            }

        }


        static void SetPrime()
        {
            primeArray[1] = 2;
            int primeNum = 2;
            int primeSum = 2;

            List<int> serchList = new List<int>();
            for (int i = 3; i <= 1000000; i += 2)
            {
                serchList.Add(i);
            }

            List<int> tmpList = new List<int>();
            while (true)
            {
                int prime = serchList[0];
                primeSum += prime;
                primeArray[primeNum] = primeSum;
                primeNum++;

                if (prime > Math.Sqrt(serchList[serchList.Count - 1]))
                {
                    break;
                }

                for (int k = 0; k < serchList.Count; k++)
                {
                    if (serchList[k] % prime != 0)
                    {
                        tmpList.Add(serchList[k]);
                    }
                }

                serchList = new List<int>(tmpList);
                tmpList.Clear();
            }

            for (int j = 1; j < serchList.Count; j++)
            {
                primeSum += serchList[j];
                primeArray[primeNum] = primeSum;
                primeNum++;
            }

        }

    }

}

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


int main() {
  int n = 0 ;
  cin >> n ;

  int digit = log10( n ) + 1 ; //桁数
  int ans = 0;
  if ( digit % 2 != 0 ) {
    ans += ( n - pow( 10, digit-1 ) ) + 1;
  }

  rep( i, digit ) {
    if ( i % 2 == 0 ) continue ;
    ans += pow( 10, i ) - pow( 10, i-1 ) ;
  }
  
	cout << ans << endl ;

  return 0 ;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

char c[29]={'X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int main(){
  string ch;
  cin>>ch;
  for(int i=0; i<ch.size(); i++){
    for(int j=3; j<29; j++){
      if(ch[i]==c[j]){
        cout<<c[j-3];
      }
    }
  }
  cout<<en
}




Measured memory_bytes: 3172
#include<stdio.h>
int main(){
  int n,i,j,a[20];
  char b[20],c[20]={"RGB"};
  scanf("%d",&n);
  while(n--){
    int d[20][20]={0};
    for(i=0;i<9;i++)scanf("%d" ,&a[i]);
    for(i=0;i<9;i++)scanf(" %c",&b[i]);
    for(i=0;i<9;i++){
      for(j=0;b[i]-c[j];j++);
      d[a[i]][j]++;
    }
    for(j=0;j<3;j++){
      for(i=0;i<9;i++){
	if(d[i][j]>2)d[i][j]-=3;
	if(d[i][j]>0){
	  if(d[i+1][j]<d[i][j]||d[i+2][j]<d[i][j])break;
	  d[i+1][j]-=d[i][j];
	  d[i+2][j]-=d[i][j];
	}
      }
      if(i-9)break; 
    }
    printf("%d\n",j-3?0:1);
  }
  return 0;
}

Measured memory_bytes: 600
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def permitation(x):
    res = 1
    for i in range(1, x + 1):
        res = res * i % mod
    return res


pn = permitation(n)
pm = permitation(m)

if n == m:
    res = pn * pm * 2 % mod
    print(res)
elif n == m - 1 or n == m + 1:
    res = pn * pm % mod
    print(res)
else:
    print(0)


Measured memory_bytes: 9152
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Array{Int}(2,n)
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
	end
	if n == 1
		println(1)
	else
		d = Dict{Tuple,Int}()
		for i in 1:n-1
			for j in i+1:n
				p = a[1,i]-a[1,j]
				q = a[2,i]-a[2,j]
				if !haskey(d,(p,q))
					d[(p,q)] = 1
				else
					d[(p,q)] += 1
				end
				if !haskey(d,(-p,-q))
					d[(-p,-q)] = 1
				else
					d[(-p,-q)] += 1
				end
			end
		end
		println(n-maximum(values(d)))
	end
end

main()

Measured memory_bytes: 171372
//#include<iostream>
//using namespace std;
//
//int main() {
//
//	int n;
//	int j;
//	cin >> n;
//	int a[105];
//	for (int i = 0; i < n; i++) {
//		cin >> a[i];
//	}
//
//	for (int i = 0; i < n; i++) {
//		if (i != n - 1) cout << a[i] << " ";
//		if (i == n - 1)cout << a[i] << endl;
//	}
//	for (int i = 1; i < n; i++) {
//
//		int v = a[i];
//
//		j = i - 1;
//		while (j >= 0 && a[j] > v) {
//			a[j + 1] = a[j];
//			j--;
//		}
//		a[j + 1] = v;
//		for (int i = 0; i < n; i++) {
//			if (i != n - 1) cout << a[i] << " ";
//			if (i == n - 1)cout << a[i] << endl;
//		}
//
//	}
//
//
//}

#include<iostream>

using namespace std;
int main() {
	int n,v;
	int A[105];
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < n; i++) {
		if (i == n - 1)cout << A[i] << endl;
		else cout << A[i] << " ";
	}


	for (int i = 1; i <= n - 1; i++) {
		v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		for (int i = 0; i < n; i++) {
			if (i == n - 1)cout << A[i] << endl;
			else cout << A[i] << " ";
		}

	}
	return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    boolean check = false;
    loop: for (int i = 1; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        if (a == i * j) {
          check = true;
          break loop;
        }
      }
    }
    System.out.println(check ? "Yes" : "No");
  }
}

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

int main(){
    long long int n;
    scanf("%lld",&n);
    for(long long int i=1;i<n+1;i++){
        if(i%3==0){
            printf(" %lld",i);
        }else{
            long long x = i;
            while(1){
                if(x%10==3){
                    printf(" %lld",i);
                    break;
                }
                x/=10;
                if(x==0) break;
            }
        }
    }
    printf("\n");
}


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

int main()
{

        int N, M;
        cin >> N >> M;

        std::vector<int> A;
        long long total = 0;
        for (int i = 0; i < N; ++i) {
                int tmp;
                cin >> tmp;
                total += tmp;
                A.push_back(tmp);
        }

        std::sort(A.begin(), A.end(), greater<int>());
        double judge = (double)total / (4 * M);
        for (int i = 0; i < M; ++i) {
                if (A[i] < judge) {
                        cout << "No" << endl;
                        exit(0);
                }
        }
        cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
    int k = 100;
    double xa[k],ya[k],ra[k];
    double xb[k],yb[k],rb[k];
    double dist;
    int ans[k];
    
    int i,j;
    scanf("%d",&j);
    for(i = 0;i < j;i++){
        scanf("%lf %lf %lf %lf %lf %lf",&xa[i],&ya[i],&ra[i],&xb[i],&yb[i],&rb[i]);
        dist = sqrt((xa[i] - xb[i]) * (xa[i] - xb[i]) + (ya[i] - yb[i]) * (ya[i] - yb[i]));
        if(dist > ra[i] + rb[i]) {
            ans[i] = 0;
        }
        else if(ra[i] > rb[i] && dist < ra[i] - rb[i]) {
            ans[i] = 2;
        }
        else if(ra[i] < rb[i] && dist < rb[i] - ra[i]) {
            ans[i] = -2;
        }
        else {
            ans[i] = 1;
        }
        
    }
    for(i = 0;i < j;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 644
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

template <typename T, typename S> ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  string s;
  int n, k;
  vector<pair<int, int>> v;
  cin>>n>>k;
  cin>>s;
  int x=1;
  int c=0;
  int z=0;
  int sum=0;
  s.push_back('2');
  for(auto it=s.begin(); it!=s.end(); it++) {
    if((int)*it-'0'==x) {
      c++;
    } else {
      sum+=c;
      v.push_back(make_pair(x, sum));
      if(x==0)
	z++;
      x=(x+1)%2;
      c=1;
    }
  }
  if(v.size()%2==0) v.push_back(make_pair(1, (v.end()-1)->second));
  if(z<=k) {
    std::cout << n << std::endl;
    return 0;
  }
  int r = k*2;
  int l=1;
  int m = v[r].second;
  for(r=k*2+2 ; r<v.size(); r+=2, l+=2) {
    m=max(m, v[r].second-v[l].second);
  }
  std::cout << m << std::endl;

  // if(zero.size()<=k) {
  //   std::cout << n << std::endl;
  //   return 0;
  // } else {
  //   int m;
  //   if(v[0].first==1) {
  //     m=v[k*2].second;
  //     for(int i=k*2+2; i<=z-1; ) {
  // 	m = max(m, v[i].second-v[i-(k*2+1)].second);
  // 	if(i==z-2)
  // 	  i++;
  // 	else
  // 	  i+=2;
  //     }
  //   } else {
  //     m = v[k*2-1].second;
  //     for(int i=k*2+1; i<=z-1; ) {
  // 	m= max(m, v[i].second-v[i-(k*2)].second);
  // 	if(i==z-2)
  // 	  i++;
  // 	else
  // 	  i+=2;
  //     }
  //   }
  //   std::cout << m << std::endl;
  // }
  return 0;
}



Measured memory_bytes: 1528
from collections import deque
s = deque(input())
q = int(input())

state = 0
for i in range(q):
    query = list(input().split())
    if query[0] == "1":
        state += 1
    else:
        if (int(query[1]) + state) % 2 == 1:
            s.appendleft(query[2])
        else:
            s.append(query[2])

if state % 2 == 1:
    s = list(s)[::-1]

print("".join(s))

Measured memory_bytes: 10228
#include<iostream>
int main(){
  int n;
  std::cin >> n;
  int a[n+1];
  int i;
  int M[n];
  for(i=0;i<n;i++){
    std::cin >> a[i];
  }
  M[0] = 0;
  for(i=0;i<n;i++){
    if (i%2 == 0) M[0] += a[i];
    else M[0] -= a[i];
  }
  std::cout << M[0] << std::endl;
  for(i=1;i<n;i++){
    M[i] = 2*a[i-1] - M[i-1];
    std::cout << M[i] << std::endl;
  }
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <iomanip>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    int N;
    vector<ll> a;
    ll A;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A;
        a.push_back(A);
    }
    
    bool flag = 0;
    for (int i = 0; i < N; i++) {
        if (a.at(i) % 2 == 1) flag = 1;
    }
    
    if (flag) cout << "first" << endl;
    else cout << "second" << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <math.h>
#include <string>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int N, M, X;
	cin >> N >> M >> X;
	
	int A[101] = {};
	for(int i = 0; i < M; ++i){
		int idx;
		cin >> idx;
		A[idx] = 1;
	}

	int adv_count = 0;
	for(int i = X; i < N; ++i){
		if(A[i] == 1){
			adv_count++;
		}
	}

	int rev_count = 0;
	for(int i = X; i > 0; --i){
		if(A[i] == 1){
			rev_count++;
		}
	}

	cout << MIN(adv_count, rev_count) << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int F[44] = {0};

int fibonacci(int n){

  if(n == 1 || n == 0) return F[n] = 1;
  if(F[n] != 0) return F[n];
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}


int main(){
  int n;
  int fib;

  scanf("%d",&n);

  fib = fibonacci(n);

  printf("%d\n",fib);

  return 0;
}



Measured memory_bytes: 2048
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()


def binary_upper(k, x):
    return len(k) - bisect.bisect_right(k, x)


def binary_lower(k, x):
    return bisect.bisect_left(k, x)


ans = 0

for middle in b:
    cnt_a = binary_lower(a, middle)
    cnt_c = binary_upper(c, middle)
    ans += cnt_a * cnt_c

print(ans)

Measured memory_bytes: 23360
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int tl = 0;
    int re = 0;
    int ac = 0;
    int wa = 0;
    while ( n > 0){
        string s;
        cin >> s;
        n--;
        
        if ( s == "TLE"){
            tl++;
        }
        if (s == "WA"){
            wa++;
        }
        if (s == "RE"){
            re++;
        }
        if (s == "AC"){
            ac++;
        }
        
    }
    cout << "AC" << " " << "x" << " " << ac << "\n";
    cout << "WA" << " " << "x" << " " << wa << "\n";
    cout << "TLE" << " " << "x" << " " << tl << "\n";
    cout << "RE" << " " << "x" << " " << re;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <tuple>
#include <list>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)


// dream dreamer erase eraser
bool solve2() {
    string s;
    cin >> s;
    string words[] = {"dream0", "dreamer0", "erase0", "eraser0"};
    queue<pair<int,int>> nextMatchables;
    queue<pair<int,int>> nextMatchables2;
    
    REP(i, 4) {
        nextMatchables.push(make_pair(i,0));
        
    }
    int si,ci;
    
    bool wEnd = false;
    for(char c : s){
        wEnd = false;
        if (nextMatchables.empty()){
            return false;
        }
        while(!nextMatchables.empty()){
            tie(si,ci) = nextMatchables.front(); nextMatchables.pop();
            if(words[si][ci] == c){
                if(words[si][ci + 1] == '0'){
                    wEnd = true;
                }
                else{
                    nextMatchables2.push(make_pair(si, ci + 1));
                }
            }
        }
        if (wEnd == true) {
            REP(i,4) nextMatchables2.push(make_pair(i, 0));
        }
        swap(nextMatchables, nextMatchables2);
    }
    
    return wEnd;
}

void solve(){
    cout << ((solve2()) ? "YES" : "NO") << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif


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


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  int D;
  cin >>N>>D;
  int x=2*D+1;
  int y=N/x;
  if(N%x !=0) {
cout << y+1<< endl;
  }
 else {
cout << y<< endl;
 }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s[2];
   cin >> s[0] >> s[1];
   map<string,int> val;
   cin >> val[s[0]] >> val[s[1]];
   string u;
   cin >> u;
   val[u]--;
   cout << val[s[0]] << ' ' << val[s[1]] << '\n';
   return 0;
} 

Measured memory_bytes: 256
n, k = map(int, input().split())
if k > (n - 1) * (n - 2) // 2:
    print(-1)
else:
    edges = []
    e = n * (n - 1) // 2 - k
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            if e > 0:
                edges.append((a, b))
                e -= 1
    print(len(edges))
    for e in edges:
        print(e[0], e[1])

Measured memory_bytes: 43376
#include <bits/stdc++.h>
using namespace std;
  
int main() { 
  
  int N, K, x, distance;
  cin >> N >> K;
  
  for(int i = 0;i < N;i++){
  cin >> x;
    if(x <= K - x){
    distance = distance + x * 2;
    }
    else{
    distance = distance + (K - x) * 2;
    }
  }
  cout << distance << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  1 <= A, B, C, D <= 10;
  int L;
  L = (A + B);
  int R;
  R = (C + D);
  if( L > R ) {
    cout << "Left" << endl;
  }
  else{
    if( L == R ) {
    cout << "Balanced" << endl;
    }
    else{
      cout << "Right" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
         
int main(void){
  char word[12],t[1010];
  int i,count=0;
         
  scanf("%s",word);
  for(i=0;i<strlen(word);i++)  word[i]=tolower(word[i]);
  while(1){
    scanf("%s",t);
    if(strcmp(t,"END_OF_TEXT")==0)  break;
    for(i=0;i<strlen(t);i++)  t[i]=tolower(t[i]);
    if(strcmp(t,word)==0)  count++;
  }
         
  printf("%d\n",count);
         
  return 0;
}

Measured memory_bytes: 552
#include <cstdio>
#include <cstring>

int main()
{
  char a[50][51], b[50][51];
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
  {
    scanf("%s", a[i]);
  }
  for (int i = 0; i < m; ++i)
  {
    scanf("%s", b[i]);
  }

  for (int i = 0; i <= n - m; ++i)
  {
    for (int j = 0; j <= n - m; ++j)
    {
      bool r = true;
      for (int ii = 0; ii < m; ++ii)
      {
        for (int jj = 0; jj < m; ++jj)
        {
          if (a[i + ii][j + jj] != b[ii][jj])
          {
            r = false;
            break;
          }
        }
      }
      if (r)
      {
        puts("Yes");
        return 0;
      }
    }
  }
  
  puts("No");
  return 0;
}

Measured memory_bytes: 128
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	string T = "";
	string S = "";
	cin >> S >> T;
	fi(i, 0, S.size(), 1) {
		if(S[i] != T[i]) {
			// cout << S[i] << " " << T[i] << "\n";
			printf("No\n");
			quit;
		}
	}
	printf("Yes\n");
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int a, b, c;
  int k;
  cin >> a >> b >> c >> k;
  if(a >= k)cout << k << endl;
  else if(a + b >= k)cout << a << endl;
  else cout << a - (k - a - b) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    string s,p;
    cin>>s>>p;
    s+=s;
    if(s.find(p)!=string::npos){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



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

int main(){
  map<string,int> result;
  string s;
  int N,mx=0;
  cin>>N;
  
  for(int i=0;i<N;i++){
    cin>>s;
    if(result.count(s)){
      result.at(s)+=1;
    }else{
      result[s]=1;
    }
  }
  
  for(pair<string,int> p:result){
    mx=max(mx,p.second);
  }
  
  for(pair<string,int> p:result){
    if(mx==p.second){
      cout<<p.first<<endl;
    }
  }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,x;
	scanf("%d %d",&a,&b);
	if(a>=0&&a<=23&&b>=0&&b<=23)
	{
		x=a+b;
		if(x>=24)
		{
		x-=24;
	    }
		printf("%d",x);

	}
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

ll digitsum(ll b, ll n) {
	if (n < b) return n;
	return digitsum(b, n / b) + n % b;
}

int main() {
	ll n, s; cin >> n >> s;
	
	ll sqr = sqrt(n);
	
	ll ans = INF;
	
	if (n == s) ans = s + 1;
	
	FOR(i, 2, sqr + 1) if (digitsum(i, n) == s) chmin(ans, i);
	FOR(i, 1, sqr + 1) {
		ll b = (n - s + i) / i;
		if (b < 2) continue;
		if (digitsum(b, n) != s) continue;
		
		chmin(ans, b);
	}
	
	if (ans == INF) ans = -1;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static final long MOD = 1000_000_007L;

    public static void main(String[] args) {
	long N = Long.parseLong(scan.next());

	int digit = (int)(Math.log10(N)/Math.log10(2) + 1.0);
	int[] bitN = new int[digit];
	for (int i = 0; i < digit; i++) {
	    bitN[digit-1-i] = (int)(N % 2);
	    N = N / 2;
	}

	long[][] dp = new long[digit+1][3];
	dp[0][0] = 1;

	for (int i = 1; i <= digit; i++) {
	    if(bitN[i-1] == 1) {
		dp[i][0] = dp[i-1][0];
		dp[i][1] = (dp[i-1][0] + dp[i-1][1]) % MOD;
		dp[i][2] = (2*dp[i-1][1] + 3*dp[i-1][2]) % MOD;
	    } else {
		dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % MOD;
		dp[i][1] = dp[i-1][1];
		dp[i][2] = (dp[i-1][1] + 3*dp[i-1][2]) % MOD;
	    }
	}

	long ans = (dp[digit][0] + dp[digit][1] + dp[digit][2]) % MOD;
	System.out.println(ans);
	scan.close();
    }
}


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

int main(){
    int n;
    cin >> n;
    for(int i = 1; ++i <= n;){
        int x = i;
        if(x % 3 == 0){
            cout << " " << i;
        }else{
            while(1){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
                if(x < 1) break;
            }
        }
    }
    cout << endl;
    return 0;
}

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

int n;
struct Edge{
  int to,id;
};
vector<vector<Edge> > g;
vector<int> ans;

void dfs(int v,int c=-1,int p=-1){
  int k=1;
  rep(i,g[v].size()){
      int u=g[v][i].to;
      if (u==p)continue;
      if (k==c)++k;
      ans[g[v][i].id]=k;++k;
      dfs(u,k-1,v);
  }
}

int main() {
  cin >> n;
  g.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    g[a].push_back((Edge){b,i});
    g[b].push_back((Edge){a,i});
  }
  ans.resize(n);
  dfs(0);
  int mx=0;
  rep(i,n-1){
    mx=max(mx,int(g[i].size()));
  }
  cout << mx << endl;
  rep(i,n-1){
    cout << ans[i] << endl;
  }
  
  return 0;
}



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

int main(){
    int N,num;
    cin >> N;
    int sum = 0, max = 0;
    for(int i=0;i<N;i++){
        cin >> num;
        sum += num;
        if(max < num) max = num;
    }
    cout << sum - (int)max/2;
}

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

// x番の組織が親組織に提出する枚数を返す
// childrenは組織の関係を表す2次元配列(参照渡し)
int main() {
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i=0; i < N-1; i++) {
    cin >> B.at(i);
  }
  vector<int> A(N);
  
  A.at(0) = B.at(0);
  A.at(1) = B.at(0);
  for (int i=1; i < N-1; i++) {
    if (A.at(i) > B.at(i))
      A.at(i) = B.at(i);
    A.at(i+1) = B.at(i);
  }

  cout << accumulate(A.begin(), A.end(), 0) << endl;
  
  
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <set>
#define MOD 1000000007
using namespace std;


set<int> a;
int n,b,c;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>b>>c;
	a.insert(n);
	a.insert(b);
	a.insert(c);
	cout<<a.size();
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <utility>
#include <functional>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <deque>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	string s1, s2;
	cin >> s1 >> s2;

	while (s1 != ".") {
		string ans = "DIFFERENT";
		// s1とs2が一致
		if (s1 == s2) ans = "IDENTICAL";
		// s1とs2が惜しいかを判定
		else {
			bool counter = true;
			rep(i,0,200) {
				string S1 = "", S2 = "";
				// " "内の処理 " "の中身をS1,S2に入れ、s1,s2から削除
				if (s1[i] == '"' && s2[i] == '"') {
					int j = i + 1;
					while (s1[j] != '"') {
						S1 += s1[j];
						s1.erase(s1.begin() + j);
					}
					while (s2[j] != '"') {
						S2 += s2[j];
						s2.erase(s2.begin() + j);
					}
					i = j;
				}
				// " "外で異なる文字列があればループを抜ける
				else if (s1[i] != s2[i]) break;
				// ""内の文字が異なればCLOSE(1回目)
				if (S1 != S2) {
					ans = "CLOSE";
					counter = false;
					break;
				}
			}
			// ""内の文字が異なればDIFFERENT(2回目)
			if (!counter && s1 != s2) ans = "DIFFERENT";
		}
		
		cout << ans << endl;

		cin >> s1 >> s2;
	}

	return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll a,b,x,ans=0;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
void Main(){
    cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
listA = list(map(int,input().split()))
A = sorted(listA,reverse=True)
T = sum(A)
b = True
for i in range(M):
    if A[i] < T/(4*M):
        b = False
if b == True:
    print('Yes')
else:
    print('No')


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


int main(){
    int L;
    cin >> L;
    double S = (L / 3.0) * (L / 3.0) * (L / 3.0);
    cout << fixed << setprecision(10) << S << endl;
}


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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3612
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(INF)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	a--;
	For(i,b-a,b+a) cout<<i<<" \n"[i==b+a];
	return 0;
}




























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd seocnd

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int a[n];
    fr(i, 0, n){
        cin >> a[i];
    }
    int maxi = -1;
    fr(i, 0, n){
        if(maxi == -1 || a[i]  > a[maxi]) maxi = i;
    }
    int minj = -1;
    fr(i, 0, n){
        if(i == maxi) continue;
        if(minj == -1 || a[i] < a[minj]) minj = i;
    }
    cout << a[maxi] - a[minj] << endl;
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int X, Y;
	cin >> X >> Y;

	int ans = 0;
	ans += max(0, 400000 - 100000 * X);
	ans += max(0, 400000 - 100000 * Y);
	if(X == 1 and Y == 1) ans += 400000;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

ans = 0
(0..a).each do |_a|
  (0..b).each do |_b|
    (0..c).each do |_c|
      ans += 1 if _a * 500 + _b * 100 + _c * 50 == x
    end
  end
end

puts ans


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}


int a[100010];

using edge=struct{int to;};
using G=vector<vector<edge>>;

void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
	graph[to].push_back({from});
}

G graph;


bool dfs(int v,int p){

	for(auto &e:graph[v]){
		if(e.to==p) continue;
		if(a[v] > a[e.to] and dfs(e.to,v)==false) return true;
	}

	return false;
}


int main(void){
	int n;
	cin >> n;

	rep(i,n) cin >> a[i];

	graph.resize(n);

	rep(i,n-1){
		int u,v;
		cin >> u >> v;
		u--,v--;
		add_edge(graph,u,v);
	}

	vector<int> ans;
	rep(v,n) if(dfs(v,-1)) ans.push_back(v+1);
	rep(i,ans.size()) cout << (i?" ":"") << ans[i];
	cout << endl;

	return 0;
}

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

int main(){
    int n,m,c;
    int B[20];
    int A[20][20];
    int sum,num;

    cin>>n>>m>>c;

    for(int i=0;i<m;i++) cin>>B[i];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }

    

    for(int i=0;i<n;i++){
        sum=c;
        for(int j=0;j<m;j++){
          sum+=A[i][j]*B[j];
        }

        if(sum>0){
            num++;
        }
        
    }
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

class C{
    public:
        int abc[3], sign;
        C(int _a, int _b, int _c, int _sign);
};

C::C(int _a, int _b, int _c, int _sign){
    abc[0] = _a;
    abc[1] = _b;
    abc[2] = _c;
    sign = _sign;
}

int cntOK(C cls, vector<int> ok){
    int ret = 0;
    REP(i, 3){
        if(ok[cls.abc[i]] == true) ret++;
    }
    return ret;
}

int searchNG(C cls, vector<int> ok){
    REP(i, 3){
        if(ok[cls.abc[i]] == 2) return cls.abc[i];
    }
    return -1;
}

int main(){
    int x, y, z;
    while(cin >>x >>y >>z && (x && y && z)){
        int sum = x + y + z;
        vector<int> ok(sum + 1, 2);

        int n;
        cin >>n;
        vector<C> vec;
        REP(i, n){
            int a, b, c, s;
            cin >>a >>b >>c >>s;

            if(s == 0){
                C cls(a, b, c, s);
                vec.push_back(cls);
            } else{
                ok[a] = 1; ok[b] = 1; ok[c] = 1;
            }

        }

        while(true){
            bool isChanged = false;

            REP(i, vec.size()){
                if(vec[i].sign == 1) continue;

                int cntok = cntOK(vec[i], ok);
                if(cntok == 2){

                    ok[searchNG(vec[i], ok)] = 0;
                    vec[i].sign = 1;
                    isChanged = true;

                }
            }
            if(!isChanged) break;
        }
        FOR(i, 1, ok.size()) cout <<ok[i] <<endl;
    }

    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define Mashu cout << "UUZ ate it." << endl
#define RE register int
#define ll long long
using namespace std;

inline int read(){
	char ch=getchar();
	int x=0,cf=1;
	while(ch<'0'||ch>'9') {
		if(ch=='-') cf=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	if (cf < 0) return -x;
	else return x;
}

int G[55];
template<class T> inline void write(T x){
	int g=0;
	do{G[++g]=x%10;x/=10;}while(x);
	for(int i=g;i>=1;--i)putchar('0'+G[i]);putchar('\n');
}

struct edge{
	int to;
	int nxt;
	int w;
}e[400010];

int f[200010], cnt = 0;

void add(int u, int v, int w){
	e[++cnt].to = v;
	e[cnt].w = w;
	e[cnt].nxt = f[u];
	f[u] = cnt;
}

int main(){
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's') s.insert(s.end(), 'e'), s.insert(s.end(), 's');
	else s.insert(s.end(), 's');
	cout << s << endl;
	return 0;
	Mashu;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i < a.size(); i++){
    cin >> a.at(i);
    
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < a.size(); i += 2){
    Alice += a.at(i);
  }
  for (int i = 1; i < a.size(); i += 2){
    Bob += a.at(i);
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
using namespace std;
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main(){
    IOS
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout); 
    int t=1;
    // cin>>t;
    while(t--){
        double l;
        cin>>l;
        double x=l/3;
        cout << std::fixed;
        cout << std::setprecision(10) << pow(x,3) << '\n';
        // cout<<pow(x,3);
        // cout<<endl;
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    char s[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>s[i];
        if(i==k-1)
          s[i]=s[i]+32;
    }
    for (int i = 0; i < n; ++i)
    {
     cout<<s[i];
    } 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

void warshall_floyd(const int& n, vector<vector<int>>& d) {
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
}

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

  int n, m, R;
  cin >> n >> m >> R;
  vector<int> r(R);
  rep(i, R) {
    cin >> r[i];
    r[i]--;
  }

  vector<vector<int>> d(n, vector<int>(n, INF));
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = c; d[b][a] = c;
  }

  warshall_floyd(n, d);

  sort(ALL(r));

  int ans = INF;
  do {
    int tmp = 0;
    for (int i = 0; i < r.size()-1; i++) {
      tmp += d[r[i]][r[i+1]];
    }
    chmin(ans, tmp);
  } while (next_permutation(ALL(r)));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


X,Y,A,B,C = MI()
P,Q,R = LI(),LI(),LI()

Z = [(P[i],1) for i in range(A)] + [(Q[i],0) for i in range(B)] + [(R[i],-1) for i in range(C)]
Z.sort(reverse=True)
a,b,c = 0,0,0
n = 0
ans = 0
for x in Z:
    if n == X+Y:
        break
    s,t = x
    if t == 1 and a == X:
        continue
    elif t == 0 and b == Y:
        continue
    else:
        n += 1
        ans += s
        if t == 1:
            a += 1
        elif t == 0:
            b += 1
        else:
            c += 1

print(ans)


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

using namespace std;

long long int gcd(long long int a,long long int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main()
{

    int N;

    cin >> N;

    long long int A[N];

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

    long long int mingcd = 1000000007;


    for (int i=0;i<N-1;i++)
    {
        mingcd = min(mingcd, gcd(A[i],A[i+1]));
    }

    long long int counter = 0;

    while (mingcd%2 == 0)
    {
        mingcd = mingcd/2;
        counter++;
    }

    cout << counter << "\n";



return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 20;
	public static final double INF = Double.MAX_VALUE;
	
	
	public static boolean can_all(final int n, int cur, int bit, double time, double[][] adj){
		if(bit == (1 << n) - 1){
			return true;
		}
		
		for(int next = 0; next < n; next++){
			if((bit & (1 << next)) != 0){
				continue;
			}
			
			final double g_time = adj[next][n];
			final double next_time = time + adj[cur][next];
			
			if(g_time <= next_time){
				return false;
			}
		}
		
		for(int next = 0; next < n; next++){
			if((bit & (1 << next)) != 0){
				continue;
			}
			
			final double next_time = time + adj[cur][next];
			
			if(can_all(n, next, bit | (1 << next), next_time, adj)){
				return true;
			}
		}
		
		return false;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long[][] points = new long[MAX + 2][2];
		double[][] adj = new double[MAX + 2][MAX + 2];
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			final long h_x = sc.nextInt();
			final long h_y = sc.nextInt();
			final long g_x = sc.nextInt();
			final long g_y = sc.nextInt();
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < 2; j++){
					points[i + 1][j] = sc.nextInt();
				}
			}
			points[0][0] = h_x;
			points[0][1] = h_y;
			points[n + 1][0] = g_x;
			points[n + 1][1] = g_y;
			
			final int size = n + 1;
			
			for(int i = 0; i <= size; i++){
				for(int j = i + 1; j <= size; j++){
					long sum = 0;
					for(int k = 0; k < 2; k++){
						sum += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
					}
					
					adj[i][j] = adj[j][i] = Math.sqrt(sum);
					//System.out.println(adj[i][j]);
				}
			}
			//System.out.println(min);
			
			System.out.println(can_all(size, 0, 1, 0, adj) ? "YES" : "NO");
		}
	}

}

Measured memory_bytes: 25772