akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int n;
double v[50];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v, v+n);
	for(int i=1;i<n;i++){
		v[i] = (v[i-1] + v[i]) / 2;
	}
	cout<<v[n-1];
	return 0;
}

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

cd = []
for i in range(m):
    cd.append(list(map(int, input().split())))

for _ab in ab:
    ans = 0
    d = 10**9
    for _cd in cd:
        _d = abs(_ab[0] - _cd[0]) + abs(_ab[1] - _cd[1])
        if _d < d:
            ans = cd.index(_cd)+1
            d = _d

    print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int x = 0;
		int sum = 0;
		
		Scanner sn = new Scanner(System.in);
		int n = sn.nextInt();
		if(1 <= n && n <= Math.pow(10, 8)){
			x = n;
		}
		sn.close();
		sum = calc(x);
		
		if( x % sum == 0){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	
	public static int calc(int x){
		int sum = 0;
		String xStr = Integer.toString(x);
		int k = xStr.length();
		while(k != 0){
			String c = xStr.substring(k-1, k);
			sum = sum + Integer.parseInt(c);
			k--;
		}
		return sum;
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

int main() {
	LL n,x=0,y;
	cin>>n;
	for(int i=1;i<=100000;i++){
		x+=i;
		if(x>=n){
			x = i;
			break;
		}
	}
	while(n){
		if(n>=x){
			n-=x;
			cout<<x<<endl;
		}
		x--;
	}
	return 0;
}

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

void solve(long long N)
{
    long long N2;
    N2 = N;
    while (N2 >= 10)
    {
        if (N2 >= 10)
            N2 = N2 % 10;
    }

    if (N >= 0 && N < 10)
    {
        N2 = N;
    }

    if (N2 == 2 || N2 == 4 || N2 == 5 || N2 == 7 || N2 == 9)
    {
        cout << "hon" << endl;
    }
    else if (N2 == 0 || N2 == 1 || N2 == 6 || N2 == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "bon" << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

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

#include <set>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll g = gcd(n, m);
    set<ll> fact;
    ll t = g;
    for (ll i = 2; i * i <= g; i++) {
        while (t % i == 0) {
            t /= i;
            fact.insert(i);
        }
    }
    if (t != 1) {
        fact.insert(t);
    }
    cout << fact.size() + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	cin>>a;
	for(int s=a.size()-1;s>=0;s--)
	b=b+a[s];
	for(int s=0;s<b.size();s++)
	{
		switch(b[s])
		{
			case 'p':b[s]='q';break;
			case 'q':b[s]='p';break;
			case 'b':b[s]='d';break;
			case 'd':b[s]='b';break;
		}
	}
	if(b==a)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 696
N = int(input())
N_list = list(str(N))

for i in range(999):
  if N_list[0] == N_list[1] == N_list[2]:
    print(int(N_list[0] + N_list[1] + N_list[2]))
    break
  else:
    N += 1
    N_list = list(str(N))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
ll n,a[18],b[18];
ll solve(ll d){
    rep(i,n)if(d&(1LL<<i))swap(a[i],b[i]);
    pair<ll,ll> v[18];
    rep(i,n)v[i]=make_pair(a[i],i);
    sort(v,v+n);
    ll ans=0;
    ll bef=-1,ecnt=0,obef=-1;
    rep(i,n){
	ll cnt=0;
	rep(j,n){
	    if(v[i].first==v[j].first)continue;
	    bool vl=(v[j].first<v[i].first);
	    bool vr=(v[j].second<v[i].second);
	    cnt+=vl^vr;
	}
	if(d&(1LL<<v[i].second))cnt++;
	if(v[i].first!=bef){
	    if(~obef)ans=1e9;
	    obef=-1,ecnt=0;
	    bef=v[i].first;
	}
	ecnt++;
	if(cnt%2==1){
	    if(~obef){
		if((ecnt-obef)%2==0)ans=1e9;
		else ans+=(ecnt-obef)*2,obef=-1;
	    }
	    else obef=ecnt;
	}
	if(d&(1LL<<v[i].second))cnt--;
	ans+=cnt;
    }
    if(~obef)ans=1e9;
    rep(i,n)if(d&(1LL<<i))swap(a[i],b[i]);
    return ans/2;
}
int main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll ans=1e9;
    rep(i,(1<<n)){
	chmin(ans,solve(i));
    }
    if(ans>=1e6)ans=-1;
    cout<<ans<<endl;
}




Measured memory_bytes: 256
n, m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
dis = []
if n >= m:
    print(0)
else:    
    for i in range(m-1):
        dis.append(abs(x[i+1]-x[i]))
    dis.sort(reverse=True)
    for i in range(n-1):
        dis.pop(0)
    ans = sum(dis)
    print(ans)

Measured memory_bytes: 13968
N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(1,N-1):
  A = P[i-1:i+2]
  #print(A)
  if max(A) > P[i] and min(A) < P[i]:
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  int ss,ts;
  ss = s.size();
  ts = t.size();
  int ans = ts;
  for(int i=0;i<ss-ts+1;i++){//sのそれぞれに対して
      int k = ts;
     for(int j=0;j<ts;j++){
       if(s.at(i+j) == t.at(j)){
         k--;
       }
     }
    ans = min(ans,k);
  }
  cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x, y;
    cin >> x >> y;
    forab(a, 0, x+1){
        if (2*a+4*(x-a)==y){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

int main(void){
	int r, g, b, n;
	long long ans = 0LL;
	cin >> r >> g >> b >> n;
	for(int i = 0; i <= n/r; ++i){
		for(int j = 0; j <= n/g; ++j){
			if( (n-i*r-j*g) % b == 0){
				if((n-i*r-j*g) / b >= 0){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int N;
	int A[102];
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d",&A[i]);
	}
	A[N+1] = 0;
	
	int ans = 1;
	int loc = 0;
	for(int i = 1 ; i <= N+1 ; i ++){
		if(A[i] == 0){
			if(ans < i-loc)	ans = i-loc;
			loc = i;
		}
	}
	printf("%d\n",ans);
}


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

int main(){
    int n, m, c, in;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b.at(i);
    int ans = 0;
    rep(i, n){
        int sum = 0;
        rep(j, m){
            cin >> in;
            sum += b.at(j)*in;
        }
        if(sum + c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
n, d = map(int, input().split())

x = []
for _ in range(n):
    x.append(list(map(int, input().split())))

count = 0
for i in range(n):
    for j in range(i+1, n):
        s = 0
        for k in range(d):
            diff = x[i][k]-x[j][k]
            s += diff * diff
        sq = math.sqrt(s) 
        if sq == int(sq):
            count += 1
print(count)


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

int c[33], s[444][33], l[33];
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    stringstream ss[36];
    int M = -1e9, tt;
    for(int a = 0; a < 6; a++) {
        for(int b = 0; b < 6; b++) {
            int r = 0;
            for(int i = 0; i < d; i++) {
                auto m = 0.;
                int t = 0;
                for(int j = 0; j < 26; j++) {
                    double p = s[i][j];
                    p += c[j] * (i + 1 - l[j]) * .2 * a;
                    for(int k = 1; k < 10; k++)
                        if(i + k < d)
                            p -= s[i + k][j] * (10 - k) * .05 * b;
                    if(p > m)
                        m = p, t = j;
                }
                ss[a * 6 + b] << t + 1 << '\n';
                l[t] = i + 1;
                r += s[i][t];
                for(int j = 0; j < 26; j++)
                    r -= c[j] * (i + 1 - l[j]);
            }
            if(r > M)
                M = r, tt = a * 6 + b;
        }
    }
    cout << ss[tt].str();
    cerr << M << endl;
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  double a,b;
  cin>>a>>b;
  a=(a+b)/2;
  int z=round(a);
  cout<<z<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 7048
import sys
input = sys.stdin.readline

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

DP=[[0]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        DP[i][j]=min(i,j,N-1-i,N-1-j)

USED=[[1]*N for i in range(N)]
ANS=0

def update(z,w):
    if 0<=z<N and 0<=w<N:
        if DP[z][w]>DP[x][y]+USED[z][w]:
            DP[z][w]=DP[x][y]+USED[z][w]
            Q.append((z,w))
    

for p in P:
    q,r=divmod(p-1,N)
    ANS+=DP[q][r]
    DP[q][r]-=1
    USED[q][r]=0

    Q=[(q,r)]

    while Q:
        x,y=Q.pop()

        update(x+1,y)
        update(x-1,y)
        update(x,y+1)
        update(x,y-1)

print(ANS)

Measured memory_bytes: 149976
package main

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

const INF int = 1000000

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	list := make([]int, n)
	for i := 0; i < n; i++ {
		list[i] = nextInt()
	}

	// TODO
	dict := map[int]int{}

	// 種類ごとに個数をカウント
	for _, v := range list {
		_, hasKey := dict[v]
		if hasKey {
			dict[v]++
		} else {
			dict[v] = 1
		}
	}

	// 種類がk以下なら0
	l := len(keys(dict))
	if l <= k {
		fmt.Println(0)
		return
	}

	numReduce := l - k

	// kより多い場合、少ないものから消していく
	// ソートする
	vals := values(dict)
	sort.Ints(vals)

	idx := 0
	ans := 0
	for numReduce > 0 {
		ans += vals[idx]
		idx++
		numReduce--
	}

	// for {
	// 	var minKey int
	// 	minVal := INF
	// 	for key, val := range dict {
	// 		if min(minVal, val) == val {
	// 			minKey = key
	// 			minVal = val
	// 		}
	// 	}

	// 	ans += minVal
	// 	delete(dict, minKey)
	// 	numReduce--
	// 	if numReduce == 0 {
	// 		break
	// 	}
	// }

	fmt.Println(ans)
}

func keys(m map[int]int) []int {
	ks := []int{}
	for k := range m {
		ks = append(ks, k)
	}
	return ks
}

func values(m map[int]int) []int {
	vs := []int{}
	for _, v := range m {
		vs = append(vs, v)
	}
	return vs
}

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


Measured memory_bytes: 17280
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a 
def multiple_gcd(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = gcd(ans, a[i])
    return ans

def pairwise_coprime_gcd():
    for i in range(N-1):
        for j in range(i+1, N):
            if gcd(A[i], A[j]) != 1:
                return 0
    return 1
def pairwise_coprime(A):
    prime = set()
    for i in range(N):
        fact = factorization(A[i])
        for x in fact:
            if x[0] in prime:
                return 0
            if x[0] != 1:
                prime.add(x[0])
    return 1

N = int(input())
A = list(map(int, input().split()))

if pairwise_coprime(A) == 1:
    print('pairwise coprime')
elif multiple_gcd(A) == 1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 197532
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

template <typename T>
struct dijkstra
{
  int V;
  const T INF_d;
  struct edge
  {
    int to;
    T cost;
  };
  vector<vector<edge>> E;
  vector<T> d;
  using pt = pair<T, int>;
  dijkstra(int V_, T INF_d_ = LINF) : V(V_), INF_d(INF_d_)
  {
    E.resize(V);
    d.resize(V);
  }

  void add_E(int a, int b, T c = 1, bool directed = true)
  {
    E[a].emplace_back(edge{b, c});
    if (!directed)
      E[b].emplace_back(edge{a, c});
  }

  void calc(int s)
  {
    priority_queue<pt, vector<pt>, greater<pt>> que;
    fill(d.begin(), d.end(), INF_d);
    que.emplace(0LL, s);
    d[s] = 0;
    while (!que.empty())
    {
      pt p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      for (auto &&e : E[v])
      {
        if (d[e.to] > d[v] + e.cost)
        {
          d[e.to] = d[v] + e.cost;
          que.emplace(d[e.to], e.to);
        }
      }
    }
  }
};

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

  ll n, m, s;
  cin >> n >> m >> s;
  dijkstra<ll> ds(n * 2502);
  rep(i, m)
  {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    rep(k, 2501)
    {
      if (k - a < 0)
        continue;
      ds.add_E(u + k * n, v + (k - a) * n, b);
      ds.add_E(v + k * n, u + (k - a) * n, b);
    }
  }
  rep(i, n)
  {
    ll c, d;
    cin >> c >> d;
    rep(k, 2501)
    {
      if (k + c >= 2500)
      {
        ds.add_E(i + k * n, i + 2500 * n, d);
      }
      else
      {
        ds.add_E(i + k * n, i + (k + c) * n, d);
      }
    }
  }
  rep(i, n)
  {
    rep(k, 2500)
    {
      ds.add_E(i + (k + 1) * n, i + k * n, 0);
    }
  }
  s = min(2500LL, s);
  ds.calc(s * n);
  REP(i, 1, n)
  {
    cout << ds.d[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 26468
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	String s;
	char[] chars;
	int N;
	int[][] a;
	ArrayList<Integer>[] indexes;
	public void solve() {
		s = next();
		N = s.length();
		chars = s.toCharArray();

		for(int i = 0;i < N;i++){

			if(i + 1 < N){
				if(chars[i] == chars[i + 1]){
					out.println((i + 1) + " " + (i + 2));
					return;
				}
			}

			if(i + 2 < N){
				if(chars[i] == chars[i + 2]){
					out.println((i + 1) + " " + (i + 3));
					return;
				}
			}
		}

		out.println("-1 -1");

	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    if(N == 3){
        cout << 2 << ' ' << 3 << ' ' << 25 << endl;
        return 0;
    }
    int sum = 0;
    rep(i, 5000){
        if(sum >= N-3) break;
        cout << 6*i+2 << ' ' << 6*i+4 << ' ';
        sum += 2;
    }
    rep(i, 2500){
        if(sum >= N-1) break;
        cout << 12*i+3 << ' ' << 12*i+9 << ' ';
        sum += 2;
    }
    rep(i, 5000){
        if(sum >= N) break;
        cout << 6*(i+1) << ' ';
        sum++;
    }
    cout << endl;
}

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

int main()
{
    int a,b;
    cin>>a>>b;

    /*if(b%2==0){
        cout<<a+b;
    }
    else{
        cout<<a-b<<endl;
    }*/

    int ans=6-b-a;
    cout<<ans<<endl;
}


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

int main() {
    int cnt = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int INF=1001001001001001001ll;

int N,E,T;
int X[111111];
int dp[111111];

signed main(){
    cin>>N>>E>>T;
    rep(i,N)cin>>X[i+1];

    int ei=INF;
    int L=1;
    deque<pint>deq;
    for(int i=1;i<=N;i++){
        int tmp=dp[i-1]+X[i]-X[i-1];
        while(deq.size()&&deq.back().fi>T+tmp-X[i])deq.pop_back();
        deq.push_back({T+tmp-X[i],i});
        while((X[i]-X[L])*2>T){
            chmin(ei,dp[L-1]+X[L]-X[L-1]-3*X[L]);
            if(deq.front().se==L)deq.pop_front();
            L++;
        }

        dp[i]=min(deq.front().fi+X[i],ei+3*X[i]);
    }

    cout<<dp[N]+E-X[N]<<endl;
    return 0;
}


Measured memory_bytes: 2560
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
temp = A[0]

for i in range(N-1):
    if(temp>A[i+1]):
        ans += temp-A[i+1]
    else:
        temp = A[i+1]

print(ans)


Measured memory_bytes: 97400
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char hash[256] = {};
    string s;
    cin >> s;
    REP(i, s.size()) hash[(int)s[i]]++;
    REP(i, 256) {
        if(hash[i] > 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, a;

    cin >> n >> a;

    int x[60];

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

    long long dp[60][60][2510] = {0};

    dp[0][0][0] = 1;

    for (int j = 0; j <= n; ++j) {
        for (int k = 0; k <= n; ++k) {
            for (int s = 0; s <= n*a; ++s) {
                if (k >= 1 && x[j] <= s) {
                    dp[j+1][k][s] = dp[j][k][s] + dp[j][k-1][s-x[j]];
                } else {
                    dp[j+1][k][s] = dp[j][k][s];
                }
            }
        }
    }

    long long result = 0;

    for (int k = 1; k <= n; ++k) {
        result += dp[n][k][k*a];
    }

    cout << result << endl;
}


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

using namespace std;

int main()
{

  while(1){
    int num;
    cin>>num;
    if(num == 0){
      break;
    }

    int ans = 0;
    while(1){
      if(num == 1){
        break;
      }

      if(num % 2 == 0){
        num = num / 2;
      }
      else{
        num = (3 * num) + 1;
      }

      ++ans;
    }

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


Measured memory_bytes: 3068
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0

for i in range(n):
  A = list(map(int, input().split()))
  S = 0
  for i in range(m):
    S += A[i] * B[i]
  if S + c > 0:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

typedef long long LL;

int n,m;
int pa[20000];

void init()
{
    for(int i=1;i<=n;i++)
        pa[i] = i;
}

int find(int x)
{
    if(pa[x] != x) pa[x] = find(pa[x]);
    return pa[x];
}

struct edge
{
    int x,y;
    double w;
    bool operator < (struct edge t) const
    {
        return (t.w - w) < 1e-6;
    }
}e[100000];

struct point
{
    double x,y;
}p[100000];

double kruskal()
{
    double res = 0;
    int cnt = 0;
    for(int i=1;i<=m;i++)
    {
        int a = find(e[i].x), b = find(e[i].y);
        if(a != b)
        {
            pa[a] = b;
            cnt++;
            res += e[i].w;
        }
        if(cnt == n-1) break;
    }
    return res;
}


int main()
{
    //freopen("C:in.txt","r",stdin);
    //freopen("C:out.txt","w",stdout);
    while(~scanf("%d%d",&n,&m))
    {
        memset(p,0,sizeof(p));
        memset(e,0,sizeof(e));

        init();
        double sum = 0;

        for(int i=1;i<=n;i++)
            scanf("%lf%lf",&p[i].x,&p[i].y);

        for(int i=1;i<=m;i++)
        {
            int tx,ty;
            scanf("%d%d",&tx,&ty);
            e[i].x = tx, e[i].y = ty;
            e[i].w = sqrt((p[tx].x - p[ty].x)*(p[tx].x - p[ty].x) + (p[tx].y - p[ty].y)*(p[tx].y - p[ty].y));
            sum += e[i].w;
        }
        sort(e+1,e+m+1);
        printf("%.3f\n",sum-kruskal());
    }
    return 0;
}

Measured memory_bytes: 4280
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 100000;

int n, c, k;
int t[maxn];

int main(void) {
  scanf("%d%d%d", &n, &c, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &t[i]);
  }
  sort(t, t + n);
  int cntbus = 0;
  for (int i = 0; i < n; ) {
    int end = i;
    while (end < n && t[end] - t[i] <= k && end - i + 1 <= c) {
      ++end;
    }
    ++cntbus;
    i = end;
  }
  printf("%d\n", cntbus);
  return 0;
}


Measured memory_bytes: 512
N,k = map(int,input().split())

A = [0] * N
#print(A)
#print(type(A))

for okashi_number in range(k):
	di = int(input())
	D = list(map(int,input().split()))
	for x in range(di):
		A[D[x]-1]= 1
#print(A)
count = 0
for i in range(N):
	if A[i] == 0:
		count = count + 1
print(count)

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

int main(void){
    string S,T;
    cin>>S>>T;

    for(int i=0;i<S.size();i++){
        char f=S[S.size()-1];
        string s=S;
        for(int j=1;j<S.size();j++){
            S[j]=s[j-1];
        }
        S[0]=f;
        if(S==T){
        cout<<"Yes"<<endl;
            return 0;
        }
    }
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
from functools import lru_cache

@lru_cache(None)
def solve(n,k) :
  if n<=9:
    if k==0: return 1
    if k==1: return n
    return 0
  m = n//10
  r = n%10
  return r*solve(m, k-1)+(9-r)*solve(m-1, k-1)+solve(m, k)

N = int(input())
K = int(input())
print(solve(N, K))

Measured memory_bytes: 6240
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,a[200000];
    cin>>n;
    map<int,int>mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i;
        mp[a[i]]++;
    }
    int ans=0;
    for(int i=0;i<n;i++)
        ans+=mp[-i-i-a[i]];
    cout<<ans<<endl;
}

Measured memory_bytes: 27768
#include <stdio.h>


int main(void){
	int x, y, N, n, d, i, j;
	int sx[200], sy[200];
	int SW, SS, SE, SN;
	while(1){
		SW = SS = SE = SN = 0;
		scanf("%d",&N);
		if(N == 0)
			break;
		x = y = 0;
		sx[0] = x; sy[0] = y;
		for(i = 1;i < N;i++){
			scanf("%d%d",&n,&d);
			x = sx[n]; y = sy[n];
			if(d == 0)
				x--;
			else if(d == 1)
				y++;
			else if(d == 2)
				x++;
			else
				y--;
			sx[i] = x; sy[i] = y;
			if(SW > x)
				SW = x;
			else if(SS < y)
				SS = y;
			else if(SE < x)
				SE = x;
			else if(SN > y)
				SN = y;
		}
		printf("%d %d\n",SE - SW + 1,SS - SN + 1);
	}
	return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  int x[20][20];
  int y[20][20];
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }

  // 正直者・嘘つきのパターンを全部試す
  int maxi = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool b[N];
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) b[j] = true;
      else b[j] = false;
    }

    bool ans = true;
    for (int j = 0; j < N; j++) {
      if (!b[j]) continue;
      for (int k = 0; k < a[j]; k++) {
        if (b[x[j][k]-1] != y[j][k]) {
          ans = false;
        }
      }
    }

    if (ans) {
      int cnt = 0;
      for (int j = 0; j < N; j++) if (b[j]) cnt++;
      maxi = max(maxi, cnt);
    }
  }

  cout << maxi << endl;
  return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
PII a[N];
HEAP heap;

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ ) scanf("%d%d", &a[i].F, &a[i].S);
	sort(a, a + n);
	
	int res = 0;
	for (int i = 1, j = 0; i <= m; i ++ )
	{
		while (j < n && a[j].F == i)
		{
			heap.push(a[j].S);
			j ++ ;
		}
		
		if (heap.size())
		{
			res += heap.top();
			heap.pop();
		}
	}
	
	printf("%d\n", res);
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    string s;
    int k;
    cin >>s>>k;

    rep(i,s.length()){
        
        if(i == s.length()-1 && k>0){
            int p=s[i]-'a';
            s[i] = 'a'+(p+k)%26;
            break;
        }

        if(s[i]!='a'){
            int op = 26 - (s[i]-'a');
            //db(op);ln;
            if(k-op >= 0)k-=op;
            else continue;
            s[i]='a';
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<s<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    string S;
    cin >> S;
    stack<int> s1;
    stack<pair<int,int>> s2;
    ll sm = 0;
    REP(i,S.size()) {
        switch (S[i]) {
            case '\\':
                s1.push(i);
                break;
            case '/':
                if(s1.empty()) break;
                auto top = s1.top(); s1.pop();
                sm += i - top;

                auto mizutamari = i-top;
                while(!s2.empty() && s2.top().first > top) {
                    mizutamari += s2.top().second; s2.pop();
                }
                s2.emplace(top,mizutamari);
        }
    }

    list<int> ans;
    while(!s2.empty()) {
        ans.push_front(s2.top().second); s2.pop();
    }
    ans.push_front(ans.size());
    cout << sm << endl;

    for(auto i = ans.begin(); i != ans.end(); i++) {
        if(i != ans.begin()) cout << ' ';
        cout << *i;
    }
    cout << endl;
}

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


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(ll i=(a);i<=(b);i++)
#define repi(i,n) fori(i,0,(n)-1)
#define forr(i,a,b) for(ll i=(b);i>=(a);i--)
#define repr(i,n) forr(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define vec vector<ll>
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

#define N 3000
double p[N];
double dp[N+1][N+1];
void solve(){
    ll n;cin>>n;
    repi(i,n)cin>>p[i];
    dp[0][0]=1;
    fori(i,1,n)fori(j,0,i){
        dp[i][j]=dp[i-1][j]*(1-p[i-1]);
        if(j>0)dp[i][j]+=dp[i-1][j-1]*p[i-1];
    }
    double ans=0;
    fori(i,n/2+1,n)ans+=dp[n][i];
    cout.precision(10);
    cout<<ans<<endl;
}

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


Measured memory_bytes: 68992
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,1000)}
  n := input.NextInt()
  g := make([][]int,n)
  for i:=0;i<n-1;i++ {
    x,y := input.NextInts()
    g[x-1] = append(g[x-1],y-1)
    g[y-1] = append(g[y-1],x-1)
  }
  s := input.NextLine()
  c := make([]bool,n)
  w := 0
  r := -1
  for i:=0;i<n;i++ {
    c[i] = (s[i:i+1] == "B")
    if !c[i] {
      w++
      if r < 0 { r = i }
    }
  }
  if w < 2 { fmt.Println(w);return }
  b := make([]bool,n)
  var trim func(int,int) bool
  trim = func(u,p int) bool {
    ok := c[u]
    for _,v := range g[u] {
      if v == p { continue }
      ok = trim(v,u) && ok
    }
    b[u] = ok
    return ok
  }
  trim(r,-1)
  t := make([][]int,n)
  for i:=0;i<n;i++ {
    if b[i] { continue }
    for _,j := range g[i] {
      if b[j] { continue }
      t[i] = append(t[i],j)
    }
  }
  num := make([]int,n)
  var dfs func(int,int,int)
  dfs = func(u,p,d int) {
    if c[u] != (len(t[u])%2 == 0) { d++ }
    num[u] = d
    for _,v := range t[u] {
      if v == p { continue }
      dfs(v,u,d)
    }
  }
  dfs(r,-1,0)
  for i:=0;i<n;i++ {
    if num[r] < num[i] && !c[i] { r = i }
  }
  dfs(r,-1,0)
  for i:=0;i<n;i++ {
    if num[r] < num[i] && !c[i] { r = i }
  }
  ans := -2*num[r]-2
  for i:=0;i<n;i++ {
    if b[i] { continue }
    ans += 2
    if c[i] != (len(t[i])%2 == 0) { ans++ }
  }
  fmt.Println(ans)
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

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

int n, sum = 0;
string s;

int main() {
	
	cin >> n;
	for(int i = n ; i >= 1 ; i--){
		s = to_string(i);
		if(s.length() % 2 == 1){
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define enter putchar('\n')
#define space putchar(' ')
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-8
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 - '0' + c;
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int L,N;
void add(int u,int v,int c) {
    out(u);space;out(v);space;out(c);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    read(L);
    int r;
    for(r = 20 ; r >= 0 ; --r) {
        if(L & (1 << r)) break;
    }
    N = r + 1;out(N);space;int M = r * 2 + __builtin_popcount(L) - 1;out(M);enter;
    for(int i = 1 ; i <= N - 1 ; ++i) {
        add(i,i + 1,(1 << i - 1));add(i,i + 1,0);
    }
    for(int i = 1 ; i <= N - 1 ; ++i) {
        if(L & (1 << i - 1)) {
            L ^= (1 << i - 1);
            add(i,N,L);
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

bool cmp(const pi &a,const pi &b){
	return a.second*b.first>a.first*b.second;
}
int n; double W;
vector<pi> p;

int main(){
	cin>>n>>W;
	double ans=0;
	rep(i,n){
		int w,v; cin>>w>>v;
		if(w<=0&&v>=0)ans+=v, W-=w;
		else if(v<=0&&w>=0)continue;
		else if(v>0&&w>0)p.pb(mp(w,v));
		else{
			p.pb(mp(-w,-v));
			ans+=v, W-=w;
		}
	}
	sort(all(p),cmp);
	for(int i=0;i<p.size();i++){
		double use=min(1.0,W/p[i].first);
		W-=use*p[i].first;
		ans+=p[i].second*use;
		if(W<EPS)break;
	}
	printf("%.12f\n",ans);
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if(a+b > c+d){
            System.out.println("Left");
        } else if(a+b == c+d){
            System.out.println("Balanced");

        } else {
            System.out.println("Right");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

int a, b, c, d, e;

int main(){
	cin >> a >> b >> c >> d >> e;
	int f = a*e;
	int s = c > e ? b : b + (e - c)*d;
	cout << (f > s ? s : f) << endl;

	return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;  
ll gcd(ll x,ll y)  
{  
    return y==0?x:gcd(y,x%y);  
}  
int main()  
{  
    ll x,y;  
    while(~scanf("%lld%lld",&x,&y))  
    {  
                  ll res1=gcd(x,y);  
                  printf("%lld %lld\n",res1,x*y/res1);  
    }  
    return 0;  
} 

Measured memory_bytes: 596
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const int INF = 1e9;

int N;

//b(N)を構築する
//b[i]は0か1

//a1が1なら全部の和が奇数 -> 1の総数が奇数 0なら1の総数が偶数
//a2が決まれば、2の倍数とそうでない添え字それぞれで1の総数が決定する
//a3が決まれば、

//1は2以降の動作に全く関わらないので、最初に決定してしまえる
//a1が1なら1,a0が0なら0
//としてしまうと他の1の総数が偶数である前提になる
//2はa2が1なら+1,0なら+0とすると 以降の2の倍数が表れる回数は(N/2 - 1) でその1の総数が偶数の全恵智

//NはaNが1なら1, 0なら0
//N-1は k(N-1)の和と a[N-1]の差が奇数なら1、偶数なら0 



int main() {
    cin >> N;
    vector<int> a(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    vector<int> b(N+1,0);
    for (int i = N; i > 0; i--) {
        int tmp = a[i];
        int j = 2 * i;
        while (j <= N) {
            tmp += b[j];
            j += i;
        }
        b[i] = tmp % 2;
    }
    int res = 0;
    for (int i = 1; i <= N; i++) {
        res += b[i];
    }
    cout << res << endl;
    for (int i = 1; i <= N; i++) {
        if (b[i]) cout << i << " ";
    }
    cout << endl;

    
    
    
}


Measured memory_bytes: 2432
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var str string
	var lastWord string
	s_map := make(map[string]bool, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&str)

		if s_map[str] {
			fmt.Print("No")
			return
		}
		if lastWord != "" && str[:1] != lastWord[len(lastWord)-1:]   {
			fmt.Print("No")
			return
		}

		lastWord = str
		s_map[str] = true
	}

	fmt.Print("Yes")
}

Measured memory_bytes: 512
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	string s,t;
	cin>>s>>t;
	cout<<t+s;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 256
// -*- coding: utf-8 -*-
// Last-Updated : <2014/06/19 00:29:01 by samui>

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#define MP(a, b) make_pair(a, b)
#define X first
#define Y second
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); ++(i))
#define rer(i,l,n) for(int (i) = l; (i) <= (int)(n); ++(i))
#define reu(i,l,n) for(int (i) = l; (i) < (int)(n); ++(i))
template<typename T,typename U> inline void amin(T &x,U y){ if(y<x) x = y;}
template<typename T,typename U> inline void amax(T &x,U y){ if(x<y) x = y;}
template<typename TYPE,std::size_t SIZE>
std::size_t len(const TYPE (&array)[SIZE]){return SIZE;}


const int M = 1000000;

void refresh(std::vector<int>& arr,int x){
  rer(i,x,M){
    amin(arr[i],arr[i-x]+1);

  }
}
int main(int argc, char *argv[])
{
  std::vector<int> s(M+10);
  std::vector<int> all(M+10,10000000);
  std::vector<int> odd(M+10,10000000);
  all[0] = 0;
  odd[0] = 0;
  //odd[0] = 0;
  reu(i,1,M+100){
    int x = i*(i+1)*(i+2)/6;
    if(x > M) break;
    rer(j,x,M){
      amin(all[j],all[j-x]+1);
    }
    //refresh(all,x);
    if(x&1) refresh(odd,x);
  }
  int i;
  while(std::cin>>i){
    if(i == 0)
      break;
    std::cout<<all[i]<<" "<<odd[i]<<std::endl;

  }
  return 0;
}

Measured memory_bytes: 12672
#include<iostream>
using namespace std;
int main(){
    char b;
    cin>>b;
char ans;
    switch(b){
        case 'A':ans='T';break;
        case 'T':ans='A';break;
        case 'G':ans='C';break;
        case 'C':ans='G';break;
    }
    cout<<ans<<endl;
}

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

int main()
{
    int N;
    cin >> N;

    const long long MAX = 5e5;

    vector<pair<double, double>> XY(N);

    double x, y;
    for (pair<double, double> &xy : XY)
    {
        cin >> x >> y;
        xy = make_pair(x, y);
    }

    double ans = 0;
    for (long long i = 0; i < MAX; i++)
    {
        double theta = M_PI / 2;
        theta += ((double)i / (double)MAX) * (2 * M_PI);
        x = 0;
        y = 0;
        double c = cos(theta);
        double s = sin(theta);
        for (pair<double, double> xy : XY)
        {
            if (c * xy.first + s * xy.second > 0)
            {
                x += xy.first;
                y += xy.second;
            }
        }
        ans = max(ans, sqrt((double)(x * x + y * y)));
    }
    cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 384