akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

func NextStringsLine() []string {
	strs := []string{}
	stringsStr := NextLine()
	tmp := strings.Split(stringsStr, " ")
	for _, s := range tmp {
		strs = append(strs, s)
	}
	return strs
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var w, a, b int

func main() {
	tmp := NextIntsLine()
	w, a, b = tmp[0], tmp[1], tmp[2]
	if a < b {
		answer := b - (a + w)
		fmt.Println(Max(0, answer))
	} else {
		answer := a - (b + w)
		fmt.Println(Max(0, answer))
	}
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
using namespace std;

void file()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

typedef long long ll;
typedef pair<int, int> pi;
const ll INF64 = 1e18;
const int INF = 1e9 + 7;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define x first
#define y second
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int N = 1e5 + 10;
int dp[N][3];
int a[N][3];

int main()

{
	file();

	int n;
	cin >> n;
	forn(i, n)
		forn(j, 3)
			cin >> a[i][j];
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	fore(i, 1, n)
	{
		dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = a[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
 
int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  char s;
  if(a > b) s = '>';
  else if(a == b) s = '=';
  else s = '<';
  if(s != '=')printf("a %c b\n", s);
  else printf("a == b\n");
  return 0;
}


Measured memory_bytes: 2696
#coding:utf-8

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

min_A = min(A)

while True:
    for i in range(N):
        if A[i] == min_A:
            continue
        A[i] = A[i] % min_A
    min_A = min([i for i in A if i!= 0])
        
    if max(A)==1:
        print(min_A)
        break

    if max(A) == min_A:
        print(min_A)
        break




Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-10)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
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;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double& r){ return (r > EPS) - (r < -EPS); }
int sgn(const double& a, const double &b){ return sgn(a - b); }

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
double p,t;

double calc(double l, double r, double a, double b, int dep, double cur_prob=1.0){
	// puta("  call :", l,r,a,b,dep);
	if(dep==0){
		double td=(l+r)/2;
		if(sgn(a,td)<=0 and sgn(td,b)<=0)return cur_prob;
		else return 0;
	}
	if(sgn(a,l)<=0 and sgn(r,b)<=0) return cur_prob;
	if(sgn(l,b)>0 or sgn(a,r)>0) return 0;
	double m=(l+r)/2,ret=0;
	if(m-EPS<=t){
		ret=calc(l,m,a,b,dep-1, cur_prob*(p))+calc(m,r,a,b,dep-1, cur_prob*(1-p));
	}else{
		ret=calc(l,m,a,b,dep-1, cur_prob*(1-p))+calc(m,r,a,b,dep-1, cur_prob*(p));
	}
	// puta("return :",l,r,a,b,dep,"=",ret);
	return ret;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k; double l,r,e;
	cin>>k>>l>>r>>p>>e>>t;

	fcout(10)<<calc(l,r,t-e,t+e,k)<<endl;
	return 0;
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}



int main(){
  ll K;
  ll H,W;
  cin>>H>>W>>K;
  vector<string> mp(H);
  REP(H){
    cin>>mp[i];
  }
  vector<vector<ll>> ans(H,vector<ll>(W));

  ll cur=1;
  ll prev=0;
  REP(H){
    ll j=0;
    while(j<W&&mp[i][j]!='#'){
      ans[i][j]=cur;
      ++j;
    }
    if(j==W){
      if(i>0&&prev==0)For(j,W){
        ans[i][j]=ans[i-1][j];
      }else{
        ++prev;
      }
      continue;
    }
    ans[i][j]=cur;
    ++j;
    for (; j < W; j++)
    {
      if(mp[i][j]=='#'){
        ++cur;
      }
      ans[i][j]=cur;
    }
    ++cur;
    if(prev>0){
      ll tmp=prev;
      prev=0;
      for (ll j = tmp;  j > 0;  j--)
      {
        For(k,W){
          ans[i-j][k]=ans[i][k];
        }
      }
    }
  }
  For(i,H){
    For(j,W){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1664
MOD = int(1e9) + 7

def main():
    buf = input()
    buflist = buf.split()
    H = int(buflist[0])
    W = int(buflist[1])
    S = []
    for i in range(H):
        buf = input()
        S.append(buf)
    lightmap_h = []
    for i in range(H):
        lightmap_h.append([])
        for j in range(W):
            lightmap_h[i].append(0)
    lightmap_v = []
    for j in range(H):
        lightmap_v.append([])
        for i in range(W):
            lightmap_v[j].append(0)
    for i in range(H):
        light_count = 0
        last_pointer = 0
        for j in range(W):
            if S[i][j] == '.':
                light_count += 1
            else:
                for k in range(last_pointer, j):
                    lightmap_h[i][k] = light_count
                light_count = 0
                last_pointer = j+1
        for k in range(last_pointer, W):
            lightmap_h[i][k] = light_count
    for j in range(W):
        light_count = 0
        last_pointer = 0
        for i in range(H):
            if S[i][j] == '.':
                light_count += 1
            else:
                for k in range(last_pointer, i):
                    lightmap_v[k][j] = light_count
                light_count = 0
                last_pointer = i+1
        for k in range(last_pointer, H):
            lightmap_v[k][j] = light_count
    maximum = 0
    for i in range(H):
        for j in range(W):
            hor = lightmap_h[i][j]
            vert = lightmap_v[i][j]
            if hor == 0 or vert == 0:
                continue
            light_distance = hor + vert - 1
            if light_distance > maximum:
                maximum = light_distance
    print(maximum)

if __name__ == '__main__':
    main()


Measured memory_bytes: 126296
<?php
define("TOP",1);
define("FRONT",2);
define("RIGHT",3);
define("LEFT",4);
define("BEHIND",5);
define("BOTTOM",6);
class Dice{
    private $numbers;
    // before => after
    private $IDX_ROLL = [
        "E" => [TOP => RIGHT,RIGHT => BOTTOM,LEFT => TOP,BOTTOM => LEFT],
        "N" => [TOP => BEHIND,FRONT => TOP,BEHIND => BOTTOM,BOTTOM => FRONT],
        "S" => [TOP => FRONT,FRONT => BOTTOM,BEHIND => TOP,BOTTOM => BEHIND],
        "W" => [TOP => LEFT,RIGHT => TOP,LEFT => BOTTOM,BOTTOM => RIGHT],
        "C" => [FRONT => LEFT,RIGHT => FRONT,LEFT => BEHIND,BEHIND => RIGHT]    // spin:clockwise
    ];
    public function __construct($numbers){
        $this->numbers = $numbers;
    }
    public function getNumbers(){
        return $this->numbers;
    }
    public function roll($dir){
        $pos = $this->numbers;
        foreach($this->IDX_ROLL[$dir] as $before => $after){
            $this->numbers[$after] = $pos[$before];
        }
    }
    // is equal
    public function isEq($another){
        for($i = 1; $i <= 6; $i++){
            if($this->numbers[$i] !== $another[$i]) return false; 
        }
        return true;
    }
    public function isEqual($another){
        for($i = 0; $i < 6; $i++){
            for($j = 0; $j < 4; $j++){
                if($this->isEq($another)) return true;
                $this->roll("C");
            }
            if($i % 2) $this->roll("W");
            else $this->roll("N");
        }
        return false;
    }
}
//============== main ==============
$num = getStdin();
for($i = 0; $i < $num; $i++){
    $dice[$i] = getInstance();
}
for($i = 0; $i < $num - 1; $i++){
    for($j = $i + 1; $j < $num; $j++){
        if($dice[$i]->isEqual($dice[$j]->getNumbers())){
            echo "No\n";
            exit;
        }
    }
}
echo "Yes\n";
//============== input ==============
function getStdin(){
    return trim(fgets(STDIN));
}
function getInstance(){
    $a = explode(" ",getStdin());
    $numbers = array_combine(range(1,6),$a);
    return new Dice($numbers);
}

Measured memory_bytes: 15524
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 120000;

int n, m;
int cnt[MAXN];
int fl[MAXN];

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i)
		cnt[i] = 1;
	fl[0] = 1;
	for (int i = 0; i < m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		--x;
		--y;
		--cnt[x];
		++cnt[y];
		if (fl[x])
			fl[y] = 1;
		if (cnt[x] == 0)
			fl[x] = 0;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans += fl[i];
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1024
// Aizu 1297: Swimming Jam
// 2017.11.2 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 52
typedef struct { int t, c, a; } T;   // a: arive time
T q[2][MAX+2]; int top[2], end[2];
T p[MAX+2]; int sz;

int cmp(T *a, T *b) { if (a->t - b->t) return a->t - b->t; return b->c - a->c; }

int uniq(int n)
{
	int i, j;
	
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && p[j].t == p[i].t) j++;
		if (j < n) if (++i != j) p[i] = p[j];
	}
	return i+1;
}

int main()
{
	int n, i, j, k, t, a, ans, t1;

    while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++ ) scanf("%d%d", &p[i].t, &p[i].c), p[i].a = p[i].t;
		qsort(p, n, sizeof(T), cmp);
		n = uniq(n);
		if (n == 1) { printf("%d\n", (p[0].t<<1) * p[0].c); continue; }
		for (i = 0; i < n; i++) q[0][i] = p[i];
		top[0] = top[1] = end[0] = end[1] = 0, end[0] = n;

		ans = 0;
		while (n > 0) {
			j = 0, t = t1 = 0x7fffffff;
			if (top[0] != end[0]) t  = q[0][top[0]].a;
			if (top[1] != end[1]) t1 = q[1][top[1]].a;
			if (t > t1) j = 1, t = t1;

			sz = 0;
			while (top[j] != end[j]) {
				k = top[j];
				a = q[j][k].a;
				if (t < a) break;
				if (j == 1) q[j][k].c--;
				if (!q[j][k].c) n--, ans = t;
				else p[sz] = q[j][k], p[sz].a = t + p[sz].t, sz++; 
				if (++k == MAX) k = 0;
				top[j] = k;
			}
			if (n == 0) break;
			qsort(p, sz, sizeof(T), cmp);

			j = !j, k = end[j];
			for (i = 0; i < sz; i++) {
				q[j][k] = p[i]; if (++k == MAX) k = 0;
			}
			end[j] = k;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
long long dp[200010][3];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto & a : A) cin >> a;
    dp[0][0] = A[0];
    dp[1][1] = A[1];
    for (int i = 2; i < n; ++i) {
        dp[i][0] = dp[i-2][0]+A[i];
        dp[i][1] = dp[i-2][1]+A[i];
        dp[i][2] = dp[i-2][2]+A[i];
        if (i > 2) {
            dp[i][1] = max(dp[i][1], dp[i-3][0]+A[i]);
            dp[i][2] = max(dp[i][2], dp[i-3][1]+A[i]);
        }
        if (i > 3) {
            dp[i][2] = max(dp[i][2], dp[i-4][0]+A[i]);
        }
    }
    long long ans = max(dp[n-1][1+n%2], dp[n-2][0+n%2]);
    if (n > 2 && n%2 == 1) ans = max(ans, dp[n-3][0]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 8736
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define vel vector<long long>
using namespace std;
int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') { ans++; }
		else { ans--; }
	}
	if (ans > 0) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define fill(x,t) memset(x,t,sizeof(x))
 
const int INF=0x3f3f3f3f;
const int N=200005;
 
int a[N],rec[N];
 
int main(void) {
	int n; scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	int mx1=0,mx2=0,r1,r2;
	for (int i=1;i<=n;i+=2) rec[a[i]]++;
	for (int i=1;i<=n;i+=2) {
		if (rec[a[i]]>rec[mx1]||rec[a[i]]==rec[mx1]&&a[i]!=mx1) mx2=mx1,mx1=a[i];
		else if (rec[a[i]]>rec[mx2]&&a[i]!=mx1) mx2=a[i];
	}
	r1=rec[mx1],r2=rec[mx2];
	int mx3=0,mx4=0,r3,r4;
	fill(rec,0);
	for (int i=2;i<=n;i+=2) rec[a[i]]++;
	for (int i=2;i<=n;i+=2) {
		if (rec[a[i]]>rec[mx3]||rec[a[i]]==rec[mx3]&&a[i]!=mx3) mx4=mx3,mx3=a[i];
		else if (rec[a[i]]>rec[mx4]&&a[i]!=mx3) mx4=a[i];
	}
	r3=rec[mx3],r4=rec[mx4];
	int ans=INF;
	if (mx1!=mx3) ans=std:: min(ans,n-r1-r3);
	if (mx1!=mx4) ans=std:: min(ans,n-r1-r4);
	if (mx2!=mx3) ans=std:: min(ans,n-r2-r3);
	if (mx2!=mx4) ans=std:: min(ans,n-r2-r4);
	if (ans==INF) ans=n/2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=mod;
    }
    now*=now;
    now%=mod;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    double x[n],y[n];
    rep(i,0,n)cin>>x[i]>>y[i];
    double ans=0;
    double t=1;
    rep(i,0,n-1)t*=(i+1);
    rep(i,0,n){
        rep(j,0,n){
            if(i==j)continue;
            double dis=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
            dis=pow(dis,0.5);
            ans+=dis*t;
        }
    }
    t*=n;
    ans/=t;
    cout<<fixed<<setprecision(12)<<ans<<endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> a = vector<int>(n);
  
  for(int i=0; i<k; i++){
    int d;
    cin >> d;
    for(int i=0; i<d; i++){
      int b;
      cin >> b;
      a[b-1]++;
    }
  }
  int ans = 0;
  for(int i=0; i<n; i++){
    if(a[i] == 0) ans++;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
char a,b;
cin >> a >> b;
if (a==b)
{
  cout << 'H' << endl;
}else
{
  cout << 'D' << endl;
}


  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,k,c,d;
  cin>>a>>b>>k;
  c=max(0L,a-k);
  k=max(0L,k-a);
  d=max(0L,b-k);
  cout<<c<<' '<<d<<endl;
}

Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
using namespace std;
int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    if(a%x==0)cout<<(b/x)-((a/x)-1)<<endl;
    else cout<<(b/x)-(a/x)<<endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    iota(readln().chomp().to!int()).map!(_=>readln().split().map!(to!int).array()).array().sort!((a,b)=>a[1]>b[1]||(a[1]==b[1]&&a[0]<b[0]))[0].map!(to!string).join(" ").writeln();
}

Measured memory_bytes: 1084
#include <stdio.h>
#include <stdlib.h>

/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int N;
char S[114514];

int count[10][10];
int cost[10][10];

int main(void) {
	int i, j;
	int bestScore = -1;
	int bestHaiti[9] = {0};
	int haiti[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 1; i < N; i++) {
		count[S[i - 1] - '0'][S[i] - '0']++;
	}
	do {
		int score;
		for (i = 0; i < 9; i++) {
			int x1 = i % 3;
			int y1 = i / 3;
			for (j = i + 1; j < 9; j++) {
				int x2 = j % 3;
				int y2 = j / 3;
				cost[haiti[i]][haiti[j]] = cost[haiti[j]][haiti[i]] = abs(x1 - x2) + abs(y1 - y2);
			}
			cost[haiti[i]][haiti[i]] = 0;
		}
		score = 0;
		for (i = 1; i <= 9; i++) {
			for (j = 1; j <= 9; j++) {
				score += count[i][j] * cost[i][j];
			}
		}
		if (bestScore < 0 || score < bestScore) {
			bestScore = score;
			for (i = 0; i < 9; i++) bestHaiti[i] = haiti[i];
		}
	} while (next_permutation(haiti, 9));
	for (i = 0; i < 3; i++) {
		printf("%d%d%d\n", bestHaiti[i * 3], bestHaiti[i * 3 + 1], bestHaiti[i * 3 + 2]);
	}
	return 0;
}



Measured memory_bytes: 2144
def main():
  M=10**9+7
  n,k,*a=map(int,open(0).read().split())
  b=[1]+[0]*k
  for i in a:
    t,d=0,[]
    for v in b[:i+1]:
      t+=v
      t%=M
      d+=t,
    for w,v in zip(b,b[i+1:]):
      t+=v-w
      t%=M
      d+=t,
    b=d
  print(t)
main()

Measured memory_bytes: 12988
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
   
 
   cin >> n;
  
   if(n%2==0){
     
     int a = n/2;
     cout << a*a << endl;
     
   }else{
     
     int a = n/2;
     cout << a*(a+1) << endl;
     
   }
  
   
 
  
  return 0;
}

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

struct Problem {

    void Solve() {
        UL K; cin >> K;
        string S; cin >> S;
        if (S.size() <= K) cout << S << endl;
        else cout << S.substr(0, K) << "..." << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
int main() {
    int p = 700,i;
    char S[3];

    for (i = 0; i < 3; i++) {
      std::cin >> S[i];
      if ( S[i] == 'o' )
          p += 100;
      else
          p = p;
    }
    std::cout << p;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10 ** -7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)


def gcd_3(x, y, z):
    return gcd(gcd(x, y), z)

K = inp()

dic = {} # key: (i, j, k), el: gcd(i, j, k)
ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        tmp = gcd(i, j)
        for k in range(j, K + 1):
            a = gcd(tmp, k)
            if i == j == k:
                ans += a
            elif i == j or j == k:
                ans += a * 3
            else:
                ans += a * 3 * 2
print(ans)


Measured memory_bytes: 11240
#  def II(): return int(input())
#def LI(): return [int(i) for i in input().split()]

#N, K = LI()
#H = LI()

#cost = [0] * N
#cost[0] = 0
#for n in range(1, N):
#  cost[n] = min([ cost[n-k]+abs(H[n-k]-H[n]) for k in range(1, min(n+1, K+1)) ])

#print(cost[-1])

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()

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





int main() {
    
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v(n);
    ll now=0;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        v[i]=mp(b,a);
    }
    Sort(v);
    rep(i,n)swap(v[i].fi,v[i].se);
    rep(i,n){
        now+=v[i].fi;
        if(now>v[i].se){
            fin("No");
            return 0;
        }
    }
    fin("Yes");

}



Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
	int w1,w2,w3,w4,h,m;
	cin>>w1>>w2>>w3>>w4;
	h = (w1+w2+w3+w4)/60;
	m = (w1+w2+w3+w4)%60;
	cout<<h<<endl<<m<<endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll n,m;
vector<string> a(n),b(m);
bool solve(int i, int j){
	bool flag=true;
	FOR(k,i,i+m){
		if(a[k].substr(j,m)!=b[k-i]){
			flag=false;
		}
	}
	return flag?true:false;
}
int main(){
	cin>>n>>m;
	string s;
	rep(i,n){
		cin>>s;
		a.pb(s);
	}
	rep(i,m){
		cin>>s;
		b.pb(s);
	}
	//始点を決める(i,j)
	rep(i,n-m+1){
		rep(j,n-m+1){
			if(solve(i,j)){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 7 * 100 + 17;

int n, m, col[MAXN], a, b, ans;
set<int> adj[MAXN];
bool dp[2 * MAXN][2 * MAXN];
vector<pair<int, int>> t;

void dfs(int v, int c) {
	if (c == 1)
		a++;
	else
		b++;
	col[v] = c;
	for (auto u : adj[v]) {
		if (col[u] != 0 and col[u] == col[v]) {
			cout << -1 << endl;
			exit(0);
		}
		if (!col[u])
			dfs(u, 3 - c);
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			if (i == j)
				continue;
			adj[i].insert(j);
		}
	for (int i = 1; i <= m; i++) {
		int v, u;
		cin >> v >> u;
		adj[u].erase(v);
		adj[v].erase(u);
	}
	for (int i = 1; i <= n; i++) {
		if (!col[i]) {
			a = 0;
			b = 0;
			dfs(i, 1);
			t.pb({a, b});
		}
	}
	dp[0][abs(t[0].ff - t[0].ss)] = true;
	for (int i = 1; i < t.size(); i++)
		for (int j = 0; j < n; j++)
			dp[i][j] = (dp[i - 1][j + abs(t[i].ff - t[i].ss)] || dp[i - 1][abs(j - abs(t[i].ff - t[i].ss))]);
	for (int i = 0; i < MAXN; i++)
		if (dp[t.size() - 1][i]) {
			int p1 = (n + i) / 2, p2 = (n - i) / 2;
			ans = ((p1 * (p1 - 1)) / 2) + ((p2 * (p2 - 1)) / 2);
			break;
		}
	cout << ans << endl;
	return 0;
}

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

int main() {
 int a,v;
 cin>>a>>v;
 int b,w;
 cin>>b>>w;
 int t;
 cin>>t;
 int res;
 
 if(w>=v)
 res=0;
 
 else
 {
 	long long int dist=abs(b-a);
 	long long int vel=v-w;
 	long long d=vel*t;
 	if(d>=dist)
 	res=1;
 	else res=0;
 	
 }
 if(res)
 cout<<"YES"<<endl;
 else
 cout<<"NO"<<endl;
  
}

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

int main(void)
{
    double L;
    cin >> L;
//    cout << L << endl;

    double l = L/3;
//    cout << l << endl;

    double m = l*l*l;

    cout << fixed << std::setprecision(18) <<  m << endl;    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef long double ld;
const double E = 1e-7;
const ll INF = 1e17;
#define forn(i, s, f) for (int i = s; i < f; ++i)
#define ft first                                                 
#define sec second
#define fora(i, n) for (auto i : n)
#define sz(a) (int)(a).size()
#define sort_(a) sort(a.begin(), a.end())
#define pb push_back
#define mp make_pair
#define rsort_(a) sort(a.begin(), a.end()); reverse(a.begin(), a.end())
#define fast_ cin.tie(0), ios_base::sync_with_stdio(false)
// ____________________________________________________________
#define cina(a) forn(i,0,sz(a)) cin >> a[i]
#define cinpr(a) cin >> a.ft >> a.sec 
//--------------------------------------------------------------
 
int main() {
    int n; cin >> n;
    if (n >= 30) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3632
n = io.read("*n", "*l")
t = {}
for i = 1, n do
    u = {}
    for j = 0, 25 do u[string.char(97 + j)] = 0 end
    s = io.read()
    len = string.len(s)
    for j = 1, len do
        a = string.sub(s, j, j)
        u[a] = u[a] + 1
    end
    for j = 0, 25 do
        moji = string.char(97 + j)
        if(t[moji] == nil) then t[moji] = u[moji] else t[moji] = math.min(t[moji], u[moji]) end
    end
end
for i = 0, 25 do
    moji = string.char(97 + i)
    if(t[moji] ~= nil) then
        for j = 1, t[moji] do
            io.write(moji)
        end
    end
end
io.write("\n")

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
int main(){
  rd(A);
  rd(B);
  if(A%3==0||B%3==0||(A+B)%3==0){
    wt_L("Possible");
    wt_L('\n');
  }
  else{
    wt_L("Impossible");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B;
// {
//   rd(A,B);
//   wt(if[A%3==0||B%3==0||(A+B)%3==0, "Possible", "Impossible"]);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int main(){
	int n,k;read(n),read(k);int ans=0;
	while (n--){
		int x;cin>>x;if (x>=k) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
ll N, W, V = 1000;
int main() {
	scanf("%lld%lld", &N, &W);
	vector<ll> w(N), v(N);
	ll max_v = 100000;
	vector<ll> dp(max_v + 1, 1e13);
	rep(i, 0, N)scanf("%lld%lld", &w[i], &v[i]);
	dp[0] = 0;
	rep(i, 0, N) {
		for (ll i2 = max_v; i2 >= 0; i2--) {
			if (i2 >= v[i]) dp[i2] = min(dp[i2 - v[i]] + w[i], dp[i2]);
		}
	}
	ll ans = 0;
	rep(i2, 0, max_v + 1) {
		if (dp[i2] <= W)ans = max(i2, ans);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll x, y;
  cin >> x >> y;
  if(y%2==1) {
    cout << "No" << endl;
    return 0;
  }
  if(y>=x*2 && y<=x*4) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  string S;
  cin >> S;

  int Q;
  cin >> Q;

  string pre = "";
  string post = "";

  bool direction = false;
  rep(i, Q){
    int t, f;
    char c;

    cin >> t;
    switch(t){
      case 1:
        direction ^= 1;
        break;

      case 2:
        cin >> f >> c;
        if(f == 1 && direction == false || f == 2 && direction == true){
          pre += c;
        }else if(f == 1 && direction == true || f == 2 && direction == false){
          post += c;
        }
        break;

      default:
        break;
    }
  }
  if(direction == false){
    reverse(ALL(pre));
    cout << pre << S << post << endl;
  }else{
    reverse(ALL(S));
    reverse(ALL(post));
    cout << post << S << pre << endl;
  }
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N): par(N),size(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            size[i] = -1;
        }
            
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getsize(int x){
        return -size[root(x)];
    }
    int getNunion(){//これちょっと遅い sameと組み合わせて順次数えていけば早くなりそう。
        map<int,int> m;
        rep(i,par.size()){
            m[this->root(i)]++;
        }
        return int(m.size());
    }
};

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> G(N);
    ll a, b;
    vector<ll> A(N), B(N);
    rep(i,N-1){
        cin >> a >> b;
        a--;b--;
        A[i] = a;
        B[i] = b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<ll> que;
    que.push(0);
    vector<ll> dist(N, 1e18), memo(N,-1);
    dist[0] = 0;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto& u:G[v]){
            if(dist[u] != 1e18) continue;
            dist[u] = dist[v] + 1;
            memo[u] = v;
            que.push(u);
        }
    }
    ll d = dist[N-1];
    //ll df = (d+1)/2;
    ll ds = (d-1)/2;
    ll id = N-1;
    rep(i,ds){
        id = memo[id];
    }
    UnionFind tr(N);
    rep(i,N-1){
        if(A[i] == id && B[i] == memo[id] || A[i] == memo[id] && B[i] == id){
            continue;
        }
        tr.unite(A[i], B[i]);
    }
    ll nf = tr.getsize(0);
    ll ns = tr.getsize(N-1);
    if(nf == ns){
        cout << "Snuke" << endl;
    }else if(nf > ns){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    //memo[id], id;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

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

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

int main() {
    int64 N;
    cin >> N;
    vector<int64> perm(N);
    vector<int64> x(N+1), y(N+1);
    iota(all(perm), 0);
    REP(i,N) {
        cin >> x[i] >> y[i];
    }
    double res = INF_LL;
    do {
        double now = 0;
        double sum = 0;
        int64 px = 0, py = 0;
        REP(i, N+1) {
            int64 nid = (i == N ? N : perm[i]);
            double deg = atan2(y[nid]-py, x[nid]-px);
            double diff = abs(now-deg);
            diff = min(diff, 2*M_PI-diff);
            now = deg;
            sum += diff;
            px = x[nid]; py = y[nid];
        }
        chmin(res, sum);
    } while(next_permutation(all(perm)));
    cout << fixed << setprecision(10) << res/M_PI*180 << endl;
}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main()
{
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }

    bool k = true;
    for (int i = n - 1; i > 0; i--)
    {
        if (h[i - 1] - h[i] > 1)
            k = false;
        else if (h[i - 1] - h[i] == 1)
            h[i - 1]--;
    }
    rep(i, n - 1) if (h[i] > h[i + 1]) k = false;

    if (k)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 4024
#include<iostream>

int main(){
	
	int S , h , m , s;
	
	std::cin >> S;
	
	s = S % 60 , m =(S/60)%60 , h=S/3600 ;

    std::cout << h << ":"<<m<<":"<<s<<"\n";
	
	return 0;
	
}

Measured memory_bytes: 1164
IDENTIFICATION DIVISION.
      PROGRAM-ID. 149A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(300).
      01 S   PIC X(100).
      01 T   PIC X(100).
      01 OUT PIC X(200).
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      UNSTRING INP DELIMITED BY " "
      INTO S T.
      
      STRING T S DELIMITED " "
      INTO OUT.
      
      DISPLAY FUNCTION TRIM(T) FUNCTION TRIM(S).
      
      STOP RUN.

Measured memory_bytes: 508
#include<iostream>
int main(){
int n,m,b,c;
std::cin>>n>>m>>b;c=b;
for(int i=0;i<99;i++){
if(c%(n+m)<=n)goto a;
c+=60;
}
c=-1;
a:
std::cout<<c<<"\n";return 0;}

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



int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
     long long int x = n + pow(n,2)+ pow(n,3);
     cout<<x;
    
    
	return 0;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB pop_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 25
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
#define vi vector<long long>

using namespace std;
typedef long long ll;
const ll mod=1e9;
const ll inf = 1e18+7;
const int maxn = 2e5+7;
int k;

int main(){
    ll k,a,b,t,n,u,v,w,y,r;
    FIO
    cin>>a;
    b=100;
    for(int i=1;i<=1e7;i++){
        b+=(b)/100;
        if(b>=a){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}
/**
5
6
7
1 2 2 4
2 4 3 3
3 4 2 4
1 3 4 1
4 6 2 1
3 5 2 0
5 4 3 2
**/


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

int main()
{
    int N, p[100010];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> p[i];

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
	using namespace std;
	#define sim template < class c
	#define ris return * this
	#define dor > debug & operator <<
	#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
	sim > struct rge { c b, e; };
	sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
	sim > auto dud(c* x) -> decltype(cerr << *x, 0);
	sim > char dud(...);
	struct debug {
	#ifdef LOCAL
	~debug() { cerr << endl; }
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
	}
	#else
	sim dor(const c&) { ris; }
	#endif
	};
	#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
	#define deb debug()
	#define lel(...) deb << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
	#define ll long long
	#define all(x) (x).begin(), (x).end()
	// 
using namespace std;
 
const int N = 50010;
ll mod = 998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} 


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin >> x;
	int t = x / 500;
	int j = x % 500;
	j /= 5;
	cout << 1000 * t + 5 * j << endl;


	
	
	return 0;
}

Measured memory_bytes: 256