akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    std::vector<int> dum(200);
    dum[0]=1;
    rrep(i,1,200){
        dum[i]=(i+1)+dum[i-1];
    }
    std::vector<int> p(200);p[0]=1;
    std::vector<int> pp;
    rrep(i,1,200){
        p[i]=p[i-1]+dum[i];
    }
    //erep(i,p)std::cout << i << std::endl;
    erep(i,p){
        if(i%2==1)pp.pb(i);
    }
    int m=p.size(),mm=pp.size();
    std::vector<int> dp(1000001,INF),ddp(1000001,INF);
    dp[0]=0;
    ddp[0]=0;
    rep(i,1000001){
        erep(j,p){
          //  if(i==0)std::cout << j << std::endl;
            if(i+j<=1000000)chmin(dp[i+j],dp[i]+1);
            else break;
        }
        erep(j,pp){
            if(i+j<=1000000)chmin(ddp[i+j],ddp[i]+1);
            else break;
        }
    }
    for(;;){
        int nn;
        std::cin >> nn;
        if(nn==0)exit(0);
        else ppri(dp[nn],ddp[nn]);
    }
}


Measured memory_bytes: 10932
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

long long int GCD(long long int a, long long int b) {
    if(a<b) {
        long long int tmp=a;
        a=b;
        b=tmp;
    }
    
    if(b==0) {
        return a;
    }


    return GCD(b, a%b);
}

int main() {
    int N;
    cin >> N;
    
    priority_queue<long long int, vector<long long int>, greater<long long int> > T;
    for(int n=0; n<N; n++) {
        long long int t;
        cin >> t;
        T.push(t);
    }

    while(T.size()>=2) {
        // cout << T.size() << endl;
        // cout << "calc tmp1" << endl;
        long long int tmp1=T.top(); T.pop();
        // cout << "tmp1 = " << tmp1 << endl;
        // cout << "calc tmp2" << endl;
        long long int tmp2=T.top(); T.pop();
        // cout << "tmp2 = " << tmp2 << endl;
        // cout << "calc tmp3" << endl;
        long long int tmp3 = tmp1/GCD(tmp2, tmp1)*tmp2;
        // cout << "tmp3 = " << tmp3 << endl;
        // cout << "push tmp3" << endl;
        T.push(tmp3);
    }
    
    cout << T.top() << endl;

    return 0;
    
}

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

#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL),cout.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
#define    endl                     "\n"

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int n,k,c,x=0;
    cin>>n>>k>>c;
    c++;
    string s;
    cin>>s;
    vector<int>a,b;
    for(int i=0;i<n;)
    {
        if(x>=k)
            break;
        if(s[i]=='x')
            i++;
        else
        {
            a.pb(i);
            x++;
            i+=c;
        }
    }
    x=0;
    for(int i=n-1;i>=0;)
    {
        if(x>=k)
            break;
        if(s[i]=='x')
            i--;
        else
        {
            b.pb(i);
            x++;
            i-=c;
        }
    }
    x=0;
    vector<int>ans;
    for(int i=0;i<k;i++)
        if(a[i]==b[k-1-i])
        {
             x++;
            ans.pb(a[i]);
        }
    f(i,0,x-1)
        cout<<ans[i]+1<<endl;
}

Measured memory_bytes: 9716
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vi B(M);
	vector<vi> A(N);
	rep(m, M)
		cin >> B[m];
	rep(i, N) {
		A[i].resize(M);
		rep(m, M)
			cin >> A[i][m];
	}
	int ans = 0;
	rep(i, N) {
		int sum = C;
		rep(m, M)
			sum += A[i][m] * B[m];
		if (sum > 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	int n,k;
	string s;
	cin >> n>>k>>s;

	if(s[k-1] == 'A')s[k-1] ='a'; 
	if(s[k-1] == 'B')s[k-1] ='b';
	if(s[k-1] == 'C')s[k-1] ='c';

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

H,W,K = map(int,input().split())
c = int_mtx(H)
ans = 0

for ih in range(2**H):

    for iw in range(2**W):

        ca = c.copy()

        for jh in range(0,H):

            for jw in range(0,W):

                if ((ih >> jh) & 1):
                    ca[jh,:] = 0
                if ((iw >> jw) & 1):
                    ca[:,jw] = 0

        if np.count_nonzero(ca == "#") == K:
            ans += 1

print(ans)

Measured memory_bytes: 27008
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n; cin >> n;
	string s; cin >> s;
	rep (i, s.size()) {
		rep (j, n) {
			if (s[i] == 'Z') s[i] = 'A';
			else s[i]++;
		}
	}
	cout << s << endl;
	return;
}

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

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	A := sc.NextIntArray()
	count := make([]int, N / 2 + 1)
	for i := 0; i < N; i++ {
		if A[i] % 2 == N % 2 {
			fmt.Println(0)
			return
		}
		count[A[i] / 2]++
		if count[A[i] / 2] > 2 {
			fmt.Println(0)
			return
		}
	}
	if N % 2 == 1 {
		if count[0] != 1 {
			fmt.Println(0)
			return
		}
	}
	ans := pow(2, N / 2, (1e9 + 7))

	fmt.Println(ans)
}

