akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main(){
    double w;
     
    while(cin>>w){
        if(w > 91)cout<<"heavy";
        else if(w > 81)cout<<"light heavy";
        else if(w > 75)cout<<"middle";
        else if(w > 69)cout<<"light middle";
        else if(w > 64)cout<<"welter";
        else if(w > 60)cout<<"light welter";
        else if(w > 57)cout<<"light";
        else if(w > 54)cout<<"feather";
        else if(w > 51)cout<<"bantam";
        else if(w > 48)cout<<"fly";
        else cout<<"light fly";
        cout<<endl;
    }
     
    return 0;
}

Measured memory_bytes: 1220
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	ans := ((n-1)/111 + 1) * 111
	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;
import java.util.TreeSet;
import java.util.Map;
import java.util.HashMap;

public class Main{
  static final int INF = Integer.MAX_VALUE / 2;
  static int n;
  static int[] a;

  static final boolean DEBUG = false;

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

    n = sc.nextInt();

    a = new int[3 * n];
    for(int i = 0; i < 3 * n; i++){
      a[i] = sc.nextInt();
    }

    int[] b = new int[3 * n];
    for(int i = 0; i < 3 * n; i++){
      b[i] = a[3 * n - i - 1];
    }

    long[] dp1 = new long[3 * n + 1];
    int min = INF;
    TreeSet< Integer > s1 = new TreeSet< >();
    Map< Integer, Integer > c1 = new HashMap< >();
    for(int i = 0; i < n; i++){
      min = Math.min(min, a[i]);
      dp1[n] += (long)a[i];
      s1.add(a[i]);

      if(!c1.containsKey(a[i])){
        c1.put(a[i], 1);
      }
      else{
        c1.put(a[i], c1.get(a[i]) + 1);
      }
    }
    for(int i = n + 1; i <= 3 * n; i++){
      s1.add(a[i - 1]);
      if(!c1.containsKey(a[i - 1])){
        c1.put(a[i - 1], 1);
      }
      else{
        c1.put(a[i - 1], c1.get(a[i - 1]) + 1);
      }
      if(a[i - 1] > min){
        dp1[i] = dp1[i - 1] - (long)min + (long)a[i - 1];
        if(c1.get(min) == 1){
          c1.remove(min);
          min = s1.higher(min);
        }
        else{
          c1.put(min, c1.get(min) - 1);
        }
      }
      else{
        dp1[i] = dp1[i - 1];
      }
    }

    long[] dp2 = new long[3 * n + 1];
    int max = 0;
    TreeSet< Integer > s2 = new TreeSet< >();
    Map< Integer, Integer > c2 = new HashMap< >();
    for(int i = 0; i < n; i++){
      max = Math.max(max, b[i]);
      dp2[n] += (long)b[i];
      s2.add(b[i]);
      if(!c2.containsKey(b[i])){
        c2.put(b[i], 1);
      }
      else{
        c2.put(b[i], c2.get(b[i]) + 1);
      }
    }
    for(int i = n + 1; i <= 3 * n; i++){
      s2.add(b[i - 1]);
      if(!c2.containsKey(b[i - 1])){
        c2.put(b[i - 1], 1);
      }
      else{
        c2.put(b[i - 1], c2.get(b[i - 1]) + 1);
      }
      if(b[i - 1] < max){
        dp2[i] = dp2[i - 1] - (long)max + (long)b[i - 1];
        if(c2.get(max) == 1){
          c2.remove(max);
          max = s2.lower(max);
        }
        else{
          c2.put(max, c2.get(max) - 1);
        }
      }
      else{
        dp2[i] = dp2[i - 1];
      }
    }

    if(DEBUG){
      for(int i = n; i <= 3 * n; i++){
        System.out.println("dp1[" + i + "] = " + dp1[i]);
      }
      for(int i = n; i <= 3 * n; i++){
        System.out.println("dp2[" + i + "] = " + dp2[i]);
      }
    }

