akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        md1: (i32, i32),
        md2: (i32, i32),
    }
    if md1.0 != md2.0 {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2136
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B, K;

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

  rep( i, K )
  {
    if( i&1 )
    {
      if( B&1 )
        --B;

      A += B/2;
      B -= B/2;
    }
    else
    {
      if( A&1 )
        --A;

      B += A/2;
      A -= A/2;
    }
  }

  printf( "%d %d\n", A, B );

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>

#define MAX 2000000
#define INFTY 1073000000

int A[MAX+1],H=0;


int parent(int);
int left(int);
int right(int);
void maxHeapify(int);
void insert(int);
void increaseKey(int,int);
int extractMax(void);
void swap(int,int);

 int parent(int i){
  return i/2;
}
 
int left(int i){
  return 2*i;
}
 
int right(int i){
  return 2*i+1;
}
 
int main(){
  int key;
  char c[10];
  
  while(1){
    scanf("%s",c);
    
    if(c[0] =='e' && c[1] == 'n') break;

    if(c[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }
  
  return 0;
}
 
void maxHeapify(int i){
  int r,lef,largest;
  
  lef = left(i);
  r = right(i);
 
  if(lef <= H && A[lef] > A[i]) largest = lef;
  else largest = i;

  if(r <= H && A[r] > A[largest]) largest = r;
 
  if(largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}
 

void swap(int i, int largest){
  int tmp;
  tmp = A[i];
  A[i] = A[largest];
  A[largest] = tmp;
}
 
 
void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}
 
int extract(void){
  int max;

  if(H < 1) return -INFTY;

  max = A[1];
  A[1] = A[H--];
  maxHeapify(1);
   
  return max;
}

void increaseKey(int i,int key){
  if(key < A[i]) return;
  A[i] = key;
  
  while(i > 1 && A[parent(i)] < A[i]){
    swap(parent(i),i);
    i = parent(i);
  }
}



Measured memory_bytes: 5556
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn z_algorithm(s: &[char]) -> Vec<usize> {
    let n = s.len();
    let mut prefix = vec![0; n];
    prefix[0] = n;

    let mut i = 1;
    let mut j = 0;
    while i < n {
        while i+j < n && s[j] == s[i+j] {
            j += 1;
        }
        prefix[i] = j;
        if j == 0 {
            i+=1;
            continue;
        }

        let mut k = 1;
        while i+k < n && k+prefix[k] < j {
            prefix[i+k] = prefix[k];
            k += 1;
        }
        i += k;
        j -= k;
    }
    prefix
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut s: chars,
    }

    let mut ans = 0;
    let mut t = vec![];
    t.push( s.pop().unwrap() );
    while s.len() > 0 {
        let mut z = t.clone();
        z.push('$');
        z.extend(s.clone());

        let z_array = z_algorithm(&z);
        for j in t.len()+1..z.len() {
            ans = max(ans, z_array[j]);
        }
        t.insert(0, s.pop().unwrap());
    }
    puts!("{}\n", ans);
}


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

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

const double per = 0.006;

int main()
{
	int N, T, A;
	cin >> N;
	cin >> T >> A;
	int ans_num = 1;
	double stk;
	cin >> stk;
	double ans = abs(T - (stk * per) - A);
	for (int i = 1; i < N; i++) {
		cin >> stk;
		if (abs(T - (stk * per) - A) < ans) {
			ans = abs(T - (stk * per) - A);
			ans_num = i + 1;
		}
	}
	cout << ans_num << endl;
}



Measured memory_bytes: 256
N, M = map(int, input().split())

ans = 0
if N != 1 and M != 1:
    ans = (N-2) * (M-2)
elif N == 1 and M != 1:
    ans = N * (M-2)
elif N != 1 and M == 1:
    ans = (N-2) * M
else:
    ans = 1
print(ans)


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

typedef long long ll;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    if(k == 1){
        cout << n << endl;
        return 0;
    }

    int max_number = n-k+1;
    int MOD = 1e9+7;
    
    vector<ll> fac(max_number+1,1);
    vector<ll> inv(max_number+1,1);
    vector<ll> finv(max_number+1,1);
    vector<ll> nCk(max_number+1,1);
    for(i = 2;i <= max_number;++i){
        inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        fac.at(i) = fac.at(i-1)*i%MOD;
        finv.at(i) = finv.at(i-1)*inv.at(i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        nCk.at(i) = fac.at(max_number)*finv.at(i)%MOD*finv.at(max_number-i)%MOD;
    }

    int max_number2 = k-1;
    vector<ll> fac2(max_number2+1,1);
    vector<ll> inv2(max_number2+1,1);
    vector<ll> finv2(max_number2+1,1);
    vector<ll> nCk2(max_number2+1,1);
    for(i = 2;i <= max_number2;++i){
        inv2.at(i) = MOD - inv2.at(MOD%i)*(MOD/i)%MOD;
    }
    for(i = 1;i <= max_number2;++i){
        fac2.at(i) = fac2.at(i-1)*i%MOD;
        finv2.at(i) = finv2.at(i-1)*inv2.at(i)%MOD;
    }
    for(i = 1;i <= max_number2;++i){
        nCk2.at(i) = fac2.at(max_number2)*finv2.at(i)%MOD*finv2.at(max_number2-i)%MOD;
    }
    for(i = 1;i <= k;++i){
        if(i > max_number){
            cout << 0 << endl;
        }else{
            cout << nCk.at(i)*nCk2.at(i-1)%MOD << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int[] H = new int[N];

		for(int i=0;i<N;i++) {
			H[i] = sc.nextInt();
		}

		double diff = 100001;
		int index = -1;
		for(int i=0;i<H.length;i++) {
			double d = Math.abs(A- (T - H[i]*0.006));
			if(diff >d) {
				diff = d;
				index = i;
			}
		}
//	    int ans = ;
	    System.out.println(index+1);
	    sc.close();
	}



}


Measured memory_bytes: 21972
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    ll Q;
    cin >> Q;
    ll B[100010], C[100010];
    map<ll,ll> mp;
    ll sum = 0;
    rep(i,0,N) sum += A[i];
    rep(i,0,N) mp[A[i]]++;

    rep(i,0,Q){
        cin >> B[i] >> C[i];
        ll n = mp[B[i]];
        sum -= n * B[i];
        mp[B[i]] = 0;
        mp[C[i]] += n;
        sum += n * C[i];
        print(sum);
    }

    

}

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

Measured memory_bytes: 11860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

ll gcd(ll a, ll b){
    while(b != 0){
        ll t = a;
        a = b;
        b = t%b;
    }
    return a;
}

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

int main(){
    int N; cin >> N;
    vector<ll> t(N);
    for(int i=0; i<N; i++) cin >> t[i];
    ll ans = 1LL;
    for(int i=0; i<N; i++) ans = lcm(ans, t[i]);

    cout << ans << endl;

}

Measured memory_bytes: 256
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  int n;
  cin >> n;
  int a = n % 10;
  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: 3588
S = input()
s_set = set()
for s in S:
  s_set.add(s)
if len(s_set) == 4:
  print('Yes')
elif len(s_set) == 2 and (('W' in s_set and 'E' in s_set) or \
('S' in s_set and 'N' in s_set)):
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9056
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*

fun bsCondOpCl(N: Long, L: Long, R: Long): Long {
    fun isCondition(m: Long): Boolean {
        if ((1+m)*m/2 < N) return false
        return true
    }
    var l = L; var r = R
    while (l+1 < r) {
        val m = (l + r) / 2
        if (isCondition(m)) {
            r = m
        } else {
            l = m
        }
    }
    return r
}

fun solve() {
    val N = rd.readLong()

    var i = bsCondOpCl(N, 0, N)
    var sum = (1+i)*i/2

    val ans = ArrayList<Long>()
    for (j in 1L .. i) {
        if (j == sum-N) continue
        else ans.add(j)
    }

    for (a in ans) {
        println(a)
    }
}


//val rd = debug.Reader("etc", "cf16-final", "b", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 36380
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define L 100
#define Gard NULL

typedef struct Tree{
  int nodekey;
  struct Tree *parent;
  struct Tree *leftch;
  struct Tree *rightch;
}Tree;

typedef struct Tree  *Search;
Search road;

void Insert(int );
void Pre(Search );
void In(Search );


int main(){
  int loop,numnode;
  char order[L];
  int i;
    
  scanf("%d",&loop);
  
  for(i=0;i<loop;i++){
    scanf("%s",order);
    
    if(order[0]=='i'){
      scanf("%d",&numnode);
      Insert(numnode);
    }
    
    else if(order[0]=='p'){
      In(road);
      printf("\n");
      Pre(road);
      printf("\n");
    }
  }
  
  return 0;
}

void Insert(int numnode){
  Search xnode,ynode,znode;
  
  xnode=road;
  ynode=Gard;
  znode=(struct Tree *)malloc(sizeof(struct Tree));
  znode->nodekey=numnode;
  znode->leftch=Gard;
  znode->rightch=Gard;
  
  while(1){
    if(xnode==Gard)break;
    ynode=xnode;
    
    if(znode->nodekey<xnode->nodekey){
      xnode=xnode->leftch;
    }
    
    else{
      xnode=xnode->rightch;
    }
  }
  
  znode->parent=ynode;
  
  if(ynode==Gard){
    road=znode;
  }
  
  else if(znode->nodekey<ynode->nodekey){
    ynode->leftch=znode;
  }
  
  else{
    ynode->rightch=znode;
  }
    
}

void Pre(Search road){

  if(road==Gard){
    return;
  }
  
  printf(" %d",road->nodekey);
 
  Pre(road->leftch);
  Pre(road->rightch);
  
}

void In(Search road){

  if(road==Gard){
    return;
  }
  
  In(road->leftch);
  
  printf(" %d",road->nodekey);
  
  In(road->rightch);
}



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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int cac=0;
    int cwa=0;
    int tle=0;
    int cre=0;
    for(int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        if(tmp=="AC") cac++;
        else if(tmp=="WA") cwa++;
        else if(tmp=="TLE") tle++;
        else cre++;
    }
    cout << "AC x " << cac << "\n";
    cout << "WA x " << cwa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << cre << "\n";

    return 0;
}

Measured memory_bytes: 3648
// AtCoder154 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

int main() {

    int n, i, k;
    int* a; // 動的メモリの先頭アドレス用のポインタ
    double thp, tac, ahp, aac;

    scanf("%lf %lf %lf %lf", &thp, &tac, &ahp, &aac);

    
    if (ceil(ahp / tac) <= ceil(thp / aac)) {
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll>A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    // 関係ない桁は総和が0か奇数
    // 総和0はガウスの消去法に影響しないので総和が奇数の桁を0にする
    ll mask = 0; // 和が奇数の桁が1
    for (int i = 0; i < N; ++i) {
        mask ^= A[i];
    }
    for (int i = 0; i < N; ++i) {
        A[i] &= ~mask;
    }

    // ガウスの消去法でAの部分集合のxorを最大化
    int fixed = 0;
    for (int i = 59; i >= 0; --i) {
        queue<int> que;
        for (int j = fixed; j < N; ++j) {
            if(__builtin_clzll(A[j]) == 63 - i) que.push(j);
        }
        if(que.empty()) continue;
        int top = que.front();
        que.pop();
        // 入れ替え対象は自分自身かqueueに入らないもの
        ll temp = A[fixed];
        A[fixed] = A[top];
        A[top] = temp;
        while (! que.empty()){
            A[que.front()] ^= A[fixed];
            que.pop();
        }
        fixed++;
    }
    ll res = 0;
    for (int i = 0; i < N; ++i) {
        res = max(res, res ^ A[i]);
    }
    res *= 2;
    res += mask;
    cout << res;
    return 0;
}

Measured memory_bytes: 1360
using System;

namespace ABC063B
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            bool[] chk = new bool[26];

            for (int i = 0; i < str.Length; i++)
            {
                if (chk[str[i] - 'a'])
                {
                    Console.WriteLine("no");
                    return;
                }
                chk[str[i] - 'a'] = true;
            }

            Console.WriteLine("yes");
        }
    }
}


