akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	int[] preorder = new int[n];
	int[] inorder = new int[n];
	String[] inputPre, inputIn;
	inputPre = scan.nextLine().split(" ");
	inputIn = scan.nextLine().split(" ");
	for (int i = 0; i < n; i++) {
	    preorder[i] = Integer.parseInt(inputPre[i]);
	    inorder[i] = Integer.parseInt(inputIn[i]);
	}
	Reconstructer recnst = new Reconstructer(preorder, inorder);
	recnst.runReconstruct();
	recnst.printPostorder();
    }
}
class Reconstructer {
    int[] preorder;
    int[] inorder;
    int[] postorder;
    int prePosition, postPosition;
    Reconstructer (int[] preorder, int[] inorder) {
	this.preorder = preorder;
	this.inorder = inorder;
	postorder = new int[preorder.length];
    }
    void runReconstruct () {
	reconstruct(0, preorder.length);
    }
    void reconstruct (int left, int right) {
	if (left >= right) {
	    return;
	}	
	int inPosition = 0;
	int node = preorder[prePosition++];
	while (node != inorder[inPosition]) {
	    inPosition++;
	}
	reconstruct(left, inPosition);
	reconstruct(inPosition+1, right);
	postorder[postPosition++] = node;
    }
    void printPostorder () {
	StringBuilder sb = new StringBuilder();
	int n = postorder.length;
	for (int i = 0; i < n - 1; i++) {
	    sb.append(postorder[i] + " ");
	}
	sb.append(postorder[n-1] + "\n");
	System.out.print(sb);
    }
}

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

int main () {
  long long n, m;
  cin >> n >> m;
  vector<long long> sei;
  vector<long long> hu;
  long long sub;
  for (long long i = 0; i < n; i++) {
    cin >> sub;
    if (sub >= 0) {
      sei.push_back(sub);  
    }   
    else { 
      hu.push_back(-1 * sub);  
    }
  }  
  if (hu.size() > 0) {
    reverse(hu.begin(), hu.end());
  }
  

  // まず...
  long long min = -1;
  if (m <= sei.size()) {
    min = sei[m - 1];      
  }
    // 負の力を借りる
    for (long long i = 0; i <= (m - 1); i++) {
      
      // つまりm - i個負から借りる
      if ((m - i) <= hu.size() && i <= sei.size()) {
        long long sus, sussus;
        long long minmin;
        sus = (i == 0) ? 0 : (sei[i - 1]);
        sussus = hu[m - i - 1];  
        if (sus > sussus) {
          minmin = sus + sussus * 2;    
        }
        else {
          minmin = sus*2 + sussus;  
        }
        if (minmin < min || min < 0) {
          min = minmin;  
        } 
      }  
    }  
  cout << min << endl;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	for(char c: s)
		cout << 'x';
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve()
{
    int N;

    std::cin >> N;

    int num;

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

    std::sort(nums.begin(), nums.end());

    double sum = nums[0];

    for (int i = 1; i < N; ++i)
        sum = (sum + nums[i]) / 2.0;

    cout << setprecision(14) << sum << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back

const int N = 1e3 + 5;
int n, x[N], y[N], cnt[2];
vector<int> d;
string ans[N];

bool in (int lim, int x, int y) { return x + y <= lim && x + y >= -lim && x - y >= -lim && x - y <= lim; }

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i], cnt[ ( (x[i] + y[i]) % 2 + 2) % 2 ] ++, ans[i] = "";
    if (cnt[0] && cnt[1]) return cout << -1, 0;

    for (int i = 30; i >= 0; --i) d.pb(1 << i);

    for (int _ = 1; _ <= n; ++_) {
        if (cnt[0]) x[_] --;
        for (int i : d) {
            if (in(i - 1, x[_] - i, y[_]) ) {
                ans[_] += 'R';
                x[_] = x[_] - i;
            }
            else if (in(i - 1, x[_] + i, y[_]) ) {
                ans[_] += 'L';
                x[_] = x[_] + i;
            }
            else if (in(i - 1, x[_], y[_] - i) ) {
                ans[_] += 'U';
                y[_] = y[_] - i;
            }
            else if (in(i - 1, x[_], y[_] + i) ) {
                ans[_] += 'D';
                y[_] = y[_] + i;
            }
        }
        reverse(ans[_].begin(), ans[_].end() );
        if (cnt[0]) ans[_] += 'R';
    }

    reverse(d.begin(), d.end() );
    if (cnt[0]) d.pb(1);

    cout << d.size() << '\n';
    for (int _ : d) cout << _ << ' '; cout << '\n';
    for (int _ = 1; _ <= n; ++_) cout << ans[_] << '\n';

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	map<pair<int,string >,int>m1;
	int penaltis = 0;
	int ac = 0;
	while(m--){
		int x;
		string s;
		cin>>x>>s;
		if(s == "WA"){
			if(m1[{x,"AC"}] == 0)
				m1[{x,s}]++;
		}else{
			if(m1[{x,s}] == 0){
				ac++;
				penaltis += m1[{x,"WA"}];
				m1[{x,s}]  = 1;
			}
		}
	}
	cout<<ac<<" "<<penaltis<<endl;
	return 0;
}