    long ans = Long.MIN_VALUE / 2;
    for(int i = n; i <= 2 * n; i++){
      ans = Math.max(ans, dp1[i] - dp2[3 * n - i]);
      if(DEBUG){
        System.out.println("i = " + i);
        System.out.println("3 * n - i = " + (3 * n - i));
        System.out.println(dp1[i] - dp2[3 * n - i]);
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 115652
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int N;
vector<int> a, b;

int calc(int shift)
{
	// T
	int t = (1 << shift);
	//cout << n << endl;
	vector<int> aa(N), bb(N);
	for(int i=0; i<N; i++){
		aa[i] = a[i] % (t*2);
		bb[i] = b[i] % (t*2);
	}

	sort(bb.begin(), bb.end());
	//cout << "aa : ";
	//for(int i=0; i<N; i++)
	//	cout << aa[i] << " ";
	//cout << endl;
	//cout << "bb : ";
	//for(int i=0; i<N; i++)
	//	cout << bb[i] << " ";
	//cout << endl;

	long long cnt = 0;
	for(int i=0; i<N; i++){
		for(int j=1; j<=2; j++){
			int c = 2 * j -1;
			int lt = c * t;
			int rt = lt + t;
			auto left = lower_bound(bb.begin(), bb.end(), lt-aa[i]);
			auto right = lower_bound(bb.begin(), bb.end(), rt-aa[i]);
			cnt += right - left;
			//cout << aa[i] << " : [" << lt << ", " << rt << ") : " << lt-aa[i] << " " << rt-aa[i] << " : " << right - left << endl;
		}
	}

	return (cnt%2 == 1 ? t : 0);
}

int main(void)
{
	cin >> N;

	a = vector<int>(N);
	for(int i=0; i<N; i++)
		cin >> a[i];

	b = vector<int>(N);
	for(int i=0; i<N; i++)
		cin >> b[i];

	int ret = 0;
	for(int i=0; i<29; i++){
		ret += calc(i);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3432
package main

import (
	"fmt"
)

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

	x := 0

	if b > n {
		x = n
	} else {
		x = b - 1
	}
	fmt.Println(int(float64(a)*float64(x)/float64(b)) - a*int(float64(x)/float64(b)))
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int S;
	scanf("%lld", &S);
	int X1, Y1, X2, Y2, X3, Y3;
	X1 = 0;
	Y1 = 0;
	X2 = (int)(1e9);
	Y3 = (S + X2 - 1) / X2;
	Y2 = 1;
	X3 = X2 * Y3 - S;
//	printf("%lld\n", X2 * Y3 - Y2 * X3);
	printf("%lld %lld %lld %lld %lld %lld\n", X1, Y1, X2, Y2, X3, Y3);
	return 0;
}

Measured memory_bytes: 256
/*
   THE DARK NIGHT RISES
I LOVE YOU 72 AND WILL FOREVER DO SO
Patience, Persistence, Perseverance, Passion, Purpose
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int N = 2e5 + 20 ;
#define F first
#define S second
# define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mk make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x)       (int)x.size()
const long long int mod=1e9 + 7;
const long double EPS=1e-12;
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )
 
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
void solve()
{
    ll a , b ;
    cin >> a >> b ;
    ll ans = 0 ;
    ll lim = (100*a)/8 ;
    for(ll i = -500 ; i < 500 ; i++)
        {
            ld v11 = (ld(lim+i)*8.0)/100.0 , v22 = ld(lim+i)/10.0;
            ll v1 = ll(v11) , v2 = ll(v22) ;
            if(v1==a && v2==b) { ans = lim+i ;break;}
        } 
        if(ans <= 0 ) cout << -1 ;
        else
        cout << ans ;
    
}
int main()
{
    fast;
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
 
    return 0;
}
// Patience, Persistence, Perseverance, Passion, Purpose
// I LOVE YOU 72 AND WILL FOREVER DO SO.

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
const int MOD = INF+7;

int main(){
    int n;ll res = 0;
    cin>>n;
    REP(i,1,n){
        REP(j,1,n){
            REP(k,1,n){
                res += gcd(gcd(i,j),k);
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3192
n,k = gets.split.map(&:to_i)
h = []
n.times{h << gets.to_i}
h.sort!

ans = h[k-1] - h[0]
i = 0
while i + k - 1 < n
    ans = h[i+k-1] - h[i] if ans > h[i+k-1] - h[i]
    i += 1
end

puts ans

Measured memory_bytes: 4016
#include<iostream>
#include<cstdio>
#include<algorithm>
const int N=2e5+5;
struct Edge {
    int u,v,w;
    bool operator < (const Edge &b) const {
        return w>b.w;
    }
}a[N];
int par[N];bool ban[N];
int fd(int x) {
    return par[x]==x?x:par[x]=fd(par[x]);
}
void init(int n) {
    for(int i=1;i<=n;i++) {
        par[i]=i;
        ban[i]=false;
    }
}
int main() {
    int n,h,w;
    scanf("%d%d%d",&n,&h,&w);
    for(int i=1;i<=n;i++) {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        a[i].w=w;a[i].u=u;
        a[i].v=v+h;
    }
    init(h+w);
    long long ans=0;
    std::sort(a+1,a+1+n);
    for(int i=1;i<=n;i++) {
        int u=a[i].u,v=a[i].v;
        u=fd(u);v=fd(v);
        if(u!=v) {
            if(ban[u]&&ban[v]) continue;
            par[u]=v;
            ban[v]=ban[v]||ban[u];
        }
        else {
            if(!ban[u]) {
                ban[u]=1;
            }
            else continue;
        }
        ans+=a[i].w;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2688
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

ll op(ll a, ll b){return max(a, b);};
ll e(){return -1;};
ll target;
bool f(ll x){
    return x < target;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,q; cin >> n >> q;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    segtree<ll, op, e> seg(a);
    rep(i,0,q){
        ll t,x,y; cin >> t >> x >> y;
        if(t == 1){
            x--;
            seg.set(x, y);
        }
        else if(t == 2){
            x--;
            cout << seg.prod(x, y) << "\n";
        }
        else{
            target = y;
            x--;
            ll id = seg.max_right<f>(x);
            cout << id + 1 << "\n";
        }
    }
}

Measured memory_bytes: 9048
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k - 1])

Measured memory_bytes: 38256
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;

bool check(string s, string t){
  for(int i = 1; i < 26; ++i){
    for(int j = 0; j < (int)s.size(); ++j){
      if(s[j] == 'a' + i){
	--s[j];
	if(s[j] != t[j]) return false;
	break;
      }
      if(s[j] < 'a'+i && s[j] != t[j]) return false;
    }
  }
  return true;
}

void make(set<string> &S, string s, string ret, int i){
  //cout << ret << endl;
  if(s.size() == ret.size()){
    S.insert(ret);
    return;
  }
  string ret1 = ret + string(1,s[i]), ret2 = ret + string(1,s[i]+1);
  //cout << ret1 << " " << ret2 << endl;
  if(check(ret1,s)) make(S,s,ret1,i+1);
  if(s[i] < 'z' && check(ret2,s)) make(S,s,ret2,i+1);
}

int main(){
  string s;
  while(cin >> s, s != "#"){
    set<string> S;
    make(S,s,"",0);
    cout << S.size() << endl;
    if(S.size() < 11){
      for(set<string>::iterator itr = S.begin(); itr != S.end(); ++itr)
	cout << *itr << endl;
    }else{
      set<string>::iterator itr = S.begin();
      vector<string> V;
      for(int i = 0; i < 5; ++i){
	V.push_back(*itr);
	++itr;
      }
      itr = S.end();
      for(int i = 0; i < 5; ++i){
	--itr;
	V.push_back(*itr);
      }
      sort(V.begin(),V.end());
      for(int i = 0; i < 10; ++i)
	cout << V[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4652
#include <stdio.h>

class Dice3{
public:
	Dice3(){
		number = new int[6];
		checkTable = new int[101];
		for(int i = 0; i < 101; i++) checkTable[i] = -1;
	};
	~Dice3(){
		delete[] number;
		delete[] checkTable;
	};

	void setLabel(int index,int num){
		number[index] = num;
		checkTable[num] = index;
	};

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isValidMember(int inputed[]){
		for(int i = 0; i < 6; i++)
		{
			if(checkTable[inputed[i]] == -1)
				return false;
		}
		return true;
	}
	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* checkTable;
};

int main(){
	Dice3 dice3;
	int tmp,inputed[6];
	for(int i = 0; i < 6; i++){
		scanf("%d",&tmp);
		dice3.setLabel(i,tmp);
	}
	for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);

	if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2692
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    aa=list(map(int, readline().rstrip().split()))
    p=0

    if k<n:
        for i in range(k):
            p=(aa[p]-1)
        print(p+1)
        return

    memo=[-1]*n
    memo[0]=0
    for i in range(n*2):
        p=(aa[p]-1)
        if memo[p]==-1:
            memo[p]=i+1
        else:
            diff=(i+1)-memo[p]
            re=k-i-1
            re=re%diff
            for j in range(re):
                p=(aa[p]-1)
            print(p+1)
            return


    #re=k%n
    #for i in range(re):
    #    p=(aa[p]-1)
    #print(p+1)



    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

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

    vector<int> l(n+2, 0), r(n+2, 0);
    partial_sum(a.begin(), a.end(), l.begin()+1, [](int a, int b){return max(a, b);});
    partial_sum(a.rbegin(), a.rend(), r.rbegin()+1, [](int a, int b){return max(a, b);});

    rep(i, n) ppp(max(l[i], r[i+2]));


    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define ll long long
#define pb(a) push_back(a)
using namespace std;

int main()
{
    vector<int>var(5);
    for(int i=0;i<5;i++)
    cin>>var[i];
    for(int i=0;i<5;i++)
    if(var[i]==0)
    {
        cout<<i+1;
        break;
    }
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

//#define NDEBUG
// for DEBUG {{{
#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))
// }}}

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}
void merge_int(int *a, int *b, int lower, int sep, int upper) {// {{{
	int i_lower = lower;
	int i_upper = sep;
	int i_b = 0;
	while ((i_lower < sep) && (i_upper < upper)) {
		if (a[i_lower] < a[i_upper]) {
			b[i_b++] = a[i_lower++];
		} else {
			b[i_b++] = a[i_upper++];
		}
	}
	if (i_lower >= sep) {
		while (i_upper < upper) {
			b[i_b++] = a[i_upper++];
		}
	} else {
		while (i_lower < sep) {
			b[i_b++] = a[i_lower++];
		}
	}
	for (i_lower = 0; i_lower < i_b; i_lower++) {
		a[i_lower+lower] = b[i_lower];
	}
}// }}}
void merge_sort_int(int *a, int *b, int lower, int upper) {// {{{
	int sep;
	if ((lower == upper) || (lower + 1 == upper)) {
		return;
	}
	sep = (lower + upper) / 2;
	merge_sort_int(a,b,lower,sep);
	merge_sort_int(a,b,sep,upper);
	merge_int(a,b,lower,sep,upper);
}// }}}

int main(int argc, char **argv) {
	int N;
	fscanf(stdin,"%d",&N) > 0;

	int y = N /1.08;
	int z = (y * 1.08);
	if (z == N) {
		fprintf(stdout,"%d\n",y);
		return 0;
	}
	y += 1;
	z = (y * 1.08);
	if (z == N) {
		fprintf(stdout,"%d\n",y);
		return 0;
	}
	if (z > N) {
		fprintf(stdout,":(\n");
	}

	return 0;
}



Measured memory_bytes: 128
import sys
for n, m in (map(int, l.split()) for l in sys.stdin):
    if not n:
        break
    if m == 1:
        print(n)
        continue

    a = list(range(1, n+1))
    rem = 0

    while len(a) > m:
        d, _rem = divmod(len(a)+rem, m)
        for i in list(range(-rem+m-1, len(a), m))[::-1]:
            del a[i]
        rem = _rem

    while len(a) > 1:
        i = (m % len(a) - rem - 1) % len(a)
        del a[i]
        rem = len(a)-i

    print(a[0])


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  long long N; cin>>N;
  vector<string> S(N);
  for(long long i=0;i<N;i++) cin>>S[i];
  vector<long long> c(5,0);

  for(long long i=0;i<N;i++){
    if(S[i][0]=='M') c[0]++;
    else if(S[i][0]=='A') c[1]++;
    else if(S[i][0]=='R') c[2]++;
    else if(S[i][0]=='C') c[3]++;
    else if(S[i][0]=='H') c[4]++;
  }

  long long ans=0;
  ans+=c[0]*c[1]*c[2];
  ans+=c[0]*c[1]*c[3];
  ans+=c[0]*c[1]*c[4];
  ans+=c[0]*c[2]*c[3];
  ans+=c[0]*c[2]*c[4];
  ans+=c[0]*c[3]*c[4];
  ans+=c[1]*c[2]*c[3];
  ans+=c[1]*c[2]*c[4];
  ans+=c[1]*c[3]*c[4];
  ans+=c[2]*c[3]*c[4];

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 6144
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn solve(src: &str) -> f64 {
    input! {
        source=src,
        n:usize,
    }
    let odd = (n + 1) / 2;
    let ans = odd as f64 / n as f64;

    ans
}

fn main() {

    println!("{}", solve(&stdin!()));
}








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

int main(){
	int a, b, A;
	char op;
	
	while(1){
	cin >> a >> op >> b;
	if(op == '+'){
		A = a + b;
	}
	else if(op == '-'){
		A = a - b;
	}else if(op == '*'){
		A = a * b;
	}else if(op == '/'){
		A = a / b;
	}else{
		break;
	}
	
	cout << A << endl;
	}
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S,T;
ll nxt[200010][26];

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

  cin>>S>>T;
  ll N=S.size();
  ll M=T.size();
  S="$"+S+S;

  memset(nxt,-1,sizeof(nxt));
  for(ll i=2*N-2;i>=0;i--){
    rep(j,26){
      if(S[i+1]-'a'==j){
        nxt[i][j]=i+1; // i から次のalphabet 'a'+j までの position がi+1
      }else{
        nxt[i][j]=nxt[i+1][j]; 
      }
    }
  }

  ll crt=0,res=0;
  rep(i,M){
    if(nxt[crt][T[i]-'a']==-1){
      cout<<-1<<endl;
      return 0;
    }
    res+=nxt[crt][T[i]-'a']-crt;
    crt=nxt[crt][T[i]-'a']%N;
  }
  cout<<res<<endl;

  return 0;
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int d = a[0] + k - a[n - 1];
  rep(i, n - 1) d = max(d, a[i + 1] - a[i]);

  int ans = k - d;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli a,b;
    cin>>a>>b;
    if(2*a>b) return cout<<"No", 0;
    
    lli rem=b-2*a;
    if(rem%2 || rem>2*a) return cout<<"No", 0;
    
    return cout<<"Yes", 0;
    return 0;
}

Measured memory_bytes: 3596
import numpy
N = int(input())
a = numpy.array([int(i) for i in input().split()])
min =  10**9+1
minus = 0
total = 0
for i in a :
    if i < 0 :
        minus += 1
    if abs(i) < min :
        min = abs(i)
    total += abs(i)
#    print(i,min,total)
if minus %2 == 0 :
    print(total)
else :
    print(total-min*2)


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

using namespace std;

const int N = 1234567;

int a[N], pr[N], ne[N], pos[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    pos[a[i]] = i;
  }
  for (int i = 0; i <= n + 1; i++) {
    pr[i] = i - 1;
    ne[i] = i + 1;
  }
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    int j = pos[i];
    ans += i * 1LL * (j - pr[j]) * (ne[j] - j);
    pr[ne[j]] = pr[j];
    ne[pr[j]] = ne[j];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
N, K = map(int, input().split())
td = [list(map(int, input().split()))
      for _ in range(N)]
td.sort(key=lambda x: -x[1])
q = []
v = set()
sd = 0
for t, d in td[:K]:
    sd += d
    if t in v:
        q.append(d)
    v.add(t)
ans = len(v) ** 2 + sd
for t, d in td[K:]:
    if 0 >= len(q):
        break
    if t in v:
        continue
    v.add(t)
    md = q.pop()
    sd = sd - md + d
    tans = len(v) ** 2 + sd
    ans = max(ans, tans)
print(ans)


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  string s; cin>>s;
  string ans="";
  rep(i,s.size())
  {
    if(s[i]=='C'||s[i]=='F') ans+=s[i];
  }
  rep(i,ans.size()-1)
  {
    if(ans.substr(i,2)=="CF")
    {
      print("Yes");
      return 0;
    }
  }
  print("No");

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        Set<String> set = new HashSet<>();
        int n = scanner.nextInt();
        for(int i = 0; i < n; i++){
            String s = scanner.next();
            set.add(s);
        }
        System.out.println(set.size());
    }
}


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

int main(void) {

  string youbi;
  cin >> youbi;

  if (youbi == "MON") {
    cout << 6 << endl;
  } else if (youbi == "TUE") {
    cout << 5 << endl;
  } else if (youbi == "WED") {
    cout << 4 << endl;
  } else if (youbi == "THU") {
    cout << 3 << endl;
  } else if (youbi == "FRI") {
    cout << 2 << endl;
  } else if (youbi == "SAT") {
    cout << 1 << endl;
  } else {
    cout << 7 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n=int(input())

headB=0
tailA=0
middleAB=0
ck=0
for _ in range(n):
    s=list(input())

    for i in range(1,len(s)):
        if s[i-1]=="A" and s[i]=="B":
            middleAB+=1
    if s[0]=="B":
        headB+=1
    if s[-1]=="A":
        tailA+=1
    if s[0]=="B" and s[-1]=="A":
        ck+=1

#BA
#BC
#CA みたいなケースは2になる

#BA
#BA　みたいなケースは１になる

if ck>0 and ck==tailA and ck==headB:
    print(middleAB+min(headB,tailA)-1)
else:
    print(middleAB+min(headB,tailA))



Measured memory_bytes: 50536
#include<stdio.h>
#define MAX 100000

int parent(int i){
    return i/2;
}
int left(int i){
    return 2*i;
}
int right(int i){
    return 2*i+1;
}
int main(){
    int H,A[MAX+1],i;

    scanf("%d",&H);
    for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
    for(i=1;i<=H;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if(parent(i) >= 1){
        printf("parent key = %d, ",A[parent(i)]);
        }
        if(left(i) <= H){
        printf("left key = %d, ",A[left(i)]);
        }
        if(right(i) <= H){
        printf("right key = %d, ",A[right(i)]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;
	long N, M; cin >> N >> M;
	long L[100009], R[100009]; for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
	long mycount[100009] = {};

	for (int i = 0; i < M; i++) mycount[L[i]]++;
	for (int i = 0; i < M; i++) mycount[R[i] + 1]--;

	for (int i = 1; i <= N ; i++) mycount[i] += mycount[i - 1];

    for(int i = 1; i <= N ; i++) if(mycount[i] == M) res++;
    
	cout << res << endl;
}

Measured memory_bytes: 2560
L = int(input())

def decompose(L):
    if L < 2:
        assert L == 1
        return []
    r = L % 2
    return [r] + decompose((L - r) // 2)

dec = decompose(L)

N = len(dec) + 1
edge = []

base = 1
for i in range(len(dec) - 1, -1, -1):
    for w in range(2):
        edge.append((i+1, i+2, w * base))
    base *= 2
    for w in range(dec[i]):
        edge.append((i+1, N, base + w))
    base += dec[i]

M = len(edge)
print(N, M)
for e in edge:
    print(' '.join(map(str, e)))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;
ll ans[300000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        ll a;
        cin >> a;
        ans[a]++;
    }
    for(int i = 1; i <= N; i++) cout << ans[i] << endl;
    return 0;
}


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

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

    for(int i = 0; i < N.length(); i++){
        if(N[i] == '1'){
            N[i] = '9';
        }else if(N[i] == '9'){
            N[i] = '1';
        }
    }cout << N << endl;
}

Measured memory_bytes: 256
import math

N = int(input())
numberList = []
numberList = list(map(int, input().split(" ")))
numberList.sort(reverse=True)
numberDict = {}

for number in numberList:
    if number not in numberDict:
        numberDict[number] = 0
    numberDict[number] += 1

ret = 0

for number in numberList:
    if numberDict[number] > 0:
        numberDict[number] -= 1
#        print(number)
#        print(math.log(number,2))
        gap = 2 ** (int(math.log(number, 2)) + 1) - number
        if gap in numberDict and numberDict[gap] > 0:
            numberDict[gap] -= 1
            ret += 1

print(ret)


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

int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  if(a[0] == 5 && a[1] == 5 && a[2] == 7){
    cout << "YES\n";
  }else{
    cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    while (1) {
        c -= b;
        if (c <= 0) {
            std::cout << "Yes" << std::endl;
            break;
        }

        a -= d;
        if (a <= 0) {
            std::cout << "No" << std::endl;
            break;
        }
    }
}


Measured memory_bytes: 3592
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, T): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let (A, B): (Vec<usize>, Vec<usize>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    let I = {
        let mut I = (0..N).collect::<Vec<_>>();
        I.sort_by_key(|&i| A[i]);
        I
    };
    let mut dp = vec![0; T + 1];
    for &i in &I {
        dp[T] = std::cmp::max(dp[T], *dp[0..T].iter().max().unwrap() + B[i]);
        for k in (A[i]..T).rev() {
            dp[k] = std::cmp::max(dp[k], dp[k - A[i]] + B[i]);
        }
    }
    let ans = dp[T];

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


Measured memory_bytes: 4476
from collections import defaultdict
d = defaultdict(int) 
n=int(input())
a=list(map(int,input().split()))
q=int(input())

L=[]

for key in a:
    d[key] += 1
# for i in range(len(a)):
#     L.append(a[i])
#     d[a[i]]+=1
#     L.append(d)
s=0
# for k,v in enumerate(dict(d)):
#     s+=k*v
#     L.append(s)
s=sum(a)

for j in range(q):

    b,c=map(int,input().split())
    s+=d[b]*(c-b)
    d[c]+=d[b]
    d[b]=0
    L.append(s)
for j in range(len(L)):
    print(L[j])

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

bool debug = false;
string ds;
int ask(int i){
	string s;
	if( debug ){
		s = ds[i];
	}else{
		cout << i << endl;
		cin >> s;
	}

	if( s[0] == 'V'){
		return -1;
	}
	return s[0] == 'F' ? 1 : 0;
}

int solve(int N){
	int p0 = ask(0);
	if( p0 == -1 ) return -1;
	int l = 0, r = N - 1;
	while( l != r ){
		int m = (l+r) / 2;
		int am = ask(m);
		if( am == -1 ) return -1;
		if( (m % 2) ^ (am != p0)){
			r = m;
		}else{
			l = m + 1;
		}
	}
	return ask(l);
}

int main(){	
	// while(true){
	// 	// int n = 2 * (rand() % 100) + 1;
	// 	int n = 5;
	// 	ds = "MFMFV";
	// 	// for(int i = 0 ; i < n ; i++){
	// 	// 	char c = "FMV"[rand() % 3];
	// 	// 	if( c == 'V' || ds.size() == 0 ) ds += c;
	// 	// 	else if( c != 'V' and ds.back() == c){
	// 	// 		i--;
	// 	// 		continue;
	// 	// 	}else{
	// 	// 		ds += c;
	// 	// 	}
	// 	// }
	// 	// if( ds.back() != 'V' && ds.back() == ds.front() ) continue;
	// 	// if( count(ds.begin(),ds.end(),'V') == 0 ) continue;
	// 	// if( solve(n)!= -1 ){
	// 		cout << solve(n) << " " << ds << endl;
	// 		// return 0;
	// 	// }
	// }
	int N;
	cin >> N;
	solve(N);
	return 0;
}



Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> d(n+5,7);
    int b[n+5]={};
    for(int i=0;i<n;i++){
        cin>>d[i]>>b[i];
    }
    int aa=0;
    for(int i=0;i<n;i++){
        if(d[i]==b[i]&&d[i+1]==b[i+1]&&b[i+2]==d[i+2]){
        aa++;
        }
    }

    if(aa>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return(0);
    }

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#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())
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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<62;
constexpr double eps = (1e-9);

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> p(n);
  vector<pair<int, int>> c;
  rep(i, m) {
    int pp, y;
    cin >> pp >> y;
    pp--;
    c.push_back({pp, y});
    p[pp].push_back(y);
  }

  rep(i, n) sort(ALL(p[i]));

  for (auto& v : c) {
    auto& vec = p[v.first];
    auto itr = lower_bound(ALL(vec), v.second);
    int num = int(itr - vec.begin());
    printf("%06d%06d\n", v.first + 1, num + 1);
  }

  return 0;
}


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

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

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, s=0, c=0, l;
    string a, b;
    cin >> a >> b;
    if(a.size()+1==b.size())
    {
        for(i=0; i<a.size(); i++)
        {
            if(a[i]==b[i])
                s++;
            else
            {
                break;
            }
            
        }
        if(s==a.size())
            cout << "Yes\n";
        else
        {
            cout << "No\n";
        }
        
    }
    else
    {
        cout << "No\n";
    }
    
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
int dp[2][(1 << 15) + 10][5];

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

	vector<int> s;
	for(int i = 1; i < 1 << 8 && i * i <= 1 << 15; i++) {
		s.push_back(i * i);
	}

	dp[0][0][0] = 1;
	for(int i = 0; i < s.size(); i++) {
		for(int j = 0; j <= 1 << 15; j++) {
			for(int k = 0; k <= 4; k++) {
				if(dp[0][j][k] == 0) continue;
				for(int l = 0; k + l <= 4; l++) {
					if(j + l * s[i] < (1 << 15) + 10) {
						dp[1][j + l * s[i]][k + l] += dp[0][j][k];
					}
				}
			}
		}
		swap(dp[0], dp[1]);
		for(int j = 0; j <= 1 << 15; j++) {
			for(int k = 0; k <= 4; k++) {
				dp[1][j][k] = 0;
			}
		}
	}

	int n;
	while(cin >> n, n) {
		int ans = 0;
		for(int i = 1; i <= 4; i++) {
			ans += dp[0][n][i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4408
#include <iostream>
#include <string>
using i64 = long long;

int main() {
    std::string s, t;
    std::cin >> s >> t;
    int ret = 0;
    for (int i = 0; i < s.size(); i++) ret += s[i] != t[i];
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3884
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        list.add(a + b);
        list.add(a - b);
        list.add(a * b);
        System.out.println(Collections.max(list));
    }
}

Measured memory_bytes: 35688
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a = [-1] * n
flag = 1
for i in range(0, m):
    s, c = map(int, input().split())
    if n > 1 and s == 1 and c == 0:
        flag = 0
        break
    if a[s-1] == -1:
        a[s-1] = c
    else:
        if a[s-1] != c:
            flag = 0
            break

if flag == 1:
    if n == 1 and (a[0] == -1 or a[0] == 0):
        print(0)
    else:
        ans = ""
        if a[0] == -1:
            a[0] = 1
        ans += str(a[0])
        for i in range(1, n):
            if a[i] == -1:
                a[i] = 0
            ans += str(a[i])
        print(ans)
        
else:
    print(-1)

Measured memory_bytes: 3064
use proconio::{
    input,
    marker::Chars,
};

fn main() {
    input! {
        s: Chars,
    }

    let mut b_count: usize = 0;
    let mut count: usize = 0;
    for c in s {
        match c {
            'B' => {
                b_count += 1;
            },
            'W' => {
                count += b_count;
            },
            _ => {},
        }
    }

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


Measured memory_bytes: 3012