akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll N;
	cin >> N;
	vector<ll> A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	ll ans = INF;

	rep(i, 1 << N) {
		//cout <<i<<endl;

		vector<pair<ll, ll>> ev, od;

		rep(j, N) {
			if ((i >> j) % 2 == 0) {
				if (j % 2 == 0) { ev.push_back({A[j],j}); }
				else { od.push_back({ A[j], j }); }
			}
			else {
				if (j % 2 == 0) { od.push_back({ B[j], j }); }
				else { ev.push_back({ B[j],j }); }
			}
		}

		if (ev.size() != (N+1) / 2) { continue; }

		sort(ev.begin(), ev.end());
		sort(od.begin(), od.end());

		ll b = 1;
		rep(j, od.size()) { if (ev[j].first > od[j].first) { b = 0;; } }
		rep(j, ev.size() - 1) { if (od[j].first > ev[j + 1].first) { b = 0; } }
		if (b == 0) { continue; }

		vector<ll> ar(N);
		rep(j, (N + 1) / 2) { ar[ev[j].second] = 2 * j; }
		rep(j, N / 2) { ar[od[j].second] = 2 * j + 1; }

		//rep(j, N) cout << ar[j] << " ";
		//cout << endl;

		ll now = 0;
		rep(j, N)for (ll k = j + 1; k < N; k++) {
			if (ar[k] < ar[j]) { now++; }
		}

		ans = min(now, ans);
	}
	
	if (ans == INF) { ans = -1; }
	cout << ans << endl;

	system("PAUSE");
}


Measured memory_bytes: 504
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll k;
	cin>>k;
	vector<ll> ans(50);
	if(k%50==0) {
		REP(i,50) ans[i]=49+(k/50);
		cout<<50<<endl;
		DUMP(ans);
	} else {
		REP(i,50) {
			if(i<50-k%50) ans[i]=49+(k/50+1)-(k%50+1);
			else ans[i]=49+(k/50+1)+(50-k%50);
		}
		cout<<50<<endl;
		DUMP(ans);
	}
}


Measured memory_bytes: 256
N=gets.to_i
as=gets.split.map(&:to_i).sort
bs=gets.split.map(&:to_i).sort
cs=gets.split.map(&:to_i).sort

dp1 = Array.new(N,0)

bs.each.with_index(0) do |b,i|
    j = cs.bsearch_index {|c| b < c}
    dp1[i] = N - j if j
end
(N-2).downto(0) do |i|
    dp1[i] += dp1[i+1]
end

ret = 0
as.each do |a|
    i = bs.bsearch_index {|b| a < b}
    # p [a,dp1[i]]
    ret += dp1[i] if i
end

# p dp1
puts ret