Measured memory_bytes: 22228
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    string S;
    cin >> S;
    int cnt = 0;
    char before = S[0];
    rep2(i, 1, S.size())
    {
        if (before != S[i])
        {
            cnt++;
        }
        before = S[i];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let mut ans = 0;
    for i in 0..3 {
        for j in i..3 {
            if !&s[i..j+1].contains('S') && j+1-i > ans {
                ans = j+1-i;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2092
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int

	fmt.Scan(&n)
	count, prev := 0, math.MaxInt64
	for i := 0; i < n; i++ {
		var p int
		fmt.Scan(&p)
		if p < prev {
			prev = p
			count++
		}
	}

	fmt.Println(count)
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = 998244353;
const int N = 3005;

int dp[N][N];
int a,b,c,d;

int rec(int x,int y)
{
    if(x == a && y == b)return 1;
    if(x<a || y<b)return 0;
    if(dp[x][y] != -1)return dp[x][y];
    int ans = (y*rec(x-1,y))%M;
    ans += (x*rec(x,y-1))%M;ans %= M;
    ans -= (((x-1)*(y-1))*rec(x-1,y-1))%M;
    ans += M;ans %= M;
    dp[x][y] = ans;
    return ans;
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        memset(dp,-1,sizeof(dp));
        cin>>a>>b>>c>>d;
        cout<<rec(c,d)<<endl;
    }
    return 0;
}


Measured memory_bytes: 74592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		sc.close();

		int[] a = {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};
		System.out.println(a[k - 1]);
	}
}


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

#define Online 1
// #define multitest 1
#define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

bool yymm(int y,int m)
{
    if(m>0 && m<=12) return true;
    return false;
}
void solve()
{
    string str;
    cin >> str;
    int x = (str[0]-'0')*10+str[1]-'0';
    int y = (str[2]-'0')*10+str[3]-'0';
    bool a = yymm(x,y);
    bool b = yymm(y,x);
    if(a&&b) cout << "AMBIGUOUS";
    else if(a) cout << "YYMM";
    else if(b) cout << "MMYY";
    else cout << "NA";
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

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


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

  int a,b,c;
  cin >> a >> b >> c;
  if(b-a==c-b) cout <<"YES" << endl;
  else cout << "NO" << endl;
  
		 

  return 0;
    

}


Measured memory_bytes: 256
import collections
N = int(input())
l = []
for i in range(N):
    l.append(input())

c = collections.Counter(l)
cc = c.most_common()
cc.sort(key=lambda x: x[1],reverse=True)
ll = []
m = 0
for k,v in cc:
    if v >= m:
        m = v
        ll.append((k))
ll = sorted(ll)
for a in ll:
    print(a)


Measured memory_bytes: 119920
#include<iostream>
#include<vector>

int main() {
	std::vector<int> v(2, 1);
	int num;

	std::cin >> num;

	while (v.size() < num + 1) {
		v.push_back((v.back()) + (v[v.size() - 2]));
	}

	std::cout << v.back() << std::endl;

	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
    int main(void) {
      int N,T[1000],M,P[1000],X[1000],i,j,ans[1000];
      scanf("%d",&N);
      for(i=0;i<N;i++){
        scanf("%d",&T[i]);
      }
      scanf("%d",&M);
      for(i=0;i<M;i++){
        scanf("%d %d",&P[i],&X[i]);
      }
      for(i=0;i<M;i++){
        for(j=0;j<N;j++){
          if((P[i]-1)==j){
            ans[i]+=X[i];
          }else{
          ans[i]+=T[j];
          }
        }
        printf("%d\n",ans[i]);
      }
      return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,r;
    cin>>n>>r;
    int dr=0,ir=0;
    if(n>=10)
    {cout<<r<<endl;
    }
    else
    {dr=100*(10-n);
    ir=r+dr;
    cout<<ir<<endl;
    }
    
}

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

int w, h; 
struct Pos {
  int x;
  int y;
  bool operator==(Pos that) {
    return x == that.x && y == that.y;
  }
  Pos operator+(Pos that) {
    return {x+that.x, y+that.y};
  }

  Pos (int xx, int yy) {
    x = xx; y = yy;
  }
};

bool inner(Pos p) {
  return 0 <= p.x && p.x < w
      && 0 <= p.y && p.y < h;
}

Pos search_charactor(vector<string> &map, char charactor) {
  for (int i=0; i<map.size(); i++)
    for (int l=0; l<map[i].size(); l++)
      if (map[i][l] == charactor) {
        map[i][l] = '.';
        return {l, i};
      }
}

bool exnor (bool x, bool y) {
  return !(x xor y);
}

template <typename T>
using V=vector<T>;

int main(){
  while (cin >> w >> h, w+h != 0) {
    vector<string> rooml, roomr;
    rooml.reserve(h); roomr.reserve(h);
    for (int i=0; i<h; i++) {
      string l, r;
      cin >> l >> r; 
      reverse(r.begin(), r.end());
      rooml.push_back(l);
      roomr.push_back(r);
    }
    Pos len_pos = search_charactor(rooml, 'L');
    Pos rin_pos = search_charactor(roomr, 'R');
    Pos len_goal = search_charactor(rooml, '%');
    Pos rin_goal = search_charactor(roomr, '%');

    queue<pair<Pos, Pos>> q;
    q.push(make_pair(len_pos, rin_pos));
    // cout<<"goal: ("<<len_goal.x<<", "<<len_goal.y<<") "<<"("<<rin_goal.x<<", "<<rin_goal.y<<")"<<endl;
    // for (int i=0; i<rooml.size(); i++) {
    //   cout << rooml[i] << " " << roomr[i] << endl;
    // }

    V<V<V<V<bool>>>> already(h, V<V<V<bool>>>(w, V<V<bool>>(h, V<bool>(w, false))));
    bool f = true;
    while (!q.empty()) {
      Pos len = q.front().first;
      Pos rin = q.front().second; 
      q.pop();
      // cout<<"("<<len.x<<", "<<len.y<<") "<<"("<<rin.x<<", "<<rin.y<<")"<<endl;

      if (len==len_goal && rin==rin_goal) {
        cout << "Yes" << endl;
        f = false;
        break;
      }

      for (Pos np: {Pos(0,1), Pos(0,-1), Pos(1,0), Pos(-1,0)}) {
        Pos l = (inner(np+len) && rooml[np.y+len.y][np.x+len.x] == '.') ? len + np : len;
        Pos r = (inner(np+rin) && roomr[np.y+rin.y][np.x+rin.x] == '.') ? rin + np : rin;
        if (!already[l.y][l.x][r.y][r.x] && inner(l) && inner(r) 
          && rooml[l.y][l.x] == '.' && roomr[r.y][r.x] == '.'
          && exnor(l==len_goal, r==rin_goal)) {
          q.push(make_pair(l, r));
          already[l.y][l.x][r.y][r.x] = true;
        }
      }
    }
    if (f) cout << "No" << endl;
  }
}



Measured memory_bytes: 12168
if __name__ == '__main__':
    n = int(input())
    x = [int(i) for i in input().split()]
    min = -1

    for i in range (100):
        sum = 0
        i = i+1
        for j in x:
            sum =sum + (i - j) * (i - j )

        if min == -1 or min > sum:
            min = sum
    print(min)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
 
int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);

	long long int a,b;
	cin>>a>>b;
	long long int c[a],ct=0;
	forr(i,0,a)
		cin>>c[i];
	sort(c,c+a);
	forr(i,0,a-b)
	{
		ct+=c[i];
	}
	cout<<ct;
	
	return 0;	
}

