akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--)
	{
		int r=0,i;
		char a[100001];
		cin>>a;
		 i=0;
int  j=strlen(a)-1;
  while(i<j)
   {
   char temp=a[i];
   a[i]=a[j];
   a[j]=temp;
   i++;
   j--;
   }
		for(i=0;i<strlen(a);)
		{
			r=0;
			if(a[i]=='m'&&a[i+1]=='a'&&a[i+2]=='e'&&a[i+3]=='r'&&a[i+4]=='d')
			{i+=5;r=1;}
			if(a[i]=='e'&&a[i+1]=='s'&&a[i+2]=='a'&&a[i+3]=='r'&&a[i+4]=='e')
			{i+=5;r=1;}
			if(a[i]=='r'&&a[i+1]=='e'&&a[i+2]=='m'&&a[i+3]=='a'&&a[i+4]=='e'&&a[i+5]=='r'&&a[i+6]=='d')
			{i+=7;r=1;}
			if(a[i]=='r'&&a[i+1]=='e'&&a[i+2]=='s'&&a[i+3]=='a'&&a[i+4]=='r'&&a[i+5]=='e')
			{i+=6;r=1;}
			if(r==0)
			break;
		}
		cout<<(r!=0?"YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B;
    cin >> A >> B;
    
    int ans = -1;
    
    int  Amax = A/0.07;
    int  Bmin = B/0.10;
    
    for (int i=Bmin; i<Amax; i++ ) {
        int x = i * 0.08;
        int y = i * 0.10;
        
        if (x == A && y ==B) {
            ans = i;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
	n = int(input())
	costs = list(map(int, input().split()))
	
	if n==1: return 0
	# each cur represents minimum cost needed to reach the step
	two_before = 0
	one_before = abs(costs[1] - costs[0])
	for step in range(2, n):
		two_before, one_before = one_before, min(one_before + abs(costs[step] - costs[step-1]), two_before + abs(costs[step] - costs[step - 2]))
	return one_before


print(main())


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

using namespace std;
using ll = long long;

const int N = 2e5 + 5;

vector<int> g[N];
int cnt[N];

void dfs(int u, int par = -1) {
    for (int v : g[u]) {
        if (v == par) continue;
        cnt[v] += cnt[u];
        dfs(v, u);
    }
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    while (q--) {
        int r, x;
        cin >> r >> x;
        cnt[r] += x;
    } 
    dfs(1);
    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << ' ';
    }
}

Measured memory_bytes: 23552
#!/usr/bin/env python3

n, k = list(map(int, input().split()))
p = list(map(lambda x: int(x) - 1, input().split()))
c = list(map(int, input().split()))

best = max(c)
for i in range(n):
    curr = 0
    score = [0]
    start = i
    while p[start] != i:
        start = p[start]
        curr += c[start]
        score.append(curr)
    cycle_score = score[-1] + c[i]
    cycle_len = len(score)

    for j in range(cycle_len):
        if j <= k and j != 0:
            # if j <= k:
            cycles = (k-j)//cycle_len
            thing = score[j] + max(0, cycle_score) * cycles
            best = max(best, thing)
        elif j == 0 and k >= cycle_len:
            thing = cycle_score * k//cycle_len
            best = max(best, thing)
print(best)


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

int main() {
    ll l, r, d;
    cin >> l >> r >> d;

    ll ans = 0;

    for (int i = l; i<r+1; i++)  {
        if (i%d == 0 && i/d > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=10,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int n,m,ans,vis[N];
vector<int>e[N];
void dfs(int u,int s){
	if(s==n){
		ans++;return;
	} 
	vis[u]=1;
	for(int v:e[u]){
		if(!vis[v]) dfs(v,s+1);
	}
	vis[u]=0;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v),e[u].pb(v),e[v].pb(u);
	} 
	dfs(1,1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3740
#include<iostream>

using namespace std;

int main() {
    int n, a, b;
    cin >> n;
    int count = 0;
    while (n > 0) {
        cin >> a >> b;
        if (a == b) count += 1;
        else count = 0;

        if (count == 3) {
            cout << "Yes" << endl;
            break;
        }
        n--;
    }

    if (count < 3) cout << "No" << endl;

    return 0;
}


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

int main() {
  int N;
  cin>>N;
  int a;
  if(N>9){
    if(N>99){
      a=N%10;
    }
    else{
      a=N%10;
    }
  }
  else{
    a=N;
  }
  if(a==3){
    cout<<"bon"<<endl;
  }
  else{
    if(a==0||a==1||a==6||a==8){
      cout<<"pon"<<endl;
    }
    else{
      cout<<"hon"<<endl;
    }
  }
}

Measured memory_bytes: 3636
from bisect import bisect_left

N = int(input())

L = list(map(int, input().split()))
L.sort()

ans = 0


for i in range(N):
    for j in range(i + 1, N):
        c = L[i] + L[j]
        # a+bが入る場所を返す
        idx = bisect_left(L, c)
        ans += max(0, idx - (j + 1))

print(ans)


Measured memory_bytes: 9348
package main

import (
	"fmt"
)

func main() {
	var (
		k, s, count int
	)
	fmt.Scan(&k, &s)

	for i := 0; i <= k; i++ {
		for j := 0; j <= k; j++ {
			kk := s - i - j
			if 0 <= kk && kk <= k {
				count++
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long x;
  cin>>x;
  for(long long i=-200;i<=200;i++)
    for(long long j=-200;j<=200;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout<<i<<" "<<j;
        return 0;
      }
    }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll H, W;
    cin >> H >> W;
    vector<string> sss;

    copy_n(istream_iterator<string>(cin), H, back_inserter(sss));

    vector<pair<int, int>> dirs = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };

    for (auto w = 0; w < W; ++w) {
        for (auto h = 0; h < H; ++h) {
            if (sss[h][w] != '#')
                continue;
            bool ok = false;
            for (auto&& d : dirs) {
                auto x = w + d.first;
                auto y = h + d.second;
                if (0 <= x && x < W && 0 <= y && y < H) {
                    if (sss[y][x] == '#') {
                        ok = true;
                        break;
                    }
                }
            }
            if (!ok) {
                cout << "No\n";
                return;
            }
        }
    }
    cout << "Yes\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> cnt(N, 0);
  rep(i, N) {
    cin >> A[i];
    A[i]--;
    cnt[A[i]]++;
  }

  sort(all(cnt));
  cnt.erase(cnt.begin(), upper_bound(all(cnt), 0));

  int ans = 0;
  int M = cnt.size();
  rep(i, M - K) { ans += cnt[i]; }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>

int lcm(int a, int b) {
	if (a < b) return lcm(b, a);
	int tmp = a % b;
	if (tmp == 0) return b;
	else return lcm(b, tmp);
}

int main() {
	int N, M;
	char S[100001], T[100001];
	scanf("%d %d", &N, &M)+1;
	scanf("%s", S)+1;
	scanf("%s", T)+1;

	int retLcm = lcm(N, M);
	//int gcm = N * M / lcm(N, M);
	int waruN = N / retLcm;
	int waruM = M / retLcm;

	for (int i = 0; i < retLcm; i++) {
		if (S[waruN * i] != T[waruM * i]) {
			printf("-1");
			return 0;
		}
	}

	printf("%lld", ((long long)N * M) / retLcm);
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

void solve() {
    int r; cin >> r;
    cout << 2 * PI * r;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();

        int[] B = new int[M];
        for (int i = 0; i < M; i++) {
            B[i] = sc.nextInt();
        }

        int counter = 0;
        for (int i = 0; i < N; i++) {
            int judge = 0;
            for (int j = 0; j < M; j++) {
                judge += sc.nextInt() * B[j];
            }

            if (judge + C > 0)
                counter++;
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 23892
import sys
readline=sys.stdin.buffer.readline
K, N = map(int, readline().rstrip().split())
s= readline().rstrip().split()
max = 0
for i in range(N):
    if i == N-1:
        if max <  (int(s[0])+K) - int(s[i]):
            max = (int(s[0])+K) - int(s[i])
    else: 
        if max <  int(s[i+1])-int(s[i]):
            max = int(s[i+1])-int(s[i])

print(K-max)

Measured memory_bytes: 13884
#include <bits/stdc++.h>
const int maxn=1e5+5;
const int mod=1e9+7;
#define ll long long
using namespace std;
ll a[maxn],b[maxn];
ll aa[maxn],bb[maxn];
int main()
{
    int i,j,n,m;
    ll h=0,w=0;
    scanf("%d%d",&n,&m);
    for(i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    for(i=1; i<=m; i++)
    {
        scanf("%lld",&b[i]);
    }
//    for(i=1; i<=n; i++)
//    {
//        scanf("%d",&a[i]);
//        aa[i]=aa[i-1]+a[i];
//    }
//    for(i=1; i<=m; i++)
//    {
//        scanf("%d",&b[i]);
//        bb[i]=bb[i-1]+b[i];
//    }
//    for(i=1; i<n; i++)
//    {
//        h+=aa[n]-aa[i]-(a[i]%mod*(n-i)%mod)%mod;
//        if(h>=mod) h-=mod;
//    }
//    cout<<h<<endl;
//    for(i=1; i<m; i++)
//    {
//        w+=bb[m]-bb[i]-b[i]*(m-i);
//        if(w>=mod) w-=mod;
//    }
//    cout<<w<<endl;
    for(int l=1, r=n; l<r; ++l,--r)
        w = (w + (a[r]-a[l])*(r-l))%mod;
    for(int l=1, r=m; l<r; ++l,--r)
        h = (h + (b[r]-b[l])*(r-l))%mod;
    cout<<(w%mod*h%mod)%mod<<endl;
    return 0;
}
/*622259192
993828220*/


Measured memory_bytes: 1792
H, W = map(int,input().split())
HW = [input() for _ in range(H)]

ans = "Yes"
for i in range(H-1):
  for j in range(W-1):
    if(HW[i][j] == "."):
      continue
    if(i != 0 and HW[i-1][j] == "#"):
      continue
    if(j != 0 and HW[i][j-1] == "#"):
      continue
    if(j != H and HW[i+1][j] == "#"):
      continue
    if(j != W and HW[i][j+1] == "#"):
      continue
    ans = "No"
print(ans)

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


void solve(std::string b){

    if(b == "A") std::cout << "T" << endl;
    else if(b == "C") std::cout << "G" << endl;
    else if(b == "G") std::cout << "C" << endl;
    else if(b == "T") std::cout << "A" << endl;
}

int main(){
    std::string b;
    std::cin >> b;
    solve(b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	int a, b, c;
	//int count5 = 0, count7 = 0;
	map<int, int> M;
	cin >> a >> b >> c;
	M[a]++, M[b]++, M[c]++;
	if(M[5]==2 && M[7]==1){
		cout << "YES\n";
	}
	else{
		cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
int n;

int cnt(int i){
	if(i == 1)	return 1;
	if(i == 2)	return 2;
	if(i == 3)	return 4;

	return cnt( i-3 ) + cnt( i-2 ) + cnt( i-1 );
}


int main(void){
	while(1){
		std::cin >> n;
		if(n == 0)	return 0;
		std::cout << std::ceil(cnt(n) / 10.0 / 365.0) << std::endl;
	}
}

Measured memory_bytes: 1232
#include <iostream>
using namespace std;
int num[205];
int main(void)
{
    int n;
    cin>>n;
    for(auto i=0;i<n;i++)
        cin>>num[i];
    int ans=0;
    while(0==0)
    {
        auto i=0;
        for(i=0;i<n;i++)
            if(num[i]&1)
                goto en;
            else num[i]/=2;
        ans+=(i==n)?1:0;
    }
    en:
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    
//    int A, B;
//    int flag = 0; //flagの初期化を忘れた結果、flagに1が最初から入っていた場合失敗する?
//    
//    cin >> A >> B;
//    if(A % 3 == 0 ) flag = 1;
//    if(B % 3 == 0 ) flag = 1;
//    if((A+B)%3 == 0 )flag = 1;
//   
//    if(flag == 1) cout << "Possible" << endl;
//    else cout << "Impossible" << endl;
//    
//    return 0;
    int A, B;
    
    cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A+B)%3 == 0 )
        cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    var results = (1..205).map { it * 0 }.toMutableList()
    results[0] = 300000
    results[1] = 200000
    results[2] = 100000
    if (x==1 && y==1) println(results[x-1]+results[y-1]+400000)
    else println(results[x-1]+results[y-1])
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e5+5, mod = 1e9+7;

void solve() {
    int n, k; cin >> n >> k;

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

        if (i > k) {
            if (a[i] > a[i - k]) {
                cout << "Yes\n";
            } else {
                cout << "No\n";
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 4448
#include <iostream>

using namespace std;

int main(void){
    int N, M;
    int i, j;
    cin >> N >> M;
    int food[N][M+1];
    int count = 0;
    int check = 0;

    for(i = 0; i < N; i++){
        cin >> food[i][0];
        for(j = 1; j <= food[i][0]; j++)
            cin >> food[i][j];
    }
    for(int k = 1; k <= M; k++){
    for(i = 0; i < N; i++){
            for(j = 1; j <= food[i][0]; j++){
                if(food[i][j] == k)
                    count++;
                }
        }
        if(count == N)
            check++;
    count = 0;
    }

    cout << check << endl;

    return 0;
}

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

struct Point { int row, column; };
bool operator<(const Point p, const Point q) { return make_pair(p.row, p.column) < make_pair(q.row, q.column); }

using ll = long long;

int main()
{
    int R, C, N; cin >> R >> C >> N;

    auto rectangles = map<Point, int>();
    for (auto i = 0; i < N; i++)
    {
        int row, column; cin >> row >> column;
        row--; column--;

        for (auto r1 = row-2; r1 <= row; r1++) for (auto c1 = column-2; c1 <= column; c1++)
        {
            const auto r2 = r1+2, c2 = c1+2;
            if (r1 >= 0 && c1 >= 0 && r2 < R && c2 < C)
                rectangles[{r1, c1}]++;
        }
    }

    auto counts = array<ll, 10>{};
    for (const auto kv : rectangles)
        counts[kv.second]++;
    counts[0] = static_cast<ll>(R-2)*(C-2) - accumulate(begin(counts), end(counts), 0);

    for (const auto x : counts) cout << x << endl;
}




Measured memory_bytes: 56448
import java.io.*;
import java.util.*;

public class Main {
  private static char getLastChar(String s) {
    return s.charAt(s.length() - 1);
  }
  
  private static boolean solve(String[] abc) {
    return getLastChar(abc[0]) == abc[1].charAt(0) && getLastChar(abc[1]) == abc[2].charAt(0);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    String[] abc = reader.next(3);
    out.println(solve(abc) ? "YES" : "NO");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public 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();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

string S;
int Q;
int NUM[200005], F[200005];
char C[200005];

void solve() {
	deque<char> dq;
	rep (i, S.size()) dq.push_back(S[i]);
	bool nor = true;
	rep (i, Q) {
		if (NUM[i] == 1) nor = !nor;
		else {
			if (nor && F[i] == 1) dq.push_front(C[i]);
			else if(nor && F[i] == 2) {dq.push_back(C[i]);}
			else if (!nor && F[i] == 1) {dq.push_back(C[i]);}
			else {dq.push_front(C[i]);}
		}
	}
	string ans = "";
	rep (i, dq.size()) ans.pb(dq[i]);
	if (!nor) reverse(rng(ans));
	cout << ans << endl;
}

int main() {
	cin >> S;
	cin >> Q;
	rep (i, Q) {
		cin >> NUM[i];
		if (NUM[i] == 2) cin >> F[i] >> C[i];
	}
	solve();

	return 0;
}

Measured memory_bytes: 6000
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, S):
    ans = 0
    S = [list(map(int, [c for c in r])) for r in S]
    # for r in S:
    #     print(r)
    # wn = sum([sum(r) for r in S])
    # # print(wn)


    ans = INF
    for p in product([0, 1], repeat=H-1):
        spl = [i+1 for i, v in enumerate(p) if v == 1]
        cand = len(spl)
        spl.append(H)
        rs = []
        p = 0
        for si in spl:
            r = [0] * W
            for j in range(W):
                for k in range(p, si):
                    r[j] += S[k][j]
            rs.append(r)
            p = si
        # print(spl,'------')
        # for r in rs:
        #     print(r)

        sr = [0] * len(rs)
        impossible = False
        for i in range(W):
            if any([sr[j] + rs[j][i] > K for j in range(len(rs))]):
                cand += 1
                for j in range(len(rs)):
                    sr[j] = rs[j][i]
                    if sr[j] > K:
                        impossible = True
            else:
                for j in range(len(rs)):
                    sr[j] += rs[j][i]
        if not impossible:
            ans = min(ans, cand)



    return ans


def main():
    H, W, K = read_int_n()
    S = [read_str() for _ in range(H)]
    print(slv(H, W, K, S))


if __name__ == '__main__':
    main()


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  int cnt = 0;
  for (ll i = 0; i < m; i++) {
    ll in;
    cin >> in;
    cnt += in;
  }
  cout << (n >= cnt ? n - cnt : -1) << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

int main(){
  string S; cin>>S;
  int ans=1e9;
  rep(i,S.length()-2){
    string tmp="";
    tmp+=S[i];
    rep(j,2) tmp+=S[i+j+1];
    ans=min(ans,abs(753-stoi(tmp)));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  bool a = true;
  
  for(int i = 0; i < 3; i++){
    if(s.at(i)==s.at(i+1)){
      a = false;
      break;
    }
    else{
      continue;
    }
  }
    
    if(a){
      cout << "Good" << endl;
    }
    else{
      cout << "Bad" <<endl;
    }

}

Measured memory_bytes: 256
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var A = NextInt();
		var B = NextInt();
		var ans = 0;

		for (var i = A; i <= B; i++) {
			if (Judge(i)) {
				ans++;
			}
		}
		WriteLine(ans);
	}

	static bool Judge(int m) {
		var s = m.ToString();
		var n = s.Length;
		for (var i = 0; i < n / 2; i++) {
			if (s[i] != s[n - i - 1]) {
				return false;
			}
		}
		return true;
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

Measured memory_bytes: 15316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 500;
int range[MAX_N + 2][MAX_N + 2];

int main()
{
	memset(range, 0, sizeof(range));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M, Q; cin >> N >> M >> Q;
	rep (i, M){
		int L, R; cin >> L >> R;
		++range[L][R];
	} // end rep

	for (int i = 1; i <= 501; ++i){
		for (int j = 1; j <= 501; ++j){
			range[i][j] += range[i][j-1];
		} // end for
	} // end for

	for (int i = 1; i <= 501; ++i){
		for (int j = 1; j <= 501; ++j){
			range[i][j] += range[i-1][j];
		} // end for
	} // end for

	rep (i, Q){
		int p, q; cin >> p >> q;
		int res = range[q][q] - range[p-1][q] - range[q][p-1] + range[p-1][p-1];
		cout << res << endl;
	} // end rep
	
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)



//--------------入力受け取る場所----------------------------------------------------
intl n,m;
intl a,b,c,d;
string s,t;

void input_var(){
    cin >> a >> b >> c;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    fp(a <= b * c);
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <climits>

using namespace std;

int main()
{
	char mozi[] = { 'K', 'U', 'C', 'P' };
	char input;
	int cnt[26];
	while(1)
	{
		for(int i=0; i < 26; i++) cnt[i] = 0;
		bool eof = true;
		while(~scanf("%c", &input)) {
			if(input == '\n'){
				eof = false;
				break;
			}
			if(input <= 'Z') {
				cnt[input - 'A']++;
			}
		}
		if(eof) break;
		int m = INT_MAX;
		for(int i=0; i < 4; i++) {
			m = min(m, cnt[(mozi[i]-'A')]);
		}
		cout << m << endl;
	}
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int n, r;
    int min = INT_MAX, ans = INT_MIN;

    cin >> n;
    for (int t = 0; t < n; t++) {
        cin >> r;
        if (r-min > ans) ans = r-min;
        if (r < min) min = r;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
// #include <set>
// #include <cmath>
// #include <string>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    int max_score = accumulate(s.begin(), s.end(), 0);
    if (max_score % 10 != 0) {
        cout << max_score << endl;
        return 0;
    }

    sort(s.begin(), s.end());
    int eliminated = -1;
    for (int item : s) {
        if (item % 10 != 0) {
            eliminated = item;
            break;
        }
    }

    if (eliminated == -1) {
        cout << 0 << endl;
    } else {
        cout << max_score - eliminated << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2000)
def joken(a,n):
  if n==1:
    return 0
  elif a%n==0 and a//n>=n:
    return joken(a//n,n)
  elif a%n==1:
    return 1
  elif a%n==0 and a//n==1:
    return 1
  else:
    return 0
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N=int(input())
c=len(make_divisors(N-1))
d=make_divisors(N)
a=0
for i in range(len(d)):
  a+=joken(N,d[i])
print(a+c-1)

Measured memory_bytes: 9468
#include<stdio.h>
 
int main(void){
    int i,j;
    char w[20],t[2000];
    char end[20] = "END_OF_TEXT";
 
    scanf("%s",w);
 
    j = 0;
    while(1){
        scanf("%s",t);
        for(i = 0;i < 12;i++)
            if(t[i] != end[i])
                break;
        if(i == 12)
            break;
 
        i = -1;
        while(t[++i] !='\0')
            if(t[i] >= 'A' && t[i] <= 'Z')
                t[i] += 0x20;
 
        i = 0;
        while(1){
            if(t[i] != w[i])
                break;
            if(t[i] == '\0'){j++;break;}
            i++;
        }
    }
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
struct xyz{string x;int y;int z;};
bool cmp1(xyz a,xyz b){return a.x<b.x;}

void solve(){
     int n,m;cin >> n >> m;
     vector< vector<int> >a(m);
     for(int i = 0;i<m;i++){
        int k;cin >> k;
        for(int j = 0;j<k;j++){
            int temp;cin >> temp;
            a[i].push_back(temp);
        }
     }
     vector<int>p(m);
     for(int i = 0;i<m;i++) cin >> p[i];
     int ans = 0;
     for(int i = 0;i<(1<<n);i++){
        int ii = i;
        vector<bool>b(n+1,0);
        int cnt = 1;
        while(ii){
            if(ii%2==1) b[cnt] = 1;
            cnt++;
            ii /= 2;
        }
        bool ok = 1;
        for(int j = 0;j<m;j++){
            int cur = 0;
            for(int k = 0;k<a[j].size();k++){
                if(b[a[j][k]]==1) cur++;
            }
            if(cur%2!=p[j]) ok = 0;
        }
        if(ok) ans++;
     }
     cout << ans;
}

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int A,B,C,D;
  cin>>A>>B>>C;
  D=A+B+1;
  if(D>C){
  cout<<B+C<<endl;
  }else{
  cout<<A+B+B+1<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

u_int getDigit(u_int n){
	u_int digit = 0;
	
	while(n > 0){
		n /= 10;
		++digit;
	}
	
	return digit;
}
  
int main(){
    u_int a, b;
    
    while(std::cin >> a >> b){
        std::cout << getDigit(a + b) << std::endl;
    }
	
    return 0;
}

Measured memory_bytes: 3008
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
q=[0]*M
v=[[]for _ in q]
z=0
for a,b in t:
	if a<=M:v[a-1]+=[b]
for i in v:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)

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

int main()
{
  long long a[100];
  a[0]=2;
  a[1]=1;

  for(int i = 2;i<=87;i++)
    a[i] = a[i-1]+a[i-2];

  long long n;
  cin>>n;
  cout<<a[n]<<endl;

  //main();


}





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

int main(){
  ll N,A,B,count=0;
  cin>>N>>A>>B;
  count+=N/(A+B)*A;
  if(N%(A+B)<=A){
    count+=N%(A+B);
  }
  else{
    count+=A;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3636
a = int(input())
b = int(input())
c = int(input())
X = int(input())
count = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            sum = i * 500 + j * 100 + k * 50
            if sum == X:
                count += 1

print(count)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
ans = 0
for i in S:
	if i == "+":
		ans += 1
	else:
		ans -= 1
print(ans)

Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10 , OO = 0x3f3f3f3f;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


int r;



int main()
{   

      ios_base::sync_with_stdio(0);
      cin.tie(0);cout.tie(0);

      cin >> r;
      cout << 3*(r*r) << "\n";




      return 0;
}

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

void solve() {
	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<int>> dp(n, vector<int>(3, 0));
	vector<bool> vec(n, false);
	dp[0] = {a[0], b[0], c[0]};
	int mark = -1;
	for (int i = 1; i < n; ++i) {
		dp[i] = {a[i], b[i], c[i]};
		for (int j = 0; j < 3; ++j) {
			int mx = -1;
			for (int k = 0; k < 3; ++k) {
				if (j == k) continue;
				mx = max(mx, dp[i - 1][k]);
			}
			dp[i][j] += mx;
		}
	}
	cout << *max_element(dp[n - 1].begin(), dp[n - 1].end());
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    map <int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ++cnt[a[i]];
    }
    ll ans = 0;
    for (auto &i : cnt) {
        ans += (ll)i.y * (i.y - 1ll) / 2ll;
    }
    for (int i = 0; i < n; i++) {
        ans -= (ll)cnt[a[i]] * (cnt[a[i]] - 1ll) / 2ll;
        ans += (ll)(cnt[a[i]] - 1ll) * (cnt[a[i]] - 2ll) / 2ll;
        cout << ans << '\n';
        ans += (ll)cnt[a[i]] * (cnt[a[i]] - 1ll) / 2ll;
        ans -= (ll)(cnt[a[i]] - 1ll) * (cnt[a[i]] - 2ll) / 2ll;
    }
}


Measured memory_bytes: 10000
#include<iostream>
#include<vector>
using namespace std;
long long f(long long a,long long b){
  long long tmp  = 1;
  for(int i=0;i<b;i++){
    tmp*=a;
  }
  return tmp;
}
int main(){
  int n,num,p,ev=0,odd=0;
  cin >> n >> p;
  for(int i=0;i<n;i++){
    cin >> num;
    if(num%2==0) ev++;
    else odd++;
  }
  if(odd==0){
    if(p==1) cout << 0 << endl;
    else cout << f(2,n)<<endl;
  }else{
    cout << f(2,n-1)<<endl;
  }
}


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

#define FOR(i,a,b) for(int i = (a);i < (int) (b);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
using namespace std;

int N;
vector<int> L;

int main()
{
	scanf("%d",&N);
	L.assign(N * 2,0);
	FOR(i,0,N * 2){
		scanf("%d",&L [i]);
	}
	sort(ALL(L));

	int ans = 0;
	for(int i = 0;i < N * 2;i += 2){
		ans += min(L [i],L [i + 1]);
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 764
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk

# slist = "abcdefghijklmnopqrstuvwxyz"
MOD = 10**9 + 7
K = int(input())
S = input()

if len(S)<= K:
    print(S)
else:
    print(S[:K]+"...")

# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  map<string, vector<pair<int, int>>> sp;
  REP(i, N) {
    string s; int p;
    cin >> s >> p;
    sp[s].push_back(make_pair(p, i));
  }

  for (auto v : sp) {
    sort(ALL(v.second), greater<pair<int, int>>());

    for (auto i : v.second) {
      cout << i.second+1 << endl;
    }
  }
}

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

int main(){
	ios::sync_with_stdio(false);

	int A,B,K; cin>>A>>B>>K;
	for(int i=A; i<=min(A+K-1, B); i++){
		cout << i << endl;
	}

	for(int i=max(B-K+1, A+K); i<=B; i++){
		cout << i << endl;
	}
}


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    int n, k, q;
    int[] as;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        k = sc.nextInt();
        q = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        int[] bs = as.clone();
        Arrays.sort(bs);
        int prevMin = -1;
        int diff = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int minNum = bs[i];
            if (prevMin == minNum) {
                prevMin = minNum;
                continue;
            }
            prevMin = minNum;
            int l = 0;
            List<Integer> candidates = new ArrayList<>();
            PriorityQueue<Integer> pQueue = new PriorityQueue<>();
            for (int j = 0; j <= n; j++) {
                if (j == n || as[j] < minNum) {
                    if (j - l >= k) {
                        PriorityQueue<Integer> tempQueue = new PriorityQueue<>();
                        for (int m = l; m < j; m++) {
                            tempQueue.offer(as[m]);
                        }
                        for (int m = 0; m < j - l - k + 1; m++) {
                            candidates.add(tempQueue.poll());
                        }
                    }
                    l = j + 1;
                }
            }
            if (candidates.size() < q) {
                continue;
            }
            Collections.sort(candidates);
            int tempDiff = candidates.get(q - 1) - candidates.get(0);
            if (tempDiff < diff) {
                diff = tempDiff;
            }
        }
        System.out.println(diff);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 60944
def hantei(num)
  num >= 1 && num <= 12
end

S = STDIN.gets.chomp

# 正規表現で前からx文字を切り出す
# 正規表現より前のもの, ()でくくった正規表現, 残ったものに分割
f, b = S.split(/\A(.{1,2})/, 2)[1..-1].map(&:to_i)

if !hantei(f) && hantei(b) then
  puts "YYMM"
elsif hantei(f) && !hantei(b)
  puts "MMYY"
elsif hantei(f) && hantei(b)
  puts "AMBIGUOUS"
else
  puts "NA"                                                             
end

Measured memory_bytes: 1788
// time-limit: 2000
#include <bits/stdc++.h>
using namespace std;

string s,t;
int sLen, tLen, ans = 1e9;
int compare(int x) {
    int res = 0;
    for (int i = 0; i < tLen; ++i) {
        res += (t[i] != s[i+x]);
    }
    return res;
}

void solve() {
    cin >> s >> t;
    sLen = s.length(); tLen = t.length();
    for (int i = 0; i <= sLen-tLen; ++i) {
        int diff = compare(i);
        ans = min(ans, diff);
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
const int limit = 200000;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    vector<int> o_v;
    vector<int> e_v;

    for(int i=1;i<=n;i++){
        int a;cin >> a;
        if(i%2==0) e_v.push_back(a);
        else o_v.push_back(a);
    }
    if(n==1){
        cout << o_v[0] << endl;
    } else if(n%2==0){
        for(int i=e_v.size()-1;i>=0;i--){
            cout << e_v[i] << " " ;
        }
        for(int i=0;i<o_v.size()-1;i++){
            cout << o_v[i] << " " ;
        }
        cout << o_v[o_v.size()-1] << endl;
    } else {
        for(int i=o_v.size()-1;i>=0;i--){
            cout << o_v[i] << " " ;
        }
        for(int i=0;i<e_v.size()-1;i++){
            cout << e_v[i] << " " ;
        }
        cout << e_v[e_v.size()-1] << endl;
    }
}

Measured memory_bytes: 3188