Measured memory_bytes: 27392
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let (d, x) = read!(usize, usize);
    let a: Vec<usize> = read!(usize; n);

    let mut ans = x;

    for i in 0..n {
        let mut count = 0;
        let mut day = 1;
        while day <= d {
            count += 1;
            day += a[i];
        }
        ans += count;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
sx, sy, tx, ty = list(map(int, input().split()))
dx = tx - sx
dy = ty - sy
ans1 = ans2 = ''
table = ans1.maketrans({'U': 'D', 'D': 'U', 'L': 'R', 'R': 'L'})

# 1往復
if dx > 0:
    ans1 += 'R' * abs(dx)
else:
    ans1 += 'L' * abs(dx)

if dy > 0:
    ans1 += 'U' * abs(dy)
else:
    ans1 += 'D' * abs(dy)

ans1 += ans1.translate(table)

# 2往復
if dx > 0 and dy > 0:
    ans2 += 'D' + 'R' * (abs(dx) + 1) + 'U' * (abs(dy) + 1) + 'L'
elif dx < 0 and dy > 0:
    ans2 += 'R' + 'U' * (abs(dx) + 1) + 'L' * (abs(dy) + 1) + 'D'
elif dx < 0 and dy < 0:
    ans2 += 'U' + 'L' * (abs(dx) + 1) + 'D' * (abs(dy) + 1) + 'R'
elif dx > 0 and dy < 0:
    ans2 += 'L' + 'D' * (abs(dx) + 1) + 'R' * (abs(dy) + 1) + 'U'

ans2 += ans2.translate(table)

print(ans1+ans2)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

vector<vector<int>> G;

int dfs(int i, set<int> visited) {
  visited.insert(i);
  if (visited.size() == G.size()) {
    return 1;
  }

  int total = 0;
  for (int v : G[i]) {
    if (!visited.count(v)) {
      total += dfs(v, visited);
    }
  }
  return total;
}

int main() {
  int N, M; cin >> N >> M;
  G.resize(N);
  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b; --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cout << dfs(0, {}) << endl;
}


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

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
	int k;cin>>k;
	long long ans=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				ans+=gcd(gcd(i,j),l);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 10が5個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()

using namespace std;

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

    int n = w.size();
    
    int sum = 1;
    if(w.size()==1) cout << "No" << endl;
    else{
    sort(all(w));
    REP(i,n-1){
        if(w[i]==w[i+1]){
            sum = sum + 1;
        }
        else{
            if(sum % 2 == 1){
                cout << "No" << endl;
                goto last;
            }
            else{
                sum = sum + 1;
            } 
       }
    }
    cout << "Yes" << endl;
    last: ;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func f(n int) int {
	ans := 0
	for x := 1; x <= n; x++ {
		p := x*x
		if p > n {
			break
		}
		for y := 1; y <= n; y++ {
			q := p + y*y + x*y
			if  q > n {
				break
			}

			for z := 1; z <= n; z++ {
				r := q + z*z + y*z + z*x
				if r > n {
					break
				}

				if r == n {
					ans++
				}
			}
		}
	}
	return ans
}

func solve(n int) []int {
	ans := make([]int, n)

	for i := 1; i <= n; i++ {
		ans[i-1] = f(i)
	}

	return ans
}

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

	result := solve(N)
	for _, i := range result {
		fmt.Println(i)
	}
}


Measured memory_bytes: 2008
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using vpii = vector<pii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
constexpr int dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
template<typename A, typename B> bool cmin(A &a, const B &b) { if (a > b) { a = b; return true; } else return false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { if (a < b) { a = b; return true; } else return false; }
namespace fpl {
  template<typename V, typename F> constexpr V fmap(V v, const F &f) { transform(all(v), v.begin(), f); return v; }
  template<typename V, typename F> constexpr V filterNot(V v, const F &f) { v.erase(remove_if(all(v), f), v.end()); return v; }
  template<typename V, typename F> constexpr V filter(V v, const F &f) { return filterNot(v, [&](typename V::value_type x) { return !f(x); }); }
  template<typename X, typename V, typename F> constexpr X fold(const X &x, const V &v, const F &f) { return accumulate(all(v), x, f); }
  template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
  constexpr bool odd(const int &n) { return n & 1; }
  constexpr bool even(const int &n) { return !odd(n); }
  template<typename V, typename F> constexpr bool andall(const V &v, const F &f) { for (auto &p : v) if (!f(p)) return false; return true; }
  template<typename V, typename F> constexpr bool orany(const V &v, const F &f) { for (auto &p : v) if(f(p)) return true; return false; }
  constexpr int gcd(int a, int b) { int c = 0; while (a) { c = a; a = b % a; b = c; } return b; }
  constexpr int pows(int a, int b) { int c = 1; while (b) { if (odd(b)) c *= a; b >>= 1; a *= a; } return c; }
}
using namespace fpl;
// clang-format on

main {
  int h, w;
  cin >> h >> w;
  rep(i, h) rep(j, w) {
    string s;
    cin >> s;
    if (s == "snuke") {
      cout << char(j + 'A') << i + 1 << endl;
      bye;
    }
  }
}


Measured memory_bytes: 256
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
s = input()
s_set = set(s)
if len(s_set) == 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5480
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	
      	if (a + b >= 10) {
          	System.out.println("error");
        } else {
        	System.out.println(a + b);
        }
    }
}

Measured memory_bytes: 20948
fun main(args : Array<String>) {
    val S = readLine()!!
    if (S == "Sunny") {
        println("Cloudy")
        return
    }
    if (S == "Cloudy") {
        println("Rainy")
        return
    }
    if (S == "Rainy") {
        println("Sunny")
        return
    }
}

Measured memory_bytes: 31748
S = [int(x) for x in input().split()]
A = S[0]
B = S[1]
ans = -1