Measured memory_bytes: 1792
n = gets.to_i
a = gets.split.map &:to_i
n.times do |i|
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v do
    a[j+1] = a[j]
    j -= 1
  end
  a[j+1] = v
  puts a.join(" ")
end


Measured memory_bytes: 6892
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
V a;
ll func(ll b){
	ll res=0LL;
	repi(itr,a){
		res+=abs(b+(*itr));
	}
	return res;
}




//include  ll func(ll value)

//三部探索、(下限、上限、探す場所(falseで最大値))->極値の場所と値
pair<ll,ll>TripleSearch(ll begin,ll end,bool comp=true){
	pair<ll, ll> down,up, pup, pdown,res;
	down = mp(begin, func(begin));
	up = mp(end, func(end));
	if((down.S <up.S)xor comp){
		res=up;
	}else{
		res=down;
	}
	while (down.F + 2 < up.F){
		pup.F = down.F + 2 * (up.F - down.F) / 3;
		pdown.F = down.F + (up.F - down.F) / 3;
		pup.S = func(pup.F);
		pdown.S = func(pdown.F);
		if (pdown.S < pup.S){
			up = pup;
			if((pdown.S <res.S)== comp){
				res=pdown;
				}
		}else{
			down = pdown;
			if ((pup.S < res.S) == comp){
				res = pup;
			}
		}
	}
	return res;
}