Measured memory_bytes: 11092
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		String s = sc.next();
		String t = sc.next();
		int q = sc.nextInt();
		
		int[] as = new int[s.length()+1];
		int[] at = new int[t.length()+1];
		
		for(int i=0; i<s.length(); i++){
			if(s.charAt(i)=='A'){
				as[i+1] = as[i]+1;
			}else{
				as[i+1] = as[i]+2;
			}
		}
		for(int i=0; i<t.length(); i++){
			if(t.charAt(i)=='A'){
				at[i+1] = at[i]+1;
			}else{
				at[i+1] = at[i]+2;
			}
		}
		
		for(int i=1; i<=q; i++){
			if( (as[sc.nextInt()-1]*-1 + as[sc.nextInt()])%3 == (at[sc.nextInt()-1]*-1 + at[sc.nextInt()])%3 ){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
		return;
	}
}
 
 
 
 
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 53040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    private int ceil(int x, int y) {
        if (x % y == 0) {
            return x / y;
        }
        return x / y + 1;
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int[] x = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            x[i] = scan.nextInt();
            sum += x[i];
        }
        int limit = ceil(sum, A) * A + 1;
        long[][][] dp = new long[N+1][N+1][limit];
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                Arrays.fill(dp[i][j], 0);
            }
        }
        dp[0][0][0] = 1;
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                for (int k = 0; k < limit; k++) {
                    // i枚目まででj枚を選択いて合計がk
                    if (x[i-1] <= k && 1 <= j) {
                        dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
                    } else {
                        dp[i][j][k] = dp[i-1][j][k];
                    }
                }
            }
        }
        long answer = 0;
        for (int j = 1; j <= N; j++) {
            if (j * A < limit) {
                answer += dp[N][j][j * A];
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 83012
import itertools


def out(X):
    return list(itertools.accumulate(X, func=lambda x, y: x * y % mod))[-1]


N, K = [int(_) for _ in input().split()]
A = sorted([int(_) for _ in input().split()], key=lambda x: -abs(x))
mod = 10**9 + 7
cnt = 0
ipos = ineg = -1
for i, a in enumerate(A[:K]):
    if a < 0:
        cnt += 1
        ineg = i
    else:
        ipos = i
if cnt % 2 == 0:
    print(out(A[:K]))
else:
    oneg = opos = -10**10
    for i, a in enumerate(A[K:]):
        if a < 0 and ipos != -1:
            X = A[:ipos] + A[ipos + 1:K] + [A[K + i]]
            oneg = out(X)
            beforeneg = A[ipos]
            afterneg = A[K + i]
            ipos = -1
        elif a > 0 and ineg != -1:
            Y = A[:ineg] + A[ineg + 1:K] + [A[K + i]]
            opos = out(Y)
            beforepos = A[ineg]
            afterpos = A[K + i]
            ineg = -1
    if oneg != -10**10 and opos != -10**10:
        #afterneg/beforeneg > afterpos>beforepos
        if afterneg * beforepos > afterpos * beforeneg:
            print(oneg)
        else:
            print(opos)
    elif oneg != -10**10 or opos != -10**10:
        print(max(opos, oneg))
    else:
        C = A[::-1]
        print(out(C[:K]))


Measured memory_bytes: 32000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int N;
  cin>>N;
  int p[N];
  rep(i,N){
      cin>>p[i];
  }
  int cnt=0;
  for(int i=1;i<N-1;i++){
      if(p[i]-p[i-1]>0&&p[i]-p[i+1]<0){
          cnt++;
      }
      else if(p[i]-p[i-1]<0&&p[i]-p[i+1]>0){
          cnt++;
      }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  int ans = 0;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  for (int i = 1; i < n-1; ++i) {
    if ((a[i-1] > a[i] and a[i] > a[i+1]) or (a[i-1] < a[i] and a[i] < a[i+1])) {
      ans += 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b; cin>>n>>a>>b;
    cout<<min(a*n,b)<<endl;
    return  0;
}


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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    string moji;
    cin >> moji ;
    int nagasa = (int)(moji.length());
    char ca;
    int maxlength = 0;
    int nowlength = 0;

    REP(i,0,nagasa){
        ca = moji[i];
        if(ca == 'A' || ca=='T' || ca=='G' || ca =='C' ){
           nowlength++;
           if(nowlength >= maxlength) maxlength = nowlength; 
        }else{
            nowlength=0;
        }
    }

    cout << maxlength << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    int sx, sy;
    cin >> s >> sx >> sy;

    VI movx, movy;
    int n = s.size(), cnt = 0, now = 0;
    rep(i, n){
        if (s[i] == 'T'){
            if (now == 0) movx.push_back(cnt);
            else movy.push_back(cnt);
            now = !now;
            cnt = 0;
        }else cnt++;
    }
    if (now == 0) movx.push_back(cnt);
    else movy.push_back(cnt);

    int d = movx[0];
    movx.erase(movx.begin());
    int nx = movx.size(), ny = movy.size(), lim = 2*n+1, mid = n;
    vector<vector<bool>> dpx(nx+1, vector<bool>(lim)), dpy(ny+1, vector<bool>(lim));
    dpx[0][mid + d] = true, dpy[0][mid] = true;

    rep(i, nx){
        rep(j, lim){
            int jxm = j - movx[i];
            int jxp = j + movx[i];
            if (0 < jxm && jxp < lim) dpx[i+1][j] = dpx[i][jxm] || dpx[i][jxp];
            else if (0 < jxm) dpx[i+1][j] = dpx[i][jxm];
            else if (jxp < lim) dpx[i+1][j] = dpx[i][jxp];
        }
    }

    rep(i, ny){
        rep(j, lim){
            int jym = j - movy[i];
            int jyp = j + movy[i];
            if (0 < jym && jyp < lim) dpy[i+1][j] = dpy[i][jym] || dpy[i][jyp];
            else if (0 < jym) dpy[i+1][j] = dpy[i][jym];
            else if (jyp < lim) dpy[i+1][j] = dpy[i][jyp];
        }
    }

    if (dpx[nx][mid+sx] && dpy[ny][mid+sy]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 19108
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007B
using namespace std;
using ll = long long;
int main(){
    vector<int> a(3);
    REP(i,3){
        cin >> a[i];
    }
    SORT(a);
    if(a[0]+a[1] == a[2])
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}

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

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

    int a;
    string s;
    cin >> a >> s;
    if (a < 3200)
        cout << "red" << endl;
    else
        cout << s << endl;

    return 0;
}


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



int main() {
  ll N,K,x,ans = 0;
  cin >> N >> K;
  rep (i,N)
  {
    cin >> x;
    ans += 2 * min (x,K - x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <time.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


int main(int argc, char* argv[])
{
    int n,K;
    scanf("%d%d", &n, &K);

    vector<int> a(n);
    int i;;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.rbegin(), a.rend());
    int m=MIN(n,K);
    ll sum=0;
    for(i=m; i<n; i++) {
        sum+=a[i];
    }
    printf("%lld\n", sum);

    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli ans[110][110];

void func(long long H, long long W, long long N, std::vector<long long> a){

    lli now=0;
    lli cnt=0;

    REP(i,0,H){
        for(lli j = (i%2==0)?0:W-1; j>= 0 && j<W; j += (i%2==0)?1:-1){
            if(cnt>=a[now]){
                now++;
                cnt=0;
                j -= (i%2==0)?1:-1;
                continue;
            }
            ans[i][j] = now;
            cnt++;
        }
    }

    REP(i,0,H){
        REP(j,0,W){
            cout<<ans[i][j]+1<<" ";
        }
        cout<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    func(H, W, N, std::move(a));
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
string S;
int N;
 
void input() {
    cin >> N;
    cin >> S;
}
 
void solve() {
    input();
    string tmp = "No";
    int K = N / 2;
    if(N % 2 == 0 && S.substr(0, K) == S.substr(K, K)) tmp = "Yes";
    cout << tmp << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define datamax 500001
#define banpei 1000000001
int left[datamax/2 +1];
int right[datamax/2 + 1];
int cnt;
void merge(int *,int,int,int,int);
void mergeSort(int *,int,int,int);
  int main(){
  int a[datamax],n,i;
  cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  mergeSort(a,n,0,n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}

void merge(int a[],int n, int leftnum ,int mid,int rightnum){
  int n1,n2,i=0,j=0,k;
   n1 = mid - leftnum;
   n2 = rightnum - mid;
  for(i=0;i<n1;i++)left[i] = a[leftnum + i];
  for(i=0;i<n2;i++)right[i] = a[mid + i];
  left[n1] = right[n2] = banpei;
  i=0;
  for(k=leftnum;k<rightnum;k++){
    cnt++;
    if(left[i] <= right[j]){
      a[k] = left[i++]; 
    }else{
      a[k] = right[j++];
    }
  }
}

void mergeSort(int a[],int n,int leftnum,int rightnum){
  int mid;
  if(leftnum +1 != rightnum){
    mid = (leftnum + rightnum) / 2;
    mergeSort(a,n,leftnum,mid);
    mergeSort(a,n,mid,rightnum);
    merge(a,n,leftnum,mid,rightnum);
  }
}




Measured memory_bytes: 5604
package main

import "fmt"

func max(a []int) (x int) {
	x = -int(^uint(0)>>1) - 1
	for _, i := range a {
		if i > x {
			x = i
		}
	}
	return
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	x := []int{(a + a - 1), (a + b), (b + b - 1)}
	fmt.Println(max(x))
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int chkin(void)
{
  char ac[3] = "AC";
  char wa[3] = "WA";
  char tle[4] = "TLE";
  char re[3] = "RE";
  char in[4];

  if (!(scanf("%s", in)))
    return (0);
  if (!(strcmp(in, ac)))
    return (1);
  if (!(strcmp(in, wa)))
    return (2);
  if (!(strcmp(in, tle)))
    return (3);
  if (!(strcmp(in, re)))
    return (4);
  return (-1);
}

int main(void)
{
  int n;
  int count[4];
  int i = 0;
  
  if (!(scanf("%d", &n)))
    return (0);
  while (i < 4)
    count[i++] = 0;
  while (n > 0)
  {
    n--;
    switch (chkin())
    {
      case 1:
        count[0]++;
        continue;
      case 2:
        count[1]++;
        continue;
      case 3:
        count[2]++;
        continue;
      case 4:
        count[3]++;
        continue;
    }
  }
  printf("AC x %d\n", count[0]);
  printf("WA x %d\n", count[1]);
  printf("TLE x %d\n", count[2]);
  printf("RE x %d\n", count[3]);
  return (0);
}

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

struct Program {
    int start;
    int end;
    int ch;
};

struct Recorder {
    int end;
    int ch;
};

int main()
{
    int N, C;
    cin >> N >> C;
    vector<Program> programs(N);
    for (int i = 0; i < N; i++) {
        cin >> programs[i].start >> programs[i].end >> programs[i].ch;
    }

    sort(programs.begin(), programs.end(), [&](const Program& lhs, const Program& rhs){
        return (lhs.start < rhs.start);
    });

    vector<Recorder> recoders;
    Recorder first;
    first.end = programs[0].end;
    first.ch = programs[0].ch;
    recoders.push_back(first);

    for (int i = 1; i < N; i++) {
        bool flag = false;
        for (int j = 0; j < recoders.size(); j++) {
            //録画できるレコーダーがあるならそいつに任せる
            if (recoders[j].end < programs[i].start
                    || recoders[j].ch == programs[i].ch) {
                flag = true;
                recoders[j].end = programs[i].end;
                recoders[j].ch = programs[i].ch;
                break;
            }
        }

        if (!flag) {
            Recorder add;
            add.end = programs[i].end;
            add.ch = programs[i].ch;
            recoders.push_back(add);
        }
    }
    cout << recoders.size() << endl;
}


Measured memory_bytes: 1408
import java.util.*;
public class Main {
	public static Scanner sc = new Scanner(System.in);
	static int n;
	public static void main(String[] args) {
		while(read()) {
			solve();
		}
	}
	
	static boolean read() {
		if(!sc.hasNext()) return false;
		n = sc.nextInt();
		return true;
	}
	
	static void solve() {
		int cnt = 0;
		int ans = 0;
		if(n > 36)	{
			System.out.println(0);
			return;
		}
		for(int i=0; i <= 9; i++) {
			for(int j=0; j <= 9; j++) {
				for(int k=0; k <= 9; k++) {
					for(int l=0; l <= 9; l++) {
						ans = i+j+k+l;
						if(n == ans) cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
using vi = vector<int>;

string str;
string stra;
int id = 0;

void pt(vector<int> v){
  for(int r=0;r<v.size();r++){
    cout << v[r];
  }
  cout << endl;
}

vi number(){
  vi res;
  for (;'0'<=stra[id]&&stra[id]<='9'; id++) {
    res.push_back(stra[id] - '0');
  }
  reverse(res.begin(),res.end());
  return res;
}
int solve(){
  stra = str;
  for (int i = 9; i >= 0; i--) {
    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }
    vi b = number();

    a.resize(max(b.size() + 1,a.size()+1),0);

    for (int j = 0; j < (int)b.size(); j++) {
      a[j] += b[j];
      if (a[j]>=10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    for (int j = b.size(); j < (int)(a.size()-1); j++) {
      if (a[j] >= 10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }


    if(a[a.size()-1]==0){
      a.pop_back();
    }


    if (stra[id] == '=') {
      id++;
    }

    vi c = number();
    while(a.size()<c.size()){
      a.push_back(0);
    }
    // while(a.size()>c.size()){
    //   c.push_back(0);
    // }
    
    if (a.size() != c.size()) {
      continue;
    }
    int flag = 0;
    for (int j = 0; j < (int)a.size(); j++) {
      if (a[j] == c[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    }

  }
  return -1;
}
int main(){
  cin >> str;
  while(str.size()){
  int ans = solve();
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    cout << "NA" << endl;
  }
  str="";
  cin >> str;
}
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

typedef pair<double, int> PD;

 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int n;
int l;
int t[100010];
bool ch[100010];

int main(){
    cin >> n >> l;
    for(int i = 1;i <= n;i++){
        cin >> t[i];
    }
    priority_queue<P, vector<P>, greater<P> > que;
    int ans = 0;
    if(t[1] > t[2]){
        que.push(P(l-t[1],1));
        ans = max(ans,l-t[1]);
   //     ch[1] = true;
    }
    if(t[n] > t[n-1]){
        que.push(P(l-t[n],n));
        ans = max(ans,l-t[n]);
    //    ch[n] = true;
    }

    for(int i = 2;i < n;i++){
        if(t[i] > t[i-1] && t[i] > t[i+1]){
            que.push(P(l-t[i],i));
            ans = max(ans,l-t[i]);
       //     ch[]
        }
    }
    
    while(!que.empty()){
        P q = que.top(); que.pop();
        ch[q.sc] = true;
        t[q.sc] = 0;
        for(int i = -1;i <= 1;i++){
            int ni = q.sc+i;
            if(ni <= 0 || ni > n)continue;
            if(i == 0)continue;
            if(ch[ni] == true)continue;
            if(t[ni] > t[ni-1] && t[ni] > t[ni+1]){
                que.push(P(q.fs+l-t[ni],ni));
                ans = max(ans,q.fs+l-t[ni]);
            }

        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 3868
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	string s,s1;
	int i;
	cin>>s;
	rep(i,min((int)s.length(),4)){
		s1+=s[i];
	}
	if(s1=="YAKI"){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
} 


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

int N, ans=0, cnt =0;
 
int main(){
    cin >> N;
    
    for(int i=1; i<= N; i+=2){
            for(int j=1; j<= i; j+=2){
                if(i%j==0){
                    cnt++;
                }
            }
            if(cnt == 8) ans++;
            cnt = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    if (A * B > A+B && A*B > A-B) {
        cout << A * B << endl;
    }   else if(A+B > A*B && A+B > A-B) {
        cout << A + B << endl;
    } else {
        cout << A - B << endl;
    }
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long[] a = new long[n];
		long[] b = new long[n];

		for(int i=0;i<n;i++) {
			a[i]=Long.parseLong(sc.next());
		}
		for(int i=0;i<n;i++) {
			b[i]=Long.parseLong(sc.next());
		}
		sc.close();

		List<Long> plus = new ArrayList<Long>();
		long sum = 0;
		int num = 0;

		for(int i=0;i<n;i++) {
			long dif = a[i] - b[i];
			if(dif < 0) {sum -= dif;num++;}
			else plus.add(dif);
		}
		if(num == 0) {System.out.println(0);return;}

		int res = num;

		Collections.sort(plus,Collections.reverseOrder());

		long p=0;
		for (int i = 0; i < plus.size(); i++) {
            p += plus.get(i);
            res++;
            if (p >= sum) break;
        }

		if (p >= sum) System.out.println(res);
        else System.out.println(-1);

	}

}

Measured memory_bytes: 63520
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    if(a+b==c+d) cout << "Balanced";
    if(a+b>c+d) cout << "Left";
    if(a+b<c+d) cout <<" Right";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,n;
    cin>>h>>n;
    int a[100000];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        h=h-a[i];
        if(h<=0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    char c;
    cin >> c;

    if (c >= 'A' && c <= 'Z') {
        cout << "A" << endl;
    } else
        cout << "a" << endl;

    return 0;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
import itertools

input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

a, b, c = map(int, input().split())
k = int(input())

for x in list(itertools.combinations_with_replacement([0,1,2], k)):
    a_, b_, c_ = a, b, c
    for val in x:
        if val == 0:
            a_ *= 2
        elif val == 1:
            b_ *= 2
        elif val == 2:
            c_ *= 2
    if b_ > a_ and c_ > b_:
        print('Yes')
        sys.exit()
print('No')




Measured memory_bytes: 65352