akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int n,b,f,r,v;
    int count[5][4][11];
    for(int i = 0; i < 5; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 11; k++){
                count[i][j][k] = 0;
            }
        }
    }
    cin >> n;
    for(int l = 0; l < n; l++){
        cin >> b >> f >> r >> v;
        count[b][f][r] += v;
    }
    for(int m = 1; m < 5; m++){
        for(int n = 1; n < 4 ; n++){
            for(int p = 1; p < 11; p++){
                cout <<" "<< count[m][n][p];
            }
        cout << endl;
        }
        for(int q = 0; q < 20; q++){
            if(m == 4) break;
            cout << "#";
        }
        (m != 4) ? cout << endl : cout << "";
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (n < 4) {
    puts("No");
    return 0;
  }

  string t = "YAKI";
  for (int i = 0; i < 4; ++i) {
    if (s[i] != t[i]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,k;
	cin>>n>>k;
	set<int> S;
		for(int i =0; i<k ; i++){
			int d=0;
			cin>>d;
			for(int j =0; j<d ; j++){
				int a=0;
				cin>>a;
			S.insert(a);}
		}
	cout<< n-S.size()  << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
  int X, N;
  cin >> X >> N;
  
  if(N == 0){
    cout << X << endl;
    return 0;
  }
  
  int ans;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  
  vector<int>num(101, 0);
  for(int i=0;i<N;i++){
    num[p[i]]++;
  }
  
  int d = 999;
  for(int i=0;i<101;i++){
    if(num[i] == 0 && abs(X - i) < d){
      d = abs(X - i);
      ans = i;
    }
  }
  
  if(abs(X - 101) < d){
    d = abs(X - 101);
    ans = 101;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3636
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll fa[100009];
ll fam[100009];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}


ll nck(ll n,ll k){
    ll ans=0;
    ans = (fa[n]*fam[n-k]%mod)*fam[k];
    ans %= mod;
    return ans;
}

signed main(){
    rep(i,100009){
        if(i==0) fa[i]=1, fam[i] = 1;
        else {
            fa[i]= i* fa[i-1];
            fa[i] %= mod;
            fam[i] = fam[i-1] * modinv(i,mod);
            fam[i] %= mod;
        }
    }
    ll n,k,s=0;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll ts = 0;
    rep(i,n){
        ts = 0;
        if(n-1-i >= k-1) ts -= (a[i]%mod) * (nck(n-1-i,k-1));
        if(i >= k-1) ts += (a[i]%mod) * (nck(i,k-1));
        ts %= mod;
        s += ts;
        s %= mod;
        if(s<0) s += mod;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 2560
//
// AtCoder ABC122C
//
//

#include <bits/stdc++.h>
using namespace std;


void solve(long long N, long long Q, std::string S, std::vector<long long> l, std::vector<long long> r){

    string ss;
    int cc[N] ={};
    int ccount=0;
    for(long long i=S.size()-2; i>=0; i--) {
        if (S[i] == 'A' && S[i+1] == 'C' ) {
            ccount++;
        }
        cc[i] = ccount;
    }
    for(long long i=0; i<Q; i++) {
        int count1 = cc[ l[i]-1 ] - cc[ r[i]-1 ];
        cout << count1 << endl;
    }
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::string S;
    std::cin >> S;
    std::vector<long long> l(Q);
    std::vector<long long> r(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&l[i]);
        scanf("%lld",&r[i]);
    }
    solve(N, Q, S, std::move(l), std::move(r));
    return 0;
}


Measured memory_bytes: 3072
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

bool dp[100001];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	vector <int> p = { 100,101,102,103,104,105 };
	int n;

	cin >> n;

	memset(dp, false, sizeof(dp));
	dp[0] = true;

	for (int i = 0; i <= 100000; i++)
	{
		if (dp[i] == false)
		{
			continue;
		}
		for (int j = 0; j < p.size(); j++)
		{
			if (i + p[j] <= 100000)
			{
				dp[i + p[j]] = true;
			}
		}
	}

	cout << dp[n] << '\n';

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rg register
#define us unsigned
#define ll long long
#define ui <int>
#define pi <int, int>
#define tmpl template <typename typ>
#define oprt operator
#define sp putchar(32)
#define el putchar(10)
#define flin(x) freopen(x, "r", stdin)
#define flout(x) freopen(x, "w", stdout)
#define flio(x) flin(x".in"), flout(x".out")
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define itrt iterator
using namespace std;
tmpl inline bool up(typ &x, const typ &y) { return x < y ? x = y, 1 : 0; }
tmpl inline bool dn(typ &x, const typ &y) { return y < x ? x = y, 1 : 0; }
tmpl inline bool inrange(const typ &x, const typ &l, const typ &r) { return !(x < l) && !(r < x); }
namespace orh {
inline void useios() { ios_base::sync_with_stdio(false); cin.tie(0); }
inline char rc() { rg char ch; while (!isgraph(ch = getchar())); return ch; }
tmpl typ ri() {
	rg typ x = 0; rg bool neg = false; rg char ch;
	while (!inrange(ch = getchar(), '0', '9')) neg |= ch == '-';
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inrange(ch = getchar(), '0', '9'));
	return neg ? -x : x;
}
tmpl typ ru() {
	rg typ x = 0; rg char ch;
	while (!inrange(ch = getchar(), '0', '9'));
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inrange(ch = getchar(), '0', '9'));
	return x;
}
tmpl void wi(rg typ x) {
	if (x < 0) { putchar('-'); x = -x; }
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
tmpl void wu(rg typ x) {
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
}

const int maxn = 1e5 + 5;
const int inf = 1e9;
int n, k, s, a[maxn];

signed main() {
	
	n = orh::ru ui(), k = orh::ru ui(), s = orh::ru ui();
	for (rg int i = 1; i <= k; ++i)
		cout << s << " ";
	for (rg int i = k + 1; i <= n; ++i)
		if (s == inf) cout << inf - 1 << " ";
		else cout << inf << " ";
	
	return 0; 
}

Measured memory_bytes: 1280
from sys import stdin
n,s = map(int,stdin.readline().split())
ans = 0
a = []
for i in xrange(n):
  x,y = map(int,stdin.readline().split())
  a.append((x,y))
a.sort()
for x,y in a:
  mi = min(y,s)
  ans += mi * x
  s -= mi
print ans

Measured memory_bytes: 15804
s = input().split()
A = int(s[0])
B = int(s[1])

A_price_low = A / 0.08
B_price_low = B / 0.1
A_price_high = (A+1) / 0.08
B_price_high = (B+1) / 0.1

if B_price_low <= A_price_low < B_price_high:
    if A % 2 == 0:
        print(int(A_price_low))
    else:
        print(int(A_price_low) + 1)
elif A_price_low <= B_price_low < A_price_high:
    print(int(B_price_low))
else:
    print(-1)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N 10005
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int A[N];
int main()
{
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	printf("%d\n",A[n]-A[1]);
	return 0;
}


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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int n;
int a[100000];
ll r[100001];
void solve(){
	sort(a,a+n,greater<int>());
	repr(i,n){
		r[i]=r[i+1]+a[i];
	}
	rep(i,n)
		if(a[i]>2*r[i+1]) {cout<<i+1<<endl;return;}
	cout<<n<<endl;
}

int main(){
	cin>>n;
	rep(i,n) {
		cin>>a[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 1408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

//nt a[100000010]={-1};
int main(){
	int n;
	while(cin>>n,n){
		int sum = 1;
		if(n==1){
			cout <<"deficient number"<<endl;
			continue;
		}
		for(int i=2;i*i<=n;i++){
			if(n%i==0){
				if(i*i==n)sum+=i;
				else sum +=i+n/i;
			}
		}
		if(sum==n){
			cout <<"perfect number"<<endl;
		}else if(sum>n){
			cout <<"abundant number"<<endl;
		}else{
			cout <<"deficient number"<<endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
using namespace std;
int main(){
    string w;int m,h,i;
    while(true){
        cin >> w;
        if(w == "-") break;
        cin >> m;
        for(i=0;i<m;i++){
            cin >> h;
            w = w.substr(h)+w.substr(0,h);
        }
        cout << w << endl;
    }
}


Measured memory_bytes: 3204
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        boolean[] p = new boolean[100001];
        Arrays.fill(p, true);
        p[0] = false; p[1] = false;
        boolean[] s = new boolean[100001];
        int[] sum = new int[100001];
        for (int i = 2; i <= 100000; i++) {
            sum[i] += sum[i-1];
            if(p[i]){
                for(int j = 2 * i; j <= 100000; j += i) p[j] = false;
                if(p[(i+1)/2]){
                    s[i] = true;
                    sum[i]++;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            sb.append(sum[r] - sum[l-1]).append("\n");
        }

        System.out.println(sb.toString());
        sc.close();
    }

}


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

int w[101];
long long v[101];
long long dp[100001][101];
int n,wmaks;
using namespace std;

long long ans(int wnow, int ind){
    if (ind==n)
        return 0;

    if (dp[wnow][ind]!=-1)
        return dp[wnow][ind];

    if (wnow+w[ind+1]>wmaks){
        dp[wnow][ind]=ans(wnow,ind+1);
        return dp[wnow][ind];
    }

    dp[wnow][ind]=max(ans(wnow+w[ind+1],ind+1)+v[ind+1],ans(wnow,ind+1));
    return dp[wnow][ind];
}

int main()
{

    cin >> n >> wmaks;

    for (int i=0;i<100001;i++)
        for (int j=0;j<101;j++)
            dp[i][j]=-1;

    for (int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }

    cout << ans(0,0) << endl;
/*
    for (int i=1;i<wmaks+1;i++)
        for (int j=1;j<n+1;j++)
            cout << dp[i][j] <<endl;
*/
    return 0;
}


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

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

  vector<long long> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  rep(i, n) {
    int cnt = 0;
    int j = i;
    while ((j < n - 1) && (h[j] >= h[j + 1])) {
      cnt++;
      j++;
    }
    i = j;
    ans = max(ans, cnt); 
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll N;
ll tp[5];

int main(){
    cin>>N;
    rep(i,5) cin>>tp[i];

    ll mini=100100100100100100;
    rep(i,5){
        if(tp[i]<mini) mini=tp[i];
    }

    ll ans=N%mini==0?N/mini+4:N/mini+5;

    cout<<ans<<endl;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll k,n,cnt=0,ans=0,i;
    cin>>n>>k;
    vector<ll> arr(n);
   	for(ll i=0;i<n;i++)
   	{
   			cin>>arr[i];
   			
   		
	}
	if(k>=n)
		ans=0;
	else
	{
		sort(arr.begin(),arr.end());
		for(i=n-1;i>n-1-k;--i)
			arr[i]=0;
		for(i=0;i<=n-1-k;i++)
			cnt+=arr[i];
		
		ans=cnt;
	}
	cout<<ans<<endl;
	
	
	
	
   		
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    int N;
    int C, K;
    void Solve()
    {
        N = cin.Nextint;
        C = cin.Nextint;
        K = cin.Nextint;
        var T = new int[N];
        for (int i = 0; i < N; i++)
        {
            T[i] = cin.Nextint;
        }
        Array.Sort(T);
        var L = T[0] + K;
        int cnt = 1;
        int ans = 0;


        for (int i = 1; i < N; i++)
        {
            if (cnt == C)
            {
                ans++;
                L = T[i] + K;
                cnt = 1;
            }
            else
            {
                if (T[i] <= L)
                {
                    cnt++;
                }
                else
                {
                    ans++;
                    L = T[i] + K;
                    cnt = 1;
                }
            }
        }
        ans++;
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) (int) stuff.size()

#define int long long
#define float long double 
#define ll long long

const int inf = (int) 1e16;
const int upper = (int) 3e5 + 50;
const int M = (ll) 1e9 + 7;
const int mod = (ll) 998244353;
const double eps =  1e-8;

int f (int n) {
	if (n == -1) return 0;
	int r = n % 4;
	if (r == 0) return n;
	if (r == 1) return 1;
	if (r == 2) return n + 1;
	if (r == 3) return 0;
}

signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif

	int a, b; cin >> a >> b;
	cout << (f(b) ^ f(a - 1));
 	end_routine();	
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		double a =scan.nextDouble();
		double b =scan.nextDouble();
		double C =scan.nextDouble();
		double Crad = Math.toRadians(C);
		double keisan =0.0;
		//??¢??? ??? ??????a * ???b sin(ab???????§????C)/2?????????C???????????¢????§???????????????????????????¨???
		keisan = a*b * Math.sin(Crad) /2 ;
		System.out.println(keisan);
		//??¨ ??? a + b +???a?????? + b?????? - 2*a*b*cos(C)
		keisan = (a+b)+Math.sqrt(a*a + b*b - 2*a*b*Math.cos(Crad));
		System.out.println(keisan);
		//?????? ??? b*sin(C)
		keisan = b*Math.sin(Crad);
		System.out.println(keisan);
	}
}

Measured memory_bytes: 27916
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        auto c = s[i];
        if(c != t[i]) ans++;
    }

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


Measured memory_bytes: 3856
#include<stdio.h>
int main(void){
  int k;
  double a[11];
  double sum;
  while(scanf("%lf",&a[1])!=EOF){
    sum = a[1];
    for(k=2;k<=10;k++){
      if(k%2==0){
        a[k] = a[k-1] * 2;
      }else{
        a[k] = a[k-1] / 3;
      }
      sum += a[k];
    }
    printf("%lf\n",sum);
  }
  return 0;
}

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

 bool BinarySearch(int t, vector<int> S)
 {
 	int start = 0;
 	int end = S.size() - 1;
 	do{
 		int middle = (end - start) / 2 + start;
 		if(t == S[middle]){
 			return true;
 		}else if(t < S[middle]){
 			end = middle - 1;
 		}else if(t > S[middle]){
 			start = middle + 1;
 		}
 //		cout << t << " " << start << " " << middle " " << end << endl;
 	}while(end - start >= 0);
 	return false;
 }

 int main()
 {
 	int Count = 0;
 	int n;
 	cin >> n;
 	vector<int> S;
 	for(int i = 0; i < n; i++){
 		int s;
 		cin >> s;
 		S.push_back(s);
 	}
 	int q;
 	cin >> q;
 	for(int i = 0; i < q; i++){
 		int t;
 		cin >> t;
 		if(BinarySearch(t, S)){
 			Count++;
 //			cout << "t:" << t << endl;
 		}
 	}
 	cout << Count << endl;
 	return 0;
 }

Measured memory_bytes: 1936
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[m];
        int sum = 0;
        for(int i=0; i<m; i++) {
            a[i] = in.nextInt();
            sum += a[i];
        }
        System.out.println((n-sum < 0) ? -1 : (n-sum));
    }
}


Measured memory_bytes: 46280
from collections import deque

def bfs(maze,dist,sy,sx):
    #キューオブジェクトの生成
    queue = deque([[sy,sx]])
    dist[sy][sx] = 0
    md = 0
    l = []
    while queue:
        #先頭から要素を一つ削除する
        y,x = queue.popleft()
        for j, k in ([1,0],[-1,0],[0,1],[0,-1]):
            new_y, new_x = y+j, x+k
            #迷路内に収まっているか確かめる
            if 0 <= new_y < H and 0 <= new_x < W:
                #道かどうか確かめる
                if maze[new_y][new_x] == "." and dist[new_y][new_x] == -1:
                    dist[new_y][new_x] = dist[y][x] + 1
                    queue.append([new_y, new_x])
                    md = max(dist[new_y][new_x],md)
    return md
H, W = map(int,input().split())
maze = [input() for i in range(H)]

ans = 0
for i in range(H):
    for j in range(W):
        dist = [[-1]*W for k in range(H)]
        if maze[i][j] != "#":
            a = bfs(maze,dist,i,j)
            ans = max(a,ans)
print(ans)

Measured memory_bytes: 3444
#include<iostream>

void sort(int A[],int N){
    for(int i=1;i<N;i++){
        int v=A[i];
        int j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(int k=0;k<N;k++){
            std::cout<<A[k];
            if(k!=N-1) std::cout<<" ";
       }
       std::cout<<std::endl;
    }
}

int main(void){
    int N;
    int A[100];
    std::cin>>N;
    for(int i=0;i<N;i++)
        std::cin>>A[i];
    for(int i=0;i<N;i++){
        if(i) std::cout<<" ";
        std::cout<<A[i];
    }
    std::cout<<std::endl;
    sort(A,N);
    
    return 0;
}


Measured memory_bytes: 3072
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int D;
vector<int> c(26);
int ss[365][26];
vector<int> ans(0);

double powyabai = 1.2;
double cyabaipow = 1.2;
double uresisapow = 0.95;
int akanC = 70;

double evaluate(int day, int kind){
    double yabasa = 0;
    int s = ans.size();
    int idx;
    for(idx = s - 1; 0 <= idx; idx--){
        if(ans[idx] == kind) break;
    }
    yabasa = pow(day - idx, powyabai) * pow(c[kind], cyabaipow);
    double uresisa = pow(ss[day][kind], uresisapow);
    return yabasa + uresisa;
}

int main(){
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D)rep(j, 26) cin >> ss[i][j];
    rep(i, D){
        double max_eva = -inf;
        double choice = 0;
        rep(j, 26){
            if(c[j] < akanC && chmax(max_eva, evaluate(i, j))) choice = j;
        }
        ans.push_back(choice);
    }
    rep(i, D) pt(ans[i] + 1);
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int r, c, k;
ll M[3001][3001], dp[3001][3001][4];

int main() {
    cin >> r >> c >> k;
    rep(i, k) {
        ll r, c, v;
        cin >> r >> c >> v;
        M[r][c] = v;
    }
    reps(i, r) reps(j, c) rep(k, 4) {
        if (k == 0) {
            dp[i][j][k] = max({dp[i - 1][j][0], dp[i - 1][j][1], dp[i - 1][j][2], dp[i - 1][j][3], dp[i][j - 1][0]});
        } else if (M[i][j] != 0) {
            if (k == 1)
                dp[i][j][k] = max({dp[i - 1][j][0] + M[i][j], dp[i - 1][j][1] + M[i][j], dp[i - 1][j][2] + M[i][j],
                                   dp[i - 1][j][3] + M[i][j], dp[i][j - 1][1]});
            else
                dp[i][j][k] = max(dp[i][j - 1][k - 1] + M[i][j], dp[i][j - 1][k]);
        } else {
            dp[i][j][k] = dp[i][j - 1][k];
        }
    }
    // reps(i, r) {
    //     reps(j, c) { printf("%lld\t", max({dp[i][j][0], dp[i][j][1], dp[i][j][2], dp[i][j][3]})); }
    //     puts("");
    // }
    cout << max({dp[r][c][0], dp[r][c][1], dp[r][c][2], dp[r][c][3]}) << endl;
    return 0;
}

Measured memory_bytes: 354908
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    vector<int> u(N-1), v(N-1);
    REP(i, N-1){
        cin >> u[i] >> v[i];
    }
    ll ans = N*(N*N+3*N+2)/6;
    REP(i, N-1){
        ans -= min(u[i], v[i])*(N-max(u[i], v[i])+1);
    }

    pr(ans);
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l,sum, ans;
ll a[200500],  b[200500];
vector<ll> g[100500];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[a[i]] = i;
    }
    ll ans = 0, sum = 0;
    ll ko = 0;
    for (int i = 1; i <= n; i++) {
        if (b[i] > ko) {
            sum++;
            ko = b[i];
        } else {
            ans = max(ans, sum);
            sum = 1;
            ko = b[i];
        }
    }
    ans = max(ans, sum);
    cout << n-ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    vector<bool> m(10001, false);
    long s;
    cin >> s;
    ll count=1;
    m[s]=true;
    while(true)
    {
        if(s % 2 == 0) s/=2;
        else s= s*3 +1;
        count++;
        if(m[s]==true) break;
        else m[s]=true;
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

const long long mod = 1e9 + 7;

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

    int ans;
    ans = c- (a-b);
    if(ans < 0) ans = 0;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Open(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout);
#define inl inline
#define reg register
#define i64 long long 
#define int long long 
using namespace std;
inl int read(){int x=0,f=0;char ch=0;while(!isdigit(ch))f|=(ch=='-'),ch=getchar();while(isdigit(ch))(x*=10)+=(ch^48),ch=getchar();return f?-x:x;}
inl void Ot(reg int x){if(x<0)x=-x,putchar('-');if(x>=10)Ot(x/10);putchar(x%10+'0');}
inl void Print(reg int x,char til='\n'){Ot(x);putchar(til);}
inl int Max(reg int x,reg int y){return x>y?x:y;}
inl int Min(reg int x,reg int y){return x<y?x:y;}
inl int Abs(reg int x){return x<0?-x:x;}
const int MAXN=105060;
int n,k;
int Smin,Smax;
int a[MAXN],ans;
int sum[MAXN];
int fac[MAXN],inv[MAXN];
const int Mod=1e9+7;
inl int qpow(int x,int y=Mod-2){
	int ret=1;
	for(;y;y>>=1,x=x*x%Mod)if(y&1)ret=ret*x%Mod;
	return ret;
}
void Init(){
	inv[0]=fac[0]=1;
	for(reg int i=1;i<=n;i++)fac[i]=(fac[i-1]*i)%Mod;
	inv[n]=qpow(fac[n]);
	for(reg int i=n-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%Mod;
}
int C(int n,int m){return fac[n]%Mod*inv[m]%Mod*inv[n-m]%Mod;}
signed main(){
	#ifndef ONLINE_JUDGE
		//freopen("../../data.in","r",stdin);
	#endif
	n=read(),k=read();
	if(k==1)return puts("0"),0;
	Init();
	for(reg int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	// cout<<C[n]<<endl;
	// for(reg int i=1;i<=n;i++)
		// printf("C(%lld,%lld)=%lld\n",i,k-1,C[i]);
	for(reg int i=1;i<=n-k+1;i++)
		Smin=(C(n-i,k-1)*a[i]%Mod+Smin)%Mod;
	for(reg int i=n;i>=k;i--)
		Smax=(C(i-1,k-1)*a[i]%Mod+Smax)%Mod;
	// cout<<Smax<<" "<<Smin<<endl;
	Print(((Smax-Smin)%Mod+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 2560
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	ll n;cin>>n;
    ll base = 100;
    ll ans = 0;
    while(1){
        base += base*0.01;
        ++ans;
        if(base>=n){
            cout<<ans;
            break;
        }
    }
	return 0;
}

Measured memory_bytes: 3648
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val n = sc.nextInt()
        val d = Array(n) { sc.nextInt() }.sorted()

        println(d[n/2] - d[n/2-1])
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 38772
import java.util.Arrays;

public class Main {


  private static void solve() {
    int n = ni();
    int m = ni();
    
    int[][] p = ntable(n, 2);
    Arrays.sort(p, (o1, o2) -> o1[0] - o2[0]);
    
    long ret = 0;
    for (int[] q : p) {
      int x = Math.min(m, q[1]);
      ret += (long)x * q[0];
      m -= x;
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 45016
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

S = input()
Q = I()

d = collections.deque()
d.append(S)

rev = 0
for i in range(Q):
    line = input().split()

    if int(line[0]) == 1:
        rev += 1
    else:
        F = int(line[1])
        C = line[2]

        if F == 1:
            if rev % 2 == 1:
                d.append(C)
            else:
                d.appendleft(C)
        else:
            if rev % 2 == 1:
                d.appendleft(C)
            else:
                d.append(C)

ans = "".join(d)

if rev % 2 == 1:
    ans = ans[::-1]

print(ans)


Measured memory_bytes: 68956
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
typedef unsigned long long ull;
int n;
ull a[100000],x,bl;
ull umi(ull a,ull b){
	return (a<b)?a:b;
}
ull uma(ull a,ull b){
	return (a>b)?a:b;
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x^=a[i];
	}
	for(int i=0;i<n;i++)
		a[i]=a[i]&(~x);
	int rk=0,pos;
	for(int i=59;i>=0;i--){
		pos=-1;
		for(int j=rk;j<n;j++){if((a[j]>>i)&1){pos=j;break;}}
		if(pos==-1) continue;
		if(pos>rk) a[rk]^=a[pos];
		for(int j=rk+1;j<n;j++)
			a[j]=umi(a[j],a[j]^a[rk]);
		rk++;
	}
	for(int i=0;i<n;i++)
		bl=uma(bl,bl^a[i]);
	cout<<bl*2+x<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)


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

    repn (i,1,10){
        if(n % i == 0 && n/i < 10){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll mod=998244353;

const ll INF=1e9;

int main(){
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        bool ok=true;
        rep(j,i){
            if(s[n-i+j]!=t[j]) ok=false;
        }
        if(ok) ans=max(ans,i);
    }
    cout << 2*n-ans << endl;
    return 0;
}

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

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

const int maxn = 1e3 + 3;
const int mod = 1e9 + 7;

int mul() { return 1; }
template <typename T, typename... V>
T mul(T a, V... v) {
#if !defined(_WIN32) || defined(_WIN64)
	return (int) ((long long) a * mul(v...) % mod);
#endif
	unsigned long long x = (long long) a * mul(v...);
	unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
	asm(
		"divl %4; \n\t"
		: "=a" (d), "=d" (m)
		: "d" (xh), "a" (xl), "r" (mod)
	);
	return m;
}

int n, k;
int a[maxn];
int C[maxn][maxn];
int dp[21][maxn];

int main(int argc, char const *argv[])
{
#ifdef LOCAL
	freopen("in", "r", stdin);
#endif
	for(int i = 0; i < maxn; i++) {
		C[i][i] = C[i][0] = 1;
	}
	for(int i = 1; i < maxn; i++) {
		for(int j = 1; j < i; j++) {
			C[i][j] = C[i-1][j] + C[i-1][j-1];
			if(C[i][j] >= mod) C[i][j] -= mod;
		}
	}
	cin >> n >> k;
	for(int i = 1; i <= k; i++) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	for(int i = 1; i <= k; i++) {
		dp[i][0] = mul(dp[i-1][0], C[n][a[i]]);
		for(int j = 1; j <= n; j++) {
			for(int tek = 0; tek <= j and tek <= a[i]; tek++) {
				dp[i][j] += mul(dp[i-1][j-tek], C[j][tek], C[n-tek][a[i]-tek]);
				if(dp[i][j] >= mod) dp[i][j] -= mod;
			}
		}
	}
	cout << dp[k][n] << endl;
	return 0;
}

Measured memory_bytes: 4224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

map<ll,ll> pfmp; //各素因数の冪指数の総和を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void PF(ll N){
  ll n=N;
  if(n<=0) return;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    while(n%2==0){
      n/=2;
      pfmp[2]++;
    }
  }
  if(n==1) return;
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      while(n%i==0){
        n/=i;
        pfmp[i]++;
      }
    }
  }
  if(n!=1){
    if(pfmp[n]==0) pfv.push_back(n);
    pfmp[n]++;
  } 
  sort(all(pfv));
}

int main(){
  int N; cin >> N;
  for(int i=2;i<=N;i++){
    PF(i);
  }
  ll ans=1;
  for(auto c:pfmp){
    ans*=c.second+1;
    ans%=MOD;
  }
  cout << ans << endl;
}

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

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

    int n;
    cin >> n;
    vector<int> L(n);
    REP(i, n) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    REP(b, n) REP(a, b) {
        int ab = L[a] + L[b];
        // lower_bound は，そのベクトルの中で指定した値より大きい，
        // 一番小さい値のイテレーターを返してくれる．
        int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
        int l = b + 1;
        ans += r - l;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256