int main(){
	int n;
	ll ans=0LL;
	cin >>n;
	a.resize(n);
	rep(i,n){
		cin>>a[i];
		a[i]-=(i+1);
		a[i]*=-1LL;
		clog<<a[i]<<endl;
	}
	//=----------------//triple tharch
	cout<<TripleSearch(-1e10,1e10).S<<endl;
	//----------------//
	//cout<<min(up.S,min(down.S,min(pup.S,pdown.S)))<<endl;
}
/*
|a-b|:a-b or b-a

2 2 3 5 5
|2-b-1| |2-b-2| |3-b-3| |4-b-5| |5-b-5|

|1-b| |b| |b| |1-b| |b| =>2

|2-b-6| |2-b-5| |3-b-4| |4-b-3| |5-b-2| |6-b-1|

|4+b| |3+b| |1+b| |1-b| |3-b| |5-b|
|1-b| |1+b| |3-b| |3+b| |4+b| |5-d|

-4->

|1-b-1| |2-b-1| |3-b-1| |4-b-2| |5-b-3| |6-b-4|
|1-b| |1-b|  |2-b| |2-b| |2-b| |2-b|
0=>10
1=>4
2->2
3->8
*/

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define ALL(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int sx,sy,tx,ty;

main()
{
        cin>>sx>>sy>>tx>>ty;
        tx-=sx; ty-=sy;
        sx=0; sy=0;
        string ans="";
        rep(i,ty)ans.push_back('U');
        rep(i,tx)ans.push_back('R');

        rep(i,ty)ans.push_back('D');
        rep(i,tx)ans.push_back('L');

        rep(i,1)ans.push_back('L');
        rep(i,ty+1)ans.push_back('U');
        rep(i,tx+1)ans.push_back('R');
        rep(i,1)ans.push_back('D');

        rep(i,1)ans.push_back('R');
        rep(i,ty+1)ans.push_back('D');
        rep(i,tx+1)ans.push_back('L');
        rep(i,1)ans.push_back('U');

        cout<<ans<<endl;
}

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

using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    vvi g(n + 1);

    for(int i = 0; i < n - 1; i++)
    {
        int a, b; cin >> a >> b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    vi col(n + 1);

    col[1] = 1;
    col[n] = 2;

    queue<int> q;

    q.push(1);
    q.push(n);

    while(!q.empty())
    {
        int k = q.front(); q.pop();

        for(auto x : g[k]) if(!col[x])
        {
            col[x] = col[k];
            q.push(x);
        }
    }

    vi cnt(3);

    for(int i = 1; i <= n; i++) cnt[col[i]]++;

    string ans;

    if(cnt[1] > cnt[2]) ans = "Fennec";
    else ans = "Snuke";

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

Measured memory_bytes: 6144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    int n, r_num=0, w_num=0;
    char c[200001];
    scanf("%d", &n);
    scanf("%s", c);
    for(int i=0;i<n;i++){
        if(c[i] == 'R'){
            r_num++;
        }
    }
    for(int j=0;j<r_num;j++){
        if(c[j] == 'W'){
            w_num++;
        }
    }
  	if(w_num == 0){
      printf("0");
    }else if(w_num <= r_num){
      printf("%d", w_num);
    }
    
    return 0;
}

Measured memory_bytes: 1932
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int a[110],b[110];
Int dp[110][110];

Int f(int n,int m){
	if(dp[n][m]!=0)return dp[n][m];
	if(n==m)return 0;
	int i;
	Int mn=1000000000000LL;
	for(i=n;i<m;i++){
		chmin(mn,f(n,i)+f(i+1,m)+a[n]*b[i]*a[i+1]*b[m]);
	}
	dp[n][m]=mn;
	return mn;
}

int main() {
	int n,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	cout<<f(0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 0
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        mut n: usize,
        mut a: [i64;n]
    }
    a.insert(0, 0);
    a.push(0);
    n += 2;
    let mut sum = 0;
    for i in 0..n-1 {
        sum += (a[i+1] - a[i]).abs();
    }

    for i in 1..n-1 {
        if a[i-1] <= a[i] && a[i] <= a[i+1] {
            println!("{}", sum);
        } else {
            println!("{}", sum - (a[i-1]-a[i]).abs() - (a[i+1]-a[i]).abs()+(a[i-1]-a[i+1]).abs());
        }
    }
}

Measured memory_bytes: 5372
N=int(input())
S=input()
ans=S.count("R")*S.count("G")*S.count("B")
for i in range(N):
    for j in range(i+1,N):
        k=2*j-i
        if k<N and S[k]!=S[i] and S[k]!=S[j] and S[j]!=S[i]:
            ans-=1

print(ans)

Measured memory_bytes: 68076
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
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; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    multiset<ll> s; vl A(N); rep(i, N) {cin >> A[i];};
    s.insert(-1);
    ll cnt = 0;
    rep(i, N){
        if(s.count(A[i]) > 0){
            auto it = --s.lower_bound(A[i]);
            if(*it == -1){
                cnt++;
            }
            else{
                s.erase(it);
            }
             s.insert(A[i]);
        }
        else{
            s.insert(A[i]);
            auto it = --s.lower_bound(A[i]);
            if(*it == -1){
                cnt++;
            }
            else{
                s.erase(it);
            }
        }
    }
    cout << cnt << endstr;
    return 0;
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ld r;
	cin >> r;
	cout << fixed << setprecision(6) << 2 * r * 3.14159 << '\n';
}