for i in range(1000):
    num = (i+1)
    MotoA = int(num * 0.08)
    MotoB = int(num * 0.1)
    if MotoA == A and MotoB ==B:
        ans = num
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int count = 0;
	for (int i = 1 ; i <= x ; i++)
	{
		int a = i;
		int z = 0;
		while (a > 0)
		{
			a /= 10;
			z++;
		}
		if (z % 2 == 1)
		{
			count++;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>

#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
typedef long long LL;

using namespace std;

int N;
LL T[100002],A[100002],lt[100002],ut[100002],la[100002],ua[100002];
LL mod=1000000000+7;

int main(void){
    scanf("%d",&N);
    REP(i,N)scanf("%lld",T+i+1);
    REP(i,N)scanf("%lld",A+i+1);
    for(int i=1;i<=N;i++){
        if(T[i-1]<T[i])
            lt[i]=ut[i]=T[i];
        else{
            ut[i]=T[i];
            lt[i]=1;
        }
    }
    for(int i=N;0<i;i--){
        if(A[i+1]<A[i])
            la[i]=ua[i]=A[i];
        else{
            ua[i]=A[i];
            la[i]=1;
        }
    }
    LL ans=1;
    // for(int i=1;i<=N;i++){
        // printf("ut=%lld ua=%lld lt=%lld la=%lld\n",ut[i],ua[i],lt[i],la[i]);
    // }
    for(int i=1;i<=N;i++){
        LL z=0;
        ans*=max(z,(min(ut[i],ua[i])+1-max(lt[i],la[i])));
        ans%=mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4864
import sys
S = input()
ok = ["A","G","T","C"]
for l in range(len(S),0,-1):
  for i in range(0,len(S)-l+1):
    for s in S[i:i+l]:
      if s in ok:
        continue
      else:
        break
    else:
      print(l)
      sys.exit()
else:    
  print(0)
    

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>

using namespace std;

long long N, K;

vector<long long> a, acc;
vector<long long> b;

long long mask[50];
long long cand[1000000];
int main()
{
    cin >> N >> K;

    int hoge = 1;
    for (long long i = 1; hoge <= 45; i *= 2)
    {
        mask[hoge++] = i;
        //cout << mask[hoge - 1] << endl;
    }

    a.resize(N);
    b.resize(N*(N+1)/2);
    acc.resize(N + 1);
    acc[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        acc[i + 1] = a[i] + acc[i];
    }

    long long cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j < i;j++)
        {
            b[cnt++] = acc[i] - acc[j];
            //cout << b[cnt - 1] << endl;
        }
    }

    long long num = (N+1)*N / 2;
    for (int i = 45; i >= 1; i--)
    {
        cnt = 0;
        for (int j = 0; j < num; j++)
        {
            if((b[j] & mask[i]) != 0)
            {
                cand[cnt++] = b[j];
            }
        }
        if(cnt >= K)
        {
            for (int j = 0; j < cnt;j++)
            {
                b[j] = cand[j];
            }
            num = cnt;
            //cout << "i = " << i << endl;
            /*
            
            for (int j = 0; j < num; j++)
            {
                cout << b[j] << endl;
            }
            */
        }
    }
    long long ans = b[0];
    for (int i = 1; i < num;i++)
    {
        ans = ans & b[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int n;
	cin>>n;
	cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <cctype>
#include <random>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	for (ll i = k; i < n; i++) {
		if (a[i] > a[i - k]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4836
#include<stdio.h>                                          
void trace(int A[],int N){ 
    int i;
    for(i=0;i<N;i++){
        if(i>0)
            printf(" ");
        printf("%d",A[i]);  
    }       
    printf("\n");
}


void insertionSort(int A[],int N){
    int j,i,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;            
        }       
        A[j+1]=v;
        trace(A,N);

    }
        
}

int main(void){
    int N,i,j;
    int A[100];

    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);
    trace(A,N);
    insertionSort(A,N);
        
   return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <queue>

using namespace std;
using LL = long long;

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

    queue<LL> que;

    for (int i = 1; i <= 9; i++) {
        que.push(i);
    }

    LL ans;

    while (K--) {
        ans = que.front(), que.pop();
        if (ans % 10 != 0)
            que.push(ans * 10 + ans % 10 - 1);
        que.push(ans * 10 + ans % 10);
        if (ans % 10 != 9)
            que.push(ans * 10 + ans % 10 + 1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) = abc158d()

fun abc158d() {
    val s = readLine()!!
    val q = readLine()!!.toInt()

    val stack = ArrayDeque(s.toList())
    var reversed = false

    for (i in 1..q) {
        val t = readLine()!!.split(' ')
        when (t[0].toInt()) {
            1 -> {
                reversed = !reversed
            }
            else -> {
                val f = t[1].toInt()
                val c = t[2][0]
                when (f) {
                    1 -> {
                        if (reversed) stack.addLast(c) else stack.addFirst(c)
                    }
                    else -> {
                        if (!reversed) stack.addLast(c) else stack.addFirst(c)
                    }
                }
            }
        }
    }

    val answer = (if (reversed) stack.reversed() else stack).joinToString("")

    println(answer)
}


Measured memory_bytes: 77124
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int inf = 1e17+21;


int32_t main(){
    FAST;
    string s;   cin >> s;
    int n = s.size();

    stack<char> st;

    int ans = 0;

    for(auto ch : s){
        if(st.empty()){
            st.push(ch);
        }else{
            char t = st.top();
            char cmp = ch;
            if(t == cmp){
                st.push(ch);     
                 continue;
            }

            st.pop();
            ans += 2;
        }
    }

    cout << ans;





    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

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


Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
int main (){
 	int k,panjang;
 	char s[101];
 	scanf("%d",&k);
 	scanf("%s",&s);
 	panjang = strlen (s);
 	
 	if (panjang <= k){
 		printf("%s",s);
	}
	else if (panjang > k ){
		for (int i=0; i <= k-1; i++){
			printf("%c",s[i]);
		}
		printf("...");
	}
return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;
    cin>> s;

    int mx= 0, c=0;

    for(int i=0; i<s.size(); i++)
    {
        if( s[i]== 'C' || s[i]== 'T' || s[i]== 'A' || s[i]== 'G')
            c++;

        else
        {
            mx= max(mx, c);
            c= 0;
        }
    }

    cout << max ( mx, c);
    nl;

    return 0;
}




Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define p 1000000007
using namespace std;
typedef long long ll;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n,m,last;
struct matrix
{
    ll a[5][5];
}f,g,ans;
matrix operator *(const matrix &a,const matrix &b)
{
    matrix c;
    memset(c.a,0,sizeof(c.a));
    for(int i=0;i<=2;++i)
        for(int j=0;j<=2;++j)
            for(int k=0;k<=2;++k)
                c.a[i][j]=(c.a[i][j]+a.a[i][k]*b.a[k][j]%p)%p;
    return c;
}
matrix qp(matrix x,ll y)
{
    matrix e;
    memset(e.a,0,sizeof(e.a));
    for(int i=0;i<=2;++i) e.a[i][i]=1;
    while(y)
    {
        if(y&1) e=e*x;
        x=x*x,y>>=1;
    }
    return e;
}
int main()
{
    read(n),read(m),ans.a[0][0]=1;
    f.a[0][0]=f.a[0][2]=f.a[1][1]=f.a[1][2]=f.a[2][0]=1;
    g.a[0][0]=g.a[0][2]=g.a[1][1]=g.a[1][2]=g.a[2][2]=1;
    f.a[0][1]=f.a[2][1]=f.a[2][2]=g.a[0][1]=2;
    for(int i=1;i<=m;++i)
    {
        int x;
        read(x),ans=ans*qp(f,x-last);
        ans=ans*g,last=x+1;
    }
    ans=ans*qp(f,n-last),printf("%lld",ans.a[0][2]);
    return 0;
}

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

int gcd(int a, int b, int c) {
    int answer = 1;
    int abcde = min(min(a, b), c);
    for (int i = 1;i <= abcde;i++) {
        if (a % i == 0 && b % i == 0 && c % i == 0) {
            answer = i;
        }
    }
    return answer;
}

int main() {
    int K;
    cin >> K;
    int answer = 0;
    for (int i = 1;i <= K;i++) {
        for (int j = 1;j <= K;j++) {
            for (int l = 1;l <= K;l++) {
                answer += gcd(i, j, l);
            }
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
ll adj[405][305];
bool mark[305][305];
int main()
{
    ll n;cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>adj[i][j];
            sum+=adj[i][j];
        }
    }
//    cout<<"sum = "<<sum<<endl;
    ll temp=0;
    bool ok=true;
    for(ll k=1;k<=n;k++)
            for(ll i=1;i<=n;i++)
                for(ll j=1;j<=n;j++)
                {
                    if(adj[i][j]>adj[i][k]+adj[k][j])
                    {
                        ok=false;
                    }
                    if(k==i||k==j)continue;
                    if(adj[i][j]==adj[i][k]+adj[k][j]&&mark[i][j]==0)
                    {
                        mark[i][j]=1;
                        temp+=adj[i][j];
//                        cout<<i<<" "<<j<<"  "<<k<<"  "<<adj[i][j]<<endl;
                    }

                }
    if(ok)cout<<(sum-temp)/2<<endl;
    else cout<<-1<<endl;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    llong a = A[0];
    for (int i = 1; i < (int)A.size(); ++i) {
        a ^= A[i];
    }

    if (a == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int d,r;
    scanf("%d",&d);
    r= d%10;

    if(r==2 || r==4 || r==5 || r==7 || r==9)
        printf("hon");
    else if(r==3)
        printf("bon");
    else
        printf("pon");
    return 0;
}


Measured memory_bytes: 1708
use proconio::input;

fn main() {
    input!{
        n: i64,
        mut x: i64,
        mut a: [i64; n],
    }

    a.sort();

    let mut ans = 0;
    for i in 0..n as usize {
        x -= a[i];
        ans += 1;

        if x <= 0 {
            break;
        }
    }

    if x != 0 {
        ans -= 1;
    }

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


Measured memory_bytes: 2140
N, X, Y = list(map(int, input().split()))
 
L = [0] * N
 
for i in range(1, N):
  for j in range(i + 1, N + 1):
    k = j - i
    k = min(k, abs(X - i) + 1 + abs(Y - j))
    L[k] += 1
 
for i in range(1, N):
  print(L[i])
        

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

#define lol long long
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
const lol mod=(1e9)+7;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol abs(lol x){return(x<0?-x:x);}
lol n,m,r;
string s;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  while(1){
    c-=b;
    if(c<=0){
      cout <<"Yes\n";
      return 0;
    }
    a-=d;
    if(a<=0) {
      cout <<"No\n";
      return 0;
    }
  }
  return (0);
}


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

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;
#define r tmp=d2[1];d2[1]=d2[3];d2[3]=d2[4];d2[4]=d2[2];d2[2]=tmp;
#define y tmp=d2[0];d2[0]=d2[3];d2[3]=d2[5];d2[5]=d2[2];d2[2]=tmp;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1,i,k;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
 for(i=0;i<5;i++){
  for(k=0;k<4;k++){
 check
   if(cnt==6)break;
   r
  }
 check
   if(cnt==6)break;
  tmp=d2[0];
  d2[0]=d2[1];
  d2[1]=d2[5];
  d2[5]=d2[4];
  d2[4]=tmp;
 }
 
 check
   if(cnt==6)break;
   y

  for(k=0;k<4;k++){
 check
   if(cnt==6)break;
   r
  }
 
 check
   if(cnt==6)break;
  y
  y

  for(k=0;k<4;k++){
 check
   if(cnt==6)break;
   r
  }
 check
   if(cnt==6)break;
   a=0;
 }


 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

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

int main(void)
{
	float a, c;
	float b;
	cin >> a;
	c = 1;
	while (c != 10) {
		b = a / c;
		if (b == 1 || b == 2 || b == 3 || b == 4 || b == 5 || b == 6 || b == 7 || b == 8 || b == 9)
		{
			cout << "Yes" << endl;
			break;
		}
		c += 1;
	}
	if (c == 10)
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = sum(A)

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

print(ans-sum(A))

Measured memory_bytes: 18624
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var AB = ReadLine().Split().Select(int.Parse).ToArray();
        int A = AB[0];
        int B = AB[1];
        if (A <= 8 && B <= 8)
        {
            WriteLine("Yay!");
        }
        else
        {
            WriteLine(":(");
        }
    }
}


Measured memory_bytes: 28200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1,H2,M1,M2;
  long long K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  cout << 60*H2 + M2 - 60*H1 -M1 - K << endl;

}

Measured memory_bytes: 3596
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = self.rear , self.bottom, self.front, self.top
  
    def print_top(self): 
        print(self.top)
    def print_right(self): 
        print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
 
    def compare(self, label):
        for op in 'EEENEEENEEESEEESEEENEEEN':
            if self.get_label() == label:
                return True
            self.roll(op)
        else:
            return False
   
if __name__=='__main__':
    n = int(input())
    L = []
    for i in range(n):
        label = list(map(int,input().split()))
        for d in L:
            if d.compare(label): 
                break
        else:
            L.append(dice(label))
            continue
        print('No')
        break
    else:
        print('Yes')


Measured memory_bytes: 5608
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
struct point
{
	int x, y; 
	inline bool operator <(const point &a) const
	{
		return x < a.x; 
	}
} arr[200005]; 
int mx[200005], n, app[200005]; 
inline void modify(int pos, int x)
{
	for (; pos <= n; pos += pos & -pos)
		mx[pos] = max(mx[pos], x); 
}
inline int query(int pos)
{
	int res = 0; 
	for (; pos; pos -= pos & -pos)
		res = max(res, mx[pos]); 
	return res; 
}
int main()
{
	// freopen("AGC019-C.in", "r", stdin); 
	int stx, sty, enx, eny; 
	scanf("%d%d%d%d%d", &stx, &sty, &enx, &eny, &n);
	bool f = false; 
	if (stx > enx)
	{
		swap(stx, enx); 
		swap(sty, eny); 
	}
	if (sty > eny)
	{
		sty = 1e8 - sty; 
		eny = 1e8 - eny; 
		f = true; 
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &arr[i].x, &arr[i].y); 
		if (f)
			arr[i].y = 1e8 - arr[i].y; 
		if (arr[i].x < stx || arr[i].x > enx || arr[i].y < sty || arr[i].y > eny)
		{
			i--; 
			n--; 
		}
		app[i] = arr[i].y; 
	}
	sort(app, app + n); 
	for (int i = 0; i < n; i++)
		arr[i].y = lower_bound(app, app + n, arr[i].y) - app + 1; 
	sort(arr, arr + n); 
	int ans = 0; 
	for (int i = 0; i < n; i++)
	{
		int res = query(arr[i].y) + 1; 
		modify(arr[i].y, res); 
		ans = max(ans, res); 
	}
	int s = enx - stx + eny - sty, p = ans, q = 0; 
	if (p == min(enx - stx, eny - sty) + 1)
	{
		p--; 
		q++; 
	}
	printf("%.15lf\n", (double)s * 100 - (20 - 5 * acos(-1.0)) * p + (10 * acos(-1.0) - 20) * q);
	return 0; 
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      int answer = 0;
            
      for(int i=0; i<N; i++){
        string S;
        cin >> S;
                
        if(S == "Y"){
        cout << "Four" << endl;
          break;
        }
        else if(i == N-1){
        cout << "Three" << endl;
        }
      }
    }

Measured memory_bytes: 256
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    def __add__(self, q):
        if isinstance(q, Point):
            return Point(self.x + q.x, self.y + q.y)
        else:
            return Point(self.x + q, self.y + q)
    
    def __sub__(self, q):
        if isinstance(q, Point):
            return Point(self.x - q.x, self.y - q.y)
        else:
            return Point(self.x - q, self.y - q)
    
    def __mul__(self, q):
        if isinstance(q, Point):
            return Point(self.x * q.x - self.y * q.y,
                         self.x * q.y + self.y * q.x)
        else:
            return Point(self.x * q, self.y * q)
        
    def __truediv__(self, q):
        if isinstance(q, Point):
            return self * q.conj / q.norm
        else:
            return Point(self.x / q, self.y / q)
    
    @property
    def conj(self):
        return Point(self.x, -self.y)
    
    def rot(self, ang):
        return Point(math.cos(ang) * self.x - math.sin(ang) * self.y,
                     math.sin(ang) * self.x + math.cos(ang) * self.y)
    
    def rot90(self):
        return Point(-self.y, self.x)
    
    def cross(self, q):
        return self.x * q.y - self.y * q.x
    
    def dot(self, q):
        return self.x * q.x + self.y * q.y
    
    @property
    def norm(self):
        return self.dot(self)

    def __abs__(self):
        return self.dot(self) ** 0.5


class Line:
    def __init__(self, a, b):
        if not isinstance(a, Point) or not isinstance(b, Point):
            raise AttributeError("points should be instance of Point")
            
        self.a = a
        self.b = b
    
    def cross_point(self, l, eps=1e-12):
        deg = (l.b - l.a).cross(self.b - self.a)
        if abs(deg) < eps:
            return Point(0, 0)
        
        return self.a + (self.b - self.a) * (l.b - l.a).cross(l.b - self.a) / deg


def simple_ccw(a, b, c, eps=1e-12):
    if (b - a).cross(c - a) > eps:
        return 1
    if (b - a).cross(c - a) < -eps:
        return -1
    return 0


def circum_center(a, b, c):
    ab = Line((a + b) / 2, (a + b) / 2 + (a - b).rot90())
    bc = Line((b + c) / 2, (b + c) / 2 + (b - c).rot90())
    return ab.cross_point(bc)


# ---------------------------------------
# Solution
# ---------------------------------------

N = int(input())
vecs = []
for _ in range(N):
    x, y = map(int, input().split())
    vecs.append(Point(x, y))

cand = []
for i in range(N):
    for j in range(i + 1, N):
        cand.append((vecs[i] + vecs[j]) / 2)
        
        for k in range(j + 1, N):
            if simple_ccw(vecs[i], vecs[j], vecs[k]) == 0:
                continue
                
            cand.append(circum_center(vecs[i], vecs[j], vecs[k]))
            
ans = float("inf")
for p in cand:
    tmp = 0
    for v in vecs:
        tmp = max(tmp, abs(p - v))
    ans = min(ans, tmp)
print("{:.14f}".format(ans))


Measured memory_bytes: 63576
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x;
    cin>>x;
    int h=0;
    int c=0;
    int m[n];
    for(int i=0;i<n;i++)
    {
        cin>>m[i];
        c+=m[i];   
    }
    
    sort(m,m+n);
    h=m[0];
    
    cout<<n+(x-c)/h;
    system ("pause");
     return 0;
}
    

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define PI 3.14159265358979323846264338327950288419716939
int main(){
    double A,B,H,M;
    cin>>A>>B>>H>>M;
    pair <double,double> p1, p2;
    double A1 = H/12.0*2*PI + M/60/12.0*2*PI;
    p1 = make_pair(A*sin(A1), A*cos(A1));
    double A2 = M/60.0*2*PI;
    p2 = make_pair(B*sin(A2), B*cos(A2));
    double a,b,c,d;
    tie(a,b) = p1;
   // cout<<a<<" "<<b<<endl;
    tie(c,d) = p2;
    double ans = sqrt((a-c)*(a-c)+(b-d)*(b-d));
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int l = 0, r = 1001001001;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }
    int ans = r - l + 1;
    if(ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1])

dp = [0] * (H + 1)
for h in range(1, H + 1):
    dp[h] = min([dp[max(h - a, 0)] + b for a, b in AB])

print(dp[-1])


Measured memory_bytes: 42844
#include<bits/stdc++.h>
using namespace std;
int n,k,a[1000005],f;
int main(){
           cin>>n;
           for(k=1;k<=n;k++){
                      cin>>a[k];
                      if(a[k]%2==0){
                                 if(a[k]%3!=0 && a[k]%5!=0) 
                                 f=1;
                      }
           }
           if(f==1) cout<<"DENIED";
           else cout<<"APPROVED";
           
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n;
      
    scanf("%d",&n);
  
    if((n==1)||(n==2)||(n==3)||(n==5)||(n==6)||(n==9)||(n==10)||(n==13)||(n==17)) printf("No\n");
    else printf("Yes\n");
  
    return 0;
} 

Measured memory_bytes: 128
#include <stdio.h>
#define pi 3.141592653589793;

int main(void)
{
	double r,s,l;
	
	scanf("%lf",&r);
	s = r*r*pi;
	l = 2*r*pi;
	printf("%lf %lf\n",s,l);
	
	return 0;
}

Measured memory_bytes: 648
import math

A,B = map(int,input().split())
tmp_Bx = B * 10

f = False
for i in range(tmp_Bx,tmp_Bx+10):
    Ax = math.floor(0.08 * i)
    if Ax == A:
        print(i)
        f = True
        break
if f == False:
    print(-1)

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

int main() {
  string S;
  cin >> S;
  vector<bool>A(S.length() / 2);
  for (int i = 1; i < S.length() / 2; i++) {
    A.at(i) = true;
    for (int j = 0; j < S.length() / 2 - i; j++) {
      if (S[j] != S[S.length() / 2 - i + j]) {
        A.at(i) = false;
      }
    }
  }
  for (int i = 0; i < S.length() / 2; i++) {
    if (A.at(i)) {
      cout << S.length() - i * 2;
      break;
    }
  }
}

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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

ll freq[100001];

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ll n;
	cin >> n;
	ll a[n];
	ll sum = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		freq[a[i]] = freq[a[i]] + 1;
		sum += a[i];
	}
	ll q, x, y;
	cin >> q;
	while(q--){
		cin >> x >> y;
		ll cnt = freq[x];
		sum += cnt * (y - x);
		freq[y] += freq[x];
		freq[x] = 0;
		cout << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n+1,0);
    int ans = 0;
    while(k--){
        int d; cin >> d;
        for(int i = 0; i < d; i++){
            int x; cin >> x;
            v[x]++;
        }
    }
    for(int i = 1; i <= n; i++){
        if(v[i] == 0) ans++;
    }
    cout << ans << endl;
    
}