//aのb乗をします O(log b)
func pow(a int, b int, mod int) int {
	total := 1
	tmp := a
	for b > 0 {
		if b % 2 == 1 {
			total *= tmp
			total %= mod
		}
		b /= 2
		tmp *= tmp
		tmp %= mod
	}
	return total
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6272
using System;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            long x = int.Parse(Console.ReadLine());
            int u = 0;

            while (x>=500)
            {
                x -= 500;
                u += 1000;
            }
            while (x >= 5)
            {
                x -= 5;
                u += 5;
            }
            Console.WriteLine(u);
        }
    }
}



Measured memory_bytes: 27212
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <cassert>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int root(int x);
void unite(int x,int y);
int same(int x,int y);

ll num;
vector<ll> x,y,xx,zzz;
vector<vector<ll>> b,c;
vector<int> par;

struct p_t{
  ll s,t;
};
bool asc(p_t left,p_t right){
  return left.s==right.s?left.t<right.t:left.s<right.s;
}

void dfs(ll k){
  assert(0 <= k && k < (int)zzz.size());
  zzz[k]=1;
  assert(0 <= k && k < (int)b.size());
  for(int i=0;i<(ll)b[k].size();i++){
    assert(0 <= b[k][i] && b[k][i] < x.size());
    assert(0 <= b[k][i] && b[k][i] < (int)zzz.size());
    if(x[b[k][i]]==-1&&zzz[b[k][i]]==0){
      dfs(b[k][i]);
    }
  }
  assert(0 <= k && k < (int)x.size());
  assert(0 <= num && num < (int)y.size());
  x[k]=num;
  y[num]=k;
  num++;
  return;
}

void dfs2(ll k){
  zzz[k]=1;
  for(int i=0;i<(ll)c[k].size();i++){
    if(xx[c[k][i]]==-1&&zzz[c[k][i]]==0){
      unite(k,c[k][i]);
      dfs2(c[k][i]);
    }
  }
  xx[k]=num;
  num++;
  return;
}

int main(){
  ll v,e,q,u,vv;
  cin>>v>>e;
  vector<p_t> a;
  p_t aa;
  for(int i=0;i<e;i++){
    cin>>aa.s>>aa.t;
    a.push_back(aa);
  }
  sort(a.begin(),a.end(),asc);
  b.assign(v,vector<ll>(0,0));
  c.assign(v,vector<ll>(0,0));
  x.assign(v,-1);
  y.assign(v,-1);
  for(ll i=0;i<e;i++){
    b[a[i].s].push_back(a[i].t);
    c[a[i].t].push_back(a[i].s);
  }
  ll ii=0;
  num=0;
  while(num<v){
    for(;ii<v;ii++){
      if(x[ii]==-1){
        zzz.assign(v,0);
        dfs(ii);
        break;
      }
    }
  }
  par.assign(v,0);
  for(ll i=0;i<v;i++){
    par[i]=i;
  }
  xx.assign(v,-1);
  ii=v-1;
  num=0;
  while(num<v){
    for(;ii>=0;ii--){
      if(xx[y[ii]]==-1){
        zzz.assign(v,0);
        dfs2(y[ii]);
        break;
      }
    }
  }
  cin>>q;
  for(ll i=0;i<q;i++){
    cin>>u>>vv;
    if(same(u,vv)){
      cout<<"1"<<endl;
    }else{
      cout<<"0"<<endl;
    }
  }
  // for(ll i=0;i<v;i++){
  //   for(ll j=0;j<v;j++){
  //     if(same(i,j)){
  //       cout<<"1"<<endl;
  //     }else{
  //       cout<<"0"<<endl;
  //     }
  //   }
  // }
}