Measured memory_bytes: 3808
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}


void main() {
	const nums = readNums().sort;
	int incCount = nums[2] - nums[1];
	immutable add2Count = (nums[2] - (nums[0] + incCount) + 1) / 2;
	if(add2Count * 2 + (nums[0] + incCount) > nums[2]) {
		++incCount;
	}
	writefln("%s", incCount + add2Count);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x;
        x = x * x;
        n = n >> 1;
    }
    return ans;
}

signed main(){

    int  n;
    cin >> n;
    
    rep(i,n){
        int a;
        cin >> a;
        if(a%2 == 1){
            cout << "first" <<endl;
            return 0;
        }
    }
    cout << "second" <<endl;


    
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

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


int main() {
  int n, k, h; cin >> n >> k;
  int cnt = 0;
  rep(i, n){
    cin >> h;
    if(h >= k) cnt++;
  }
  cout << cnt << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x[3000],y[3000];
    int i;

    for(i=0;i<3000;i++)
    {
        scanf("%d %d",&x[i],&y[i]);
        if(x[i]==0&&y[i]==0)break;
    }
    for(i=0;x[i]!=0||y[i]!=0;i++)
    {
        if(x[i]>y[i])
        {
            printf("%d %d\n",y[i],x[i]);
        }
        else
        {
            printf("%d %d\n",x[i],y[i]);
        }
    }

    return 0;
}

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

int solve(vector<int> & As);

void update_LIS(int a, vector<int> & LIS);

void disp(const vector<int> & vec){
    for (auto v : vec) cout << ' ' << v;
    cout << endl;
}

int main()
{
    int n = 0;
    cin >> n;
    vector<int> As(n);
    for (auto & a: As) cin >> a;
    cout << solve(As) << endl;
    return 0;
}

int solve(vector<int> & As){
    vector<int> LIS{As[0]};
    for (auto a : As){
        update_LIS(a, LIS);
    }
    return LIS.size();
}

void update_LIS(int a, vector<int> & LIS){
    if (a > LIS.back()){
        LIS.push_back(a);
        return;
    }else if (a < LIS[0]){
        LIS[0] = a;
        return;
    }
    auto it = lower_bound(LIS.begin(), LIS.end(), a);
    *it = a;
}

Measured memory_bytes: 3808
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int n,a[200010];
    long long ans = 0;
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) {
        scanf("%d",&a[i]);
    }
    int j = 1;
    long long suma = 0,sumb = 0;
    for (int i = 1; i <= n; i++) {
        while (j <= n && (suma + a[j]) == (sumb ^ a[j])) {
            suma += a[j];
            sumb ^= a[j];
            j++;
        }
        ans += j - i;
        suma -= a[i];
        sumb ^= a[i];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3980
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, n):
    if h[i] == h[i-1]:
        continue
    if h[i] - h[i-1] >= 1:
        h[i] -= 1
        continue
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 20692
#include <iostream>
#include <stack>
#include <unordered_set>
using namespace std;