Measured memory_bytes: 3596
package main

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

type pt struct {
	y int
	x int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	h, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	w, _ := strconv.Atoi(sc.Text())

	mas := make([][]byte, h)
	que := make([]pt, 0)
	for i := 0; i < h; i++ {
		sc.Scan()
		mas[i] = []byte(sc.Text())
		for j := 0; j < w; j++ {
			if mas[i][j] == '#' {
				que = append(que, pt{y: i, x: j})
			}
		}
	}
	dpt := make([][]int, h)
	for i := 0; i < h; i++ {
		dpt[i] = make([]int, w)
	}
	var ans int
	for len(que) != 0 {
		p := que[0]
		que = que[1:]
		nbr := []pt{
			pt{y: p.y, x: p.x - 1},
			pt{y: p.y, x: p.x + 1},
			pt{y: p.y - 1, x: p.x},
			pt{y: p.y + 1, x: p.x},
		}
		for _, q := range nbr {
			if q.y < 0 || h <= q.y || q.x < 0 || w <= q.x {
				continue
			}
			if mas[q.y][q.x] == '.' {
				dpt[q.y][q.x] = dpt[p.y][p.x] + 1
				ans = dpt[q.y][q.x]
				mas[q.y][q.x] = '#'
				que = append(que, q)
			}
		}
	}
	fmt.Println(ans)
}


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