int root(int x){
  if (par[x] == x){// 根
    return x;
  }
  else {
    return par[x] = root(par[x]); // 経路圧縮
  }
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if (x == y){}
  else{
    par[x] = y;     //xの親をyの親にする
  }
}

int same(int x, int y){
  return root(x) == root(y);
}



Measured memory_bytes: 4992
N = int(input())

if N == 2:
    print(4, 7)
    print(23, 10)
    exit()

a= [[0] * N for _ in range(N)]

def sieve(n):
    '''
    :param n:
    :return: n以下の素数のリストを返す
    エラトステネスの篩→O(n log log n)
    '''
    prime = []
    is_prime = [True] * (n + 1) #is_prime[i] = Trueならiは素数
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2 * i, n + 1, i):
                is_prime[j] = False
    return prime

P = sieve(8000) #len(P) > 1000

def p1(k):
    return P[(k // 2) + 1]

def p2(k):
    if k >= 0:
        return P[(k // 2) + N + 1]
    else:
        return P[k // 2]

for i in range(N):
    for j in range(N):
        if (i + j) % 2 == 0:
            a[i][j] = p1(i + j) * p2(i - j)
        else:
            a[i][j] = p1(i + j + 1) * p1(i + j - 1) * p2(i - j + 1) * p2(i - j - 1) + 1

for i in range(N):
    print(' '.join(map(str, a[i])))

Measured memory_bytes: 16880
use std::io;


/// https://beta.atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_qualc_b
fn main() {
    let n = read_one::<u32>();
    let an = read::<usize>();
    let mut odd = 1;
    for a in an {
        if a % 2 == 0 { odd *= 2; }
    }
    println!("{}", 3u32.pow(n) - odd);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll maxSubArraySum(int a[], int size)
{
         ll max_so_far = 0, max_ending_here = 0;
   for (int i = 0; i < size; i++)
   {
       max_ending_here = max_ending_here + a[i];
       if (max_ending_here < 0)
           max_ending_here = 0;

       /* Do not compare for all elements. Compare only
          when  max_ending_here > 0 */
       else if (max_so_far < max_ending_here)
           max_so_far = max_ending_here;
   }
                return max_so_far;
}
int main()
{
	int h,a;
	cin>>h>>a;
	cout<<ceil((double)h/a);

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = INT_MAX;
const ll linf = 3e18;
const double eps = 1e-9;

struct RMQ { // segtree
    int n;
    vi seg;

    void init(int n_)
    {
        n = 1;
        while (n < n_) n *= 2;
        seg.resize(2 * n - 1);
        for (int i = 0; i < 2 * n - 1; ++i) {
            seg[i] = inf;
        }
    }

    void update(int k, int a)
    {
        k += n - 1;
        seg[k] = a;

        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
        }
    }

    int query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return seg[k];
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }

    int query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
} rmq;

signed main()
{
    int N, Q; cin >> N >> Q;

    rmq.init(N);

    rep(i, Q) {
        int c, x, y; cin >> c >> x >> y;

        if (c == 0) {
            rmq.update(x, y);
        } else {
            int v = rmq.query(x, y + 1);
            cout << v << endl;
        }
    }
}

Measured memory_bytes: 2060
#include<iostream>
#include<algorithm>
using namespace std;
 
#define INF 100000000
bool p[26][26];
int d[26];
int n;
string s[510];
 
int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)cin >> s[i];
 
    for(int i=0;i<26;i++)
      for(int j=0;j<26;j++)p[i][j] = false;
 
    bool f = true;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	int lim = min(s[i].size(),s[j].size());
	int k;
	for(k=0;k<lim;k++){
	  if(s[i][k] != s[j][k]){
	    p[s[i][k]-'a'][s[j][k]-'a'] = true;
	    break;
	  }
	}
	if(k==lim && s[i].size()>s[j].size()){
	  f = false;
	  break;
	}
      }
    }
 
    for(int k=0;k<26;k++){
      for(int i=0;i<26;i++){
	for(int j=0;j<26;j++){
	  if(p[i][k] && p[k][j])p[i][j] = true;
	}
      }
    }
  
    for(int i=0;i<26;i++)if(p[i][i])f = false;
 
    if(!f)cout << "no\n";
    else cout << "yes\n";
  }
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int X,A,B;
	scanf("%d%d" , &A, &B);

	if (A + B >= 10) {
		printf("error");
	}
	else {
		printf("%d", A + B);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

template <class T>
struct SegmentTree{
	std::vector<T> v;
	T def;
	int n;
	template<class I>
	SegmentTree(I first, I last, T default_value){
		n = 1;
		def = default_value;
		while(n < last-first) n <<= 1;
		v.assign(2*n-1, default_value);
		copy(first, last, v.begin()+n-1);
		for(int i=n-2; i>=0; i--)
			v[i] = merge(v[2*i+1], v[2*i+2]);
	}
	SegmentTree(std::vector<T> initial_data, T default_value):
	SegmentTree(initial_data.begin(), initial_data.end(), default_value){}
	void update(int idx, T val){
		idx += n-1;
		v[idx] = val;
		while(idx > 0){
			idx = (idx-1)/2;
			v[idx] = merge(v[2*idx+1], v[2*idx+2]);
		}
	}
	T q(int a, int b, int k, int l, int r){
		if(a<=l&&r<=b) return v[k];
		if(b<=l||r<=a) return def;
		return merge(q(a, b, 2*k+1, l, (l+r)/2), q(a, b, 2*k+2, (l+r)/2, r));
	}
	T query(int a, int b){
		return q(a, b, 0, 0, n);
	}
	T merge(T left, T right);
};

typedef pair<int, int> pii;
template <>
pii SegmentTree<pii>::merge(pii a, pii b){
	return {min(a.first, b.first), max(a.second, b.second)};
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> P(N);
	for(int i=0; i<N; i++) cin >> P[i];

	vector<pii> pp(N);
	for(int i=0; i<N; i++) pp[i] = {P[i], P[i]};
	SegmentTree<pii> st(pp, {1e9, -1});

	vector<int> sorted(N-K+1);
	for(int i=0; i<K-1; i++){
		sorted[0] += P[i]<P[i+1]?1:0;
	}
	for(int i=1; i<=N-K; i++){
		sorted[i] += sorted[i-1] - (P[i-1]<P[i]?1:0) + (P[i+K-2]<P[i+K-1]?1:0);
	}

	if(N==K){
		cout << 1 << endl;
		return 0;
	}

	int ans = 0;
	int n_unchanged = 0;
	for(int i=0; i<=N-K; i++){
		if(sorted[i]==K-1){
			n_unchanged += 1;
		} else if(i==N-K){
			ans++;
		} else {
			pii p = st.query(i, i+K+1);
			debug(i, sorted[i], P[i], p.first, P[i+K], p.second);
			if(p.first != P[i] || p.second != P[i+K]){
				ans++;
			}
		}
	}
	debug(ans, n_unchanged);
	cout << ans + (n_unchanged>0?1:0)<< endl;
	return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<deque>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#include<vector>
#include<ios>
#include<sstream>
#include<locale>
using namespace std;
#define ive(cris) int long long 
#define in(out) long double
#define INF 100000007
int main(){
  string a,b;;
  cin>>a>>b;
  if(a==b){
    cout<<"H"<<'\n';
  }
  else{
    cout<<"D"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())
list = []

max = 0
if A > B:
    max = A
else:
    max = B

for i in range(1, max + 1):
    if A % i == 0 and B % i == 0:
        list.insert(0, i)

print(list[K - 1])

Measured memory_bytes: 3060
def larger(x, y):
	if x > y:
		return x
	return y

N = int(input())
T, A = map(int, input().split())
for i in range(1, N):
	newT, newA = map(int, input().split())
	multiT = T // newT
	if T % newT != 0:
		multiT += 1
	multiA = A // newA
	if A % newA != 0:
		multiA += 1
	T = newT * larger(multiT, multiA)
	A = newA * larger(multiT, multiA)
print(T+A)

Measured memory_bytes: 38896
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC130
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__




void solve(void){
  
  int X, A;
    
  cin >> X >> A;
  
  puts(X>=A?"10":"0");
  
  return;
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 256
#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 k, s;
    cin >> k >> s;

    int ans = 0;
    if(s<k){
        for(int i = 0; i <= s; i++){
            ans += s+1-i;
        }
    }else if(s<k*2){
        for(int i = 0; i < s-k; i++){
            ans += 2*k - s + i + 1;
        }
        for(int i = s-k; i <= k; i++){
            ans += s - i + 1;
        }
    }else if(s<k*3){
        for(int i = s-2*k; i <= k; i++){
            ans += 3*k-s-i;
        }
    }else{
        ans = 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  if (n%10 == 7 || (n/10)%10 == 7 || n/100 == 7)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 1624
#include <stdio.h>

int main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (y<r || x<r || y+r>H || x+r>W) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
}


Measured memory_bytes: 2616
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

a,b,c=MI()
if a<=c<=b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    l = len(s)
    h = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}
    if l % 2 == 1:
        return 'No'
    for i in range(l//2):
        if s[i] != h[s[l-i-1]]:
            return 'No'

    return 'Yes'




print(main())



Measured memory_bytes: 5592
import scala.io.StdIn.{readInt, readLine}

object Main {
  def main(args:Array[String]) = {
    val n = readInt
    val adj = Array.ofDim[Int](n,n)
    for(i<-0 until n) {
      val l = readLine.split(" ").map(_.toInt)
      val u = l(0);val k = l(1)
      for(j<-0 until k) {
        val v = l(j+2)
        adj(u-1)(v-1) = 1
      }
    }
    adj.foreach{ e=>println(e.mkString(" ")) }
  }
}

Measured memory_bytes: 45940
use proconio::{input, marker::Usize1};

fn chmax(a: &mut Option<i32>, b: i32) {
    *a = Some(if let Some(v) = *a {
        v.max(b)
    } else {
        b
    });
}

fn rotate(x: &mut usize, y: &mut usize, z: &mut usize) {
    let w = *x;
    *x = *y;
    *y = *z;
    *z = w;
}

struct DP {
    l12: Vec<Vec<Option<i32>>>,
    l1_max: Vec<Option<i32>>,
    max: Option<i32>,
    n: usize,
}

impl DP {
    fn new(n: usize) -> DP {
        DP {
            l12: vec![vec![None; n + 1]; n + 1],
            l1_max: vec![None; n],
            max: None,
            n: n,
        }
    }
    fn set(&mut self, l1: usize, l2: usize, v: i32) {
        if l2 != self.n {
            chmax(&mut self.l12[l1][l2], v);
            chmax(&mut self.l12[l2][l1], v);
            chmax(&mut self.l1_max[l2], v);
        }
        chmax(&mut self.l1_max[l1], v);
        chmax(&mut self.max, v);
    }
}

fn main() {
    input! {
        n: usize,
        a: [Usize1; n * 3],
    }

    let mut dp = DP::new(n);
    dp.set(a[0], a[1], 0);
    let mut c = 0; // counter, number of cuts 3 to 5 from the left.
    for i in 1..n {
        let (mut x, mut y, mut z) = (a[i * 3 - 1], a[i * 3], a[i * 3 + 1]);
        if x == y && x == z {
            c += 1;
        } else {
            let m = dp.max.unwrap();
            let mut q = vec![];
            for _ in 0..3 {
                for l in 0..n {
                    if let Some(m) = dp.l1_max[l] {
                        let v = if y == z {
                            if let Some(l12) = dp.l12[l][y] {
                                m.max(l12 + 1)
                            } else {
                                m
                            }
                        } else {
                            m
                        };
                        q.push((l, x, v));
                    }
                }
                let v = if y == z {
                    if let Some(l1_max) = dp.l1_max[y] {
                        m.max(l1_max + 1)
                    } else {
                        m
                    }
                } else {
                    m
                };
                q.push((x, n, v));

                let v = if let Some(l12) = dp.l12[z][z] {
                    m.max(l12 + 1)
                } else {
                    m
                };
                q.push((x, y, v));

                rotate(&mut x, &mut y, &mut z);
            }

            for (x, y, v) in q {
                dp.set(x, y, v);
            }
        }
    }

    let mut v = dp.max.unwrap();
    let l = a[3 * n - 1];
    if let Some(l12) = dp.l12[l][l] {
        v = v.max(l12 + 1);
    }
    println!("{}", v + c);
}


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

int main(){
    int A, B;
    cin >> A >> B;

    int ans = 0;
    if(A >= 13) ans = B;
    else if(6 <= A) ans = B / 2;

    cout << ans << endl;

    return 0;
}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= i;
	}
	nth_element(A.begin(), A.begin() + N / 2, A.end());
	int b = A[N/2];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += abs(b - A[i]);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 10007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 400005

int n, m;
int a[maxn], num[maxn];

int main()
{
//	gen();
//	freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int res = 0;
    cin >> n >> m;
    ms(a, 0); ms(num, 0);
    For(i, 1, n){
    	int x;
    	cin >> x;
    	a[x % m]++;
    	num[x]++;
    }

    for(int i = 0; i + i <= m; i++){
    	if((i + i) % m == 0){
    		int u = a[i] / 2;
    		res += u;
    		a[i] -= u + u;
    	} else{
    		int j = m - i;
    		int d = min(a[i], a[j]);
    		res += d;
    		a[i] -= d;
    		a[j] -= d;
    	}
//    	cout << i << " " << res << endl;
    }

    For(i, 0, maxn) if(num[i]){
    	int u = min(a[i % m], num[i]) / 2;
    	res += u;
    	a[i % m] -= u + u;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3456
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	vector<int> abcd(4);
	for (int i = 0; i < 4; ++i)
		cin >> abcd[i];
	sort(abcd.begin(), abcd.end());
	cout << abs(abcd[3] + abcd[0] - abcd[1] - abcd[2]) << endl;
	return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    if((a<=c)&&(a+b)>=c)
    {
        cout<<"YES"<<NL;
    }
    else
    {
        cout<<"NO"<<NL;
    }
    return 0;
}


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

using namespace std;

struct Node {
    int cost;
    vector<string> to;
};

map<string, Node> price;

int solve(string item) {

    if(price[item].to.size() == 0) return price[item].cost;

    int sum = 0;
    for(int i = 0; i < price[item].to.size(); ++i) {
        sum += solve(price[item].to[i]);
    }

    return min(price[item].cost, sum);

}

int main() {

    int n, m, p, k;
    string s, o, q, t;

    while(cin >> n, n) {

        for(map<string, Node>::iterator it = price.begin(); it != price.end(); ++it) {
            vector<string> &to = it->second.to;
            to.erase(to.begin(), to.end());
        }

        for(int i = 0; i < n; ++i) {
            cin >> s >> p;
            price[s].cost = p;
        }

        cin >> m;

        for(int i = 0; i < m; ++i) {
            cin >> o >> k;
            for(int j = 0; j < k; ++j) {
                cin >> q;
                price[o].to.push_back(q);
            }
        }

        cin >> t;

        cout << solve(t) << endl;

    }

}

Measured memory_bytes: 3224
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N,M,L = map(int,input().split())

A = [list(map(int,input().split())) for i in range(N)] #N*M配列の取得
B = [list(map(int,input().split())) for i in range(M)] #M*L配列の取得
ANS = [[0]*L for i in range(N)] #N*L


for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y]*A[x][z]

for row in range(N):
    print("%d"%ANS[row][0],end = "")
    for col in range(1,L):
        print(" %d"%(ANS[row][col]),end = "")
    print()




Measured memory_bytes: 7072
from sys import stdin
from collections import defaultdict,deque
N = int(stdin.readline().rstrip())
adj = defaultdict(set)

for i in range(N-1):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    adj[a].add(b)
    adj[b].add(a)
    
C = [int(x) for x in stdin.readline().rstrip().split()]

ans = sum(C) - max(C)
print(ans)

visit_p = deque()
visit_p.append(1)
visited = [False]*(N+1)
visited[1] = True

C.sort(reverse=True)
 
print(C[0],end=" ")
cnt = 1
ans_lst = [0]*(N+1)
while visit_p:
    now_v = visit_p.popleft()
    for v in adj[now_v]:
        if visited[v]:
            continue
        ans_lst[v] = C[cnt]
        cnt += 1
        visited[v] = True
        visit_p.append(v)
for i in ans_lst[2:]:
    print(i,end=" ")

Measured memory_bytes: 7976
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll dp[101][100001] = {};
struct items{
    ll v,w;
};

int main(){
   
    ll n,w;
    cin >> n >> w;
    vector <items> lis;
    for (ll i=0;i<n;i++){
        items p;
        cin >> p.w >> p.v;
        lis.push_back(p);
    }
    dp[0][0] = 0;
    for (ll i=1;i<=100000;i++){
        dp[0][i] = mop;
    }

    for (ll i=0;i<n;i++){
        for (ll j=0;j<=100000;j++){
            if(j-lis[i].v < 0){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j], dp[i][j-lis[i].v] + lis[i].w);
            }
        }
    }
    ll ans = 0;
//    for (ll i=0;i<=n;i++){
//        for (ll j=0;j<=10;j++){
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
//    cout << dp[2][30] << endl;
    for (ll j=0;j<=100000;j++){
        if(dp[n][j] <= w){
            if(ans < j){
                ans = j;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 79104
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r,g=l+1,[i,l][l<H and A[i]<A[l]]
 if r<H and A[g]<A[r]:g=r
 if g>i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


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

int main(){
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  
  for(int i=A; i<=B;i++){
    string s = to_string(i);
    string t = s;
    reverse(t.begin(),t.end());
    if(s == t){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    num, k = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    ans_dic = defaultdict()
    ans_dic[k] = 0

    bin_data = list(bin(k)[2:])
    for i in range(len(bin_data)):
        if bin_data[i] == '1':
            new_data = bin_data[:i] + ['0'] + ['1' for j in range(len(bin_data) - i - 1)]
            now_str = ''.join(new_data)
            now_int = int(now_str, 2)
            ans_dic[now_int] = 0

    # print(ans_dic)


    for i in range(num):
        a, b = data[i]
        for key in ans_dic.keys():
            if key | a == key:
                ans_dic[key] += b

    ans = max(list(ans_dic.values()))
    print(ans)




if __name__ == '__main__':
    main()
    # test()


Measured memory_bytes: 57176
import bisect


N, T = map(int, input().split())
ts = list(map(int, input().split()))

ans = 0
start = 0
end = 0

for i, t in enumerate(ts):
    if i == 0:
        start, end = t, t + T
        continue

    # assert start <= t
    if t <= end:
        end = t + T
    else:
        ans += (end - start)
        start, end = t, t + T

ans += (end - start)
print(ans)


Measured memory_bytes: 25708
#include <iostream>

using namespace std;

void swap(int *x,int *y);

int main (void)
{
    int A,B,C;
    cin>>A>>B>>C;
    swap(&A,&B);
    swap(&A,&C);
    cout<<A<<" "<<B<<" "<<C<<endl;
    return 0;
}

void swap(int *x,int *y)
{
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
  double  x1, y1, x2, y2;

  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

  printf("%.8f\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

  return 0;
}



Measured memory_bytes: 2036
import java.util.*;

public class Main {

    static int NOT_FOUND = 99999999;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sArr = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sArr[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] tArr = new int[q + 1];
        int count = 0;
        for (int i = 0; i < q; i++) {
            int x = sc.nextInt();
            tArr[i] = x;
            if (linearSearch(n, sArr, x) != NOT_FOUND) count++;
        }
        System.out.println(count);
    }

    public static int linearSearch(int n, int[] arr, int key) {
        int i = 0;
        arr[n] = key;
        while (arr[i] != key) {
            i++;
        }
        if (i == n) {
            return NOT_FOUND;
        }
        return i;
    }
}



Measured memory_bytes: 80620
s = input()
q = int(input())
m = 0
t = ''
l = ''
for i in range(q):
    Q = input().split()
    if(Q[0] == '1'):
        m = m ^ 1
        # t,l = l[::-1],t[::-1]
    elif(Q[0] == '2'):
        if(Q[1] == '1'):
            if(m == 0):t += Q[2]
            else:l += Q[2]
        elif(Q[1] == '2'):
            if(m == 0):l += Q[2]
            else:t += Q[2]
# print(t,s,l)
s = t[::-1] + s + l

if(m == 1):s = s[::-1]
print(s)

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(),A.end(),greater<int>());
    vector<P> d(M);
    for(int i=0; i<M; i++){
        cin >> d[i].first >> d[i].second;
    }
    vector<vector<ll>> dp(M+1, vector<ll> (N+1,inf));
    dp[0][0] = 0;
    for(int i=0; i<M; i++){
        for(int j=0; j<=N; j++){
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j],dp[i][max(0,j-d[i].first)]+d[i].second);
        }
    }
    // for(int i=0; i<=M; i++){
    //     for(int j=0; j<=N; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << enld;
    // }
    ll ans = 0;
    ll sum = 0;
    for(int i=0; i<N; i++){
        sum += A[i];
        chmax(ans,sum-dp[M][i+1]);
    }
    cout << ans << enld;
    return 0;
}


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

using namespace std;

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

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const ll inf = 1e9;
const ll MOD = 1e9 + 7;
const ll nax = 1000000 + 10;

ll C(ll n, ll r) {
    if(r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll po(ll n, ll a)
{
    ll ans = 1;
    for(int i = 1; i <= a; i++)
        ans *= n;
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    ll o = 0, e = 0;
    ll n;
    cin >> n;
    ll p;
    cin >> p;
    for(ll i = 1; i <= n; i++)
    {
        ll num;
        cin >> num;
        if(num % 2 == 1)
            o++;
            else
            e++;
    }
    ll sum = 0;
    for(ll j = 0; j <= e; j ++)
    {
        ll cons = C(e, j);
    for(ll i = 1; i <= o; i += 2)
        {
            sum +=  cons * C(o, i);
        }
    }
    if(p == 1)
    cout << sum << endl;
    else
    cout << po(2, n) - sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int K;
    cin >> K;
    int ans = K / 2;
    ans *= (K - ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(input())
for i in range(int(input())):
    cmd, a, b, *c = input().split()
    a = int(a); b = int(b)
    if cmd == "print":
        print(*s[a:b+1], sep='')
    elif cmd == "reverse":
        s[a:b+1] = reversed(s[a:b+1])
    else:
        s[a:b+1] = c[0]


Measured memory_bytes: 5732
#include <iostream>

using namespace std;

int main(){
    int a, b, k;
    cin >> a;
    cin >> b;
    cin >> k;
    int cnt = 0, ans = (a < b) ? a : b;
    while(true){
        if(a % ans == 0 && b % ans == 0){
            cnt++;
        }
        if(cnt == k) break;
        ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a!=b&&a!=c&&b!=c)
    cout<<"3"<<endl;
  else if(a==b&&b==c)
    cout<<"1"<<endl;
  else
    cout<<"2"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] sArr = sc.next().toCharArray();
		int length = sArr.length;
		TreeSet<Long>[] sets = new TreeSet[26];
		for (int i = 0; i < 26; i++) {
		    sets[i] = new TreeSet<>();
		}
		for (int i = 0; i < length; i++) {
		    sets[sArr[i] - 'a'].add(Long.valueOf(i));
		}
		char[] tArr = sc.next().toCharArray();
		long prev = 0;
		for (char c : tArr) {
		    Long x = sets[c - 'a'].ceiling(prev % length);
		    if (x == null) {
		        prev = (prev / length + 1) * length;
		        x = sets[c - 'a'].ceiling(prev % length);
		        if (x == null) {
		            System.out.println(-1);
		            return;
		        }
		        prev += x;
		    } else {
		        prev = prev / length * length + x;
		    }
		    prev++;
		}
		System.out.println(prev);
   }
}


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

typedef long long ll;
const int INF = 1 << 30;

int n, t;
int a;

int h[1010];

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

    for (int i =0; i < n; i++){
        cin >> h[i];
    }

    double res = INF;
    int index = -1;

    for (int i = 0; i < n; i++){
        double p = t - h[i] * 0.006;
        if (abs(p - a) < res){
            index = i;
            res = abs(p-a);
        }
    }

    cout << index+1 << endl;
}

Measured memory_bytes: 256