int main() {
	int L, c, i;
	cin >> L;
	stack<int> a;
	unordered_set<int> b;
	for (i = 1; i <= L; ++i) {
		cin >> c;
		if (0 < c) {
			if (b.count(c)) break;
			else {
				a.push(c);
				b.insert(a.top());
			}
		}
		else {
			if (a.empty()) break;
			else {
				if (a.top() + c) break;
				else {
					b.erase(a.top());
					a.pop();
				}
			}
		}
	}
	if (1 + L == i) cout << "OK";
	else cout << i;
	cout << endl;
}


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

#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)>(b))?(b):(a)

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
    ll n, k;
    scanf("%lld%lld", &n, &k);

    ll res = n % k;
    if (res <= k - res)
    {
        printf("%lld", res);
    }
    else
    {
        printf("%lld", k - res);
    }
}

Measured memory_bytes: 128
from collections import*
h,w=map(int,input().split())
c=eval('list(input()),'*h)
q=deque()
for i in range(h):
    for j in range(w):
        if c[i][j]=='#':
            q.append((i,j,0))
ans=0
while q:
    y,x,v=q.popleft()
    ans=max(ans,v)
    for i,j in((y,x-1),(y,x+1),(y-1,x),(y+1,x)):
        if h>i>=0 and w>j>=0 and c[i][j]=='.':
            c[i][j]='#'
            q.append((i,j,v+1))
print(ans)

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

int main()
{
    int s, w;
    cin >> s >> w;

    if (s <= w)
    {
        cout << "unsafe" << endl;
        return 0;
    }
    else
    {
        cout << "safe" << endl;
        return 0;
    }
}

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