int main(){
  string x;
  cin>>x;
  
  if(x[0]!=x[1]&&x[0]!=x[2]&&x[1]!=x[2]){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  vector<int>L(N+1);
  vector<int>R(N+1);
  for(int i=0;i<N;i++){
    L[i+1]=__gcd(L[i],a[i]);
  }
  for(int i=N-1;i>=1;i--){
    R[i-1]=__gcd(R[i],a[i]);
  }
  int ans=0;
  for(int i=0;i<N;i++){
   ans=max(ans,__gcd(L[i],R[i]));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4516
#include <stdio.h>
int min(int a, int b)
{
  if(a>b) return b;
  else return a;
}

int main()
{
    int n;
    scanf("%d", &n);
    
    int p[n];
    int m[n];
    for(int i=0;i<n;i++){
        scanf("%d", &p[i]);
    }
  	m[0]=p[0];
  	for(int i=1;i<n;i++){
      	m[i]=min(p[i],m[i-1]);
    }
  
    int c=0;
  	for(int i=0;i<n;i++){
      	if(p[i]==m[i]) c++;
    }

    printf("%d", c);
    return 0;
}


Measured memory_bytes: 1664
n = int(input())
a = list(map(int, input().split()))

color = [0] * 8
ans = 0

for rate in a:
    if rate < 400:
        color[0] = 1
    elif rate < 800:
        color[1] = 1
    elif rate < 1200:
        color[2] = 1
    elif rate < 1600:
        color[3] = 1
    elif rate < 2000:
        color[4] = 1
    elif rate < 2400:
        color[5] = 1
    elif rate < 2800:
        color[6] = 1
    elif rate < 3200:
        color[7] = 1
    else:
        ans += 1

print(sum(color) if sum(color) > 0 else 1, sum(color) + ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest._400Problems_remain_
{
    class CF2016Final_C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            var edges = new Queue<int>[m];
            for(int i = 0; i < m; i++)
            {
                edges[i] = new Queue<int>();
            }
            for (int i = 0; i < n; i++)
            {
                int[] kls = ReadInts();
                for (int j = 0; j < kls[0]; j++)
                {
                    edges[kls[j + 1] - 1].Enqueue(i);
                }
            }
            var parents = new int[n];
            var ranks = new int[n];
            for (int i = 0; i < n; i++) parents[i] = i;
            for (int i = 0; i < m; i++)
            {
                if (edges[i].Count <= 1) continue;
                int parent = edges[i].Dequeue();
                while (edges[i].Count > 0)
                {
                    int index = edges[i].Dequeue();
                    Unite(ref parents, ref ranks, parent, index);
                }
            }
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                //Console.WriteLine(parents[i]);
                if (parents[i] != i) cnt++;
            }
            Console.WriteLine(cnt == n - 1 ? "YES" : "NO");
        }

        static int Root(ref int[] tree, int x)
        {
            int rx = x;
            while (tree[rx] != rx)
            {
                rx = tree[rx];
            }
            tree[x] = rx;
            return rx;
        }

        static bool IsSame(ref int[] tree, int x, int y)
        {
            return Root(ref tree, x)
                == Root(ref tree, y);
        }

        static void Unite(ref int[] tree, ref int[] rank,
            int x, int y)
        {
            int rx = Root(ref tree, x);
            int ry = Root(ref tree, y);
            if (rx == ry) return;
            if (rank[rx] < rank[ry])
            {
                int temp = rx;
                rx = ry;
                ry = temp;
            }
            if (rank[rx] == rank[ry])
            {
                rank[rx]++;
            }
            tree[ry] = rx;
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27316