int main()
{
	register int n, ans = 0;
	cin >> n;
	for (register int i = 1; i <= n; ++i) {
		register int p = i, cnt = 0;
		while (p) {
			++cnt;
			p = p / 10;
		}
		if (cnt % 2 == 1) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#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 Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// cout << fixed << setprecision(10);
ios::sync_with_stdio(false);
cin.tie(nullptr);
    int n;
    cin>>n;
    int x;
    vector<queue<int>> b(n);
    rep(i,n)rep(j,n-1){
        cin>>x;
        x --;
        b[i].emplace(x);
    }
    set<int> seen;
    int ans=-1;
    bool f=1;
    while(f){
        f=0;
        rep(i,n){
            if(b[i].empty()) continue;
            int op=b[i].front();
            if(op<i) continue;
            if(seen.count(op) || seen.count(i)) continue;
            if(b[op].front() != i) continue;
            f=1;
            b[i].pop();
            b[op].pop();
            seen.emplace(op);
            seen.emplace(i);
        }
        ans ++;
        seen.clear();
    }
    rep(i,n){
        if(!b[i].empty()){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 7988
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int MOD = 1e9 + 7;

struct Segment {
    int l, r;
};

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    string s;
    cin >> s;

    vector<Segment> seqs;
    while (m-- > 0) {
        int l, r;
        cin >> l >> r;

        if (SZ(seqs) > 0 && r <= seqs.back().r) {
            continue;
        }
        seqs.push_back({l, r});
    }
    m = SZ(seqs);
   
    vector<int> dp0(n + 1, 0), dp1(n + 1, 0);
    vector<int> ndp0(n + 1, 0), ndp1(n + 1, 0);

    dp0[0] = 1;
    dp1[0] = 0;
    int last = 0;
    for (int i = 1, j = 0; i <= n; ++i) {
        while (j < m && i > seqs[j].r) {
            j++;
        }
        if (j == m) {
            break;
        }
        memset(ndp0.data(), 0, sizeof(int) * (i + 1));
        memset(ndp1.data(), 0, sizeof(int) * (i + 1));
        
        if (s[i - 1] == '1') {
            for (int k = i - 1; k >= seqs[j].l; --k) {
                ndp0[k + 1] = dp0[k];
            }
            for (int k = 1; k <= i; ++k) {
                ndp0[k] = (ndp0[k - 1] + ndp0[k]) % MOD;
            }
            for (int k = 0; k < i; ++k) {
                ndp1[k] = dp1[k];
            }
            ndp1[i] = (dp0[i - 1] + ndp1[i - 1]) % MOD;
        } else {
            for (int k = i - 1; k >= seqs[j].l; --k) {
                ndp1[k + 1] = dp1[k];
            }
            for (int k = 1; k <= i; ++k) {
                ndp1[k] = (ndp1[k - 1] + ndp1[k]) % MOD;
            }
            for (int k = 0; k < i; ++k) {
                ndp0[k] = dp0[k];
            }
            ndp0[i] = (dp1[i - 1] + ndp0[i - 1]) % MOD;
        }
        dp0.swap(ndp0);
        dp1.swap(ndp1);
        last = i;
    }
    int ans = (dp0[last] + dp1[last]) % MOD;
    cout << ans << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vs vector<string>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

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

  string word;
  cin >> word;
  // 前の文字
  string pre_word = word;

  map<string, int> said;
  said[word] = 1;

  rep(i, N - 1) {
    cin >> word;
    // 同じ言葉を使っていないか
    // 前の言葉の末尾文字と今の言葉の頭文字が等しいか
    if (said[word] == 1) {
      cout << "No" << endl;
      return 0;
    }
    if (pre_word[pre_word.size() - 1] != word[0]) {
      cout << "No" << endl;
      return 0;
    } else {
      said[word] = 1;
      pre_word = word;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

a,b,c = gets.split.map(&:to_i)

puts (a+b+c) >= 22 ? "bust" : "win"

Measured memory_bytes: 14208
use std::io;
use std::collections::HashMap;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut w:Vec<char> = buf.trim().chars().collect::<Vec<char>>();
	let mut m = HashMap::new();
	for c in w {
		match m.insert(c, 1) {
			Some(n) => {
				m.insert(c, n+1);
			},
			None => (),
		}
	}
	let mut flag = true;
	for val in m.values() {
		if *val%2 == 1 {
			flag = false;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
import math
x=int(input())
maxn=1
for i in range(2,11):
    y=i
    v=False
    while True:
        if y*i>x:
            break
        y*=i
        v=True
    if (maxn<y)&v:
        maxn=y

xs=math.floor(x**0.5)**2
if maxn<xs:
    maxn=xs
print(maxn)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e6;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && a!=c) || (a==c && a!=b) ||(c==b && a!=c))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int a[N],b[N],c[N];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0; i<n; i++)
        cin>>b[i];
    for(int i=0; i<n; i++)
        cin>>c[i];
    sort(c,c+n);
    long long ans=0;
    for(int i=0; i<n; i++)
    {
        int ta=lower_bound(a,a+n,b[i])-a;
        int tc=upper_bound(c,c+n,b[i])-c;
        ans+=1ll*(n-tc)*ta;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1536
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MAXN = (int) 1e5;

int n;

int a[3][MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int j = 0; j < 3; ++j)
		for(int i = 1; i <= n; ++i)
			a[j][i] = read<int>();
}

int b[MAXN + 5], is_inv[MAXN + 5];

inline int get_ids()
{
	static int line[3 * MAXN + 5], row[3 * MAXN + 5];

	for(int j = 0; j < 3; ++j)
		for(int i = 1; i <= n; ++i)
		{
			int id = 3 * (i - 1) + j + 1;
			line[id] = j;
			row[id] = i;
		}

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j < 3; ++j) if(row[a[j][i]] != row[a[j - 1][i]] || abs(line[a[j][i]] - line[a[j - 1][i]]) != 1) return 0;
		if(abs(a[0][i] - a[2][i]) != 2) return 0;
		b[i] = row[a[0][i]], is_inv[i] = line[a[0][i]] == 2;
		if((b[i] ^ i) & 1) return 0;
	}
	return 1;
}

struct BIT
{
	int N, *c;

	inline void init(int _N) { delete c, c = new int[(N = _N) + 1], memset(c, 0, sizeof(int) * (N + 1)); }
	inline void add(int p, int val) { for(; p <= N; p += p & -p) c[p] += val; }
	inline int prefix(int p) { int res = 0; for(; p; p -= p & -p) res += c[p]; return res; }

	BIT() { }
	BIT(int _N) { init(_N); }
};

inline void solve()
{
	if(!get_ids()) { puts("No"); return; }

	int inv[2] = {0, 0};
	int sum[2] = {0, 0};
	static BIT t[2]{n, n};

	for(int i = n; i >= 1; --i)
	{
		int k = i & 1;
		inv[k] ^= is_inv[i];
		sum[k] ^= t[k].prefix(b[i]) & 1;
		t[k].add(b[i], +1);
	}

	puts(inv[0] == sum[1] && inv[1] == sum[0] ? "Yes" : "No");
}

int main()
{
#ifdef K_ON
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 5376
N = int(input())
C = {}
#A = [int(input()) for x in range(N)]

for i in range(N):
    a = int(input())
    if a in C:
        C[a] += 1
    else:
        C[a] = 1

print(len([1 for i in C.values() if i % 2 == 1]))

Measured memory_bytes: 15072
//Bartek Kostka
//  You are not prepared!

#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define SZ(x) int(x.size())
#define ll long long
#define pii pair <int, int>
#define vi vector <int>
#define ALL(x) x.begin(), x.end()

#ifdef LOCAL
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(false) cout
#endif

int main() {
  ll n;
  cin >> n;
  vector<ll> A(5);
  for(int i=0; i<5; i++) cin >> A[i];
  ll res = 0;
  for(int i=0; i<5; i++) {
    res = max(res, 5 + (A[i] - 1 + n) / A[i]);
  }
  cout << res  - 1 << "\n";
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

N, D, A = map(int, input().split())
X = []
for _ in range(N):
    x, h = map(int, input().split())
    X.append((x, h))
X = sorted(X)[::-1]
Q = deque([])

ans = 0
k = 0
while X:
    if len(Q) == 0 or X[-1][0] <= Q[0][0]:
        x, h = X.pop()
        h = max(h - k * A, 0)
        a = (h + A - 1) // A
        ans += a
        k += a
        deque.append(Q, (x + 2 * D, a))
    else:
        x, a = deque.popleft(Q)
        k -= a

print(ans)

Measured memory_bytes: 68572
t=[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(t[k-1])

Measured memory_bytes: 2940